const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PostcardManager-DbfSngsa.js","assets/usePostcardZones-C57xsAiI.js","assets/DirectMail-pbj47pyn.js"])))=>i.map(i=>d[i]); var jht=Object.defineProperty;var BMe=t=>{throw TypeError(t)};var kht=(t,s,r)=>s in t?jht(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var bn=(t,s,r)=>kht(t,typeof s!="symbol"?s+"":s,r),ufe=(t,s,r)=>s.has(t)||BMe("Cannot "+r);var cs=(t,s,r)=>(ufe(t,s,"read from private field"),r?r.call(t):s.get(t)),Za=(t,s,r)=>s.has(t)?BMe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),qn=(t,s,r,n)=>(ufe(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),Yi=(t,s,r)=>(ufe(t,s,"access private method"),r);var ZF=(t,s,r,n)=>({set _(a){qn(t,s,a,r)},get _(){return cs(t,s,n)}});function Nht(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 Fv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Co(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Rze(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 Fze={exports:{}},Zce={},zze={exports:{}},fo={};/** * @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 WD=Symbol.for("react.element"),Sht=Symbol.for("react.portal"),Cht=Symbol.for("react.fragment"),Mht=Symbol.for("react.strict_mode"),Tht=Symbol.for("react.profiler"),Aht=Symbol.for("react.provider"),Eht=Symbol.for("react.context"),Pht=Symbol.for("react.forward_ref"),Iht=Symbol.for("react.suspense"),Lht=Symbol.for("react.memo"),Dht=Symbol.for("react.lazy"),$Me=Symbol.iterator;function Oht(t){return t===null||typeof t!="object"?null:(t=$Me&&t[$Me]||t["@@iterator"],typeof t=="function"?t:null)}var Bze={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},$ze=Object.assign,qze={};function gA(t,s,r){this.props=t,this.context=s,this.refs=qze,this.updater=r||Bze}gA.prototype.isReactComponent={};gA.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")};gA.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function Uze(){}Uze.prototype=gA.prototype;function r2e(t,s,r){this.props=t,this.context=s,this.refs=qze,this.updater=r||Bze}var n2e=r2e.prototype=new Uze;n2e.constructor=r2e;$ze(n2e,gA.prototype);n2e.isPureReactComponent=!0;var qMe=Array.isArray,Vze=Object.prototype.hasOwnProperty,a2e={current:null},Hze={key:!0,ref:!0,__self:!0,__source:!0};function Wze(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)Vze.call(s,n)&&!Hze.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,je=le[ye];if(0>>1;yea(be,we))Mea(Ae,be)?(le[ye]=Ae,le[Me]=we,ye=Me):(le[ye]=be,le[We]=we,ye=We);else if(Mea(Ae,we))le[ye]=Ae,le[Me]=we,ye=Me;else break e}}return he}function a(le,he){var we=le.sortIndex-he.sortIndex;return we!==0?we:le.id-he.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,y=3,_=!1,b=!1,w=!1,j=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T(le){for(var he=r(u);he!==null;){if(he.callback===null)n(u);else if(he.startTime<=le)n(u),he.sortIndex=he.expirationTime,s(c,he);else break;he=r(u)}}function I(le){if(w=!1,T(le),!b)if(r(c)!==null)b=!0,re(L);else{var he=r(u);he!==null&&ne(I,he.startTime-le)}}function L(le,he){b=!1,w&&(w=!1,N(q),q=-1),_=!0;var we=y;try{for(T(he),f=r(c);f!==null&&(!(f.expirationTime>he)||le&&!X());){var ye=f.callback;if(typeof ye=="function"){f.callback=null,y=f.priorityLevel;var je=ye(f.expirationTime<=he);he=t.unstable_now(),typeof je=="function"?f.callback=je:f===r(c)&&n(c),T(he)}else n(c);f=r(c)}if(f!==null)var ke=!0;else{var We=r(u);We!==null&&ne(I,We.startTime-he),ke=!1}return ke}finally{f=null,y=we,_=!1}}var R=!1,$=null,q=-1,U=5,V=-1;function X(){return!(t.unstable_now()-Vle||125ye?(le.sortIndex=we,s(u,le),r(c)===null&&le===r(u)&&(w?(N(q),q=-1):w=!0,ne(I,we-ye))):(le.sortIndex=je,s(c,le),b||_||(b=!0,re(L))),le},t.unstable_shouldYield=X,t.unstable_wrapCallback=function(le){var he=y;return function(){var we=y;y=he;try{return le.apply(this,arguments)}finally{y=we}}}})(Xze);Yze.exports=Xze;var Ght=Yze.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 Kht=C,yf=Ght;function Gr(t){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+t,r=1;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Nye=Object.prototype.hasOwnProperty,Zht=/^[: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]*$/,VMe={},HMe={};function Yht(t){return Nye.call(HMe,t)?!0:Nye.call(VMe,t)?!1:Zht.test(t)?HMe[t]=!0:(VMe[t]=!0,!1)}function Xht(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 Qht(t,s,r,n){if(s===null||typeof s>"u"||Xht(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 Om(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 bh={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){bh[t]=new Om(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];bh[s]=new Om(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){bh[t]=new Om(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){bh[t]=new Om(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){bh[t]=new Om(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){bh[t]=new Om(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){bh[t]=new Om(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){bh[t]=new Om(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){bh[t]=new Om(t,5,!1,t.toLowerCase(),null,!1,!1)});var l2e=/[\-:]([a-z])/g;function c2e(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(l2e,c2e);bh[s]=new Om(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(l2e,c2e);bh[s]=new Om(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(l2e,c2e);bh[s]=new Om(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){bh[t]=new Om(t,1,!1,t.toLowerCase(),null,!1,!1)});bh.xlinkHref=new Om("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){bh[t]=new Om(t,1,!1,t.toLowerCase(),null,!0,!0)});function d2e(t,s,r,n){var a=bh.hasOwnProperty(s)?bh[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{pfe=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?Z6(t):""}function Jht(t){switch(t.tag){case 5:return Z6(t.type);case 16:return Z6("Lazy");case 13:return Z6("Suspense");case 19:return Z6("SuspenseList");case 0:case 2:case 15:return t=ffe(t.type,!1),t;case 11:return t=ffe(t.type.render,!1),t;case 1:return t=ffe(t.type,!0),t;default:return""}}function Tye(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 S5:return"Fragment";case N5:return"Portal";case Sye:return"Profiler";case u2e:return"StrictMode";case Cye:return"Suspense";case Mye:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case e9e:return(t.displayName||"Context")+".Consumer";case Jze:return(t._context.displayName||"Context")+".Provider";case h2e:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case m2e:return s=t.displayName||null,s!==null?s:Tye(t.type)||"Memo";case D_:s=t._payload,t=t._init;try{return Tye(t(s))}catch{}}return null}function emt(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 Tye(s);case 8:return s===u2e?"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 Qb(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function s9e(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function tmt(t){var s=s9e(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 QF(t){t._valueTracker||(t._valueTracker=tmt(t))}function r9e(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=s9e(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function Tie(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 Aye(t,s){var r=s.checked;return Kc({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function GMe(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=Qb(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 n9e(t,s){s=s.checked,s!=null&&d2e(t,"checked",s,!1)}function Eye(t,s){n9e(t,s);var r=Qb(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")?Pye(t,s.type,r):s.hasOwnProperty("defaultValue")&&Pye(t,s.type,Qb(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function KMe(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 Pye(t,s,r){(s!=="number"||Tie(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var Y6=Array.isArray;function Y5(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=JF.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function a8(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var fI={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},smt=["Webkit","ms","Moz","O"];Object.keys(fI).forEach(function(t){smt.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),fI[s]=fI[t]})});function l9e(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||fI.hasOwnProperty(t)&&fI[t]?(""+s).trim():s+"px"}function c9e(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=l9e(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var rmt=Kc({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 Dye(t,s){if(s){if(rmt[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Gr(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Gr(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Gr(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Gr(62))}}function Oye(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 Rye=null;function p2e(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Fye=null,X5=null,Q5=null;function XMe(t){if(t=ZD(t)){if(typeof Fye!="function")throw Error(Gr(280));var s=t.stateNode;s&&(s=ede(s),Fye(t.stateNode,t.type,s))}}function d9e(t){X5?Q5?Q5.push(t):Q5=[t]:X5=t}function u9e(){if(X5){var t=X5,s=Q5;if(Q5=X5=null,XMe(t),s)for(t=0;t>>=0,t===0?32:31-(pmt(t)/fmt|0)|0}var e7=64,t7=4194304;function X6(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 Iie(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=X6(i):(o&=l,o!==0&&(n=X6(o)))}else l=r&~a,l!==0?n=X6(l):o!==0&&(n=X6(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 GD(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-$x(s),t[s]=r}function vmt(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=xI),iTe=" ",oTe=!1;function E9e(t,s){switch(t){case"keyup":return Gmt.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function P9e(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var C5=!1;function Zmt(t,s){switch(t){case"compositionend":return P9e(s);case"keypress":return s.which!==32?null:(oTe=!0,iTe);case"textInput":return t=s.data,t===iTe&&oTe?null:t;default:return null}}function Ymt(t,s){if(C5)return t==="compositionend"||!w2e&&E9e(t,s)?(t=T9e(),Bz=v2e=db=null,C5=!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=uTe(r)}}function O9e(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?O9e(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function R9e(){for(var t=window,s=Tie();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=Tie(t.document)}return s}function j2e(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 apt(t){var s=R9e(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&O9e(r.ownerDocument.documentElement,r)){if(n!==null&&j2e(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=hTe(r,o);var l=hTe(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,M5=null,Vye=null,vI=null,Hye=!1;function mTe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Hye||M5==null||M5!==Tie(n)||(n=M5,"selectionStart"in n&&j2e(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}),vI&&u8(vI,n)||(vI=n,n=Oie(Vye,"onSelect"),0E5||(t.current=Xye[E5],Xye[E5]=null,E5--)}function ql(t,s){E5++,Xye[E5]=t.current,t.current=s}var Jb={},$h=p2(Jb),mp=p2(!1),dS=Jb;function aT(t,s){var r=t.type.contextTypes;if(!r)return Jb;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 pp(t){return t=t.childContextTypes,t!=null}function Fie(){pc(mp),pc($h)}function _Te(t,s,r){if($h.current!==Jb)throw Error(Gr(168));ql($h,s),ql(mp,r)}function W9e(t,s,r){var n=t.stateNode;if(s=s.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var a in n)if(!(a in s))throw Error(Gr(108,emt(t)||"Unknown",a));return Kc({},r,n)}function zie(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Jb,dS=$h.current,ql($h,t),ql(mp,mp.current),!0}function bTe(t,s,r){var n=t.stateNode;if(!n)throw Error(Gr(169));r?(t=W9e(t,s,dS),n.__reactInternalMemoizedMergedChildContext=t,pc(mp),pc($h),ql($h,t)):pc(mp),ql(mp,r)}var Cv=null,tde=!1,Tfe=!1;function G9e(t){Cv===null?Cv=[t]:Cv.push(t)}function xpt(t){tde=!0,G9e(t)}function f2(){if(!Tfe&&Cv!==null){Tfe=!0;var t=0,s=ul;try{var r=Cv;for(ul=1;t>=l,a-=l,zv=1<<32-$x(s)+a|r<q?(U=$,$=null):U=$.sibling;var V=y(N,$,T[q],I);if(V===null){$===null&&($=U);break}t&&$&&V.alternate===null&&s(N,$),S=o(V,S,q),R===null?L=V:R.sibling=V,R=V,$=U}if(q===T.length)return r(N,$),Tc&&Ow(N,q),L;if($===null){for(;qq?(U=$,$=null):U=$.sibling;var X=y(N,$,V.value,I);if(X===null){$===null&&($=U);break}t&&$&&X.alternate===null&&s(N,$),S=o(X,S,q),R===null?L=X:R.sibling=X,R=X,$=U}if(V.done)return r(N,$),Tc&&Ow(N,q),L;if($===null){for(;!V.done;q++,V=T.next())V=f(N,V.value,I),V!==null&&(S=o(V,S,q),R===null?L=V:R.sibling=V,R=V);return Tc&&Ow(N,q),L}for($=n(N,$);!V.done;q++,V=T.next())V=_($,N,q,V.value,I),V!==null&&(t&&V.alternate!==null&&$.delete(V.key===null?q:V.key),S=o(V,S,q),R===null?L=V:R.sibling=V,R=V);return t&&$.forEach(function(se){return s(N,se)}),Tc&&Ow(N,q),L}function j(N,S,T,I){if(typeof T=="object"&&T!==null&&T.type===S5&&T.key===null&&(T=T.props.children),typeof T=="object"&&T!==null){switch(T.$$typeof){case XF:e:{for(var L=T.key,R=S;R!==null;){if(R.key===L){if(L=T.type,L===S5){if(R.tag===7){r(N,R.sibling),S=a(R,T.props.children),S.return=N,N=S;break e}}else if(R.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===D_&&kTe(L)===R.type){r(N,R.sibling),S=a(R,T.props),S.ref=g6(N,R,T),S.return=N,N=S;break e}r(N,R);break}else s(N,R);R=R.sibling}T.type===S5?(S=O4(T.props.children,N.mode,I,T.key),S.return=N,N=S):(I=Kz(T.type,T.key,T.props,null,N.mode,I),I.ref=g6(N,S,T),I.return=N,N=I)}return l(N);case N5:e:{for(R=T.key;S!==null;){if(S.key===R)if(S.tag===4&&S.stateNode.containerInfo===T.containerInfo&&S.stateNode.implementation===T.implementation){r(N,S.sibling),S=a(S,T.children||[]),S.return=N,N=S;break e}else{r(N,S);break}else s(N,S);S=S.sibling}S=Rfe(T,N.mode,I),S.return=N,N=S}return l(N);case D_:return R=T._init,j(N,S,R(T._payload),I)}if(Y6(T))return b(N,S,T,I);if(u6(T))return w(N,S,T,I);l7(N,T)}return typeof T=="string"&&T!==""||typeof T=="number"?(T=""+T,S!==null&&S.tag===6?(r(N,S.sibling),S=a(S,T),S.return=N,N=S):(r(N,S),S=Ofe(T,N.mode,I),S.return=N,N=S),l(N)):r(N,S)}return j}var oT=X9e(!0),Q9e=X9e(!1),qie=p2(null),Uie=null,L5=null,C2e=null;function M2e(){C2e=L5=Uie=null}function T2e(t){var s=qie.current;pc(qie),t._currentValue=s}function e0e(t,s,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&s)!==s?(t.childLanes|=s,n!==null&&(n.childLanes|=s)):n!==null&&(n.childLanes&s)!==s&&(n.childLanes|=s),t===r)break;t=t.return}}function eM(t,s){Uie=t,C2e=L5=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(lp=!0),t.firstContext=null)}function Sg(t){var s=t._currentValue;if(C2e!==t)if(t={context:t,memoizedValue:s,next:null},L5===null){if(Uie===null)throw Error(Gr(308));L5=t,Uie.dependencies={lanes:0,firstContext:t}}else L5=L5.next=t;return s}var i4=null;function A2e(t){i4===null?i4=[t]:i4.push(t)}function J9e(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,A2e(s)):(r.next=a.next,a.next=r),s.interleaved=r,g1(t,n)}function g1(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 O_=!1;function E2e(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function eBe(t,s){t=t.updateQueue,s.updateQueue===t&&(s.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Wv(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function kb(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,Io&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,g1(t,r)}return a=n.interleaved,a===null?(s.next=s,A2e(n)):(s.next=a.next,a.next=s),n.interleaved=s,g1(t,r)}function qz(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,g2e(t,r)}}function NTe(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 Vie(t,s,r,n){var a=t.updateQueue;O_=!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 y=i.lane,_=i.eventTime;if((n&y)===y){p!==null&&(p=p.next={eventTime:_,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var b=t,w=i;switch(y=s,_=r,w.tag){case 1:if(b=w.payload,typeof b=="function"){f=b.call(_,f,y);break e}f=b;break e;case 3:b.flags=b.flags&-65537|128;case 0:if(b=w.payload,y=typeof b=="function"?b.call(_,f,y):b,y==null)break e;f=Kc({},f,y);break e;case 2:O_=!0}}i.callback!==null&&i.lane!==0&&(t.flags|=64,y=a.effects,y===null?a.effects=[i]:y.push(i))}else _={eventTime:_,lane:y,tag:i.tag,payload:i.payload,callback:i.callback,next:null},p===null?(u=p=_,c=f):p=p.next=_,l|=y;if(i=i.next,i===null){if(i=a.shared.pending,i===null)break;y=i,i=y.next,y.next=null,a.lastBaseUpdate=y,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);mS|=l,t.lanes=l,t.memoizedState=f}}function STe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=Efe.transition;Efe.transition={};try{t(!1),s()}finally{ul=r,Efe.transition=n}}function xBe(){return Cg().memoizedState}function bpt(t,s,r){var n=Sb(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},yBe(t))vBe(s,r);else if(r=J9e(t,s,r,n),r!==null){var a=Nm();qx(r,t,n,a),_Be(r,s,n)}}function wpt(t,s,r){var n=Sb(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(yBe(t))vBe(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,Qx(i,l)){var c=s.interleaved;c===null?(a.next=a,A2e(s)):(a.next=c.next,c.next=a),s.interleaved=a;return}}catch{}finally{}r=J9e(t,s,a,n),r!==null&&(a=Nm(),qx(r,t,n,a),_Be(r,s,n))}}function yBe(t){var s=t.alternate;return t===Wc||s!==null&&s===Wc}function vBe(t,s){_I=Wie=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function _Be(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,g2e(t,r)}}var Gie={readContext:Sg,useCallback:Sh,useContext:Sh,useEffect:Sh,useImperativeHandle:Sh,useInsertionEffect:Sh,useLayoutEffect:Sh,useMemo:Sh,useReducer:Sh,useRef:Sh,useState:Sh,useDebugValue:Sh,useDeferredValue:Sh,useTransition:Sh,useMutableSource:Sh,useSyncExternalStore:Sh,useId:Sh,unstable_isNewReconciler:!1},jpt={readContext:Sg,useCallback:function(t,s){return Ry().memoizedState=[t,s===void 0?null:s],t},useContext:Sg,useEffect:MTe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,Vz(4194308,4,hBe.bind(null,s,t),r)},useLayoutEffect:function(t,s){return Vz(4194308,4,t,s)},useInsertionEffect:function(t,s){return Vz(4,2,t,s)},useMemo:function(t,s){var r=Ry();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=Ry();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=bpt.bind(null,Wc,t),[n.memoizedState,t]},useRef:function(t){var s=Ry();return t={current:t},s.memoizedState=t},useState:CTe,useDebugValue:z2e,useDeferredValue:function(t){return Ry().memoizedState=t},useTransition:function(){var t=CTe(!1),s=t[0];return t=_pt.bind(null,t[1]),Ry().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=Wc,a=Ry();if(Tc){if(r===void 0)throw Error(Gr(407));r=r()}else{if(r=s(),Hu===null)throw Error(Gr(349));hS&30||nBe(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,MTe(iBe.bind(null,n,o,t),[t]),n.flags|=2048,v8(9,aBe.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=Ry(),s=Hu.identifierPrefix;if(Tc){var r=Bv,n=zv;r=(n&~(1<<32-$x(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=x8++,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[Ky]=s,t[p8]=n,ABe(t,s,!1,!1),s.stateNode=t;e:{switch(l=Oye(r,n),r){case"dialog":lc("cancel",t),lc("close",t),a=n;break;case"iframe":case"object":case"embed":lc("load",t),a=n;break;case"video":case"audio":for(a=0;adT&&(s.flags|=128,n=!0,x6(o,!1),s.lanes=4194304)}else{if(!n)if(t=Hie(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),x6(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!Tc)return Ch(s),null}else 2*Nd()-o.renderingStartTime>dT&&r!==1073741824&&(s.flags|=128,n=!0,x6(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=Nd(),s.sibling=null,r=Bc.current,ql(Bc,n?r&1|2:r&1),s):(Ch(s),null);case 22:case 23:return H2e(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?Kp&1073741824&&(Ch(s),s.subtreeFlags&6&&(s.flags|=8192)):Ch(s),null;case 24:return null;case 25:return null}throw Error(Gr(156,s.tag))}function Ept(t,s){switch(N2e(s),s.tag){case 1:return pp(s.type)&&Fie(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return lT(),pc(mp),pc($h),L2e(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return I2e(s),null;case 13:if(pc(Bc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Gr(340));iT()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return pc(Bc),null;case 4:return lT(),null;case 10:return T2e(s.type._context),null;case 22:case 23:return H2e(),null;case 24:return null;default:return null}}var d7=!1,Ph=!1,Ppt=typeof WeakSet=="function"?WeakSet:Set,Qn=null;function D5(t,s){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){ad(t,s,n)}else r.current=null}function c0e(t,s,r){try{r()}catch(n){ad(t,s,n)}}var zTe=!1;function Ipt(t,s){if(Wye=Lie,t=R9e(),j2e(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,y=null;t:for(;;){for(var _;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),(_=f.firstChild)!==null;)y=f,f=_;for(;;){if(f===t)break t;if(y===r&&++u===a&&(i=l),y===o&&++p===n&&(c=l),(_=f.nextSibling)!==null)break;f=y,y=f.parentNode}f=_}r=i===-1||c===-1?null:{start:i,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(Gye={focusedElem:t,selectionRange:r},Lie=!1,Qn=s;Qn!==null;)if(s=Qn,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,Qn=t;else for(;Qn!==null;){s=Qn;try{var b=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(b!==null){var w=b.memoizedProps,j=b.memoizedState,N=s.stateNode,S=N.getSnapshotBeforeUpdate(s.elementType===s.type?w:kx(s.type,w),j);N.__reactInternalSnapshotBeforeUpdate=S}break;case 3:var T=s.stateNode.containerInfo;T.nodeType===1?T.textContent="":T.nodeType===9&&T.documentElement&&T.removeChild(T.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Gr(163))}}catch(I){ad(s,s.return,I)}if(t=s.sibling,t!==null){t.return=s.return,Qn=t;break}Qn=s.return}return b=zTe,zTe=!1,b}function bI(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&&c0e(s,r,o)}a=a.next}while(a!==n)}}function nde(t,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var r=s=s.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==s)}}function d0e(t){var s=t.ref;if(s!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof s=="function"?s(t):s.current=t}}function IBe(t){var s=t.alternate;s!==null&&(t.alternate=null,IBe(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[Ky],delete s[p8],delete s[Yye],delete s[fpt],delete s[gpt])),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 LBe(t){return t.tag===5||t.tag===3||t.tag===4}function BTe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||LBe(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 u0e(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=Rie));else if(n!==4&&(t=t.child,t!==null))for(u0e(t,s,r),t=t.sibling;t!==null;)u0e(t,s,r),t=t.sibling}function h0e(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(h0e(t,s,r),t=t.sibling;t!==null;)h0e(t,s,r),t=t.sibling}var lh=null,Mx=!1;function v_(t,s,r){for(r=r.child;r!==null;)DBe(t,s,r),r=r.sibling}function DBe(t,s,r){if(s0&&typeof s0.onCommitFiberUnmount=="function")try{s0.onCommitFiberUnmount(Yce,r)}catch{}switch(r.tag){case 5:Ph||D5(r,s);case 6:var n=lh,a=Mx;lh=null,v_(t,s,r),lh=n,Mx=a,lh!==null&&(Mx?(t=lh,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):lh.removeChild(r.stateNode));break;case 18:lh!==null&&(Mx?(t=lh,r=r.stateNode,t.nodeType===8?Mfe(t.parentNode,r):t.nodeType===1&&Mfe(t,r),c8(t)):Mfe(lh,r.stateNode));break;case 4:n=lh,a=Mx,lh=r.stateNode.containerInfo,Mx=!0,v_(t,s,r),lh=n,Mx=a;break;case 0:case 11:case 14:case 15:if(!Ph&&(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)&&c0e(r,s,l),a=a.next}while(a!==n)}v_(t,s,r);break;case 1:if(!Ph&&(D5(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(i){ad(r,s,i)}v_(t,s,r);break;case 21:v_(t,s,r);break;case 22:r.mode&1?(Ph=(n=Ph)||r.memoizedState!==null,v_(t,s,r),Ph=n):v_(t,s,r);break;default:v_(t,s,r)}}function $Te(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new Ppt),s.forEach(function(n){var a=qpt.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function fx(t,s){var r=s.deletions;if(r!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=Nd()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*Dpt(n/1960))-n,10t?16:t,ub===null)var n=!1;else{if(t=ub,ub=null,Yie=0,Io&6)throw Error(Gr(331));var a=Io;for(Io|=4,Qn=t.current;Qn!==null;){var o=Qn,l=o.child;if(Qn.flags&16){var i=o.deletions;if(i!==null){for(var c=0;cNd()-U2e?D4(t,0):q2e|=r),fp(t,s)}function UBe(t,s){s===0&&(t.mode&1?(s=t7,t7<<=1,!(t7&130023424)&&(t7=4194304)):s=1);var r=Nm();t=g1(t,s),t!==null&&(GD(t,s,r),fp(t,r))}function $pt(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),UBe(t,r)}function qpt(t,s){var r=0;switch(t.tag){case 13:var n=t.stateNode,a=t.memoizedState;a!==null&&(r=a.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(Gr(314))}n!==null&&n.delete(s),UBe(t,r)}var VBe;VBe=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||mp.current)lp=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return lp=!1,Tpt(t,s,r);lp=!!(t.flags&131072)}else lp=!1,Tc&&s.flags&1048576&&K9e(s,$ie,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;Hz(t,s),t=s.pendingProps;var a=aT(s,$h.current);eM(s,r),a=O2e(null,s,n,t,a,r);var o=R2e();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,pp(n)?(o=!0,zie(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,E2e(s),a.updater=rde,s.stateNode=a,a._reactInternals=s,s0e(s,n,t,r),s=a0e(null,s,n,!0,o,r)):(s.tag=0,Tc&&o&&k2e(s),mm(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(Hz(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=Vpt(n),t=kx(n,t),a){case 0:s=n0e(null,s,n,t,r);break e;case 1:s=OTe(null,s,n,t,r);break e;case 11:s=LTe(null,s,n,t,r);break e;case 14:s=DTe(null,s,n,kx(n.type,t),r);break e}throw Error(Gr(306,n,""))}return s;case 0:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:kx(n,a),n0e(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:kx(n,a),OTe(t,s,n,a,r);case 3:e:{if(CBe(s),t===null)throw Error(Gr(387));n=s.pendingProps,o=s.memoizedState,a=o.element,eBe(t,s),Vie(s,n,null,r);var l=s.memoizedState;if(n=l.element,o.isDehydrated)if(o={element:n,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},s.updateQueue.baseState=o,s.memoizedState=o,s.flags&256){a=cT(Error(Gr(423)),s),s=RTe(t,s,n,r,a);break e}else if(n!==a){a=cT(Error(Gr(424)),s),s=RTe(t,s,n,r,a);break e}else for(nf=jb(s.stateNode.containerInfo.firstChild),of=s,Tc=!0,Ix=null,r=Q9e(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(iT(),n===a){s=x1(t,s,r);break e}mm(t,s,n,r)}s=s.child}return s;case 5:return tBe(s),t===null&&Jye(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,Kye(n,a)?l=null:o!==null&&Kye(n,o)&&(s.flags|=32),SBe(t,s),mm(t,s,l,r),s.child;case 6:return t===null&&Jye(s),null;case 13:return MBe(t,s,r);case 4:return P2e(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=oT(s,null,n,r):mm(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:kx(n,a),LTe(t,s,n,a,r);case 7:return mm(t,s,s.pendingProps,r),s.child;case 8:return mm(t,s,s.pendingProps.children,r),s.child;case 12:return mm(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,ql(qie,n._currentValue),n._currentValue=l,o!==null)if(Qx(o.value,l)){if(o.children===a.children&&!mp.current){s=x1(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=Wv(-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),e0e(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(Gr(341));l.lanes|=r,i=l.alternate,i!==null&&(i.lanes|=r),e0e(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}mm(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,eM(s,r),a=Sg(a),n=n(a),s.flags|=1,mm(t,s,n,r),s.child;case 14:return n=s.type,a=kx(n,s.pendingProps),a=kx(n.type,a),DTe(t,s,n,a,r);case 15:return kBe(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:kx(n,a),Hz(t,s),s.tag=1,pp(n)?(t=!0,zie(s)):t=!1,eM(s,r),bBe(s,n,a),s0e(s,n,a,r),a0e(null,s,n,!0,t,r);case 19:return TBe(t,s,r);case 22:return NBe(t,s,r)}throw Error(Gr(156,s.tag))};function HBe(t,s){return y9e(t,s)}function Upt(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 ug(t,s,r,n){return new Upt(t,s,r,n)}function G2e(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Vpt(t){if(typeof t=="function")return G2e(t)?1:0;if(t!=null){if(t=t.$$typeof,t===h2e)return 11;if(t===m2e)return 14}return 2}function Cb(t,s){var r=t.alternate;return r===null?(r=ug(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 Kz(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")G2e(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case S5:return O4(r.children,a,o,s);case u2e:l=8,a|=8;break;case Sye:return t=ug(12,r,s,a|2),t.elementType=Sye,t.lanes=o,t;case Cye:return t=ug(13,r,s,a),t.elementType=Cye,t.lanes=o,t;case Mye:return t=ug(19,r,s,a),t.elementType=Mye,t.lanes=o,t;case t9e:return ide(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Jze:l=10;break e;case e9e:l=9;break e;case h2e:l=11;break e;case m2e:l=14;break e;case D_:l=16,n=null;break e}throw Error(Gr(130,t==null?t:typeof t,""))}return s=ug(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function O4(t,s,r,n){return t=ug(7,t,n,s),t.lanes=r,t}function ide(t,s,r,n){return t=ug(22,t,n,s),t.elementType=t9e,t.lanes=r,t.stateNode={isHidden:!1},t}function Ofe(t,s,r){return t=ug(6,t,null,s),t.lanes=r,t}function Rfe(t,s,r){return s=ug(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function Hpt(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=xfe(0),this.expirationTimes=xfe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=xfe(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function K2e(t,s,r,n,a,o,l,i,c){return t=new Hpt(t,s,r,i,c),s===1?(s=1,o===!0&&(s|=8)):s=0,o=ug(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},E2e(o),t}function Wpt(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(ZBe)}catch(t){console.error(t)}}ZBe(),Zze.exports=jf;var cp=Zze.exports;const Q2e=Co(cp);var YBe,ZTe=cp;YBe=ZTe.createRoot,ZTe.hydrateRoot;const Xpt="modulepreload",Qpt=function(t){return"/"+t},YTe={},Wh=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=Qpt(c),c in YTe)return;YTe[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":Xpt,u||(f.as="script"),f.crossOrigin="",f.href=c,i&&f.setAttribute("nonce",i),document.head.appendChild(f),u)return new Promise((y,_)=>{f.addEventListener("load",y),f.addEventListener("error",()=>_(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)})},Jpt=1,eft=1e6;let Ffe=0;function tft(){return Ffe=(Ffe+1)%Number.MAX_SAFE_INTEGER,Ffe.toString()}const zfe=new Map,XTe=t=>{if(zfe.has(t))return;const s=setTimeout(()=>{zfe.delete(t),kI({type:"REMOVE_TOAST",toastId:t})},eft);zfe.set(t,s)},sft=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,Jpt)};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?XTe(r):t.toasts.forEach(n=>{XTe(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)}}},Zz=[];let Yz={toasts:[]};function kI(t){Yz=sft(Yz,t),Zz.forEach(s=>{s(Yz)})}function fn({...t}){const s=tft(),r=a=>kI({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>kI({type:"DISMISS_TOAST",toastId:s});return kI({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function Ra(){const[t,s]=C.useState(Yz);return C.useEffect(()=>(Zz.push(s),()=>{const r=Zz.indexOf(s);r>-1&&Zz.splice(r,1)}),[t]),{...t,toast:fn,dismiss:r=>kI({type:"DISMISS_TOAST",toastId:r})}}function Mr(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 QTe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function y1(...t){return s=>{let r=!1;const n=t.map(a=>{const o=QTe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,c=C.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:c,children:l})};n.displayName=t+"Provider";function a(o){const l=C.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 Yc(t,s=[]){let r=[];function n(o,l){const i=C.createContext(l),c=r.length;r=[...r,l];const u=f=>{var N;const{scope:y,children:_,...b}=f,w=((N=y==null?void 0:y[t])==null?void 0:N[c])||i,j=C.useMemo(()=>b,Object.values(b));return e.jsx(w.Provider,{value:j,children:_})};u.displayName=o+"Provider";function p(f,y){var w;const _=((w=y==null?void 0:y[t])==null?void 0:w[c])||i,b=C.useContext(_);if(b)return b;if(l!==void 0)return l;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[u,p]}const a=()=>{const o=r.map(l=>C.createContext(l));return function(i){const c=(i==null?void 0:i[t])||o;return C.useMemo(()=>({[`__scope${t}`]:{...i,[t]:c}}),[i,c])}};return a.scopeName=t,[n,nft(a,...s)]}function nft(...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 C.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function e2(t){const s=aft(t),r=C.forwardRef((n,a)=>{const{children:o,...l}=n,i=C.Children.toArray(o),c=i.find(ift);if(c){const u=c.props.children,p=i.map(f=>f===c?C.Children.count(u)>1?C.Children.only(null):C.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:C.isValidElement(u)?C.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var J2e=e2("Slot");function aft(t){const s=C.forwardRef((r,n)=>{const{children:a,...o}=r;if(C.isValidElement(a)){const l=lft(a),i=oft(o,a.props);return a.type!==C.Fragment&&(i.ref=n?y1(n,l):l),C.cloneElement(a,i)}return C.Children.count(a)>1?C.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var XBe=Symbol("radix.slottable");function QBe(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=XBe,s}function ift(t){return C.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===XBe}function oft(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 lft(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 XD(t){const s=t+"CollectionProvider",[r,n]=Yc(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=w=>{const{scope:j,children:N}=w,S=ht.useRef(null),T=ht.useRef(new Map).current;return e.jsx(a,{scope:j,itemMap:T,collectionRef:S,children:N})};l.displayName=s;const i=t+"CollectionSlot",c=e2(i),u=ht.forwardRef((w,j)=>{const{scope:N,children:S}=w,T=o(i,N),I=Oa(j,T.collectionRef);return e.jsx(c,{ref:I,children:S})});u.displayName=i;const p=t+"CollectionItemSlot",f="data-radix-collection-item",y=e2(p),_=ht.forwardRef((w,j)=>{const{scope:N,children:S,...T}=w,I=ht.useRef(null),L=Oa(j,I),R=o(p,N);return ht.useEffect(()=>(R.itemMap.set(I,{ref:I,...T}),()=>void R.itemMap.delete(I))),e.jsx(y,{[f]:"",ref:L,children:S})});_.displayName=p;function b(w){const j=o(t+"CollectionConsumer",w);return ht.useCallback(()=>{const S=j.collectionRef.current;if(!S)return[];const T=Array.from(S.querySelectorAll(`[${f}]`));return Array.from(j.itemMap.values()).sort((R,$)=>T.indexOf(R.ref.current)-T.indexOf($.ref.current))},[j.collectionRef,j.itemMap])}return[{Provider:l,Slot:u,ItemSlot:_},b,n]}var cft=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Jr=cft.reduce((t,s)=>{const r=e2(`Primitive.${s}`),n=C.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 ewe(t,s){t&&cp.flushSync(()=>t.dispatchEvent(s))}function dd(t){const s=C.useRef(t);return C.useEffect(()=>{s.current=t}),C.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function dft(t,s=globalThis==null?void 0:globalThis.document){const r=dd(t);C.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 uft="DismissableLayer",x0e="dismissableLayer.update",hft="dismissableLayer.pointerDownOutside",mft="dismissableLayer.focusOutside",JTe,JBe=C.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),g2=C.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...c}=t,u=C.useContext(JBe),[p,f]=C.useState(null),y=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,_]=C.useState({}),b=Oa(s,$=>f($)),w=Array.from(u.layers),[j]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),N=w.indexOf(j),S=p?w.indexOf(p):-1,T=u.layersWithOutsidePointerEventsDisabled.size>0,I=S>=N,L=fft($=>{const q=$.target,U=[...u.branches].some(V=>V.contains(q));!I||U||(a==null||a($),l==null||l($),$.defaultPrevented||i==null||i())},y),R=gft($=>{const q=$.target;[...u.branches].some(V=>V.contains(q))||(o==null||o($),l==null||l($),$.defaultPrevented||i==null||i())},y);return dft($=>{S===u.layers.size-1&&(n==null||n($),!$.defaultPrevented&&i&&($.preventDefault(),i()))},y),C.useEffect(()=>{if(p)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(JTe=y.body.style.pointerEvents,y.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),eAe(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(y.body.style.pointerEvents=JTe)}},[p,y,r,u]),C.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),eAe())},[p,u]),C.useEffect(()=>{const $=()=>_({});return document.addEventListener(x0e,$),()=>document.removeEventListener(x0e,$)},[]),e.jsx(Jr.div,{...c,ref:b,style:{pointerEvents:T?I?"auto":"none":void 0,...t.style},onFocusCapture:Mr(t.onFocusCapture,R.onFocusCapture),onBlurCapture:Mr(t.onBlurCapture,R.onBlurCapture),onPointerDownCapture:Mr(t.onPointerDownCapture,L.onPointerDownCapture)})});g2.displayName=uft;var pft="DismissableLayerBranch",e$e=C.forwardRef((t,s)=>{const r=C.useContext(JBe),n=C.useRef(null),a=Oa(s,n);return C.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),e.jsx(Jr.div,{...t,ref:a})});e$e.displayName=pft;function fft(t,s=globalThis==null?void 0:globalThis.document){const r=dd(t),n=C.useRef(!1),a=C.useRef(()=>{});return C.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let c=function(){t$e(hft,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 gft(t,s=globalThis==null?void 0:globalThis.document){const r=dd(t),n=C.useRef(!1);return C.useEffect(()=>{const a=o=>{o.target&&!n.current&&t$e(mft,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 eAe(){const t=new CustomEvent(x0e);document.dispatchEvent(t)}function t$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?ewe(a,o):a.dispatchEvent(o)}var xft=g2,yft=e$e,fd=globalThis!=null&&globalThis.document?C.useLayoutEffect:()=>{},vft="Portal",vA=C.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=C.useState(!1);fd(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?Q2e.createPortal(e.jsx(Jr.div,{...n,ref:s}),l):null});vA.displayName=vft;function _ft(t,s){return C.useReducer((r,n)=>s[r][n]??r,t)}var Id=t=>{const{present:s,children:r}=t,n=bft(s),a=typeof r=="function"?r({present:n.isPresent}):C.Children.only(r),o=Oa(n.ref,wft(a));return typeof r=="function"||n.isPresent?C.cloneElement(a,{ref:o}):null};Id.displayName="Presence";function bft(t){const[s,r]=C.useState(),n=C.useRef(null),a=C.useRef(t),o=C.useRef("none"),l=t?"mounted":"unmounted",[i,c]=_ft(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return C.useEffect(()=>{const u=m7(n.current);o.current=i==="mounted"?u:"none"},[i]),fd(()=>{const u=n.current,p=a.current;if(p!==t){const y=o.current,_=m7(u);t?c("MOUNT"):_==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(p&&y!==_?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,c]),fd(()=>{if(s){let u;const p=s.ownerDocument.defaultView??window,f=_=>{const w=m7(n.current).includes(_.animationName);if(_.target===s&&w&&(c("ANIMATION_END"),!a.current)){const j=s.style.animationFillMode;s.style.animationFillMode="forwards",u=p.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=j)})}},y=_=>{_.target===s&&(o.current=m7(n.current))};return s.addEventListener("animationstart",y),s.addEventListener("animationcancel",f),s.addEventListener("animationend",f),()=>{p.clearTimeout(u),s.removeEventListener("animationstart",y),s.removeEventListener("animationcancel",f),s.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[s,c]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:C.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function m7(t){return(t==null?void 0:t.animationName)||"none"}function wft(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 jft=o2e[" useInsertionEffect ".trim().toString()]||fd;function Yu({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=kft({defaultProp:s,onChange:r}),i=t!==void 0,c=i?t:a;{const p=C.useRef(t!==void 0);C.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=C.useCallback(p=>{var f;if(i){const y=Nft(p)?p(t):p;y!==t&&((f=l.current)==null||f.call(l,y))}else o(p)},[i,t,o,l]);return[c,u]}function kft({defaultProp:t,onChange:s}){const[r,n]=C.useState(t),a=C.useRef(r),o=C.useRef(s);return jft(()=>{o.current=s},[s]),C.useEffect(()=>{var l;a.current!==r&&((l=o.current)==null||l.call(o,r),a.current=r)},[r,a]),[r,n,o]}function Nft(t){return typeof t=="function"}var s$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"}),Sft="VisuallyHidden",ude=C.forwardRef((t,s)=>e.jsx(Jr.span,{...t,ref:s,style:{...s$e,...t.style}}));ude.displayName=Sft;var Cft=ude,twe="ToastProvider",[swe,Mft,Tft]=XD("Toast"),[r$e]=Yc("Toast",[Tft]),[Aft,hde]=r$e(twe),n$e=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,c]=C.useState(null),[u,p]=C.useState(0),f=C.useRef(!1),y=C.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${twe}\`. Expected non-empty \`string\`.`),e.jsx(swe.Provider,{scope:s,children:e.jsx(Aft,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:c,onToastAdd:C.useCallback(()=>p(_=>_+1),[]),onToastRemove:C.useCallback(()=>p(_=>_-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:y,children:l})})};n$e.displayName=twe;var a$e="ToastViewport",Eft=["F8"],y0e="toast.viewportPause",v0e="toast.viewportResume",i$e=C.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=Eft,label:a="Notifications ({hotkey})",...o}=t,l=hde(a$e,r),i=Mft(r),c=C.useRef(null),u=C.useRef(null),p=C.useRef(null),f=C.useRef(null),y=Oa(s,f,l.onViewportChange),_=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=l.toastCount>0;C.useEffect(()=>{const j=N=>{var T;n.length!==0&&n.every(I=>N[I]||N.code===I)&&((T=f.current)==null||T.focus())};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[n]),C.useEffect(()=>{const j=c.current,N=f.current;if(b&&j&&N){const S=()=>{if(!l.isClosePausedRef.current){const R=new CustomEvent(y0e);N.dispatchEvent(R),l.isClosePausedRef.current=!0}},T=()=>{if(l.isClosePausedRef.current){const R=new CustomEvent(v0e);N.dispatchEvent(R),l.isClosePausedRef.current=!1}},I=R=>{!j.contains(R.relatedTarget)&&T()},L=()=>{j.contains(document.activeElement)||T()};return j.addEventListener("focusin",S),j.addEventListener("focusout",I),j.addEventListener("pointermove",S),j.addEventListener("pointerleave",L),window.addEventListener("blur",S),window.addEventListener("focus",T),()=>{j.removeEventListener("focusin",S),j.removeEventListener("focusout",I),j.removeEventListener("pointermove",S),j.removeEventListener("pointerleave",L),window.removeEventListener("blur",S),window.removeEventListener("focus",T)}}},[b,l.isClosePausedRef]);const w=C.useCallback(({tabbingDirection:j})=>{const S=i().map(T=>{const I=T.ref.current,L=[I,...Vft(I)];return j==="forwards"?L:L.reverse()});return(j==="forwards"?S.reverse():S).flat()},[i]);return C.useEffect(()=>{const j=f.current;if(j){const N=S=>{var L,R,$;const T=S.altKey||S.ctrlKey||S.metaKey;if(S.key==="Tab"&&!T){const q=document.activeElement,U=S.shiftKey;if(S.target===j&&U){(L=u.current)==null||L.focus();return}const se=w({tabbingDirection:U?"backwards":"forwards"}),ee=se.findIndex(Q=>Q===q);Bfe(se.slice(ee+1))?S.preventDefault():U?(R=u.current)==null||R.focus():($=p.current)==null||$.focus()}};return j.addEventListener("keydown",N),()=>j.removeEventListener("keydown",N)}},[i,w]),e.jsxs(yft,{ref:c,role:"region","aria-label":a.replace("{hotkey}",_),tabIndex:-1,style:{pointerEvents:b?void 0:"none"},children:[b&&e.jsx(_0e,{ref:u,onFocusFromOutsideViewport:()=>{const j=w({tabbingDirection:"forwards"});Bfe(j)}}),e.jsx(swe.Slot,{scope:r,children:e.jsx(Jr.ol,{tabIndex:-1,...o,ref:y})}),b&&e.jsx(_0e,{ref:p,onFocusFromOutsideViewport:()=>{const j=w({tabbingDirection:"backwards"});Bfe(j)}})]})});i$e.displayName=a$e;var o$e="ToastFocusProxy",_0e=C.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=hde(o$e,r);return e.jsx(ude,{"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()}})});_0e.displayName=o$e;var QD="Toast",Pft="toast.swipeStart",Ift="toast.swipeMove",Lft="toast.swipeCancel",Dft="toast.swipeEnd",l$e=C.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,c]=Yu({prop:n,defaultProp:a??!0,onChange:o,caller:QD});return e.jsx(Id,{present:r||i,children:e.jsx(Fft,{open:i,...l,ref:s,onClose:()=>c(!1),onPause:dd(t.onPause),onResume:dd(t.onResume),onSwipeStart:Mr(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Mr(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:Mr(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:Mr(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)})})})});l$e.displayName=QD;var[Oft,Rft]=r$e(QD,{onClose(){}}),Fft=C.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:y,onSwipeEnd:_,...b}=t,w=hde(QD,r),[j,N]=C.useState(null),S=Oa(s,Q=>N(Q)),T=C.useRef(null),I=C.useRef(null),L=a||w.duration,R=C.useRef(0),$=C.useRef(L),q=C.useRef(0),{onToastAdd:U,onToastRemove:V}=w,X=dd(()=>{var de;(j==null?void 0:j.contains(document.activeElement))&&((de=w.viewport)==null||de.focus()),l()}),se=C.useCallback(Q=>{!Q||Q===1/0||(window.clearTimeout(q.current),R.current=new Date().getTime(),q.current=window.setTimeout(X,Q))},[X]);C.useEffect(()=>{const Q=w.viewport;if(Q){const de=()=>{se($.current),u==null||u()},re=()=>{const ne=new Date().getTime()-R.current;$.current=$.current-ne,window.clearTimeout(q.current),c==null||c()};return Q.addEventListener(y0e,re),Q.addEventListener(v0e,de),()=>{Q.removeEventListener(y0e,re),Q.removeEventListener(v0e,de)}}},[w.viewport,L,c,u,se]),C.useEffect(()=>{o&&!w.isClosePausedRef.current&&se(L)},[o,L,w.isClosePausedRef,se]),C.useEffect(()=>(U(),()=>V()),[U,V]);const ee=C.useMemo(()=>j?f$e(j):null,[j]);return w.viewport?e.jsxs(e.Fragment,{children:[ee&&e.jsx(zft,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:ee}),e.jsx(Oft,{scope:r,onClose:X,children:cp.createPortal(e.jsx(swe.ItemSlot,{scope:r,children:e.jsx(xft,{asChild:!0,onEscapeKeyDown:Mr(i,()=>{w.isFocusedToastEscapeKeyDownRef.current||X(),w.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(Jr.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":w.swipeDirection,...b,ref:S,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Mr(t.onKeyDown,Q=>{Q.key==="Escape"&&(i==null||i(Q.nativeEvent),Q.nativeEvent.defaultPrevented||(w.isFocusedToastEscapeKeyDownRef.current=!0,X()))}),onPointerDown:Mr(t.onPointerDown,Q=>{Q.button===0&&(T.current={x:Q.clientX,y:Q.clientY})}),onPointerMove:Mr(t.onPointerMove,Q=>{if(!T.current)return;const de=Q.clientX-T.current.x,re=Q.clientY-T.current.y,ne=!!I.current,le=["left","right"].includes(w.swipeDirection),he=["left","up"].includes(w.swipeDirection)?Math.min:Math.max,we=le?he(0,de):0,ye=le?0:he(0,re),je=Q.pointerType==="touch"?10:2,ke={x:we,y:ye},We={originalEvent:Q,delta:ke};ne?(I.current=ke,p7(Ift,f,We,{discrete:!1})):tAe(ke,w.swipeDirection,je)?(I.current=ke,p7(Pft,p,We,{discrete:!1}),Q.target.setPointerCapture(Q.pointerId)):(Math.abs(de)>je||Math.abs(re)>je)&&(T.current=null)}),onPointerUp:Mr(t.onPointerUp,Q=>{const de=I.current,re=Q.target;if(re.hasPointerCapture(Q.pointerId)&&re.releasePointerCapture(Q.pointerId),I.current=null,T.current=null,de){const ne=Q.currentTarget,le={originalEvent:Q,delta:de};tAe(de,w.swipeDirection,w.swipeThreshold)?p7(Dft,_,le,{discrete:!0}):p7(Lft,y,le,{discrete:!0}),ne.addEventListener("click",he=>he.preventDefault(),{once:!0})}})})})}),w.viewport)})]}):null}),zft=t=>{const{__scopeToast:s,children:r,...n}=t,a=hde(QD,s),[o,l]=C.useState(!1),[i,c]=C.useState(!1);return qft(()=>l(!0)),C.useEffect(()=>{const u=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(vA,{asChild:!0,children:e.jsx(ude,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},Bft="ToastTitle",c$e=C.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Jr.div,{...n,ref:s})});c$e.displayName=Bft;var $ft="ToastDescription",d$e=C.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(Jr.div,{...n,ref:s})});d$e.displayName=$ft;var u$e="ToastAction",h$e=C.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx(p$e,{altText:r,asChild:!0,children:e.jsx(rwe,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${u$e}\`. Expected non-empty \`string\`.`),null)});h$e.displayName=u$e;var m$e="ToastClose",rwe=C.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=Rft(m$e,r);return e.jsx(p$e,{asChild:!0,children:e.jsx(Jr.button,{type:"button",...n,ref:s,onClick:Mr(t.onClick,a.onClose)})})});rwe.displayName=m$e;var p$e=C.forwardRef((t,s)=>{const{__scopeToast:r,altText:n,...a}=t;return e.jsx(Jr.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function f$e(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),Uft(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(...f$e(n))}}),s}function p7(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?ewe(a,o):a.dispatchEvent(o)}var tAe=(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 qft(t=()=>{}){const s=dd(t);fd(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function Uft(t){return t.nodeType===t.ELEMENT_NODE}function Vft(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 Bfe(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var Hft=n$e,g$e=i$e,x$e=l$e,y$e=c$e,v$e=d$e,_$e=h$e,b$e=rwe;function w$e(t){var s,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(s=0;stypeof t=="boolean"?`${t}`:t===0?"0":t,rAe=Bi,HS=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return rAe(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 y=sAe(p)||sAe(f);return a[u][y]}),i=r&&Object.entries(r).reduce((u,p)=>{let[f,y]=p;return y===void 0||(u[f]=y),u},{}),c=s==null||(n=s.compoundVariants)===null||n===void 0?void 0:n.reduce((u,p)=>{let{class:f,className:y,..._}=p;return Object.entries(_).every(b=>{let[w,j]=b;return Array.isArray(j)?j.includes({...o,...i}[w]):{...o,...i}[w]===j})?[...u,f,y]:u},[]);return rAe(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 Wft=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),j$e=(...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 Gft={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 k$e=C.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},c)=>C.createElement("svg",{ref:c,...Gft,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:j$e("lucide",a),...i},[...l.map(([u,p])=>C.createElement(u,p)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z=(t,s)=>{const r=C.forwardRef(({className:n,...a},o)=>C.createElement(k$e,{ref:o,iconNode:s,className:j$e(`lucide-${Wft(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 Xz=Z("AArrowDown",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 7v9",key:"pknjwm"}],["path",{d:"m14 12 4 4 4-4",key:"buelq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qz=Z("AArrowUp",[["path",{d:"M3.5 13h6",key:"p1my2r"}],["path",{d:"m2 16 4.5-9 4.5 9",key:"ndf0b3"}],["path",{d:"M18 16V7",key:"ty0viw"}],["path",{d:"m14 11 4-4 4 4",key:"1pu57t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jz=Z("ALargeSmall",[["path",{d:"M21 14h-5",key:"1vh23k"}],["path",{d:"M16 16v-3.5a2.5 2.5 0 0 1 5 0V16",key:"1wh10o"}],["path",{d:"M4.5 13h6",key:"dfilno"}],["path",{d:"m3 16 4.5-9 4.5 9",key:"2dxa0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e9=Z("Accessibility",[["circle",{cx:"16",cy:"4",r:"1",key:"1grugj"}],["path",{d:"m18 19 1-7-6 1",key:"r0i19z"}],["path",{d:"m5 8 3-3 5.5 3-2.36 3.5",key:"9ptxx2"}],["path",{d:"M4.24 14.5a5 5 0 0 0 6.88 6",key:"10kmtu"}],["path",{d:"M13.76 17.5a5 5 0 0 0-6.88-6",key:"2qq6rc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gp=Z("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t9=Z("AirVent",[["path",{d:"M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"larmp2"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"M18.3 17.7a2.5 2.5 0 0 1-3.16 3.83 2.53 2.53 0 0 1-1.14-2V12",key:"1bo8pg"}],["path",{d:"M6.6 15.6A2 2 0 1 0 10 17v-5",key:"t9h90c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s9=Z("Airplay",[["path",{d:"M5 17H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-1",key:"ns4c3b"}],["path",{d:"m12 15 5 6H7Z",key:"14qnn2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fw=Z("AlarmClockCheck",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zw=Z("AlarmClockMinus",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"M9 13h6",key:"1uhe8q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r9=Z("AlarmClockOff",[["path",{d:"M6.87 6.87a8 8 0 1 0 11.26 11.26",key:"3on8tj"}],["path",{d:"M19.9 14.25a8 8 0 0 0-9.15-9.15",key:"15ghsc"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.26 18.67 4 21",key:"yzmioq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M4 4 2 6",key:"1ycko6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bw=Z("AlarmClockPlus",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n9=Z("AlarmClock",[["circle",{cx:"12",cy:"13",r:"8",key:"3y4lt7"}],["path",{d:"M12 9v4l2 2",key:"1c63tq"}],["path",{d:"M5 3 2 6",key:"18tl5t"}],["path",{d:"m22 6-3-3",key:"1opdir"}],["path",{d:"M6.38 18.7 4 21",key:"17xu3x"}],["path",{d:"M17.64 18.67 20 21",key:"kv2oe2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a9=Z("AlarmSmoke",[["path",{d:"M11 21c0-2.5 2-2.5 2-5",key:"1sicvv"}],["path",{d:"M16 21c0-2.5 2-2.5 2-5",key:"1o3eny"}],["path",{d:"m19 8-.8 3a1.25 1.25 0 0 1-1.2 1H7a1.25 1.25 0 0 1-1.2-1L5 8",key:"1bvca4"}],["path",{d:"M21 3a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a1 1 0 0 1 1-1z",key:"x3qr1j"}],["path",{d:"M6 21c0-2.5 2-2.5 2-5",key:"i3w1gp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i9=Z("Album",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["polyline",{points:"11 3 11 11 14 8 17 11 17 3",key:"1wcwz3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o9=Z("AlignCenterHorizontal",[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4",key:"11f1s0"}],["path",{d:"M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4",key:"t14dx9"}],["path",{d:"M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1",key:"1w07xs"}],["path",{d:"M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1",key:"1apec2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l9=Z("AlignCenterVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4",key:"14d6g8"}],["path",{d:"M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4",key:"1e2lrw"}],["path",{d:"M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1",key:"1fkdwx"}],["path",{d:"M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1",key:"1euafb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sM=Z("AlignCenter",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c9=Z("AlignEndHorizontal",[["rect",{width:"6",height:"16",x:"4",y:"2",rx:"2",key:"z5wdxg"}],["rect",{width:"6",height:"9",x:"14",y:"9",rx:"2",key:"um7a8w"}],["path",{d:"M22 22H2",key:"19qnx5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d9=Z("AlignEndVertical",[["rect",{width:"16",height:"6",x:"2",y:"4",rx:"2",key:"10wcwx"}],["rect",{width:"9",height:"6",x:"9",y:"14",rx:"2",key:"4p5bwg"}],["path",{d:"M22 22V2",key:"12ipfv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u9=Z("AlignHorizontalDistributeCenter",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M17 22v-5",key:"4b6g73"}],["path",{d:"M17 7V2",key:"hnrr36"}],["path",{d:"M7 22v-3",key:"1r4jpn"}],["path",{d:"M7 5V2",key:"liy1u9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h9=Z("AlignHorizontalDistributeEnd",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M10 2v20",key:"uyc634"}],["path",{d:"M20 2v20",key:"1tx262"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m9=Z("AlignHorizontalDistributeStart",[["rect",{width:"6",height:"14",x:"4",y:"5",rx:"2",key:"1wwnby"}],["rect",{width:"6",height:"10",x:"14",y:"7",rx:"2",key:"1fe6j6"}],["path",{d:"M4 2v20",key:"gtpd5x"}],["path",{d:"M14 2v20",key:"tg6bpw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p9=Z("AlignHorizontalJustifyCenter",[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M12 2v20",key:"t6zp3m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f9=Z("AlignHorizontalJustifyEnd",[["rect",{width:"6",height:"14",x:"2",y:"5",rx:"2",key:"dy24zr"}],["rect",{width:"6",height:"10",x:"12",y:"7",rx:"2",key:"1ht384"}],["path",{d:"M22 2v20",key:"40qfg1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g9=Z("AlignHorizontalJustifyStart",[["rect",{width:"6",height:"14",x:"6",y:"5",rx:"2",key:"hsirpf"}],["rect",{width:"6",height:"10",x:"16",y:"7",rx:"2",key:"13zkjt"}],["path",{d:"M2 2v20",key:"1ivd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x9=Z("AlignHorizontalSpaceAround",[["rect",{width:"6",height:"10",x:"9",y:"7",rx:"2",key:"yn7j0q"}],["path",{d:"M4 22V2",key:"tsjzd3"}],["path",{d:"M20 22V2",key:"1bnhr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y9=Z("AlignHorizontalSpaceBetween",[["rect",{width:"6",height:"14",x:"3",y:"5",rx:"2",key:"j77dae"}],["rect",{width:"6",height:"10",x:"15",y:"7",rx:"2",key:"bq30hj"}],["path",{d:"M3 2v20",key:"1d2pfg"}],["path",{d:"M21 2v20",key:"p059bm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v9=Z("AlignJustify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rM=Z("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nM=Z("AlignRight",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _9=Z("AlignStartHorizontal",[["rect",{width:"6",height:"16",x:"4",y:"6",rx:"2",key:"1n4dg1"}],["rect",{width:"6",height:"9",x:"14",y:"6",rx:"2",key:"17khns"}],["path",{d:"M22 2H2",key:"fhrpnj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b9=Z("AlignStartVertical",[["rect",{width:"9",height:"6",x:"6",y:"14",rx:"2",key:"lpm2y7"}],["rect",{width:"16",height:"6",x:"6",y:"4",rx:"2",key:"rdj6ps"}],["path",{d:"M2 2v20",key:"1ivd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w9=Z("AlignVerticalDistributeCenter",[["path",{d:"M22 17h-3",key:"1lwga1"}],["path",{d:"M22 7h-5",key:"o2endc"}],["path",{d:"M5 17H2",key:"1gx9xc"}],["path",{d:"M7 7H2",key:"6bq26l"}],["rect",{x:"5",y:"14",width:"14",height:"6",rx:"2",key:"1qrzuf"}],["rect",{x:"7",y:"4",width:"10",height:"6",rx:"2",key:"we8e9z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j9=Z("AlignVerticalDistributeEnd",[["rect",{width:"14",height:"6",x:"5",y:"14",rx:"2",key:"jmoj9s"}],["rect",{width:"10",height:"6",x:"7",y:"4",rx:"2",key:"aza5on"}],["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"M2 10h20",key:"1ir3d8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k9=Z("AlignVerticalDistributeStart",[["rect",{width:"14",height:"6",x:"5",y:"14",rx:"2",key:"jmoj9s"}],["rect",{width:"10",height:"6",x:"7",y:"4",rx:"2",key:"aza5on"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M2 4h20",key:"mda7wb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N9=Z("AlignVerticalJustifyCenter",[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S9=Z("AlignVerticalJustifyEnd",[["rect",{width:"14",height:"6",x:"5",y:"12",rx:"2",key:"4l4tp2"}],["rect",{width:"10",height:"6",x:"7",y:"2",rx:"2",key:"ypihtt"}],["path",{d:"M2 22h20",key:"272qi7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C9=Z("AlignVerticalJustifyStart",[["rect",{width:"14",height:"6",x:"5",y:"16",rx:"2",key:"1i8z2d"}],["rect",{width:"10",height:"6",x:"7",y:"6",rx:"2",key:"13squh"}],["path",{d:"M2 2h20",key:"1ennik"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M9=Z("AlignVerticalSpaceAround",[["rect",{width:"10",height:"6",x:"7",y:"9",rx:"2",key:"b1zbii"}],["path",{d:"M22 20H2",key:"1p1f7z"}],["path",{d:"M22 4H2",key:"1b7qnq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T9=Z("AlignVerticalSpaceBetween",[["rect",{width:"14",height:"6",x:"5",y:"15",rx:"2",key:"1w91an"}],["rect",{width:"10",height:"6",x:"7",y:"3",rx:"2",key:"17wqzy"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M2 3h20",key:"91anmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A9=Z("Ambulance",[["path",{d:"M10 10H6",key:"1bsnug"}],["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.28a1 1 0 0 0-.684-.948l-1.923-.641a1 1 0 0 1-.578-.502l-1.539-3.076A1 1 0 0 0 16.382 8H14",key:"lrkjwd"}],["path",{d:"M8 8v4",key:"1fwk8c"}],["path",{d:"M9 18h6",key:"x1upvd"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E9=Z("Ampersand",[["path",{d:"M17.5 12c0 4.4-3.6 8-8 8A4.5 4.5 0 0 1 5 15.5c0-6 8-4 8-8.5a3 3 0 1 0-6 0c0 3 2.5 8.5 12 13",key:"1o9ehi"}],["path",{d:"M16 12h3",key:"4uvgyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P9=Z("Ampersands",[["path",{d:"M10 17c-5-3-7-7-7-9a2 2 0 0 1 4 0c0 2.5-5 2.5-5 6 0 1.7 1.3 3 3 3 2.8 0 5-2.2 5-5",key:"12lh1k"}],["path",{d:"M22 17c-5-3-7-7-7-9a2 2 0 0 1 4 0c0 2.5-5 2.5-5 6 0 1.7 1.3 3 3 3 2.8 0 5-2.2 5-5",key:"173c68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I9=Z("Amphora",[["path",{d:"M10 2v5.632c0 .424-.272.795-.653.982A6 6 0 0 0 6 14c.006 4 3 7 5 8",key:"1h8rid"}],["path",{d:"M10 5H8a2 2 0 0 0 0 4h.68",key:"3ezsi6"}],["path",{d:"M14 2v5.632c0 .424.272.795.652.982A6 6 0 0 1 18 14c0 4-3 7-5 8",key:"yt6q09"}],["path",{d:"M14 5h2a2 2 0 0 1 0 4h-.68",key:"8f95yk"}],["path",{d:"M18 22H6",key:"mg6kv4"}],["path",{d:"M9 2h6",key:"1jrp98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L9=Z("Anchor",[["path",{d:"M12 22V8",key:"qkxhtm"}],["path",{d:"M5 12H2a10 10 0 0 0 20 0h-3",key:"1hv3nh"}],["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D9=Z("Angry",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["path",{d:"M7.5 8 10 9",key:"olxxln"}],["path",{d:"m14 9 2.5-1",key:"1j6cij"}],["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O9=Z("Annoyed",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 15h8",key:"45n4r"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M14 9h2",key:"116p9w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R9=Z("Antenna",[["path",{d:"M2 12 7 2",key:"117k30"}],["path",{d:"m7 12 5-10",key:"1tvx22"}],["path",{d:"m12 12 5-10",key:"ev1o1a"}],["path",{d:"m17 12 5-10",key:"1e4ti3"}],["path",{d:"M4.5 7h15",key:"vlsxkz"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F9=Z("Anvil",[["path",{d:"M7 10H6a4 4 0 0 1-4-4 1 1 0 0 1 1-1h4",key:"1hjpb6"}],["path",{d:"M7 5a1 1 0 0 1 1-1h13a1 1 0 0 1 1 1 7 7 0 0 1-7 7H8a1 1 0 0 1-1-1z",key:"1qn45f"}],["path",{d:"M9 12v5",key:"3anwtq"}],["path",{d:"M15 12v5",key:"5xh3zn"}],["path",{d:"M5 20a3 3 0 0 1 3-3h8a3 3 0 0 1 3 3 1 1 0 0 1-1 1H6a1 1 0 0 1-1-1",key:"1fi4x8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z9=Z("Aperture",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14.31 8 5.74 9.94",key:"1y6ab4"}],["path",{d:"M9.69 8h11.48",key:"1wxppr"}],["path",{d:"m7.38 12 5.74-9.94",key:"1grp0k"}],["path",{d:"M9.69 16 3.95 6.06",key:"libnyf"}],["path",{d:"M14.31 16H2.83",key:"x5fava"}],["path",{d:"m16.62 12-5.74 9.94",key:"1vwawt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B9=Z("AppWindowMac",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M14 8h.01",key:"1primd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NI=Z("AppWindow",[["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}],["path",{d:"M10 4v4",key:"pp8u80"}],["path",{d:"M2 8h20",key:"d11cs7"}],["path",{d:"M6 4v4",key:"1svtjw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $9=Z("Apple",[["path",{d:"M12 20.94c1.5 0 2.75 1.06 4 1.06 3 0 6-8 6-12.22A4.91 4.91 0 0 0 17 5c-2.22 0-4 1.44-5 2-1-.56-2.78-2-5-2a4.9 4.9 0 0 0-5 4.78C2 14 5 22 8 22c1.25 0 2.5-1.06 4-1.06Z",key:"3s7exb"}],["path",{d:"M10 2c1 .5 2 2 2 5",key:"fcco2y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SI=Z("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q9=Z("ArchiveX",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"m9.5 17 5-5",key:"nakeu6"}],["path",{d:"m9.5 12 5 5",key:"1hccrj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aM=Z("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U9=Z("Armchair",[["path",{d:"M19 9V6a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v3",key:"irtipd"}],["path",{d:"M3 16a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"1qyhux"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V9=Z("ArrowBigDownDash",[["path",{d:"M15 5H9",key:"1tp3ed"}],["path",{d:"M15 9v3h4l-7 7-7-7h4V9z",key:"ncdc4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H9=Z("ArrowBigDown",[["path",{d:"M15 6v6h4l-7 7-7-7h4V6h6z",key:"1thax2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W9=Z("ArrowBigLeftDash",[["path",{d:"M19 15V9",key:"1hci5f"}],["path",{d:"M15 15h-3v4l-7-7 7-7v4h3v6z",key:"16tjna"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G9=Z("ArrowBigLeft",[["path",{d:"M18 15h-6v4l-7-7 7-7v4h6v6z",key:"lbrdak"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K9=Z("ArrowBigRightDash",[["path",{d:"M5 9v6",key:"158jrl"}],["path",{d:"M9 9h3V5l7 7-7 7v-4H9V9z",key:"1sg2xn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z9=Z("ArrowBigRight",[["path",{d:"M6 9h6V5l7 7-7 7v-4H6V9z",key:"7fvt9c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y9=Z("ArrowBigUpDash",[["path",{d:"M9 19h6",key:"456am0"}],["path",{d:"M9 15v-3H5l7-7 7 7h-4v3H9z",key:"1r2uve"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X9=Z("ArrowBigUp",[["path",{d:"M9 18v-6H5l7-7 7 7h-4v6H9z",key:"1x06kx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q9=Z("ArrowDown01",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J9=Z("ArrowDown10",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $w=Z("ArrowDownAZ",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eB=Z("ArrowDownFromLine",[["path",{d:"M19 3H5",key:"1236rx"}],["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m6 15 6 6 6-6",key:"h15q88"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tB=Z("ArrowDownLeft",[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sB=Z("ArrowDownNarrowWide",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h4",key:"6d7r33"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h10",key:"1438ji"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CI=Z("ArrowDownRight",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rB=Z("ArrowDownToDot",[["path",{d:"M12 2v14",key:"jyx4ut"}],["path",{d:"m19 9-7 7-7-7",key:"1oe3oy"}],["circle",{cx:"12",cy:"21",r:"1",key:"o0uj5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nB=Z("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aB=Z("ArrowDownUp",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qw=Z("ArrowDownWideNarrow",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uw=Z("ArrowDownZA",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oh=Z("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iB=Z("ArrowLeftFromLine",[["path",{d:"m9 6-6 6 6 6",key:"7v63n9"}],["path",{d:"M3 12h14",key:"13k4hi"}],["path",{d:"M21 19V5",key:"b4bplr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oB=Z("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lB=Z("ArrowLeftToLine",[["path",{d:"M3 19V5",key:"rwsyhb"}],["path",{d:"m13 6-6 6 6 6",key:"1yhaz7"}],["path",{d:"M7 12h14",key:"uoisry"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const di=Z("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cB=Z("ArrowRightFromLine",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M21 12H7",key:"13ipq5"}],["path",{d:"m15 18 6-6-6-6",key:"6tx3qv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gv=Z("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dB=Z("ArrowRightToLine",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ki=Z("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uB=Z("ArrowUp01",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hB=Z("ArrowUp10",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vw=Z("ArrowUpAZ",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ud=Z("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mB=Z("ArrowUpFromDot",[["path",{d:"m5 9 7-7 7 7",key:"1hw5ic"}],["path",{d:"M12 16V2",key:"ywoabb"}],["circle",{cx:"12",cy:"21",r:"1",key:"o0uj5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pB=Z("ArrowUpFromLine",[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fB=Z("ArrowUpLeft",[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hw=Z("ArrowUpNarrowWide",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MI=Z("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gB=Z("ArrowUpToLine",[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xB=Z("ArrowUpWideNarrow",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h4",key:"1krc32"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ww=Z("ArrowUpZA",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gu=Z("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yB=Z("ArrowsUpFromLine",[["path",{d:"m4 6 3-3 3 3",key:"9aidw8"}],["path",{d:"M7 17V3",key:"19qxw1"}],["path",{d:"m14 6 3-3 3 3",key:"6iy689"}],["path",{d:"M17 17V3",key:"o0fmgi"}],["path",{d:"M4 21h16",key:"1h09gz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vB=Z("Asterisk",[["path",{d:"M12 6v12",key:"1vza4d"}],["path",{d:"M17.196 9 6.804 15",key:"1ah31z"}],["path",{d:"m6.804 9 10.392 6",key:"1b6pxd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _B=Z("AtSign",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bB=Z("Atom",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z",key:"1l2ple"}],["path",{d:"M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z",key:"1wam0m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wB=Z("AudioLines",[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jB=Z("AudioWaveform",[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fc=Z("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kB=Z("Axe",[["path",{d:"m14 12-8.5 8.5a2.12 2.12 0 1 1-3-3L11 9",key:"csbz4o"}],["path",{d:"M15 13 9 7l4-4 6 6h3a8 8 0 0 1-7 7z",key:"113wfo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gw=Z("Axis3d",[["path",{d:"M4 4v16h16",key:"1s015l"}],["path",{d:"m4 20 7-7",key:"17qe9y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NB=Z("Baby",[["path",{d:"M9 12h.01",key:"157uk2"}],["path",{d:"M15 12h.01",key:"1k8ypt"}],["path",{d:"M10 16c.5.3 1.2.5 2 .5s1.5-.2 2-.5",key:"1u7htd"}],["path",{d:"M19 6.3a9 9 0 0 1 1.8 3.9 2 2 0 0 1 0 3.6 9 9 0 0 1-17.6 0 2 2 0 0 1 0-3.6A9 9 0 0 1 12 3c2 0 3.5 1.1 3.5 2.5s-.9 2.5-2 2.5c-.8 0-1.5-.4-1.5-1",key:"5yv0yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SB=Z("Backpack",[["path",{d:"M4 10a4 4 0 0 1 4-4h8a4 4 0 0 1 4 4v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z",key:"1ol0lm"}],["path",{d:"M8 10h8",key:"c7uz4u"}],["path",{d:"M8 18h8",key:"1no2b1"}],["path",{d:"M8 22v-6a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v6",key:"1fr6do"}],["path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2",key:"donm21"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CB=Z("BadgeAlert",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MB=Z("BadgeCent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M15.4 10a4 4 0 1 0 0 4",key:"2eqtx8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kw=Z("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TB=Z("BadgeDollarSign",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AB=Z("BadgeEuro",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M7 12h5",key:"gblrwe"}],["path",{d:"M15 9.4a4 4 0 1 0 0 5.2",key:"1makmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EB=Z("BadgeHelp",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["line",{x1:"12",x2:"12.01",y1:"17",y2:"17",key:"io3f8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PB=Z("BadgeIndianRupee",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M8 8h8",key:"1bis0t"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m13 17-5-1h1a4 4 0 0 0 0-8",key:"nu2bwa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IB=Z("BadgeInfo",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"16",y2:"12",key:"1y1yb1"}],["line",{x1:"12",x2:"12.01",y1:"8",y2:"8",key:"110wyk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LB=Z("BadgeJapaneseYen",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 8 3 3v7",key:"17yadx"}],["path",{d:"m12 11 3-3",key:"p4cfq1"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M9 16h6",key:"8wimt3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DB=Z("BadgeMinus",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OB=Z("BadgePercent",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RB=Z("BadgePlus",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"12",x2:"12",y1:"8",y2:"16",key:"10p56q"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FB=Z("BadgePoundSterling",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M8 12h4",key:"qz6y1c"}],["path",{d:"M10 16V9.5a2.5 2.5 0 0 1 5 0",key:"3mlbjk"}],["path",{d:"M8 16h7",key:"sbedsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zB=Z("BadgeRussianRuble",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9 16h5",key:"1syiyw"}],["path",{d:"M9 12h5a2 2 0 1 0 0-4h-3v9",key:"1ge9c1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BB=Z("BadgeSwissFranc",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M11 17V8h4",key:"1bfq6y"}],["path",{d:"M11 12h3",key:"2eqnfz"}],["path",{d:"M9 16h4",key:"1skf3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $B=Z("BadgeX",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qB=Z("Badge",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UB=Z("BaggageClaim",[["path",{d:"M22 18H6a2 2 0 0 1-2-2V7a2 2 0 0 0-2-2",key:"4irg2o"}],["path",{d:"M17 14V4a2 2 0 0 0-2-2h-1a2 2 0 0 0-2 2v10",key:"14fcyx"}],["rect",{width:"13",height:"8",x:"8",y:"6",rx:"1",key:"o6oiis"}],["circle",{cx:"18",cy:"20",r:"2",key:"t9985n"}],["circle",{cx:"9",cy:"20",r:"2",key:"e5v82j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TI=Z("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VB=Z("Banana",[["path",{d:"M4 13c3.5-2 8-2 10 2a5.5 5.5 0 0 1 8 5",key:"1cscit"}],["path",{d:"M5.15 17.89c5.52-1.52 8.65-6.89 7-12C11.55 4 11.5 2 13 2c3.22 0 5 5.5 5 8 0 6.5-4.2 12-10.49 12C5.11 22 2 22 2 20c0-1.5 1.14-1.55 3.15-2.11Z",key:"1y1nbv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HB=Z("Bandage",[["path",{d:"M10 10.01h.01",key:"1e9xi7"}],["path",{d:"M10 14.01h.01",key:"ac23bv"}],["path",{d:"M14 10.01h.01",key:"2wfrvf"}],["path",{d:"M14 14.01h.01",key:"8tw8yn"}],["path",{d:"M18 6v11.5",key:"dkbidh"}],["path",{d:"M6 6v12",key:"vkc79e"}],["rect",{x:"2",y:"6",width:"20",height:"12",rx:"2",key:"1wpnh2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WB=Z("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GB=Z("Barcode",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M8 5v14",key:"1ybrkv"}],["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"M17 5v14",key:"ycjyhj"}],["path",{d:"M21 5v14",key:"nzette"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KB=Z("Baseline",[["path",{d:"M4 20h16",key:"14thso"}],["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n0=Z("Bath",[["path",{d:"M10 4 8 6",key:"1rru8s"}],["path",{d:"M17 19v2",key:"ts1sot"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M7 19v2",key:"12npes"}],["path",{d:"M9 5 7.621 3.621A2.121 2.121 0 0 0 4 5v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5",key:"14ym8i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZB=Z("BatteryCharging",[["path",{d:"M15 7h1a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-2",key:"1sdynx"}],["path",{d:"M6 7H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h1",key:"1gkd3k"}],["path",{d:"m11 7-3 5h4l-3 5",key:"b4a64w"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YB=Z("BatteryFull",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"13",key:"c6fn6x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XB=Z("BatteryLow",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QB=Z("BatteryMedium",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}],["line",{x1:"6",x2:"6",y1:"11",y2:"13",key:"1wd6dw"}],["line",{x1:"10",x2:"10",y1:"11",y2:"13",key:"haxvl5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JB=Z("BatteryWarning",[["path",{d:"M10 17h.01",key:"nbq80n"}],["path",{d:"M10 7v6",key:"nne03l"}],["path",{d:"M14 7h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2h-2",key:"1x5o8m"}],["path",{d:"M22 11v2",key:"1wo06k"}],["path",{d:"M6 7H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"1mdjgh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e$=Z("Battery",[["rect",{width:"16",height:"10",x:"2",y:"7",rx:"2",ry:"2",key:"1w10f2"}],["line",{x1:"22",x2:"22",y1:"11",y2:"13",key:"4dh1rd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t$=Z("Beaker",[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s$=Z("BeanOff",[["path",{d:"M9 9c-.64.64-1.521.954-2.402 1.165A6 6 0 0 0 8 22a13.96 13.96 0 0 0 9.9-4.1",key:"bq3udt"}],["path",{d:"M10.75 5.093A6 6 0 0 1 22 8c0 2.411-.61 4.68-1.683 6.66",key:"17ccse"}],["path",{d:"M5.341 10.62a4 4 0 0 0 6.487 1.208M10.62 5.341a4.015 4.015 0 0 1 2.039 2.04",key:"18zqgq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r$=Z("Bean",[["path",{d:"M10.165 6.598C9.954 7.478 9.64 8.36 9 9c-.64.64-1.521.954-2.402 1.165A6 6 0 0 0 8 22c7.732 0 14-6.268 14-14a6 6 0 0 0-11.835-1.402Z",key:"1tvzk7"}],["path",{d:"M5.341 10.62a4 4 0 1 0 5.279-5.28",key:"2cyri2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AI=Z("BedDouble",[["path",{d:"M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8",key:"1k78r4"}],["path",{d:"M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"fb3tl2"}],["path",{d:"M12 4v6",key:"1dcgq2"}],["path",{d:"M2 18h20",key:"ajqnye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n$=Z("BedSingle",[["path",{d:"M3 20v-8a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v8",key:"1wm6mi"}],["path",{d:"M5 10V6a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v4",key:"4k93s5"}],["path",{d:"M3 18h18",key:"1h113x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kv=Z("Bed",[["path",{d:"M2 4v16",key:"vw9hq8"}],["path",{d:"M2 8h18a2 2 0 0 1 2 2v10",key:"1dgv2r"}],["path",{d:"M2 17h20",key:"18nfp3"}],["path",{d:"M6 8v9",key:"1yriud"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a$=Z("Beef",[["circle",{cx:"12.5",cy:"8.5",r:"2.5",key:"9738u8"}],["path",{d:"M12.5 2a6.5 6.5 0 0 0-6.22 4.6c-1.1 3.13-.78 3.9-3.18 6.08A3 3 0 0 0 5 18c4 0 8.4-1.8 11.4-4.3A6.5 6.5 0 0 0 12.5 2Z",key:"o0f6za"}],["path",{d:"m18.5 6 2.19 4.5a6.48 6.48 0 0 1 .31 2 6.49 6.49 0 0 1-2.6 5.2C15.4 20.2 11 22 7 22a3 3 0 0 1-2.68-1.66L2.4 16.5",key:"k7p6i0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i$=Z("BeerOff",[["path",{d:"M13 13v5",key:"igwfh0"}],["path",{d:"M17 11.47V8",key:"16yw0g"}],["path",{d:"M17 11h1a3 3 0 0 1 2.745 4.211",key:"1xbt65"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 8v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-3",key:"c55o3e"}],["path",{d:"M7.536 7.535C6.766 7.649 6.154 8 5.5 8a2.5 2.5 0 0 1-1.768-4.268",key:"1ydug7"}],["path",{d:"M8.727 3.204C9.306 2.767 9.885 2 11 2c1.56 0 2 1.5 3 1.5s1.72-.5 2.5-.5a1 1 0 1 1 0 5c-.78 0-1.5-.5-2.5-.5a3.149 3.149 0 0 0-.842.12",key:"q81o7q"}],["path",{d:"M9 14.6V18",key:"20ek98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o$=Z("Beer",[["path",{d:"M17 11h1a3 3 0 0 1 0 6h-1",key:"1yp76v"}],["path",{d:"M9 12v6",key:"1u1cab"}],["path",{d:"M13 12v6",key:"1sugkk"}],["path",{d:"M14 7.5c-1 0-1.44.5-3 .5s-2-.5-3-.5-1.72.5-2.5.5a2.5 2.5 0 0 1 0-5c.78 0 1.57.5 2.5.5S9.44 2 11 2s2 1.5 3 1.5 1.72-.5 2.5-.5a2.5 2.5 0 0 1 0 5c-.78 0-1.5-.5-2.5-.5Z",key:"1510fo"}],["path",{d:"M5 8v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"19jb7n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l$=Z("BellDot",[["path",{d:"M19.4 14.9C20.2 16.4 21 17 21 17H3s3-2 3-9c0-3.3 2.7-6 6-6 .7 0 1.3.1 1.9.3",key:"xcehk"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["circle",{cx:"18",cy:"8",r:"3",key:"1g0gzu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c$=Z("BellElectric",[["path",{d:"M18.8 4A6.3 8.7 0 0 1 20 9",key:"xve1fh"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["circle",{cx:"9",cy:"9",r:"7",key:"p2h5vp"}],["rect",{width:"10",height:"6",x:"4",y:"16",rx:"2",key:"17f3te"}],["path",{d:"M14 19c3 0 4.6-1.6 4.6-1.6",key:"n7odp6"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const d$=Z("BellMinus",[["path",{d:"M18.4 12c.8 3.8 2.6 5 2.6 5H3s3-2 3-9c0-3.3 2.7-6 6-6 1.8 0 3.4.8 4.5 2",key:"eck70s"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M15 8h6",key:"8ybuxh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mb=Z("BellOff",[["path",{d:"M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5",key:"o7mx20"}],["path",{d:"M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7",key:"16f1lm"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u$=Z("BellPlus",[["path",{d:"M19.3 14.8C20.1 16.4 21 17 21 17H3s3-2 3-9c0-3.3 2.7-6 6-6 1 0 1.9.2 2.8.7",key:"guizqy"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M15 8h6",key:"8ybuxh"}],["path",{d:"M18 5v6",key:"g5ayrv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const h$=Z("BellRing",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gg=Z("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zw=Z("BetweenHorizontalEnd",[["rect",{width:"13",height:"7",x:"3",y:"3",rx:"1",key:"11xb64"}],["path",{d:"m22 15-3-3 3-3",key:"26chmm"}],["rect",{width:"13",height:"7",x:"3",y:"14",rx:"1",key:"k6ky7n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yw=Z("BetweenHorizontalStart",[["rect",{width:"13",height:"7",x:"8",y:"3",rx:"1",key:"pkso9a"}],["path",{d:"m2 9 3 3-3 3",key:"1agib5"}],["rect",{width:"13",height:"7",x:"8",y:"14",rx:"1",key:"1q5fc1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const m$=Z("BetweenVerticalEnd",[["rect",{width:"7",height:"13",x:"3",y:"3",rx:"1",key:"1fdu0f"}],["path",{d:"m9 22 3-3 3 3",key:"17z65a"}],["rect",{width:"7",height:"13",x:"14",y:"3",rx:"1",key:"1squn4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const p$=Z("BetweenVerticalStart",[["rect",{width:"7",height:"13",x:"3",y:"8",rx:"1",key:"1fjrkv"}],["path",{d:"m15 2-3 3-3-3",key:"1uh6eb"}],["rect",{width:"7",height:"13",x:"14",y:"8",rx:"1",key:"w3fjg8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const f$=Z("BicepsFlexed",[["path",{d:"M12.409 13.017A5 5 0 0 1 22 15c0 3.866-4 7-9 7-4.077 0-8.153-.82-10.371-2.462-.426-.316-.631-.832-.62-1.362C2.118 12.723 2.627 2 10 2a3 3 0 0 1 3 3 2 2 0 0 1-2 2c-1.105 0-1.64-.444-2-1",key:"1pmlyh"}],["path",{d:"M15 14a5 5 0 0 0-7.584 2",key:"5rb254"}],["path",{d:"M9.964 6.825C8.019 7.977 9.5 13 8 15",key:"kbvsx9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const g$=Z("Bike",[["circle",{cx:"18.5",cy:"17.5",r:"3.5",key:"15x4ox"}],["circle",{cx:"5.5",cy:"17.5",r:"3.5",key:"1noe27"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["path",{d:"M12 17.5V14l-3-3 4-3 2 3h2",key:"1npguv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const x$=Z("Binary",[["rect",{x:"14",y:"14",width:"4",height:"6",rx:"2",key:"p02svl"}],["rect",{x:"6",y:"4",width:"4",height:"6",rx:"2",key:"xm4xkj"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 10h4",key:"ru81e7"}],["path",{d:"M6 14h2v6",key:"16z9wg"}],["path",{d:"M14 4h2v6",key:"1idq9u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const y$=Z("Binoculars",[["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M19 7V4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3",key:"3apit1"}],["path",{d:"M20 21a2 2 0 0 0 2-2v-3.851c0-1.39-2-2.962-2-4.829V8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v11a2 2 0 0 0 2 2z",key:"rhpgnw"}],["path",{d:"M 22 16 L 2 16",key:"14lkq7"}],["path",{d:"M4 21a2 2 0 0 1-2-2v-3.851c0-1.39 2-2.962 2-4.829V8a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v11a2 2 0 0 1-2 2z",key:"104b3k"}],["path",{d:"M9 7V4a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v3",key:"14fczp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const v$=Z("Biohazard",[["circle",{cx:"12",cy:"11.9",r:"2",key:"e8h31w"}],["path",{d:"M6.7 3.4c-.9 2.5 0 5.2 2.2 6.7C6.5 9 3.7 9.6 2 11.6",key:"17bolr"}],["path",{d:"m8.9 10.1 1.4.8",key:"15ezny"}],["path",{d:"M17.3 3.4c.9 2.5 0 5.2-2.2 6.7 2.4-1.2 5.2-.6 6.9 1.5",key:"wtwa5u"}],["path",{d:"m15.1 10.1-1.4.8",key:"1r0b28"}],["path",{d:"M16.7 20.8c-2.6-.4-4.6-2.6-4.7-5.3-.2 2.6-2.1 4.8-4.7 5.2",key:"m7qszh"}],["path",{d:"M12 13.9v1.6",key:"zfyyim"}],["path",{d:"M13.5 5.4c-1-.2-2-.2-3 0",key:"1bi9q0"}],["path",{d:"M17 16.4c.7-.7 1.2-1.6 1.5-2.5",key:"1rhjqw"}],["path",{d:"M5.5 13.9c.3.9.8 1.8 1.5 2.5",key:"8gsud3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _$=Z("Bird",[["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M3.4 18H12a8 8 0 0 0 8-8V7a4 4 0 0 0-7.28-2.3L2 20",key:"oj1oa8"}],["path",{d:"m20 7 2 .5-2 .5",key:"12nv4d"}],["path",{d:"M10 18v3",key:"1yea0a"}],["path",{d:"M14 17.75V21",key:"1pymcb"}],["path",{d:"M7 18a6 6 0 0 0 3.84-10.61",key:"1npnn0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const b$=Z("Bitcoin",[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const w$=Z("Blend",[["circle",{cx:"9",cy:"9",r:"7",key:"p2h5vp"}],["circle",{cx:"15",cy:"15",r:"7",key:"19ennj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const j$=Z("Blinds",[["path",{d:"M3 3h18",key:"o7r712"}],["path",{d:"M20 7H8",key:"gd2fo2"}],["path",{d:"M20 11H8",key:"1ynp89"}],["path",{d:"M10 19h10",key:"19hjk5"}],["path",{d:"M8 15h12",key:"1yqzne"}],["path",{d:"M4 3v14",key:"fggqzn"}],["circle",{cx:"4",cy:"19",r:"2",key:"p3m9r0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const k$=Z("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const N$=Z("BluetoothConnected",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}],["line",{x1:"18",x2:"21",y1:"12",y2:"12",key:"1rsjjs"}],["line",{x1:"3",x2:"6",y1:"12",y2:"12",key:"11yl8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const S$=Z("BluetoothOff",[["path",{d:"m17 17-5 5V12l-5 5",key:"v5aci6"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M14.5 9.5 17 7l-5-5v4.5",key:"1kddfz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const C$=Z("BluetoothSearching",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}],["path",{d:"M20.83 14.83a4 4 0 0 0 0-5.66",key:"k8tn1j"}],["path",{d:"M18 12h.01",key:"yjnet6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M$=Z("Bluetooth",[["path",{d:"m7 7 10 10-5 5V2l5 5L7 17",key:"1q5490"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iM=Z("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T$=Z("Bolt",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A$=Z("Bomb",[["circle",{cx:"11",cy:"13",r:"9",key:"hd149"}],["path",{d:"M14.35 4.65 16.3 2.7a2.41 2.41 0 0 1 3.4 0l1.6 1.6a2.4 2.4 0 0 1 0 3.4l-1.95 1.95",key:"jp4j1b"}],["path",{d:"m22 2-1.5 1.5",key:"ay92ug"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const E$=Z("Bone",[["path",{d:"M17 10c.7-.7 1.69 0 2.5 0a2.5 2.5 0 1 0 0-5 .5.5 0 0 1-.5-.5 2.5 2.5 0 1 0-5 0c0 .81.7 1.8 0 2.5l-7 7c-.7.7-1.69 0-2.5 0a2.5 2.5 0 0 0 0 5c.28 0 .5.22.5.5a2.5 2.5 0 1 0 5 0c0-.81-.7-1.8 0-2.5Z",key:"w610uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P$=Z("BookA",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m8 13 4-7 4 7",key:"4rari8"}],["path",{d:"M9.1 11h5.7",key:"1gkovt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I$=Z("BookAudio",[["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8v3",key:"gejaml"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 8v3",key:"1qzp49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L$=Z("BookCheck",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 9.5 2 2 4-4",key:"1dth82"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D$=Z("BookCopy",[["path",{d:"M2 16V4a2 2 0 0 1 2-2h11",key:"spzkk5"}],["path",{d:"M22 18H11a2 2 0 1 0 0 4h10.5a.5.5 0 0 0 .5-.5v-15a.5.5 0 0 0-.5-.5H11a2 2 0 0 0-2 2v12",key:"1wz07i"}],["path",{d:"M5 14H4a2 2 0 1 0 0 4h1",key:"16gqf9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xw=Z("BookDashed",[["path",{d:"M12 17h2",key:"13u4lk"}],["path",{d:"M12 22h2",key:"kn7ki6"}],["path",{d:"M12 2h2",key:"cvn524"}],["path",{d:"M18 22h1a1 1 0 0 0 1-1",key:"w6gbqz"}],["path",{d:"M18 2h1a1 1 0 0 1 1 1v1",key:"1vpra5"}],["path",{d:"M20 15v2h-2",key:"fph276"}],["path",{d:"M20 8v3",key:"deu0bs"}],["path",{d:"M4 11V9",key:"v3xsx8"}],["path",{d:"M4 19.5V15",key:"6gr39e"}],["path",{d:"M4 5v-.5A2.5 2.5 0 0 1 6.5 2H8",key:"wywhs9"}],["path",{d:"M8 22H6.5a1 1 0 0 1 0-5H8",key:"1cu73q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O$=Z("BookDown",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 10 3 3 3-3",key:"zt5b4y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R$=Z("BookHeadphones",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 12v-2a4 4 0 0 1 8 0v2",key:"1vsqkj"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F$=Z("BookHeart",[["path",{d:"M16 8.2A2.22 2.22 0 0 0 13.8 6c-.8 0-1.4.3-1.8.9-.4-.6-1-.9-1.8-.9A2.22 2.22 0 0 0 8 8.2c0 .6.3 1.2.7 1.6A226.652 226.652 0 0 0 12 13a404 404 0 0 0 3.3-3.1 2.413 2.413 0 0 0 .7-1.7",key:"1t75a8"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z$=Z("BookImage",[["path",{d:"m20 13.7-2.1-2.1a2 2 0 0 0-2.8 0L9.7 17",key:"q6ojf0"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"10",cy:"8",r:"2",key:"2qkj4p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B$=Z("BookKey",[["path",{d:"m19 3 1 1",key:"ze14oc"}],["path",{d:"m20 2-4.5 4.5",key:"1sppr8"}],["path",{d:"M20 8v13a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"1ocbpn"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H14",key:"1gfsgw"}],["circle",{cx:"14",cy:"8",r:"2",key:"u49eql"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $$=Z("BookLock",[["path",{d:"M18 6V4a2 2 0 1 0-4 0v2",key:"1aquzs"}],["path",{d:"M20 15v6a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"1rkj32"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H10",key:"18wgow"}],["rect",{x:"12",y:"6",width:"8",height:"5",rx:"1",key:"73l30o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q$=Z("BookMarked",[["path",{d:"M10 2v8l3-3 3 3V2",key:"sqw3rj"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U$=Z("BookMinus",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V$=Z("BookOpenCheck",[["path",{d:"M12 21V7",key:"gj6g52"}],["path",{d:"m16 12 2 2 4-4",key:"mdajum"}],["path",{d:"M22 6V4a1 1 0 0 0-1-1h-5a4 4 0 0 0-4 4 4 4 0 0 0-4-4H3a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6a1 1 0 0 0 1-1v-1.3",key:"8arnkb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H$=Z("BookOpenText",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gh=Z("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W$=Z("BookPlus",[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G$=Z("BookText",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M8 11h8",key:"vwpz6n"}],["path",{d:"M8 7h6",key:"1f0q6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K$=Z("BookType",[["path",{d:"M10 13h4",key:"ytezjc"}],["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8V6H8v2",key:"x8j6u4"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z$=Z("BookUp2",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M18 2h1a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"161d7n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2",key:"1lorq7"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y$=Z("BookUp",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X$=Z("BookUser",[["path",{d:"M15 13a3 3 0 1 0-6 0",key:"10j68g"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q$=Z("BookX",[["path",{d:"m14.5 7-5 5",key:"dy991v"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9.5 7 5 5",key:"s45iea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J$=Z("Book",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eq=Z("BookmarkCheck",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tq=Z("BookmarkMinus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EI=Z("BookmarkPlus",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sq=Z("BookmarkX",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2Z",key:"169p4p"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ux=Z("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rq=Z("BoomBox",[["path",{d:"M4 9V5a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"vvzvr1"}],["path",{d:"M8 8v1",key:"xcqmfk"}],["path",{d:"M12 8v1",key:"1rj8u4"}],["path",{d:"M16 8v1",key:"1q12zr"}],["rect",{width:"20",height:"12",x:"2",y:"9",rx:"2",key:"igpb89"}],["circle",{cx:"8",cy:"15",r:"2",key:"fa4a8s"}],["circle",{cx:"16",cy:"15",r:"2",key:"14c3ya"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nq=Z("BotMessageSquare",[["path",{d:"M12 6V2H8",key:"1155em"}],["path",{d:"m8 18-4 4V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2Z",key:"w2lp3e"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M9 11v2",key:"1ueba0"}],["path",{d:"M15 11v2",key:"i11awn"}],["path",{d:"M20 12h2",key:"1q8mjw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aq=Z("BotOff",[["path",{d:"M13.67 8H18a2 2 0 0 1 2 2v4.33",key:"7az073"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}],["path",{d:"M8 8H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 1.414-.586",key:"s09a7a"}],["path",{d:"M9 13v2",key:"rq6x2g"}],["path",{d:"M9.67 4H12v2.33",key:"110xot"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oM=Z("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iq=Z("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oq=Z("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qw=Z("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lq=Z("Brackets",[["path",{d:"M16 3h3v18h-3",key:"1yor1f"}],["path",{d:"M8 21H5V3h3",key:"1qrfwo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cq=Z("BrainCircuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dq=Z("BrainCog",[["path",{d:"M12 5a3 3 0 1 0-5.997.142 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588 4 4 0 0 0 7.636 2.106 3.2 3.2 0 0 0 .164-.546c.028-.13.306-.13.335 0a3.2 3.2 0 0 0 .163.546 4 4 0 0 0 7.636-2.106 4 4 0 0 0 .556-6.588 4 4 0 0 0-2.526-5.77A3 3 0 1 0 12 5",key:"1kgmhc"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m15.7 10.4-.9.4",key:"ayzo6p"}],["path",{d:"m9.2 13.2-.9.4",key:"1uzb3g"}],["path",{d:"m13.6 15.7-.4-.9",key:"11ifqf"}],["path",{d:"m10.8 9.2-.4-.9",key:"1pmk2v"}],["path",{d:"m15.7 13.5-.9-.4",key:"7ng02m"}],["path",{d:"m9.2 10.9-.9-.4",key:"1x66zd"}],["path",{d:"m10.5 15.7.4-.9",key:"3js94g"}],["path",{d:"m13.1 9.2.4-.9",key:"18n7mc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PI=Z("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uq=Z("BrickWall",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 9v6",key:"199k2o"}],["path",{d:"M16 15v6",key:"8rj2es"}],["path",{d:"M16 3v6",key:"1j6rpj"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M8 15v6",key:"1stoo3"}],["path",{d:"M8 3v6",key:"vlvjmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hq=Z("BriefcaseBusiness",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M22 13a18.15 18.15 0 0 1-20 0",key:"12hx5q"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mq=Z("BriefcaseConveyorBelt",[["path",{d:"M10 20v2",key:"1n8e1g"}],["path",{d:"M14 20v2",key:"1lq872"}],["path",{d:"M18 20v2",key:"10uadw"}],["path",{d:"M21 20H3",key:"kdqkdp"}],["path",{d:"M6 20v2",key:"a9bc87"}],["path",{d:"M8 16V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v12",key:"17n9tx"}],["rect",{x:"4",y:"6",width:"16",height:"10",rx:"2",key:"1097i5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pq=Z("BriefcaseMedical",[["path",{d:"M12 11v4",key:"a6ujw6"}],["path",{d:"M14 13h-4",key:"1pl8zg"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M18 6v14",key:"1mu4gy"}],["path",{d:"M6 6v14",key:"1s15cj"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rh=Z("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fq=Z("BringToFront",[["rect",{x:"8",y:"8",width:"8",height:"8",rx:"2",key:"yj20xf"}],["path",{d:"M4 10a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2",key:"1ltk23"}],["path",{d:"M14 20a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2",key:"1q24h9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gq=Z("Brush",[["path",{d:"m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08",key:"1styjt"}],["path",{d:"M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z",key:"z0l1mu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xq=Z("BugOff",[["path",{d:"M15 7.13V6a3 3 0 0 0-5.14-2.1L8 2",key:"vl8zik"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M22 13h-4v-2a4 4 0 0 0-4-4h-1.3",key:"1ou0bd"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M7.7 7.7A4 4 0 0 0 6 11v3a6 6 0 0 0 11.13 3.13",key:"1njkjs"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yq=Z("BugPlay",[["path",{d:"M12.765 21.522a.5.5 0 0 1-.765-.424v-8.196a.5.5 0 0 1 .765-.424l5.878 3.674a1 1 0 0 1 0 1.696z",key:"17shqo"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M18 11a4 4 0 0 0-4-4h-4a4 4 0 0 0-4 4v3a6.1 6.1 0 0 0 2 4.5",key:"1tjixy"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vq=Z("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const La=Z("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const R4=Z("Building",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _q=Z("BusFront",[["path",{d:"M4 6 2 7",key:"1mqr15"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"m22 7-2-1",key:"1umjhc"}],["rect",{width:"16",height:"16",x:"4",y:"3",rx:"2",key:"1wxw4b"}],["path",{d:"M4 11h16",key:"mpoxn0"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M6 19v2",key:"1loha6"}],["path",{d:"M18 21v-2",key:"sqyl04"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bq=Z("Bus",[["path",{d:"M8 6v6",key:"18i7km"}],["path",{d:"M15 6v6",key:"1sg6z9"}],["path",{d:"M2 12h19.6",key:"de5uta"}],["path",{d:"M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3",key:"1wwztk"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}],["path",{d:"M9 18h5",key:"lrx6i"}],["circle",{cx:"16",cy:"18",r:"2",key:"1v4tcr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wq=Z("CableCar",[["path",{d:"M10 3h.01",key:"lbucoy"}],["path",{d:"M14 2h.01",key:"1k8aa1"}],["path",{d:"m2 9 20-5",key:"1kz0j5"}],["path",{d:"M12 12V6.5",key:"1vbrij"}],["rect",{width:"16",height:"10",x:"4",y:"12",rx:"3",key:"if91er"}],["path",{d:"M9 12v5",key:"3anwtq"}],["path",{d:"M15 12v5",key:"5xh3zn"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jq=Z("Cable",[["path",{d:"M17 21v-2a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1",key:"10bnsj"}],["path",{d:"M19 15V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V9",key:"1eqmu1"}],["path",{d:"M21 21v-2h-4",key:"14zm7j"}],["path",{d:"M3 5h4V3",key:"z442eg"}],["path",{d:"M7 5a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1V3",key:"ebdjd7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kq=Z("CakeSlice",[["circle",{cx:"9",cy:"7",r:"2",key:"1305pl"}],["path",{d:"M7.2 7.9 3 11v9c0 .6.4 1 1 1h16c.6 0 1-.4 1-1v-9c0-2-3-6-7-8l-3.6 2.6",key:"xle13f"}],["path",{d:"M16 13H3",key:"1wpj08"}],["path",{d:"M16 17H3",key:"3lvfcd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xh=Z("Cake",[["path",{d:"M20 21v-8a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8",key:"1w3rig"}],["path",{d:"M4 16s.5-1 2-1 2.5 2 4 2 2.5-2 4-2 2.5 2 4 2 2-1 2-1",key:"n2jgmb"}],["path",{d:"M2 21h20",key:"1nyx9w"}],["path",{d:"M7 8v3",key:"1qtyvj"}],["path",{d:"M12 8v3",key:"hwp4zt"}],["path",{d:"M17 8v3",key:"1i6e5u"}],["path",{d:"M7 4h.01",key:"1bh4kh"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M17 4h.01",key:"1upcoc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nq=Z("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sq=Z("Calendar1",[["path",{d:"M11 14h1v4",key:"fy54vd"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cq=Z("CalendarArrowDown",[["path",{d:"m14 18 4 4 4-4",key:"1waygx"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M18 14v8",key:"irew45"}],["path",{d:"M21 11.354V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.343",key:"bse4f3"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mq=Z("CalendarArrowUp",[["path",{d:"m14 18 4-4 4 4",key:"ftkppy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M18 22v-8",key:"su0gjh"}],["path",{d:"M21 11.343V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h9",key:"1exg90"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tq=Z("CalendarCheck2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 14V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"bce9hv"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const II=Z("CalendarCheck",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m9 16 2 2 4-4",key:"19s6y9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LI=Z("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aq=Z("CalendarCog",[["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"M21 10.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"11kmuh"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Md=Z("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eq=Z("CalendarFold",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 17V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11Z",key:"kg77oy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M15 22v-4a2 2 0 0 1 2-2h4",key:"1gnbqr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pq=Z("CalendarHeart",[["path",{d:"M3 10h18V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7",key:"136lmk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21.29 14.7a2.43 2.43 0 0 0-2.65-.52c-.3.12-.57.3-.8.53l-.34.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L17.5 22l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1t7hil"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iq=Z("CalendarMinus2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M10 16h4",key:"17e571"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lq=Z("CalendarMinus",[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 15V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1scpom"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DI=Z("CalendarOff",[["path",{d:"M4.2 4.2A2 2 0 0 0 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.82-1.18",key:"16swn3"}],["path",{d:"M21 15.5V6a2 2 0 0 0-2-2H9.5",key:"yhw86o"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h7",key:"1wap6i"}],["path",{d:"M21 10h-5.5",key:"quycpq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dq=Z("CalendarPlus2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M10 16h4",key:"17e571"}],["path",{d:"M12 14v4",key:"1thi36"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tb=Z("CalendarPlus",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 16v6",key:"tddt3s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oq=Z("CalendarRange",[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M17 14h-6",key:"bkmgh3"}],["path",{d:"M13 18H7",key:"bb0bb7"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 18h.01",key:"1bdyru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rq=Z("CalendarSearch",[["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 11.75V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h7.25",key:"1jrsq6"}],["path",{d:"m22 22-1.875-1.875",key:"13zax7"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fq=Z("CalendarSync",[["path",{d:"M11 10v4h4",key:"172dkj"}],["path",{d:"m11 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"vu0qm5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"m21 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"1qgeyt"}],["path",{d:"M21 22v-4h-4",key:"hrummi"}],["path",{d:"M21 8.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h4.3",key:"mctw84"}],["path",{d:"M3 10h4",key:"1el30a"}],["path",{d:"M8 2v4",key:"1cmpym"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zq=Z("CalendarX2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m17 22 5-5",key:"1k6ppv"}],["path",{d:"m17 17 5 5",key:"p7ous7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bq=Z("CalendarX",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m14 14-4 4",key:"rymu2i"}],["path",{d:"m10 14 4 4",key:"3sz06r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const on=Z("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $q=Z("CameraOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16",key:"qmtpty"}],["path",{d:"M9.5 4h5L17 7h3a2 2 0 0 1 2 2v7.5",key:"1ufyfc"}],["path",{d:"M14.121 15.121A3 3 0 1 1 9.88 10.88",key:"11zox6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vx=Z("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qq=Z("CandyCane",[["path",{d:"M5.7 21a2 2 0 0 1-3.5-2l8.6-14a6 6 0 0 1 10.4 6 2 2 0 1 1-3.464-2 2 2 0 1 0-3.464-2Z",key:"isaq8g"}],["path",{d:"M17.75 7 15 2.1",key:"12x7e8"}],["path",{d:"M10.9 4.8 13 9",key:"100a87"}],["path",{d:"m7.9 9.7 2 4.4",key:"ntfhaj"}],["path",{d:"M4.9 14.7 7 18.9",key:"1x43jy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uq=Z("CandyOff",[["path",{d:"m8.5 8.5-1 1a4.95 4.95 0 0 0 7 7l1-1",key:"1ff4ui"}],["path",{d:"M11.843 6.187A4.947 4.947 0 0 1 16.5 7.5a4.947 4.947 0 0 1 1.313 4.657",key:"1sbrv4"}],["path",{d:"M14 16.5V14",key:"1maf8j"}],["path",{d:"M14 6.5v1.843",key:"1a6u6t"}],["path",{d:"M10 10v7.5",key:"80pj65"}],["path",{d:"m16 7 1-5 1.367.683A3 3 0 0 0 19.708 3H21v1.292a3 3 0 0 0 .317 1.341L22 7l-5 1",key:"11a9mt"}],["path",{d:"m8 17-1 5-1.367-.683A3 3 0 0 0 4.292 21H3v-1.292a3 3 0 0 0-.317-1.341L2 17l5-1",key:"3mjmon"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vq=Z("Candy",[["path",{d:"m9.5 7.5-2 2a4.95 4.95 0 1 0 7 7l2-2a4.95 4.95 0 1 0-7-7Z",key:"ue6khb"}],["path",{d:"M14 6.5v10",key:"5xnk7c"}],["path",{d:"M10 7.5v10",key:"1uew51"}],["path",{d:"m16 7 1-5 1.37.68A3 3 0 0 0 19.7 3H21v1.3c0 .46.1.92.32 1.33L22 7l-5 1",key:"b9cp6k"}],["path",{d:"m8 17-1 5-1.37-.68A3 3 0 0 0 4.3 21H3v-1.3a3 3 0 0 0-.32-1.33L2 17l5-1",key:"5lney8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hq=Z("Cannabis",[["path",{d:"M12 22v-4",key:"1utk9m"}],["path",{d:"M7 12c-1.5 0-4.5 1.5-5 3 3.5 1.5 6 1 6 1-1.5 1.5-2 3.5-2 5 2.5 0 4.5-1.5 6-3 1.5 1.5 3.5 3 6 3 0-1.5-.5-3.5-2-5 0 0 2.5.5 6-1-.5-1.5-3.5-3-5-3 1.5-1 4-4 4-6-2.5 0-5.5 1.5-7 3 0-2.5-.5-5-2-7-1.5 2-2 4.5-2 7-1.5-1.5-4.5-3-7-3 0 2 2.5 5 4 6",key:"1mezod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wq=Z("CaptionsOff",[["path",{d:"M10.5 5H19a2 2 0 0 1 2 2v8.5",key:"jqtk4d"}],["path",{d:"M17 11h-.5",key:"1961ue"}],["path",{d:"M19 19H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2",key:"1keqsi"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M7 11h4",key:"1o1z6v"}],["path",{d:"M7 15h2.5",key:"1ina1g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jw=Z("Captions",[["rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2",key:"12ruh7"}],["path",{d:"M7 15h4M15 15h2M7 11h2M13 11h4",key:"1ueiar"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gq=Z("CarFront",[["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kq=Z("CarTaxiFront",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"m21 8-2 2-1.5-3.7A2 2 0 0 0 15.646 5H8.4a2 2 0 0 0-1.903 1.257L5 10 3 8",key:"1imjwt"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 14h.01",key:"7oqj8z"}],["rect",{width:"18",height:"8",x:"3",y:"10",rx:"2",key:"a7itu8"}],["path",{d:"M5 18v2",key:"ppbyun"}],["path",{d:"M19 18v2",key:"gy7782"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zq=Z("Car",[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yq=Z("Caravan",[["path",{d:"M18 19V9a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v8a2 2 0 0 0 2 2h2",key:"19jm3t"}],["path",{d:"M2 9h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2",key:"13hakp"}],["path",{d:"M22 17v1a1 1 0 0 1-1 1H10v-9a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v9",key:"1crci8"}],["circle",{cx:"8",cy:"19",r:"2",key:"t8fc5s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xq=Z("Carrot",[["path",{d:"M2.27 21.7s9.87-3.5 12.73-6.36a4.5 4.5 0 0 0-6.36-6.37C5.77 11.84 2.27 21.7 2.27 21.7zM8.64 14l-2.05-2.04M15.34 15l-2.46-2.46",key:"rfqxbe"}],["path",{d:"M22 9s-1.33-2-3.5-2C16.86 7 15 9 15 9s1.33 2 3.5 2S22 9 22 9z",key:"6b25w4"}],["path",{d:"M15 2s-2 1.33-2 3.5S15 9 15 9s2-1.84 2-3.5C17 3.33 15 2 15 2z",key:"fn65lo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qq=Z("CaseLower",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jq=Z("CaseSensitive",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["circle",{cx:"18",cy:"12",r:"3",key:"1kchzo"}],["path",{d:"M21 9v6",key:"anns31"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eU=Z("CaseUpper",[["path",{d:"m3 15 4-8 4 8",key:"1vwr6u"}],["path",{d:"M4 13h6",key:"1r9ots"}],["path",{d:"M15 11h4.5a2 2 0 0 1 0 4H15V7h4a2 2 0 0 1 0 4",key:"1sqfas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tU=Z("CassetteTape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["circle",{cx:"8",cy:"10",r:"2",key:"1xl4ub"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"10",r:"2",key:"r14t7q"}],["path",{d:"m6 20 .7-2.9A1.4 1.4 0 0 1 8.1 16h7.8a1.4 1.4 0 0 1 1.4 1l.7 3",key:"l01ucn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sU=Z("Cast",[["path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6",key:"3zrzxg"}],["path",{d:"M2 12a9 9 0 0 1 8 8",key:"g6cvee"}],["path",{d:"M2 16a5 5 0 0 1 4 4",key:"1y1dii"}],["line",{x1:"2",x2:"2.01",y1:"20",y2:"20",key:"xu2jvo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rU=Z("Castle",[["path",{d:"M22 20v-9H2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2Z",key:"109fe4"}],["path",{d:"M18 11V4H6v7",key:"mon5oj"}],["path",{d:"M15 22v-4a3 3 0 0 0-3-3a3 3 0 0 0-3 3v4",key:"1k4jtn"}],["path",{d:"M22 11V9",key:"3zbp94"}],["path",{d:"M2 11V9",key:"1x5rnq"}],["path",{d:"M6 4V2",key:"1rsq15"}],["path",{d:"M18 4V2",key:"1jsdo1"}],["path",{d:"M10 4V2",key:"75d9ly"}],["path",{d:"M14 4V2",key:"8nj3z6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nU=Z("Cat",[["path",{d:"M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z",key:"x6xyqk"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M11.25 16.25h1.5L12 17l-.75-.75Z",key:"12kq1m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aU=Z("Cctv",[["path",{d:"M16.75 12h3.632a1 1 0 0 1 .894 1.447l-2.034 4.069a1 1 0 0 1-1.708.134l-2.124-2.97",key:"ir91b5"}],["path",{d:"M17.106 9.053a1 1 0 0 1 .447 1.341l-3.106 6.211a1 1 0 0 1-1.342.447L3.61 12.3a2.92 2.92 0 0 1-1.3-3.91L3.69 5.6a2.92 2.92 0 0 1 3.92-1.3z",key:"jlp8i1"}],["path",{d:"M2 19h3.76a2 2 0 0 0 1.8-1.1L9 15",key:"19bib8"}],["path",{d:"M2 21v-4",key:"l40lih"}],["path",{d:"M7 9h.01",key:"19b3jx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ej=Z("ChartArea",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tj=Z("ChartBarBig",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"7",y:"13",width:"9",height:"4",rx:"1",key:"1iip1u"}],["rect",{x:"7",y:"5",width:"12",height:"4",rx:"1",key:"1anskk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iU=Z("ChartBarDecreasing",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11h8",key:"1feolt"}],["path",{d:"M7 16h3",key:"ur6vzw"}],["path",{d:"M7 6h12",key:"sz5b0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oU=Z("ChartBarIncreasing",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11h8",key:"1feolt"}],["path",{d:"M7 16h12",key:"wsnu98"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lU=Z("ChartBarStacked",[["path",{d:"M11 13v4",key:"vyy2rb"}],["path",{d:"M15 5v4",key:"1gx88a"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"7",y:"13",width:"9",height:"4",rx:"1",key:"1iip1u"}],["rect",{x:"7",y:"5",width:"12",height:"4",rx:"1",key:"1anskk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sj=Z("ChartBar",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16h8",key:"srdodz"}],["path",{d:"M7 11h12",key:"127s9w"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rj=Z("ChartCandlestick",[["path",{d:"M9 5v4",key:"14uxtq"}],["rect",{width:"4",height:"6",x:"7",y:"9",rx:"1",key:"f4fvz0"}],["path",{d:"M9 15v2",key:"r5rk32"}],["path",{d:"M17 3v2",key:"1l2re6"}],["rect",{width:"4",height:"8",x:"15",y:"5",rx:"1",key:"z38je5"}],["path",{d:"M17 13v3",key:"5l0wba"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nj=Z("ChartColumnBig",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cU=Z("ChartColumnDecreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17v-3",key:"1sqioe"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17V5",key:"1wzmnc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aj=Z("ChartColumnIncreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17V5",key:"sfb6ij"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dU=Z("ChartColumnStacked",[["path",{d:"M11 13H7",key:"t0o9gq"}],["path",{d:"M19 9h-4",key:"rera1j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xl=Z("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uU=Z("ChartGantt",[["path",{d:"M10 6h8",key:"zvc2xc"}],["path",{d:"M12 16h6",key:"yi5mkt"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 11h7",key:"wz2hg0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ij=Z("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hU=Z("ChartNetwork",[["path",{d:"m13.11 7.664 1.78 2.672",key:"go2gg9"}],["path",{d:"m14.162 12.788-3.324 1.424",key:"11x848"}],["path",{d:"m20 4-6.06 1.515",key:"1wxxh7"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["circle",{cx:"12",cy:"6",r:"2",key:"1jj5th"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}],["circle",{cx:"9",cy:"15",r:"2",key:"lf2ghp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mU=Z("ChartNoAxesColumnDecreasing",[["path",{d:"M12 20V10",key:"g8npz5"}],["path",{d:"M18 20v-4",key:"8uic4z"}],["path",{d:"M6 20V4",key:"1w1bmo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oj=Z("ChartNoAxesColumnIncreasing",[["line",{x1:"12",x2:"12",y1:"20",y2:"10",key:"1vz5eb"}],["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["line",{x1:"6",x2:"6",y1:"20",y2:"16",key:"hq0ia6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lj=Z("ChartNoAxesColumn",[["line",{x1:"18",x2:"18",y1:"20",y2:"10",key:"1xfpm4"}],["line",{x1:"12",x2:"12",y1:"20",y2:"4",key:"be30l9"}],["line",{x1:"6",x2:"6",y1:"20",y2:"14",key:"1r4le6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pU=Z("ChartNoAxesCombined",[["path",{d:"M12 16v5",key:"zza2cw"}],["path",{d:"M16 14v7",key:"1g90b9"}],["path",{d:"M20 10v11",key:"1iqoj0"}],["path",{d:"m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15",key:"1fw8x9"}],["path",{d:"M4 18v3",key:"1yp0dc"}],["path",{d:"M8 14v7",key:"n3cwzv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cj=Z("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dj=Z("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uj=Z("ChartScatter",[["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["circle",{cx:"18.5",cy:"5.5",r:".5",fill:"currentColor",key:"lysivs"}],["circle",{cx:"11.5",cy:"11.5",r:".5",fill:"currentColor",key:"byv1b8"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["circle",{cx:"17.5",cy:"14.5",r:".5",fill:"currentColor",key:"1gjh6j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fU=Z("ChartSpline",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16c.5-2 1.5-7 4-7 2 0 2 3 4 3 2.5 0 4.5-5 5-7",key:"lw07rv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gU=Z("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ma=Z("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xU=Z("ChefHat",[["path",{d:"M17 21a1 1 0 0 0 1-1v-5.35c0-.457.316-.844.727-1.041a4 4 0 0 0-2.134-7.589 5 5 0 0 0-9.186 0 4 4 0 0 0-2.134 7.588c.411.198.727.585.727 1.041V20a1 1 0 0 0 1 1Z",key:"1qvrer"}],["path",{d:"M6 17h12",key:"1jwigz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yU=Z("Cherry",[["path",{d:"M2 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z",key:"cvxqlc"}],["path",{d:"M12 17a5 5 0 0 0 10 0c0-2.76-2.5-5-5-3-2.5-2-5 .24-5 3Z",key:"1ostrc"}],["path",{d:"M7 14c3.22-2.91 4.29-8.75 5-12 1.66 2.38 4.94 9 5 12",key:"hqx58h"}],["path",{d:"M22 9c-4.29 0-7.14-2.33-10-7 5.71 0 10 4.67 10 7Z",key:"eykp1o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tl=Z("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vU=Z("ChevronFirst",[["path",{d:"m17 18-6-6 6-6",key:"1yerx2"}],["path",{d:"M7 6v12",key:"1p53r6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _U=Z("ChevronLast",[["path",{d:"m7 18 6-6-6-6",key:"lwmzdw"}],["path",{d:"M17 6v12",key:"1o0aio"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xl=Z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xa=Z("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hx=Z("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bU=Z("ChevronsDownUp",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wU=Z("ChevronsDown",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jU=Z("ChevronsLeftRightEllipsis",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kU=Z("ChevronsLeftRight",[["path",{d:"m9 7-5 5 5 5",key:"j5w590"}],["path",{d:"m15 7 5 5-5 5",key:"1bl6da"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NU=Z("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SU=Z("ChevronsRightLeft",[["path",{d:"m20 17-5-5 5-5",key:"30x0n2"}],["path",{d:"m4 17 5-5-5-5",key:"16spf4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CU=Z("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xg=Z("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MU=Z("ChevronsUp",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TU=Z("Chrome",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["line",{x1:"21.17",x2:"12",y1:"8",y2:"8",key:"a0cw5f"}],["line",{x1:"3.95",x2:"8.54",y1:"6.06",y2:"14",key:"1kftof"}],["line",{x1:"10.88",x2:"15.46",y1:"21.94",y2:"14",key:"1ymyh8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AU=Z("Church",[["path",{d:"M10 9h4",key:"u4k05v"}],["path",{d:"M12 7v5",key:"ma6bk"}],["path",{d:"M14 22v-4a2 2 0 0 0-4 0v4",key:"1pdhuj"}],["path",{d:"M18 22V5.618a1 1 0 0 0-.553-.894l-4.553-2.277a2 2 0 0 0-1.788 0L6.553 4.724A1 1 0 0 0 6 5.618V22",key:"1rkokr"}],["path",{d:"m18 7 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9.618a1 1 0 0 1 .553-.894L6 7",key:"1w6esw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EU=Z("CigaretteOff",[["path",{d:"M12 12H3a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h13",key:"1gdiyg"}],["path",{d:"M18 8c0-2.5-2-2.5-2-5",key:"1il607"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M21 12a1 1 0 0 1 1 1v2a1 1 0 0 1-.5.866",key:"166zjj"}],["path",{d:"M22 8c0-2.5-2-2.5-2-5",key:"1gah44"}],["path",{d:"M7 12v4",key:"jqww69"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PU=Z("Cigarette",[["path",{d:"M17 12H3a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h14",key:"1mb5g1"}],["path",{d:"M18 8c0-2.5-2-2.5-2-5",key:"1il607"}],["path",{d:"M21 16a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"1yl5r7"}],["path",{d:"M22 8c0-2.5-2-2.5-2-5",key:"1gah44"}],["path",{d:"M7 12v4",key:"jqww69"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yl=Z("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hj=Z("CircleArrowDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mj=Z("CircleArrowLeft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"m12 8-4 4 4 4",key:"15vm53"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pj=Z("CircleArrowOutDownLeft",[["path",{d:"M2 12a10 10 0 1 1 10 10",key:"1yn6ov"}],["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"M8 22H2v-6",key:"sulq54"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fj=Z("CircleArrowOutDownRight",[["path",{d:"M12 22a10 10 0 1 1 10-10",key:"130bv5"}],["path",{d:"M22 22 12 12",key:"131aw7"}],["path",{d:"M22 16v6h-6",key:"1gvm70"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gj=Z("CircleArrowOutUpLeft",[["path",{d:"M2 8V2h6",key:"hiwtdz"}],["path",{d:"m2 2 10 10",key:"1oh8rs"}],["path",{d:"M12 2A10 10 0 1 1 2 12",key:"rrk4fa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xj=Z("CircleArrowOutUpRight",[["path",{d:"M22 12A10 10 0 1 1 12 2",key:"1fm58d"}],["path",{d:"M22 2 12 12",key:"yg2myt"}],["path",{d:"M16 2h6v6",key:"zan5cs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yj=Z("CircleArrowRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vj=Z("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vi=Z("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ha=Z("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _j=Z("CircleChevronDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bj=Z("CircleChevronLeft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m14 16-4-4 4-4",key:"ojs7w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wj=Z("CircleChevronRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jj=Z("CircleChevronUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m8 14 4-4 4 4",key:"fy2ptz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IU=Z("CircleDashed",[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kj=Z("CircleDivide",[["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}],["line",{x1:"12",x2:"12",y1:"16",y2:"16",key:"aqc6ln"}],["line",{x1:"12",x2:"12",y1:"8",y2:"8",key:"1mkcni"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LU=Z("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DU=Z("CircleDotDashed",[["path",{d:"M10.1 2.18a9.93 9.93 0 0 1 3.8 0",key:"1qdqn0"}],["path",{d:"M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7",key:"1bq7p6"}],["path",{d:"M21.82 10.1a9.93 9.93 0 0 1 0 3.8",key:"1rlaqf"}],["path",{d:"M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69",key:"1xk03u"}],["path",{d:"M13.9 21.82a9.94 9.94 0 0 1-3.8 0",key:"l7re25"}],["path",{d:"M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7",key:"1v18p6"}],["path",{d:"M2.18 13.9a9.93 9.93 0 0 1 0-3.8",key:"xdo6bj"}],["path",{d:"M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69",key:"1jjmaz"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OU=Z("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RU=Z("CircleEllipsis",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FU=Z("CircleEqual",[["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zU=Z("CircleFadingArrowUp",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BU=Z("CircleFadingPlus",[["path",{d:"M12 2a10 10 0 0 1 7.38 16.75",key:"175t95"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M2.5 8.875a10 10 0 0 0-.5 3",key:"1vce0s"}],["path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4",key:"o3fkw4"}],["path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857",key:"1szpfk"}],["path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38",key:"9yhvd4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nj=Z("CircleGauge",[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mv=Z("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sj=Z("CircleMinus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $U=Z("CircleOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.35 2.69A10 10 0 0 1 21.3 15.65",key:"1pfsoa"}],["path",{d:"M19.08 19.08A10 10 0 1 1 4.92 4.92",key:"1ablyi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cj=Z("CircleParkingOff",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m5 5 14 14",key:"11anup"}],["path",{d:"M13 13a3 3 0 1 0 0-6H9v2",key:"uoagbd"}],["path",{d:"M9 17v-2.34",key:"a9qo08"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mj=Z("CircleParking",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tj=Z("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aj=Z("CirclePercent",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ap=Z("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ej=Z("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pj=Z("CirclePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ij=Z("CircleSlash2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qU=Z("CircleSlash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lj=Z("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dj=Z("CircleUserRound",[["path",{d:"M18 20a6 6 0 0 0-12 0",key:"1qehca"}],["circle",{cx:"12",cy:"10",r:"4",key:"1h16sb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oj=Z("CircleUser",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $c=Z("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pd=Z("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UU=Z("CircuitBoard",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M11 9h4a2 2 0 0 0 2-2V3",key:"1ve2rv"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"M7 21v-4a2 2 0 0 1 2-2h4",key:"1fwkro"}],["circle",{cx:"15",cy:"15",r:"2",key:"3i40o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VU=Z("Citrus",[["path",{d:"M21.66 17.67a1.08 1.08 0 0 1-.04 1.6A12 12 0 0 1 4.73 2.38a1.1 1.1 0 0 1 1.61-.04z",key:"4ite01"}],["path",{d:"M19.65 15.66A8 8 0 0 1 8.35 4.34",key:"1gxipu"}],["path",{d:"m14 10-5.5 5.5",key:"92pfem"}],["path",{d:"M14 17.85V10H6.15",key:"xqmtsk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HU=Z("Clapperboard",[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lM=Z("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WU=Z("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ab=Z("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GU=Z("ClipboardMinus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KU=Z("ClipboardPaste",[["path",{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",key:"1pp7kr"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",key:"2ik1ml"}],["path",{d:"m17 10 4 4-4 4",key:"vp2hj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rj=Z("ClipboardPenLine",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.5",key:"1but9f"}],["path",{d:"M16 4h2a2 2 0 0 1 1.73 1",key:"1p8n7l"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fj=Z("ClipboardPen",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-5.5",key:"cereej"}],["path",{d:"M4 13.5V6a2 2 0 0 1 2-2h2",key:"5ua5vh"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZU=Z("ClipboardPlus",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 14h6",key:"159ibu"}],["path",{d:"M12 17v-6",key:"1y8rbf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YU=Z("ClipboardType",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M9 12v-1h6v1",key:"iehl6m"}],["path",{d:"M11 17h2",key:"12w5me"}],["path",{d:"M12 11v6",key:"1bwqyc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XU=Z("ClipboardX",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m15 11-6 6",key:"1toa9n"}],["path",{d:"m9 11 6 6",key:"wlibny"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QU=Z("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JU=Z("Clock1",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 14.5 8",key:"12zbmj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eV=Z("Clock10",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 10",key:"atfzqc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tV=Z("Clock11",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 8",key:"l5bg6f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sV=Z("Clock12",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12",key:"1fub01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rV=Z("Clock2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 10",key:"1g230d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nV=Z("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aV=Z("Clock4",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iV=Z("Clock5",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 14.5 16",key:"1pcbox"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oV=Z("Clock6",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 12 16.5",key:"hb2qv6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lV=Z("Clock7",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 9.5 16",key:"ka3394"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cV=Z("Clock8",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 8 14",key:"tmc9b4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dV=Z("Clock9",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 7.5 12",key:"1k60p0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uV=Z("ClockAlert",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["path",{d:"M16 21.16a10 10 0 1 1 5-13.516",key:"cxo92l"}],["path",{d:"M20 11.5v6",key:"2ei3xq"}],["path",{d:"M20 21.5h.01",key:"1r2dzp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hV=Z("ClockArrowDown",[["path",{d:"M12.338 21.994A10 10 0 1 1 21.925 13.227",key:"1i7shu"}],["path",{d:"M12 6v6l2 1",key:"19cm8n"}],["path",{d:"m14 18 4 4 4-4",key:"1waygx"}],["path",{d:"M18 14v8",key:"irew45"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mV=Z("ClockArrowUp",[["path",{d:"M13.228 21.925A10 10 0 1 1 21.994 12.338",key:"1fzlyi"}],["path",{d:"M12 6v6l1.562.781",key:"1ujuk9"}],["path",{d:"m14 18 4-4 4 4",key:"ftkppy"}],["path",{d:"M18 22v-8",key:"su0gjh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tn=Z("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pV=Z("CloudAlert",[["path",{d:"M12 12v4",key:"tww15h"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M17 18h.5a1 1 0 0 0 0-9h-1.79A7 7 0 1 0 7 17.708",key:"xsb5ju"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fV=Z("CloudCog",[["circle",{cx:"12",cy:"17",r:"3",key:"1spfwm"}],["path",{d:"M4.2 15.1A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2",key:"zaobp"}],["path",{d:"m15.7 18.4-.9-.3",key:"4qxpbn"}],["path",{d:"m9.2 15.9-.9-.3",key:"17q7o2"}],["path",{d:"m10.6 20.7.3-.9",key:"1pf4s2"}],["path",{d:"m13.1 14.2.3-.9",key:"1mnuqm"}],["path",{d:"m13.6 20.7-.4-1",key:"1jpd1m"}],["path",{d:"m10.8 14.3-.4-1",key:"17ugyy"}],["path",{d:"m8.3 18.6 1-.4",key:"s42vdx"}],["path",{d:"m14.7 15.8 1-.4",key:"2wizun"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zj=Z("CloudDownload",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gV=Z("CloudDrizzle",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 19v1",key:"1dk2by"}],["path",{d:"M8 14v1",key:"84yxot"}],["path",{d:"M16 19v1",key:"v220m7"}],["path",{d:"M16 14v1",key:"g12gj6"}],["path",{d:"M12 21v1",key:"q8vafk"}],["path",{d:"M12 16v1",key:"1mx6rx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xV=Z("CloudFog",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 17H7",key:"pygtm1"}],["path",{d:"M17 21H9",key:"1u2q02"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yV=Z("CloudHail",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v2",key:"a1is7l"}],["path",{d:"M8 14v2",key:"1e9m6t"}],["path",{d:"M16 20h.01",key:"xwek51"}],["path",{d:"M8 20h.01",key:"1vjney"}],["path",{d:"M12 16v2",key:"z66u1j"}],["path",{d:"M12 22h.01",key:"1urd7a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vV=Z("CloudLightning",[["path",{d:"M6 16.326A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 .5 8.973",key:"1cez44"}],["path",{d:"m13 12-3 5h4l-3 5",key:"1t22er"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _V=Z("CloudMoonRain",[["path",{d:"M10.188 8.5A6 6 0 0 1 16 4a1 1 0 0 0 6 6 6 6 0 0 1-3 5.197",key:"erj67n"}],["path",{d:"M11 20v2",key:"174qtz"}],["path",{d:"M3 20a5 5 0 1 1 8.9-4H13a3 3 0 0 1 2 5.24",key:"1qmrp3"}],["path",{d:"M7 19v2",key:"12npes"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bV=Z("CloudMoon",[["path",{d:"M10.188 8.5A6 6 0 0 1 16 4a1 1 0 0 0 6 6 6 6 0 0 1-3 5.197",key:"erj67n"}],["path",{d:"M13 16a3 3 0 1 1 0 6H7a5 5 0 1 1 4.9-6Z",key:"p44pc9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wV=Z("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jV=Z("CloudRainWind",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m9.2 22 3-7",key:"sb5f6j"}],["path",{d:"m9 13-3 7",key:"500co5"}],["path",{d:"m17 13-3 7",key:"8t2fiy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kV=Z("CloudRain",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M16 14v6",key:"1j4efv"}],["path",{d:"M8 14v6",key:"17c4r9"}],["path",{d:"M12 16v6",key:"c8a4gj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NV=Z("CloudSnow",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M8 19h.01",key:"puxtts"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M12 21h.01",key:"h35vbk"}],["path",{d:"M16 15h.01",key:"rnfrdf"}],["path",{d:"M16 19h.01",key:"1vcnzz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SV=Z("CloudSunRain",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M3 20a5 5 0 1 1 8.9-4H13a3 3 0 0 1 2 5.24",key:"1qmrp3"}],["path",{d:"M11 20v2",key:"174qtz"}],["path",{d:"M7 19v2",key:"12npes"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CV=Z("CloudSun",[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}],["path",{d:"M15.947 12.65a4 4 0 0 0-5.925-4.128",key:"dpwdj0"}],["path",{d:"M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z",key:"s09mg5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bj=Z("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MV=Z("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TV=Z("Cloudy",[["path",{d:"M17.5 21H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"gqqjvc"}],["path",{d:"M22 10a3 3 0 0 0-3-3h-2.207a5.502 5.502 0 0 0-10.702.5",key:"1p2s76"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $v=Z("Clover",[["path",{d:"M16.17 7.83 2 22",key:"t58vo8"}],["path",{d:"M4.02 12a2.827 2.827 0 1 1 3.81-4.17A2.827 2.827 0 1 1 12 4.02a2.827 2.827 0 1 1 4.17 3.81A2.827 2.827 0 1 1 19.98 12a2.827 2.827 0 1 1-3.81 4.17A2.827 2.827 0 1 1 12 19.98a2.827 2.827 0 1 1-4.17-3.81A1 1 0 1 1 4 12",key:"17k36q"}],["path",{d:"m7.83 7.83 8.34 8.34",key:"1d7sxk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AV=Z("Club",[["path",{d:"M17.28 9.05a5.5 5.5 0 1 0-10.56 0A5.5 5.5 0 1 0 12 17.66a5.5 5.5 0 1 0 5.28-8.6Z",key:"27yuqz"}],["path",{d:"M12 17.66L12 22",key:"ogfahf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $j=Z("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F4=Z("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EV=Z("Codepen",[["polygon",{points:"12 2 22 8.5 22 15.5 12 22 2 15.5 2 8.5 12 2",key:"srzb37"}],["line",{x1:"12",x2:"12",y1:"22",y2:"15.5",key:"1t73f2"}],["polyline",{points:"22 8.5 12 15.5 2 8.5",key:"ajlxae"}],["polyline",{points:"2 15.5 12 8.5 22 15.5",key:"susrui"}],["line",{x1:"12",x2:"12",y1:"2",y2:"8.5",key:"2cldga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PV=Z("Codesandbox",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}],["polyline",{points:"7.5 4.21 12 6.81 16.5 4.21",key:"fabo96"}],["polyline",{points:"7.5 19.79 7.5 14.6 3 12",key:"z377f1"}],["polyline",{points:"21 12 16.5 14.6 16.5 19.79",key:"9nrev1"}],["polyline",{points:"3.27 6.96 12 12.01 20.73 6.96",key:"1180pa"}],["line",{x1:"12",x2:"12",y1:"22.08",y2:"12",key:"3z3uq6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z4=Z("Coffee",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IV=Z("Cog",[["path",{d:"M12 20a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",key:"sobvz5"}],["path",{d:"M12 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4Z",key:"11i496"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 22v-2",key:"1osdcq"}],["path",{d:"m17 20.66-1-1.73",key:"eq3orb"}],["path",{d:"M11 10.27 7 3.34",key:"16pf9h"}],["path",{d:"m20.66 17-1.73-1",key:"sg0v6f"}],["path",{d:"m3.34 7 1.73 1",key:"1ulond"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"m20.66 7-1.73 1",key:"1ow05n"}],["path",{d:"m3.34 17 1.73-1",key:"nuk764"}],["path",{d:"m17 3.34-1 1.73",key:"2wel8s"}],["path",{d:"m11 13.73-4 6.93",key:"794ttg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OI=Z("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qj=Z("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uj=Z("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LV=Z("Columns4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7.5 3v18",key:"w0wo6v"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M16.5 3v18",key:"10tjh1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DV=Z("Combine",[["path",{d:"M10 18H5a3 3 0 0 1-3-3v-1",key:"ru65g8"}],["path",{d:"M14 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"e30een"}],["path",{d:"M20 2a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"2ahx8o"}],["path",{d:"m7 21 3-3-3-3",key:"127cv2"}],["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OV=Z("Command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RV=Z("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FV=Z("Component",[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zV=Z("Computer",[["rect",{width:"14",height:"8",x:"5",y:"2",rx:"2",key:"wc9tft"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h2",key:"rwmk9e"}],["path",{d:"M12 18h6",key:"aqd8w3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BV=Z("ConciergeBell",[["path",{d:"M3 20a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1Z",key:"1pvr1r"}],["path",{d:"M20 16a8 8 0 1 0-16 0",key:"1pa543"}],["path",{d:"M12 4v4",key:"1bq03y"}],["path",{d:"M10 4h4",key:"1xpv9s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $V=Z("Cone",[["path",{d:"m20.9 18.55-8-15.98a1 1 0 0 0-1.8 0l-8 15.98",key:"53pte7"}],["ellipse",{cx:"12",cy:"19",rx:"9",ry:"3",key:"1ji25f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qV=Z("Construction",[["rect",{x:"2",y:"6",width:"20",height:"8",rx:"1",key:"1estib"}],["path",{d:"M17 14v7",key:"7m2elx"}],["path",{d:"M7 14v7",key:"1cm7wv"}],["path",{d:"M17 3v3",key:"1v4jwn"}],["path",{d:"M7 3v3",key:"7o6guu"}],["path",{d:"M10 14 2.3 6.3",key:"1023jk"}],["path",{d:"m14 6 7.7 7.7",key:"1s8pl2"}],["path",{d:"m8 6 8 8",key:"hl96qh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vj=Z("ContactRound",[["path",{d:"M16 2v2",key:"scm5qe"}],["path",{d:"M17.915 22a6 6 0 0 0-12 0",key:"suqz9p"}],["path",{d:"M8 2v2",key:"pbkmx"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B4=Z("Contact",[["path",{d:"M16 2v2",key:"scm5qe"}],["path",{d:"M7 22v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2",key:"1waht3"}],["path",{d:"M8 2v2",key:"pbkmx"}],["circle",{cx:"12",cy:"11",r:"3",key:"itu57m"}],["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",key:"12vinp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UV=Z("Container",[["path",{d:"M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z",key:"1t2lqe"}],["path",{d:"M10 21.9V14L2.1 9.1",key:"o7czzq"}],["path",{d:"m10 14 11.9-6.9",key:"zm5e20"}],["path",{d:"M14 19.8v-8.1",key:"159ecu"}],["path",{d:"M18 17.5V9.4",key:"11uown"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VV=Z("Contrast",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 18a6 6 0 0 0 0-12v12z",key:"j4l70d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HV=Z("Cookie",[["path",{d:"M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5",key:"laymnq"}],["path",{d:"M8.5 8.5v.01",key:"ue8clq"}],["path",{d:"M16 15.5v.01",key:"14dtrp"}],["path",{d:"M12 12v.01",key:"u5ubse"}],["path",{d:"M11 17v.01",key:"1hyl5a"}],["path",{d:"M7 14v.01",key:"uct60s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WV=Z("CookingPot",[["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M20 12v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8",key:"u0tga0"}],["path",{d:"m4 8 16-4",key:"16g0ng"}],["path",{d:"m8.86 6.78-.45-1.81a2 2 0 0 1 1.45-2.43l1.94-.48a2 2 0 0 1 2.43 1.46l.45 1.8",key:"12cejc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GV=Z("CopyCheck",[["path",{d:"m12 15 2 2 4-4",key:"2c609p"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KV=Z("CopyMinus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZV=Z("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YV=Z("CopySlash",[["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XV=Z("CopyX",[["line",{x1:"12",x2:"18",y1:"12",y2:"18",key:"1rg63v"}],["line",{x1:"12",x2:"18",y1:"18",y2:"12",key:"ebkxgr"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mi=Z("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QV=Z("Copyleft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.17 14.83a4 4 0 1 0 0-5.66",key:"1sveal"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JV=Z("Copyright",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M14.83 14.83a4 4 0 1 1 0-5.66",key:"1i56pz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eH=Z("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tH=Z("CornerDownRight",[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sH=Z("CornerLeftDown",[["polyline",{points:"14 15 9 20 4 15",key:"nkc4i"}],["path",{d:"M20 4h-7a4 4 0 0 0-4 4v12",key:"nbpdq2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rH=Z("CornerLeftUp",[["polyline",{points:"14 9 9 4 4 9",key:"m9oyvo"}],["path",{d:"M20 20h-7a4 4 0 0 1-4-4V4",key:"1blwi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nH=Z("CornerRightDown",[["polyline",{points:"10 15 15 20 20 15",key:"axus6l"}],["path",{d:"M4 4h7a4 4 0 0 1 4 4v12",key:"wcbgct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aH=Z("CornerRightUp",[["polyline",{points:"10 9 15 4 20 9",key:"1lr6px"}],["path",{d:"M4 20h7a4 4 0 0 0 4-4V4",key:"1plgdj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iH=Z("CornerUpLeft",[["polyline",{points:"9 14 4 9 9 4",key:"881910"}],["path",{d:"M20 20v-7a4 4 0 0 0-4-4H4",key:"1nkjon"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oH=Z("CornerUpRight",[["polyline",{points:"15 14 20 9 15 4",key:"1tbx3s"}],["path",{d:"M4 20v-7a4 4 0 0 1 4-4h12",key:"1lu4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lH=Z("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cH=Z("CreativeCommons",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M10 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1ss3eq"}],["path",{d:"M17 9.3a2.8 2.8 0 0 0-3.5 1 3.1 3.1 0 0 0 0 3.4 2.7 2.7 0 0 0 3.5 1",key:"1od56t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yg=Z("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dH=Z("Croissant",[["path",{d:"m4.6 13.11 5.79-3.21c1.89-1.05 4.79 1.78 3.71 3.71l-3.22 5.81C8.8 23.16.79 15.23 4.6 13.11Z",key:"1ozxlb"}],["path",{d:"m10.5 9.5-1-2.29C9.2 6.48 8.8 6 8 6H4.5C2.79 6 2 6.5 2 8.5a7.71 7.71 0 0 0 2 4.83",key:"ffuyb5"}],["path",{d:"M8 6c0-1.55.24-4-2-4-2 0-2.5 2.17-2.5 4",key:"osnpzi"}],["path",{d:"m14.5 13.5 2.29 1c.73.3 1.21.7 1.21 1.5v3.5c0 1.71-.5 2.5-2.5 2.5a7.71 7.71 0 0 1-4.83-2",key:"1vubaw"}],["path",{d:"M18 16c1.55 0 4-.24 4 2 0 2-2.17 2.5-4 2.5",key:"wxr772"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uH=Z("Crop",[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hH=Z("Cross",[["path",{d:"M4 9a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h4a1 1 0 0 1 1 1v4a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-4a1 1 0 0 1 1-1h4a2 2 0 0 0 2-2v-2a2 2 0 0 0-2-2h-4a1 1 0 0 1-1-1V4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4a1 1 0 0 1-1 1z",key:"1xbrqy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mH=Z("Crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sm=Z("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pH=Z("Cuboid",[["path",{d:"m21.12 6.4-6.05-4.06a2 2 0 0 0-2.17-.05L2.95 8.41a2 2 0 0 0-.95 1.7v5.82a2 2 0 0 0 .88 1.66l6.05 4.07a2 2 0 0 0 2.17.05l9.95-6.12a2 2 0 0 0 .95-1.7V8.06a2 2 0 0 0-.88-1.66Z",key:"1u2ovd"}],["path",{d:"M10 22v-8L2.25 9.15",key:"11pn4q"}],["path",{d:"m10 14 11.77-6.87",key:"1kt1wh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fH=Z("CupSoda",[["path",{d:"m6 8 1.75 12.28a2 2 0 0 0 2 1.72h4.54a2 2 0 0 0 2-1.72L18 8",key:"8166m8"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"yjz344"}],["path",{d:"m12 8 1-6h2",key:"3ybfa4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gH=Z("Currency",[["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}],["line",{x1:"3",x2:"6",y1:"3",y2:"6",key:"1jkytn"}],["line",{x1:"21",x2:"18",y1:"3",y2:"6",key:"14zfjt"}],["line",{x1:"3",x2:"6",y1:"21",y2:"18",key:"iusuec"}],["line",{x1:"21",x2:"18",y1:"21",y2:"18",key:"yj2dd7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xH=Z("Cylinder",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yH=Z("Dam",[["path",{d:"M11 11.31c1.17.56 1.54 1.69 3.5 1.69 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"157kva"}],["path",{d:"M11.75 18c.35.5 1.45 1 2.75 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"d7q6m6"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M7 3a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1L10 4a1 1 0 0 0-1-1z",key:"pr6s65"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vH=Z("DatabaseBackup",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 12a9 3 0 0 0 5 2.69",key:"1ui2ym"}],["path",{d:"M21 9.3V5",key:"6k6cib"}],["path",{d:"M3 5v14a9 3 0 0 0 6.47 2.88",key:"i62tjy"}],["path",{d:"M12 12v4h4",key:"1bxaet"}],["path",{d:"M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16",key:"1f4ei9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _H=Z("DatabaseZap",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 15 21.84",key:"14ibmq"}],["path",{d:"M21 5V8",key:"1marbg"}],["path",{d:"M21 12L18 17H22L19 22",key:"zafso"}],["path",{d:"M3 12A9 3 0 0 0 14.59 14.87",key:"1y4wr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bH=Z("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wH=Z("Delete",[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jH=Z("Dessert",[["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["path",{d:"M10.2 3.2C5.5 4 2 8.1 2 13a2 2 0 0 0 4 0v-1a2 2 0 0 1 4 0v4a2 2 0 0 0 4 0v-4a2 2 0 0 1 4 0v1a2 2 0 0 0 4 0c0-4.9-3.5-9-8.2-9.8",key:"lfo06j"}],["path",{d:"M3.2 14.8a9 9 0 0 0 17.6 0",key:"12xarc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kH=Z("Diameter",[["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["circle",{cx:"5",cy:"5",r:"2",key:"1gwv83"}],["path",{d:"M6.48 3.66a10 10 0 0 1 13.86 13.86",key:"xr8kdq"}],["path",{d:"m6.41 6.41 11.18 11.18",key:"uhpjw7"}],["path",{d:"M3.66 6.48a10 10 0 0 0 13.86 13.86",key:"cldpwv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NH=Z("DiamondMinus",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hj=Z("DiamondPercent",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0Z",key:"1tpxz2"}],["path",{d:"M9.2 9.2h.01",key:"1b7bvt"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"M14.7 14.8h.01",key:"17nsh4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SH=Z("DiamondPlus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CH=Z("Diamond",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MH=Z("Dice1",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TH=Z("Dice2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M9 15h.01",key:"fzyn71"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AH=Z("Dice3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EH=Z("Dice4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PH=Z("Dice5",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IH=Z("Dice6",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LH=Z("Dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DH=Z("Diff",[["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OH=Z("Disc2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RH=Z("Disc3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M6 12c0-1.7.7-3.2 1.8-4.2",key:"oqkarx"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M18 12c0 1.7-.7 3.2-1.8 4.2",key:"1eah9h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FH=Z("DiscAlbum",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"5",key:"nd82uf"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zH=Z("Disc",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BH=Z("Divide",[["circle",{cx:"12",cy:"6",r:"1",key:"1bh7o1"}],["line",{x1:"5",x2:"19",y1:"12",y2:"12",key:"13b5wn"}],["circle",{cx:"12",cy:"18",r:"1",key:"lqb9t5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $H=Z("DnaOff",[["path",{d:"M15 2c-1.35 1.5-2.092 3-2.5 4.5L14 8",key:"1bivrr"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c3.333-3 6.667-3 10-3",key:"nxix30"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M22 9c-1.5 1.35-3 2.092-4.5 2.5l-1-1",key:"18cutr"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.35-1.5 2.092-3 2.5-4.5L10 16",key:"rlvei3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qH=Z("Dna",[["path",{d:"m10 16 1.5 1.5",key:"11lckj"}],["path",{d:"m14 8-1.5-1.5",key:"1ohn8i"}],["path",{d:"M15 2c-1.798 1.998-2.518 3.995-2.807 5.993",key:"80uv8i"}],["path",{d:"m16.5 10.5 1 1",key:"696xn5"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c6.667-6 13.333 0 20-6",key:"1pyr53"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.798-1.998 2.518-3.995 2.807-5.993",key:"q3hbxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UH=Z("Dock",[["path",{d:"M2 8h20",key:"d11cs7"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 16h12",key:"u522kt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VH=Z("Dog",[["path",{d:"M11.25 16.25h1.5L12 17z",key:"w7jh35"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309",key:"u7s9ue"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235A7.497 7.497 0 0 1 14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5",key:"v8hric"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Td=Z("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HH=Z("Donut",[["path",{d:"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3",key:"19sr3x"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WH=Z("DoorClosed",[["path",{d:"M18 20V6a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v14",key:"36qu9e"}],["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"M14 12v.01",key:"xfcn54"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zv=Z("DoorOpen",[["path",{d:"M13 4h3a2 2 0 0 1 2 2v14",key:"hrm0s9"}],["path",{d:"M2 20h3",key:"1gaodv"}],["path",{d:"M13 20h9",key:"s90cdi"}],["path",{d:"M10 12v.01",key:"vx6srw"}],["path",{d:"M13 4.562v16.157a1 1 0 0 1-1.242.97L5 20V5.562a2 2 0 0 1 1.515-1.94l4-1A2 2 0 0 1 13 4.561Z",key:"199qr4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GH=Z("Dot",[["circle",{cx:"12.1",cy:"12.1",r:"1",key:"18d7e5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ki=Z("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KH=Z("DraftingCompass",[["path",{d:"m12.99 6.74 1.93 3.44",key:"iwagvd"}],["path",{d:"M19.136 12a10 10 0 0 1-14.271 0",key:"ppmlo4"}],["path",{d:"m21 21-2.16-3.84",key:"vylbct"}],["path",{d:"m3 21 8.02-14.26",key:"1ssaw4"}],["circle",{cx:"12",cy:"5",r:"2",key:"f1ur92"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZH=Z("Drama",[["path",{d:"M10 11h.01",key:"d2at3l"}],["path",{d:"M14 6h.01",key:"k028ub"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6.5 13.1h.01",key:"1748ia"}],["path",{d:"M22 5c0 9-4 12-6 12s-6-3-6-12c0-2 2-3 6-3s6 1 6 3",key:"172yzv"}],["path",{d:"M17.4 9.9c-.8.8-2 .8-2.8 0",key:"1obv0w"}],["path",{d:"M10.1 7.1C9 7.2 7.7 7.7 6 8.6c-3.5 2-4.7 3.9-3.7 5.6 4.5 7.8 9.5 8.4 11.2 7.4.9-.5 1.9-2.1 1.9-4.7",key:"rqjl8i"}],["path",{d:"M9.1 16.5c.3-1.1 1.4-1.7 2.4-1.4",key:"1mr6wy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YH=Z("Dribbble",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M19.13 5.09C15.22 9.14 10 10.44 2.25 10.94",key:"hpej1"}],["path",{d:"M21.75 12.84c-6.62-1.41-12.14 1-16.38 6.32",key:"1tr44o"}],["path",{d:"M8.56 2.75c4.37 6 6 9.42 8 17.72",key:"kbh691"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XH=Z("Drill",[["path",{d:"M10 18a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H5a3 3 0 0 1-3-3 1 1 0 0 1 1-1z",key:"ioqxb1"}],["path",{d:"M13 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1l-.81 3.242a1 1 0 0 1-.97.758H8",key:"1rs59n"}],["path",{d:"M14 4h3a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-3",key:"105ega"}],["path",{d:"M18 6h4",key:"66u95g"}],["path",{d:"m5 10-2 8",key:"xt2lic"}],["path",{d:"m7 18 2-8",key:"1bzku2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QH=Z("Droplet",[["path",{d:"M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z",key:"c7niix"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wx=Z("Droplets",[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JH=Z("Drum",[["path",{d:"m2 2 8 8",key:"1v6059"}],["path",{d:"m22 2-8 8",key:"173r8a"}],["ellipse",{cx:"12",cy:"9",rx:"10",ry:"5",key:"liohsx"}],["path",{d:"M7 13.4v7.9",key:"1yi6u9"}],["path",{d:"M12 14v8",key:"1tn2tj"}],["path",{d:"M17 13.4v7.9",key:"eqz2v3"}],["path",{d:"M2 9v8a10 5 0 0 0 20 0V9",key:"1750ul"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eW=Z("Drumstick",[["path",{d:"M15.4 15.63a7.875 6 135 1 1 6.23-6.23 4.5 3.43 135 0 0-6.23 6.23",key:"1dtqwm"}],["path",{d:"m8.29 12.71-2.6 2.6a2.5 2.5 0 1 0-1.65 4.65A2.5 2.5 0 1 0 8.7 18.3l2.59-2.59",key:"1oq1fw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tW=Z("Dumbbell",[["path",{d:"M14.4 14.4 9.6 9.6",key:"ic80wn"}],["path",{d:"M18.657 21.485a2 2 0 1 1-2.829-2.828l-1.767 1.768a2 2 0 1 1-2.829-2.829l6.364-6.364a2 2 0 1 1 2.829 2.829l-1.768 1.767a2 2 0 1 1 2.828 2.829z",key:"nnl7wr"}],["path",{d:"m21.5 21.5-1.4-1.4",key:"1f1ice"}],["path",{d:"M3.9 3.9 2.5 2.5",key:"1evmna"}],["path",{d:"M6.404 12.768a2 2 0 1 1-2.829-2.829l1.768-1.767a2 2 0 1 1-2.828-2.829l2.828-2.828a2 2 0 1 1 2.829 2.828l1.767-1.768a2 2 0 1 1 2.829 2.829z",key:"yhosts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sW=Z("EarOff",[["path",{d:"M6 18.5a3.5 3.5 0 1 0 7 0c0-1.57.92-2.52 2.04-3.46",key:"1qngmn"}],["path",{d:"M6 8.5c0-.75.13-1.47.36-2.14",key:"b06bma"}],["path",{d:"M8.8 3.15A6.5 6.5 0 0 1 19 8.5c0 1.63-.44 2.81-1.09 3.76",key:"g10hsz"}],["path",{d:"M12.5 6A2.5 2.5 0 0 1 15 8.5M10 13a2 2 0 0 0 1.82-1.18",key:"ygzou7"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rW=Z("Ear",[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nW=Z("EarthLock",[["path",{d:"M7 3.34V5a3 3 0 0 0 3 3",key:"w732o8"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2 2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"f02343"}],["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M12 2a10 10 0 1 0 9.54 13",key:"zjsr6q"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wj=Z("Earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aW=Z("Eclipse",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a7 7 0 1 0 10 10",key:"1yuj32"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iW=Z("EggFried",[["circle",{cx:"11.5",cy:"12.5",r:"3.5",key:"1cl1mi"}],["path",{d:"M3 8c0-3.5 2.5-6 6.5-6 5 0 4.83 3 7.5 5s5 2 5 6c0 4.5-2.5 6.5-7 6.5-2.5 0-2.5 2.5-6 2.5s-7-2-7-5.5c0-3 1.5-3 1.5-5C3.5 10 3 9 3 8Z",key:"165ef9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oW=Z("EggOff",[["path",{d:"M6.399 6.399C5.362 8.157 4.65 10.189 4.5 12c-.37 4.43 1.27 9.95 7.5 10 3.256-.026 5.259-1.547 6.375-3.625",key:"6et380"}],["path",{d:"M19.532 13.875A14.07 14.07 0 0 0 19.5 12c-.36-4.34-3.95-9.96-7.5-10-1.04.012-2.082.502-3.046 1.297",key:"gcdc3f"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cM=Z("Egg",[["path",{d:"M12 22c6.23-.05 7.87-5.57 7.5-10-.36-4.34-3.95-9.96-7.5-10-3.55.04-7.14 5.66-7.5 10-.37 4.43 1.27 9.95 7.5 10z",key:"1c39pg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ag=Z("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ig=Z("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lW=Z("EqualApproximately",[["path",{d:"M5 15a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"yrdkhy"}],["path",{d:"M5 9a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"gzkvyz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cW=Z("EqualNot",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}],["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dW=Z("Equal",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uW=Z("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hW=Z("EthernetPort",[["path",{d:"m15 20 3-3h2a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h2l3 3z",key:"rbahqx"}],["path",{d:"M6 8v1",key:"1636ez"}],["path",{d:"M10 8v1",key:"1talb4"}],["path",{d:"M14 8v1",key:"1rsfgr"}],["path",{d:"M18 8v1",key:"gnkwox"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mW=Z("Euro",[["path",{d:"M4 10h12",key:"1y6xl8"}],["path",{d:"M4 14h9",key:"1loblj"}],["path",{d:"M19 6a7.7 7.7 0 0 0-5.2-2A7.9 7.9 0 0 0 6 12c0 4.4 3.5 8 7.8 8 2 0 3.8-.8 5.2-2",key:"1j6lzo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pW=Z("Expand",[["path",{d:"m21 21-6-6m6 6v-4.8m0 4.8h-4.8",key:"1c15vz"}],["path",{d:"M3 16.2V21m0 0h4.8M3 21l6-6",key:"1fsnz2"}],["path",{d:"M21 7.8V3m0 0h-4.8M21 3l-6 6",key:"hawz9i"}],["path",{d:"M3 7.8V3m0 0h4.8M3 3l6 6",key:"u9ee12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rn=Z("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fW=Z("EyeClosed",[["path",{d:"m15 18-.722-3.25",key:"1j64jw"}],["path",{d:"M2 8a10.645 10.645 0 0 0 20 0",key:"1e7gxb"}],["path",{d:"m20 15-1.726-2.05",key:"1cnuld"}],["path",{d:"m4 15 1.726-2.05",key:"1dsqqd"}],["path",{d:"m9 18 .722-3.25",key:"ypw2yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xp=Z("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const va=Z("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xu=Z("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gW=Z("Factory",[["path",{d:"M2 20a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8l-7 5V8l-7 5V4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"159hny"}],["path",{d:"M17 18h1",key:"uldtlt"}],["path",{d:"M12 18h1",key:"s9uhes"}],["path",{d:"M7 18h1",key:"1neino"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xW=Z("Fan",[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yW=Z("FastForward",[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vW=Z("Feather",[["path",{d:"M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z",key:"18jl4k"}],["path",{d:"M16 8 2 22",key:"vp34q"}],["path",{d:"M17.5 15H9",key:"1oz8nu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _W=Z("Fence",[["path",{d:"M4 3 2 5v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"1n2rgs"}],["path",{d:"M6 8h4",key:"utf9t1"}],["path",{d:"M6 18h4",key:"12yh4b"}],["path",{d:"m12 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"3ha7mj"}],["path",{d:"M14 8h4",key:"1r8wg2"}],["path",{d:"M14 18h4",key:"1t3kbu"}],["path",{d:"m20 3-2 2v15c0 .6.4 1 1 1h2c.6 0 1-.4 1-1V5Z",key:"dfd4e2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bW=Z("FerrisWheel",[["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m6.8 15-3.5 2",key:"hjy98k"}],["path",{d:"m20.7 7-3.5 2",key:"f08gto"}],["path",{d:"M6.8 9 3.3 7",key:"1aevh4"}],["path",{d:"m20.7 17-3.5-2",key:"1liqo3"}],["path",{d:"m9 22 3-8 3 8",key:"wees03"}],["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M18 18.7a9 9 0 1 0-12 0",key:"dhzg4g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wW=Z("Figma",[["path",{d:"M5 5.5A3.5 3.5 0 0 1 8.5 2H12v7H8.5A3.5 3.5 0 0 1 5 5.5z",key:"1340ok"}],["path",{d:"M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2z",key:"1hz3m3"}],["path",{d:"M12 12.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 1 1-7 0z",key:"1oz8n2"}],["path",{d:"M5 19.5A3.5 3.5 0 0 1 8.5 16H12v3.5a3.5 3.5 0 1 1-7 0z",key:"1ff65i"}],["path",{d:"M5 12.5A3.5 3.5 0 0 1 8.5 9H12v7H8.5A3.5 3.5 0 0 1 5 12.5z",key:"pdip6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jW=Z("FileArchive",[["path",{d:"M10 12v-1",key:"v7bkov"}],["path",{d:"M10 18v-2",key:"1cjy8d"}],["path",{d:"M10 7V6",key:"dljcrl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 .274 1.01",key:"gkbcor"}],["circle",{cx:"10",cy:"20",r:"2",key:"1xzdoj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kW=Z("FileAudio2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"3",cy:"17",r:"1",key:"vo6nti"}],["path",{d:"M2 17v-3a4 4 0 0 1 8 0v3",key:"1ggdre"}],["circle",{cx:"9",cy:"17",r:"1",key:"bc1fq4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NW=Z("FileAudio",[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gj=Z("FileAxis3d",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 18 4-4",key:"12zab0"}],["path",{d:"M8 10v8h8",key:"tlaukw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SW=Z("FileBadge2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14 12.5 1 5.5-3-1-3 1 1-5.5",key:"14xlky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CW=Z("FileBadge",[["path",{d:"M12 22h6a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"12ixgl"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M5 17a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",key:"u0c8gj"}],["path",{d:"M7 16.5 8 22l-3-1-3 1 1-5.5",key:"5gm2nr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MW=Z("FileBox",[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"16lz6z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z",key:"99pj1s"}],["path",{d:"M7 17v5",key:"1yj1jh"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kj=Z("FileChartColumnIncreasing",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M12 18v-4",key:"q1q25u"}],["path",{d:"M16 18v-6",key:"15y0np"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zj=Z("FileChartColumn",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-1",key:"zg0ygc"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"M16 18v-3",key:"j5jt4h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yj=Z("FileChartLine",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m16 13-3.5 3.5-2-2L8 17",key:"zz7yod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xj=Z("FileChartPie",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3.5",key:"13ddob"}],["path",{d:"M4.017 11.512a6 6 0 1 0 8.466 8.475",key:"s6vs5t"}],["path",{d:"M9 16a1 1 0 0 1-1-1v-4c0-.552.45-1.008.995-.917a6 6 0 0 1 4.922 4.922c.091.544-.365.995-.917.995z",key:"1dl6s6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TW=Z("FileCheck2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AW=Z("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EW=Z("FileClock",[["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"37hlfg"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}],["path",{d:"M9.5 17.5 8 16.25V14",key:"1o80t2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PW=Z("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IW=Z("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qj=Z("FileCog",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3.2 12.9-.9-.4",key:"1i3dj5"}],["path",{d:"m3.2 15.1-.9.4",key:"1fvgj0"}],["path",{d:"M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5",key:"1yo3oz"}],["path",{d:"m4.9 11.2-.4-.9",key:"otmhb9"}],["path",{d:"m4.9 16.8-.4.9",key:"1b8z07"}],["path",{d:"m7.5 10.3-.4.9",key:"11k65u"}],["path",{d:"m7.5 17.7-.4-.9",key:"431x55"}],["path",{d:"m9.7 12.5-.9.4",key:"87sjan"}],["path",{d:"m9.7 15.5-.9-.4",key:"khqm91"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LW=Z("FileDiff",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DW=Z("FileDigit",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"4",height:"6",x:"2",y:"12",rx:"2",key:"jm304g"}],["path",{d:"M10 12h2v6",key:"12zw74"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OW=Z("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RW=Z("FileHeart",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10.29 10.7a2.43 2.43 0 0 0-2.66-.52c-.29.12-.56.3-.78.53l-.35.34-.35-.34a2.43 2.43 0 0 0-2.65-.53c-.3.12-.56.3-.79.53-.95.94-1 2.53.2 3.74L6.5 18l3.6-3.55c1.2-1.21 1.14-2.8.19-3.74Z",key:"1c1fso"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eb=Z("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FW=Z("FileInput",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zW=Z("FileJson2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"fq0c9t"}],["path",{d:"M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"4gibmv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BW=Z("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $W=Z("FileKey2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v6",key:"rc0qvx"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"m10 10-4.5 4.5",key:"7fwrp6"}],["path",{d:"m9 11 1 1",key:"wa6s5q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qW=Z("FileKey",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["circle",{cx:"10",cy:"16",r:"2",key:"4ckbqe"}],["path",{d:"m16 10-4.5 4.5",key:"7p3ebg"}],["path",{d:"m15 11 1 1",key:"1bsyx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UW=Z("FileLock2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v1",key:"jmtmu2"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"5",x:"2",y:"13",rx:"1",key:"10y5wo"}],["path",{d:"M8 13v-2a2 2 0 1 0-4 0v2",key:"1pdxzg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VW=Z("FileLock",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["rect",{width:"8",height:"6",x:"8",y:"12",rx:"1",key:"3yr8at"}],["path",{d:"M10 12v-2a2 2 0 1 1 4 0v2",key:"j4i8d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HW=Z("FileMinus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WW=Z("FileMinus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GW=Z("FileMusic",[["path",{d:"M10.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v8.4",key:"1d3kfm"}],["path",{d:"M8 18v-7.7L16 9v7",key:"1oie6o"}],["circle",{cx:"14",cy:"16",r:"2",key:"1bzzi3"}],["circle",{cx:"6",cy:"18",r:"2",key:"1fncim"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KW=Z("FileOutput",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jj=Z("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ek=Z("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZW=Z("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YW=Z("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XW=Z("FileQuestion",[["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QW=Z("FileScan",[["path",{d:"M20 10V7l-5-5H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h4",key:"1rdf37"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M16 14a2 2 0 0 0-2 2",key:"ceaadl"}],["path",{d:"M20 14a2 2 0 0 1 2 2",key:"1ny6zw"}],["path",{d:"M20 22a2 2 0 0 0 2-2",key:"1l9q4k"}],["path",{d:"M16 22a2 2 0 0 1-2-2",key:"1wqh5n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JW=Z("FileSearch2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eG=Z("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tG=Z("FileSliders",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M10 11v2",key:"1s651w"}],["path",{d:"M8 17h8",key:"wh5c61"}],["path",{d:"M14 16v2",key:"12fp5e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yv=Z("FileSpreadsheet",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RI=Z("FileStack",[["path",{d:"M21 7h-3a2 2 0 0 1-2-2V2",key:"9rb54x"}],["path",{d:"M21 6v6.5c0 .8-.7 1.5-1.5 1.5h-7c-.8 0-1.5-.7-1.5-1.5v-9c0-.8.7-1.5 1.5-1.5H17Z",key:"1059l0"}],["path",{d:"M7 8v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H15",key:"16874u"}],["path",{d:"M3 12v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H11",key:"k2ox98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sG=Z("FileSymlink",[["path",{d:"m10 18 3-3-3-3",key:"18f6ys"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 11V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"50q2rw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rG=Z("FileTerminal",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const In=Z("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nG=Z("FileType2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 13v-1h6v1",key:"1dh9dg"}],["path",{d:"M5 12v6",key:"150t9c"}],["path",{d:"M4 18h2",key:"1xrofg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aG=Z("FileType",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iG=Z("FileUp",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oG=Z("FileUser",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 18a3 3 0 1 0-6 0",key:"16awa0"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lG=Z("FileVideo2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"8",height:"6",x:"2",y:"12",rx:"1",key:"1a6c1e"}],["path",{d:"m10 15.5 4 2.5v-6l-4 2.5",key:"t7cp39"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cG=Z("FileVideo",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m10 11 5 3-5 3v-6Z",key:"7ntvm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dG=Z("FileVolume2",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M11.5 13.5a2.5 2.5 0 0 1 0 3",key:"1fccat"}],["path",{d:"M15 12a5 5 0 0 1 0 6",key:"ps46cm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uG=Z("FileVolume",[["path",{d:"M11 11a5 5 0 0 1 0 6",key:"193qb2"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 6.765V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-.93-.23",key:"ifyjnl"}],["path",{d:"M7 10.51a.5.5 0 0 0-.826-.38l-1.893 1.628A1 1 0 0 1 3.63 12H2.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h1.129a1 1 0 0 1 .652.242l1.893 1.63a.5.5 0 0 0 .826-.38z",key:"mk8rxu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hG=Z("FileWarning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mG=Z("FileX2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 12.5-5 5",key:"b853mi"}],["path",{d:"m3 12.5 5 5",key:"1qls4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pG=Z("FileX",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dM=Z("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fG=Z("Files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fu=Z("Film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gG=Z("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a0=Z("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xG=Z("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yG=Z("FireExtinguisher",[["path",{d:"M15 6.5V3a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v3.5",key:"sqyvz"}],["path",{d:"M9 18h8",key:"i7pszb"}],["path",{d:"M18 3h-3",key:"7idoqj"}],["path",{d:"M11 3a6 6 0 0 0-6 6v11",key:"1v5je3"}],["path",{d:"M5 13h4",key:"svpcxo"}],["path",{d:"M17 10a4 4 0 0 0-8 0v10a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2Z",key:"vsjego"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vG=Z("FishOff",[["path",{d:"M18 12.47v.03m0-.5v.47m-.475 5.056A6.744 6.744 0 0 1 15 18c-3.56 0-7.56-2.53-8.5-6 .348-1.28 1.114-2.433 2.121-3.38m3.444-2.088A8.802 8.802 0 0 1 15 6c3.56 0 6.06 2.54 7 6-.309 1.14-.786 2.177-1.413 3.058",key:"1j1hse"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33m7.48-4.372A9.77 9.77 0 0 1 16 6.07m0 11.86a9.77 9.77 0 0 1-1.728-3.618",key:"1q46z8"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98M8.53 3h5.27a2 2 0 0 1 1.98 1.67l.23 1.4M2 2l20 20",key:"1407gh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _G=Z("FishSymbol",[["path",{d:"M2 16s9-15 20-4C11 23 2 8 2 8",key:"h4oh4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bG=Z("Fish",[["path",{d:"M6.5 12c.94-3.46 4.94-6 8.5-6 3.56 0 6.06 2.54 7 6-.94 3.47-3.44 6-7 6s-7.56-2.53-8.5-6Z",key:"15baut"}],["path",{d:"M18 12v.5",key:"18hhni"}],["path",{d:"M16 17.93a9.77 9.77 0 0 1 0-11.86",key:"16dt7o"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33",key:"l9di03"}],["path",{d:"M10.46 7.26C10.2 5.88 9.17 4.24 8 3h5.8a2 2 0 0 1 1.98 1.67l.23 1.4",key:"1kjonw"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98",key:"1zlm23"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wG=Z("FlagOff",[["path",{d:"M8 2c3 0 5 2 8 2s4-1 4-1v11",key:"9rwyz9"}],["path",{d:"M4 22V4",key:"1plyxx"}],["path",{d:"M4 15s1-1 4-1 5 2 8 2",key:"1myooe"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jG=Z("FlagTriangleLeft",[["path",{d:"M17 22V2L7 7l10 5",key:"1rmf0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kG=Z("FlagTriangleRight",[["path",{d:"M7 22V2l10 5-10 5",key:"17n18y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xv=Z("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NG=Z("FlameKindling",[["path",{d:"M12 2c1 3 2.5 3.5 3.5 4.5A5 5 0 0 1 17 10a5 5 0 1 1-10 0c0-.3 0-.6.1-.9a2 2 0 1 0 3.3-2C8 4.5 11 2 12 2Z",key:"1ir223"}],["path",{d:"m5 22 14-4",key:"1brv4h"}],["path",{d:"m5 18 14 4",key:"lgyyje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fh=Z("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SG=Z("FlashlightOff",[["path",{d:"M16 16v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4",key:"1r120k"}],["path",{d:"M7 2h11v4c0 2-2 2-2 4v1",key:"dz1920"}],["line",{x1:"11",x2:"18",y1:"6",y2:"6",key:"bi1vpe"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CG=Z("Flashlight",[["path",{d:"M18 6c0 2-2 2-2 4v10a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4V2h12z",key:"1orkel"}],["line",{x1:"6",x2:"18",y1:"6",y2:"6",key:"1z11jq"}],["line",{x1:"12",x2:"12",y1:"12",y2:"12",key:"1f4yc1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MG=Z("FlaskConicalOff",[["path",{d:"M10 10 4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-1.272-2.542",key:"59ek9y"}],["path",{d:"M10 2v2.343",key:"15t272"}],["path",{d:"M14 2v6.343",key:"sxr80q"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h9",key:"t5njau"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pb=Z("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TG=Z("FlaskRound",[["path",{d:"M10 2v7.31",key:"5d1hyh"}],["path",{d:"M14 9.3V1.99",key:"14k4l0"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14 9.3a6.5 6.5 0 1 1-4 0",key:"1r8fvy"}],["path",{d:"M5.52 16h12.96",key:"46hh1i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AG=Z("FlipHorizontal2",[["path",{d:"m3 7 5 5-5 5V7",key:"couhi7"}],["path",{d:"m21 7-5 5 5 5V7",key:"6ouia7"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FI=Z("FlipHorizontal",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h3",key:"1i73f7"}],["path",{d:"M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3",key:"saxlbk"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EG=Z("FlipVertical2",[["path",{d:"m17 3-5 5-5-5h10",key:"1ftt6x"}],["path",{d:"m17 21-5-5-5 5h10",key:"1m0wmu"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PG=Z("FlipVertical",[["path",{d:"M21 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v3",key:"14bfxa"}],["path",{d:"M21 16v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-3",key:"14rx03"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fx=Z("Flower2",[["path",{d:"M12 5a3 3 0 1 1 3 3m-3-3a3 3 0 1 0-3 3m3-3v1M9 8a3 3 0 1 0 3 3M9 8h1m5 0a3 3 0 1 1-3 3m3-3h-1m-2 3v-1",key:"3pnvol"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M12 10v12",key:"6ubwww"}],["path",{d:"M12 22c4.2 0 7-1.667 7-5-4.2 0-7 1.667-7 5Z",key:"9hd38g"}],["path",{d:"M12 22c-4.2 0-7-1.667-7-5 4.2 0 7 1.667 7 5Z",key:"ufn41s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IG=Z("Flower",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 16.5A4.5 4.5 0 1 1 7.5 12 4.5 4.5 0 1 1 12 7.5a4.5 4.5 0 1 1 4.5 4.5 4.5 4.5 0 1 1-4.5 4.5",key:"14wa3c"}],["path",{d:"M12 7.5V9",key:"1oy5b0"}],["path",{d:"M7.5 12H9",key:"eltsq1"}],["path",{d:"M16.5 12H15",key:"vk5kw4"}],["path",{d:"M12 16.5V15",key:"k7eayi"}],["path",{d:"m8 8 1.88 1.88",key:"nxy4qf"}],["path",{d:"M14.12 9.88 16 8",key:"1lst6k"}],["path",{d:"m8 16 1.88-1.88",key:"h2eex1"}],["path",{d:"M14.12 14.12 16 16",key:"uqkrx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LG=Z("Focus",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DG=Z("FoldHorizontal",[["path",{d:"M2 12h6",key:"1wqiqv"}],["path",{d:"M22 12h-6",key:"1eg9hc"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 9-3 3 3 3",key:"12ol22"}],["path",{d:"m5 15 3-3-3-3",key:"1kdhjc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OG=Z("FoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RG=Z("FolderArchive",[["circle",{cx:"15",cy:"19",r:"2",key:"u2pros"}],["path",{d:"M20.9 19.8A2 2 0 0 0 22 18V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h5.1",key:"1jj40k"}],["path",{d:"M15 11v-1",key:"cntcp"}],["path",{d:"M15 17v-2",key:"1279jj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FG=Z("FolderCheck",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zG=Z("FolderClock",[["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"M7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2",key:"1urifu"}],["path",{d:"M16 14v2l1 1",key:"xth2jh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BG=Z("FolderClosed",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M2 10h20",key:"1ir3d8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $G=Z("FolderCode",[["path",{d:"M10 10.5 8 13l2 2.5",key:"m4t9c1"}],["path",{d:"m14 10.5 2 2.5-2 2.5",key:"14w2eb"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z",key:"1u1bxd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tk=Z("FolderCog",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"M10.3 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v3.3",key:"1k8050"}],["path",{d:"m21.7 19.4-.9-.3",key:"1qgwi9"}],["path",{d:"m15.2 16.9-.9-.3",key:"1t7mvx"}],["path",{d:"m16.6 21.7.3-.9",key:"1j67ps"}],["path",{d:"m19.1 15.2.3-.9",key:"18r7jp"}],["path",{d:"m19.6 21.7-.4-1",key:"z2vh2"}],["path",{d:"m16.8 15.3-.4-1",key:"1ei7r6"}],["path",{d:"m14.3 19.6 1-.4",key:"11sv9r"}],["path",{d:"m20.7 16.8 1-.4",key:"19m87a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qG=Z("FolderDot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"1",key:"49l61u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UG=Z("FolderDown",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m15 13-3 3-3-3",key:"6j2sf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VG=Z("FolderGit2",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["path",{d:"M18 19c-2.8 0-5-2.2-5-5v8",key:"pkpw2h"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HG=Z("FolderGit",[["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M14 13h3",key:"1dgedf"}],["path",{d:"M7 13h3",key:"1pygq7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WG=Z("FolderHeart",[["path",{d:"M11 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v1.5",key:"6hud8k"}],["path",{d:"M13.9 17.45c-1.2-1.2-1.14-2.8-.2-3.73a2.43 2.43 0 0 1 3.44 0l.36.34.34-.34a2.43 2.43 0 0 1 3.45-.01c.95.95 1 2.53-.2 3.74L17.5 21Z",key:"wpff58"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GG=Z("FolderInput",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KG=Z("FolderKanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZG=Z("FolderKey",[["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2",key:"3hgo9p"}],["path",{d:"m22 14-4.5 4.5",key:"1ef6z8"}],["path",{d:"m21 15 1 1",key:"1ejcpy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YG=Z("FolderLock",[["rect",{width:"8",height:"5",x:"14",y:"17",rx:"1",key:"19aais"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5",key:"1w6v7t"}],["path",{d:"M20 17v-2a2 2 0 1 0-4 0v2",key:"pwaxnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XG=Z("FolderMinus",[["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QG=Z("FolderOpenDot",[["path",{d:"m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5c0-1.1.9-2 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2",key:"1nmvlm"}],["circle",{cx:"14",cy:"15",r:"1",key:"1gm4qj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cm=Z("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JG=Z("FolderOutput",[["path",{d:"M2 7.5V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-1.5",key:"1yk7aj"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m5 10-3 3 3 3",key:"1r8ie0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sk=Z("FolderPen",[["path",{d:"M2 11.5V5a2 2 0 0 1 2-2h3.9c.7 0 1.3.3 1.7.9l.8 1.2c.4.6 1 .9 1.7.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-9.5",key:"a8xqs0"}],["path",{d:"M11.378 13.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1saktj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eK=Z("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tK=Z("FolderRoot",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M12 15v5",key:"11xva1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sK=Z("FolderSearch2",[["circle",{cx:"11.5",cy:"12.5",r:"2.5",key:"1ea5ju"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M13.3 14.3 15 16",key:"1y4v1n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rK=Z("FolderSearch",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nK=Z("FolderSymlink",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"x1c07l"}],["path",{d:"m8 16 3-3-3-3",key:"rlqrt1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aK=Z("FolderSync",[["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v.5",key:"1dkoa9"}],["path",{d:"M12 10v4h4",key:"1czhmt"}],["path",{d:"m12 14 1.535-1.605a5 5 0 0 1 8 1.5",key:"lvuxfi"}],["path",{d:"M22 22v-4h-4",key:"1ewp4q"}],["path",{d:"m22 18-1.535 1.605a5 5 0 0 1-8-1.5",key:"14ync0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iK=Z("FolderTree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oK=Z("FolderUp",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m9 13 3-3 3 3",key:"1pxg3c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lK=Z("FolderX",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9.5 10.5 5 5",key:"ra9qjz"}],["path",{d:"m14.5 10.5-5 5",key:"l2rkpq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cK=Z("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dK=Z("Folders",[["path",{d:"M20 17a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.9a2 2 0 0 1-1.69-.9l-.81-1.2a2 2 0 0 0-1.67-.9H8a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2Z",key:"4u7rpt"}],["path",{d:"M2 8v11a2 2 0 0 0 2 2h14",key:"1eicx1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uK=Z("Footprints",[["path",{d:"M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z",key:"1dudjm"}],["path",{d:"M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z",key:"l2t8xc"}],["path",{d:"M16 17h4",key:"1dejxt"}],["path",{d:"M4 13h4",key:"1bwh8b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hK=Z("Forklift",[["path",{d:"M12 12H5a2 2 0 0 0-2 2v5",key:"7zsz91"}],["circle",{cx:"13",cy:"19",r:"2",key:"wjnkru"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M8 19h3m5-17v17h6M6 12V7c0-1.1.9-2 2-2h3l5 5",key:"13bk1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mK=Z("Forward",[["polyline",{points:"15 17 20 12 15 7",key:"1w3sku"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pK=Z("Frame",[["line",{x1:"22",x2:"2",y1:"6",y2:"6",key:"15w7dq"}],["line",{x1:"22",x2:"2",y1:"18",y2:"18",key:"1ip48p"}],["line",{x1:"6",x2:"6",y1:"2",y2:"22",key:"a2lnyx"}],["line",{x1:"18",x2:"18",y1:"2",y2:"22",key:"8vb6jd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fK=Z("Framer",[["path",{d:"M5 16V9h14V2H5l14 14h-7m-7 0 7 7v-7m-7 0h7",key:"1a2nng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gK=Z("Frown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xK=Z("Fuel",[["line",{x1:"3",x2:"15",y1:"22",y2:"22",key:"xegly4"}],["line",{x1:"4",x2:"14",y1:"9",y2:"9",key:"xcnuvu"}],["path",{d:"M14 22V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v18",key:"16j0yd"}],["path",{d:"M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 2 2a2 2 0 0 0 2-2V9.83a2 2 0 0 0-.59-1.42L18 5",key:"7cu91f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yK=Z("Fullscreen",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vK=Z("GalleryHorizontalEnd",[["path",{d:"M2 7v10",key:"a2pl2d"}],["path",{d:"M6 5v14",key:"1kq3d7"}],["rect",{width:"12",height:"18",x:"10",y:"3",rx:"2",key:"13i7bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _K=Z("GalleryHorizontal",[["path",{d:"M2 3v18",key:"pzttux"}],["rect",{width:"12",height:"18",x:"6",y:"3",rx:"2",key:"btr8bg"}],["path",{d:"M22 3v18",key:"6jf3v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bK=Z("GalleryThumbnails",[["rect",{width:"18",height:"14",x:"3",y:"3",rx:"2",key:"74y24f"}],["path",{d:"M4 21h1",key:"16zlid"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M19 21h1",key:"edywat"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wK=Z("GalleryVerticalEnd",[["path",{d:"M7 2h10",key:"nczekb"}],["path",{d:"M5 6h14",key:"u2x4p"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jK=Z("GalleryVertical",[["path",{d:"M3 2h18",key:"15qxfx"}],["rect",{width:"18",height:"12",x:"3",y:"6",rx:"2",key:"1439r6"}],["path",{d:"M3 22h18",key:"8prr45"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kK=Z("Gamepad2",[["line",{x1:"6",x2:"10",y1:"11",y2:"11",key:"1gktln"}],["line",{x1:"8",x2:"8",y1:"9",y2:"13",key:"qnk9ow"}],["line",{x1:"15",x2:"15.01",y1:"12",y2:"12",key:"krot7o"}],["line",{x1:"18",x2:"18.01",y1:"10",y2:"10",key:"1lcuu1"}],["path",{d:"M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z",key:"mfqc10"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NK=Z("Gamepad",[["line",{x1:"6",x2:"10",y1:"12",y2:"12",key:"161bw2"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"15",x2:"15.01",y1:"13",y2:"13",key:"dqpgro"}],["line",{x1:"18",x2:"18.01",y1:"11",y2:"11",key:"meh2c"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SK=Z("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CK=Z("Gavel",[["path",{d:"m14.5 12.5-8 8a2.119 2.119 0 1 1-3-3l8-8",key:"15492f"}],["path",{d:"m16 16 6-6",key:"vzrcl6"}],["path",{d:"m8 8 6-6",key:"18bi4p"}],["path",{d:"m9 7 8 8",key:"5jnvq1"}],["path",{d:"m21 11-8-8",key:"z4y7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MK=Z("Gem",[["path",{d:"M6 3h12l4 6-10 13L2 9Z",key:"1pcd5k"}],["path",{d:"M11 3 8 9l4 13 4-13-3-6",key:"1fcu3u"}],["path",{d:"M2 9h20",key:"16fsjt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $4=Z("Ghost",[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bo=Z("Gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TK=Z("GitBranchPlus",[["path",{d:"M6 3v12",key:"qpgusn"}],["path",{d:"M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"1d02ji"}],["path",{d:"M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6z",key:"chk6ph"}],["path",{d:"M15 6a9 9 0 0 0-9 9",key:"or332x"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AK=Z("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rk=Z("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EK=Z("GitCommitVertical",[["path",{d:"M12 3v6",key:"1holv5"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 15v6",key:"a9ows0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PK=Z("GitCompareArrows",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IK=Z("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LK=Z("GitFork",[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DK=Z("GitGraph",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OK=Z("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RK=Z("GitPullRequestArrow",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v12",key:"ih889a"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FK=Z("GitPullRequestClosed",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 9v12",key:"1sc30k"}],["path",{d:"m21 3-6 6",key:"16nqsk"}],["path",{d:"m21 9-6-6",key:"9j17rh"}],["path",{d:"M18 11.5V15",key:"65xf6f"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zK=Z("GitPullRequestCreateArrow",[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v12",key:"ih889a"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v3",key:"1rbwk6"}],["path",{d:"M19 15v6",key:"10aioa"}],["path",{d:"M22 18h-6",key:"1d5gi5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BK=Z("GitPullRequestCreate",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 9v12",key:"1sc30k"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v3",key:"1jb6z3"}],["path",{d:"M18 15v6",key:"9wciyi"}],["path",{d:"M21 18h-6",key:"139f0c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $K=Z("GitPullRequestDraft",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M18 6V5",key:"1oao2s"}],["path",{d:"M18 11v-1",key:"11c8tz"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qK=Z("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UK=Z("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VK=Z("Gitlab",[["path",{d:"m22 13.29-3.33-10a.42.42 0 0 0-.14-.18.38.38 0 0 0-.22-.11.39.39 0 0 0-.23.07.42.42 0 0 0-.14.18l-2.26 6.67H8.32L6.1 3.26a.42.42 0 0 0-.1-.18.38.38 0 0 0-.26-.08.39.39 0 0 0-.23.07.42.42 0 0 0-.14.18L2 13.29a.74.74 0 0 0 .27.83L12 21l9.69-6.88a.71.71 0 0 0 .31-.83Z",key:"148pdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HK=Z("GlassWater",[["path",{d:"M5.116 4.104A1 1 0 0 1 6.11 3h11.78a1 1 0 0 1 .994 1.105L17.19 20.21A2 2 0 0 1 15.2 22H8.8a2 2 0 0 1-2-1.79z",key:"p55z4y"}],["path",{d:"M6 12a5 5 0 0 1 6 0 5 5 0 0 0 6 0",key:"mjntcy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WK=Z("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GK=Z("GlobeLock",[["path",{d:"M15.686 15A14.5 14.5 0 0 1 12 22a14.5 14.5 0 0 1 0-20 10 10 0 1 0 9.542 13",key:"qkt0x6"}],["path",{d:"M2 12h8.5",key:"ovaggd"}],["path",{d:"M20 6V4a2 2 0 1 0-4 0v2",key:"1of5e8"}],["rect",{width:"8",height:"5",x:"14",y:"6",rx:"1",key:"1fmf51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yp=Z("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KK=Z("Goal",[["path",{d:"M12 13V2l8 4-8 4",key:"5wlwwj"}],["path",{d:"M20.561 10.222a9 9 0 1 1-12.55-5.29",key:"1c0wjv"}],["path",{d:"M8.002 9.997a5 5 0 1 0 8.9 2.02",key:"gb1g7m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZK=Z("Grab",[["path",{d:"M18 11.5V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1.4",key:"edstyy"}],["path",{d:"M14 10V8a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"19wdwo"}],["path",{d:"M10 9.9V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"1lugqo"}],["path",{d:"M6 14a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1hbeus"}],["path",{d:"M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-4a8 8 0 0 1-8-8 2 2 0 1 1 4 0",key:"1etffm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zh=Z("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YK=Z("Grape",[["path",{d:"M22 5V2l-5.89 5.89",key:"1eenpo"}],["circle",{cx:"16.6",cy:"15.89",r:"3",key:"xjtalx"}],["circle",{cx:"8.11",cy:"7.4",r:"3",key:"u2fv6i"}],["circle",{cx:"12.35",cy:"11.65",r:"3",key:"i6i8g7"}],["circle",{cx:"13.91",cy:"5.85",r:"3",key:"6ye0dv"}],["circle",{cx:"18.15",cy:"10.09",r:"3",key:"snx9no"}],["circle",{cx:"6.56",cy:"13.2",r:"3",key:"17x4xg"}],["circle",{cx:"10.8",cy:"17.44",r:"3",key:"1hogw9"}],["circle",{cx:"5",cy:"19",r:"3",key:"1sn6vo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XK=Z("Grid2x2Check",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nk=Z("Grid2x2Plus",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M19 22v-6",key:"qhmiwi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QK=Z("Grid2x2X",[["path",{d:"M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3",key:"11za1p"}],["path",{d:"m16 16 5 5",key:"8tpb07"}],["path",{d:"m16 21 5-5",key:"193jll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ak=Z("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yf=Z("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JK=Z("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yh=Z("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eZ=Z("Grip",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"19",cy:"5",r:"1",key:"w8mnmm"}],["circle",{cx:"5",cy:"5",r:"1",key:"lttvr7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}],["circle",{cx:"19",cy:"19",r:"1",key:"shf9b7"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tZ=Z("Group",[["path",{d:"M3 7V5c0-1.1.9-2 2-2h2",key:"adw53z"}],["path",{d:"M17 3h2c1.1 0 2 .9 2 2v2",key:"an4l38"}],["path",{d:"M21 17v2c0 1.1-.9 2-2 2h-2",key:"144t0e"}],["path",{d:"M7 21H5c-1.1 0-2-.9-2-2v-2",key:"rtnfgi"}],["rect",{width:"7",height:"5",x:"7",y:"7",rx:"1",key:"1eyiv7"}],["rect",{width:"7",height:"5",x:"10",y:"12",rx:"1",key:"1qlmkx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sZ=Z("Guitar",[["path",{d:"m11.9 12.1 4.514-4.514",key:"109xqo"}],["path",{d:"M20.1 2.3a1 1 0 0 0-1.4 0l-1.114 1.114A2 2 0 0 0 17 4.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 17.828 7h1.344a2 2 0 0 0 1.414-.586L21.7 5.3a1 1 0 0 0 0-1.4z",key:"txyc8t"}],["path",{d:"m6 16 2 2",key:"16qmzd"}],["path",{d:"M8.2 9.9C8.7 8.8 9.8 8 11 8c2.8 0 5 2.2 5 5 0 1.2-.8 2.3-1.9 2.8l-.9.4A2 2 0 0 0 12 18a4 4 0 0 1-4 4c-3.3 0-6-2.7-6-6a4 4 0 0 1 4-4 2 2 0 0 0 1.8-1.2z",key:"1u8q3z"}],["circle",{cx:"11.5",cy:"12.5",r:".5",fill:"currentColor",key:"16onso"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rZ=Z("Ham",[["path",{d:"M13.144 21.144A7.274 10.445 45 1 0 2.856 10.856",key:"1k1t7q"}],["path",{d:"M13.144 21.144A7.274 4.365 45 0 0 2.856 10.856a7.274 4.365 45 0 0 10.288 10.288",key:"153t1g"}],["path",{d:"M16.565 10.435 18.6 8.4a2.501 2.501 0 1 0 1.65-4.65 2.5 2.5 0 1 0-4.66 1.66l-2.024 2.025",key:"gzrt0n"}],["path",{d:"m8.5 16.5-1-1",key:"otr954"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nZ=Z("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aZ=Z("HandCoins",[["path",{d:"M11 15h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 17",key:"geh8rc"}],["path",{d:"m7 21 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"1fto5m"}],["path",{d:"m2 16 6 6",key:"1pfhp9"}],["circle",{cx:"16",cy:"9",r:"2.9",key:"1n0dlu"}],["circle",{cx:"6",cy:"5",r:"3",key:"151irh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iZ=Z("HandHeart",[["path",{d:"M11 14h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 16",key:"1ifwr1"}],["path",{d:"m7 20 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"17abbs"}],["path",{d:"m2 15 6 6",key:"10dquu"}],["path",{d:"M19.5 8.5c.7-.7 1.5-1.6 1.5-2.7A2.73 2.73 0 0 0 16 4a2.78 2.78 0 0 0-5 1.8c0 1.2.8 2 1.5 2.8L16 12Z",key:"1h3036"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ik=Z("HandHelping",[["path",{d:"M11 12h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 14",key:"1j4xps"}],["path",{d:"m7 18 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"uospg8"}],["path",{d:"m2 13 6 6",key:"16e5sb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oZ=Z("HandMetal",[["path",{d:"M18 12.5V10a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1.4",key:"wc6myp"}],["path",{d:"M14 11V9a2 2 0 1 0-4 0v2",key:"94qvcw"}],["path",{d:"M10 10.5V5a2 2 0 1 0-4 0v9",key:"m1ah89"}],["path",{d:"m7 15-1.76-1.76a2 2 0 0 0-2.83 2.82l3.6 3.6C7.5 21.14 9.2 22 12 22h2a8 8 0 0 0 8-8V7a2 2 0 1 0-4 0v5",key:"t1skq1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lZ=Z("HandPlatter",[["path",{d:"M12 3V2",key:"ar7q03"}],["path",{d:"m15.4 17.4 3.2-2.8a2 2 0 1 1 2.8 2.9l-3.6 3.3c-.7.8-1.7 1.2-2.8 1.2h-4c-1.1 0-2.1-.4-2.8-1.2l-1.302-1.464A1 1 0 0 0 6.151 19H5",key:"n2g93r"}],["path",{d:"M2 14h12a2 2 0 0 1 0 4h-2",key:"1o2jem"}],["path",{d:"M4 10h16",key:"img6z1"}],["path",{d:"M5 10a7 7 0 0 1 14 0",key:"1ega1o"}],["path",{d:"M5 14v6a1 1 0 0 1-1 1H2",key:"1hescx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zI=Z("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BI=Z("Handshake",[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cZ=Z("HardDriveDownload",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dZ=Z("HardDriveUpload",[["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M12 2v8",key:"1q4o3n"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $I=Z("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uZ=Z("HardHat",[["path",{d:"M10 10V5a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v5",key:"1p9q5i"}],["path",{d:"M14 6a6 6 0 0 1 6 6v3",key:"1hnv84"}],["path",{d:"M4 15v-3a6 6 0 0 1 6-6",key:"9ciidu"}],["rect",{x:"2",y:"15",width:"20",height:"4",rx:"1",key:"g3x8cw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uM=Z("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hZ=Z("Haze",[["path",{d:"m5.2 6.2 1.4 1.4",key:"17imol"}],["path",{d:"M2 13h2",key:"13gyu8"}],["path",{d:"M20 13h2",key:"16rner"}],["path",{d:"m17.4 7.6 1.4-1.4",key:"t4xlah"}],["path",{d:"M22 17H2",key:"1gtaj3"}],["path",{d:"M22 21H2",key:"1gy6en"}],["path",{d:"M16 13a4 4 0 0 0-8 0",key:"1dyczq"}],["path",{d:"M12 5V2.5",key:"1vytko"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mZ=Z("HdmiPort",[["path",{d:"M22 9a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v4a1 1 0 0 0 1 1h1l2 2h12l2-2h1a1 1 0 0 0 1-1Z",key:"2128wb"}],["path",{d:"M7.5 12h9",key:"1t0ckc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qI=Z("Heading1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UI=Z("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pZ=Z("Heading3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fZ=Z("Heading4",[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gZ=Z("Heading5",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xZ=Z("Heading6",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yZ=Z("Heading",[["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M6 20V4",key:"1w1bmo"}],["path",{d:"M18 20V4",key:"o2hl4u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vZ=Z("HeadphoneOff",[["path",{d:"M21 14h-1.343",key:"1jdnxi"}],["path",{d:"M9.128 3.47A9 9 0 0 1 21 12v3.343",key:"6kipu2"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.414 20.414A2 2 0 0 1 19 21h-1a2 2 0 0 1-2-2v-3",key:"9x50f4"}],["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 2.636-6.364",key:"1bkxnm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Z=Z("Headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bZ=Z("Headset",[["path",{d:"M3 11h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5Zm0 0a9 9 0 1 1 18 0m0 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3Z",key:"12oyoe"}],["path",{d:"M21 16v2a4 4 0 0 1-4 4h-5",key:"1x7m43"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wZ=Z("HeartCrack",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"m12 13-1-1 2-2-3-3 2-2",key:"xjdxli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jZ=Z("HeartHandshake",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M12 5 9.04 7.96a2.17 2.17 0 0 0 0 3.08c.82.82 2.13.85 3 .07l2.07-1.9a2.82 2.82 0 0 1 3.79 0l2.96 2.66",key:"4oyue0"}],["path",{d:"m18 15-2-2",key:"60u0ii"}],["path",{d:"m15 18-2-2",key:"6p76be"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kZ=Z("HeartOff",[["line",{x1:"2",y1:"2",x2:"22",y2:"22",key:"1w4vcy"}],["path",{d:"M16.5 16.5 12 21l-7-7c-1.5-1.45-3-3.2-3-5.5a5.5 5.5 0 0 1 2.14-4.35",key:"3mpagl"}],["path",{d:"M8.76 3.1c1.15.22 2.13.78 3.24 1.9 1.5-1.5 2.74-2 4.5-2A5.5 5.5 0 0 1 22 8.5c0 2.12-1.3 3.78-2.67 5.17",key:"1gh3v3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NZ=Z("HeartPulse",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"1uw2ng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ii=Z("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SZ=Z("Heater",[["path",{d:"M11 8c2-3-2-3 0-6",key:"1ldv5m"}],["path",{d:"M15.5 8c2-3-2-3 0-6",key:"1otqoz"}],["path",{d:"M6 10h.01",key:"1lbq93"}],["path",{d:"M6 14h.01",key:"zudwn7"}],["path",{d:"M10 16v-4",key:"1c25yv"}],["path",{d:"M14 16v-4",key:"1dkbt8"}],["path",{d:"M18 16v-4",key:"1yg9me"}],["path",{d:"M20 6a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h3",key:"1ubg90"}],["path",{d:"M5 20v2",key:"1abpe8"}],["path",{d:"M19 20v2",key:"kqn6ft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CZ=Z("Hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MZ=Z("Highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hM=Z("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TZ=Z("HopOff",[["path",{d:"M10.82 16.12c1.69.6 3.91.79 5.18.85.28.01.53-.09.7-.27",key:"qyzcap"}],["path",{d:"M11.14 20.57c.52.24 2.44 1.12 4.08 1.37.46.06.86-.25.9-.71.12-1.52-.3-3.43-.5-4.28",key:"y078lb"}],["path",{d:"M16.13 21.05c1.65.63 3.68.84 4.87.91a.9.9 0 0 0 .7-.26",key:"1utre3"}],["path",{d:"M17.99 5.52a20.83 20.83 0 0 1 3.15 4.5.8.8 0 0 1-.68 1.13c-1.17.1-2.5.02-3.9-.25",key:"17o9hm"}],["path",{d:"M20.57 11.14c.24.52 1.12 2.44 1.37 4.08.04.3-.08.59-.31.75",key:"1d1n4p"}],["path",{d:"M4.93 4.93a10 10 0 0 0-.67 13.4c.35.43.96.4 1.17-.12.69-1.71 1.07-5.07 1.07-6.71 1.34.45 3.1.9 4.88.62a.85.85 0 0 0 .48-.24",key:"9uv3tt"}],["path",{d:"M5.52 17.99c1.05.95 2.91 2.42 4.5 3.15a.8.8 0 0 0 1.13-.68c.2-2.34-.33-5.3-1.57-8.28",key:"1292wz"}],["path",{d:"M8.35 2.68a10 10 0 0 1 9.98 1.58c.43.35.4.96-.12 1.17-1.5.6-4.3.98-6.07 1.05",key:"7ozu9p"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AZ=Z("Hop",[["path",{d:"M10.82 16.12c1.69.6 3.91.79 5.18.85.55.03 1-.42.97-.97-.06-1.27-.26-3.5-.85-5.18",key:"18lxf1"}],["path",{d:"M11.5 6.5c1.64 0 5-.38 6.71-1.07.52-.2.55-.82.12-1.17A10 10 0 0 0 4.26 18.33c.35.43.96.4 1.17-.12.69-1.71 1.07-5.07 1.07-6.71 1.34.45 3.1.9 4.88.62a.88.88 0 0 0 .73-.74c.3-2.14-.15-3.5-.61-4.88",key:"vtfxrw"}],["path",{d:"M15.62 16.95c.2.85.62 2.76.5 4.28a.77.77 0 0 1-.9.7 16.64 16.64 0 0 1-4.08-1.36",key:"13hl71"}],["path",{d:"M16.13 21.05c1.65.63 3.68.84 4.87.91a.9.9 0 0 0 .96-.96 17.68 17.68 0 0 0-.9-4.87",key:"1sl8oj"}],["path",{d:"M16.94 15.62c.86.2 2.77.62 4.29.5a.77.77 0 0 0 .7-.9 16.64 16.64 0 0 0-1.36-4.08",key:"19c6kt"}],["path",{d:"M17.99 5.52a20.82 20.82 0 0 1 3.15 4.5.8.8 0 0 1-.68 1.13c-2.33.2-5.3-.32-8.27-1.57",key:"85ghs3"}],["path",{d:"M4.93 4.93 3 3a.7.7 0 0 1 0-1",key:"x087yj"}],["path",{d:"M9.58 12.18c1.24 2.98 1.77 5.95 1.57 8.28a.8.8 0 0 1-1.13.68 20.82 20.82 0 0 1-4.5-3.15",key:"11xdqo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EZ=Z("Hospital",[["path",{d:"M12 6v4",key:"16clxf"}],["path",{d:"M14 14h-4",key:"esezmu"}],["path",{d:"M14 18h-4",key:"16mqa2"}],["path",{d:"M14 8h-4",key:"z8ypaz"}],["path",{d:"M18 12h2a2 2 0 0 1 2 2v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h2",key:"b1k337"}],["path",{d:"M18 22V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v18",key:"16g51d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PZ=Z("Hotel",[["path",{d:"M10 22v-6.57",key:"1wmca3"}],["path",{d:"M12 11h.01",key:"z322tv"}],["path",{d:"M12 7h.01",key:"1ivr5q"}],["path",{d:"M14 15.43V22",key:"1q2vjd"}],["path",{d:"M15 16a5 5 0 0 0-6 0",key:"o9wqvi"}],["path",{d:"M16 11h.01",key:"xkw8gn"}],["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 7h.01",key:"1vti4s"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IZ=Z("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LZ=Z("HousePlug",[["path",{d:"M10 12V8.964",key:"1vll13"}],["path",{d:"M14 12V8.964",key:"1x3qvg"}],["path",{d:"M15 12a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-2a1 1 0 0 1 1-1z",key:"ppykja"}],["path",{d:"M8.5 21H5a2 2 0 0 1-2-2v-9a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2h-5a2 2 0 0 1-2-2v-2",key:"1gvg2z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DZ=Z("HousePlus",[["path",{d:"M13.22 2.416a2 2 0 0 0-2.511.057l-7 5.999A2 2 0 0 0 3 10v9a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7.354",key:"5phn05"}],["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"M18 3v6",key:"x1uolp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rn=Z("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ok=Z("IceCreamBowl",[["path",{d:"M12 17c5 0 8-2.69 8-6H4c0 3.31 3 6 8 6m-4 4h8m-4-3v3M5.14 11a3.5 3.5 0 1 1 6.71 0",key:"1uxfcu"}],["path",{d:"M12.14 11a3.5 3.5 0 1 1 6.71 0",key:"4k3m1s"}],["path",{d:"M15.5 6.5a3.5 3.5 0 1 0-7 0",key:"zmuahr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lk=Z("IceCreamCone",[["path",{d:"m7 11 4.08 10.35a1 1 0 0 0 1.84 0L17 11",key:"1v6356"}],["path",{d:"M17 7A5 5 0 0 0 7 7",key:"151p3v"}],["path",{d:"M17 7a2 2 0 0 1 0 4H7a2 2 0 0 1 0-4",key:"1sdaij"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OZ=Z("IdCard",[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RZ=Z("ImageDown",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19 3 3v-5.5",key:"9ldu5r"}],["path",{d:"m17 22 3-3",key:"1nkfve"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FZ=Z("ImageMinus",[["path",{d:"M21 9v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"m87ecr"}],["line",{x1:"16",x2:"22",y1:"5",y2:"5",key:"ez7e4s"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zZ=Z("ImageOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M10.41 10.41a2 2 0 1 1-2.83-2.83",key:"1bzlo9"}],["line",{x1:"13.5",x2:"6",y1:"13.5",y2:"21",key:"1q0aeu"}],["line",{x1:"18",x2:"21",y1:"12",y2:"15",key:"5mozeu"}],["path",{d:"M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",key:"mmje98"}],["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BZ=Z("ImagePlay",[["path",{d:"m11 16-5 5",key:"j5f7ct"}],["path",{d:"M11 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6.5",key:"7s81lt"}],["path",{d:"M15.765 22a.5.5 0 0 1-.765-.424V13.38a.5.5 0 0 1 .765-.424l5.878 3.674a1 1 0 0 1 0 1.696z",key:"1omb6s"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qv=Z("ImagePlus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Z=Z("ImageUp",[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19.5 3-3 3 3",key:"9vmjn0"}],["path",{d:"M17 22v-5.5",key:"1aa6fl"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qZ=Z("ImageUpscale",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M17 21h2a2 2 0 0 0 2-2",key:"130fy9"}],["path",{d:"M21 12v3",key:"1wzk3p"}],["path",{d:"m21 3-5 5",key:"1g5oa7"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2",key:"kk3yz1"}],["path",{d:"m5 21 4.144-4.144a1.21 1.21 0 0 1 1.712 0L13 19",key:"fyekpt"}],["path",{d:"M9 3h3",key:"d52fa"}],["rect",{x:"3",y:"11",width:"10",height:"10",rx:"1",key:"1wpmix"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cl=Z("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UZ=Z("Images",[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VZ=Z("Import",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HZ=Z("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ck=Z("IndentDecrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m7 8-4 4 4 4",key:"o5hrat"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dk=Z("IndentIncrease",[["path",{d:"M21 12H11",key:"wd7e0v"}],["path",{d:"M21 18H11",key:"4wu86t"}],["path",{d:"M21 6H11",key:"6dy1d6"}],["path",{d:"m3 8 4 4-4 4",key:"1a3j6y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WZ=Z("IndianRupee",[["path",{d:"M6 3h12",key:"ggurg9"}],["path",{d:"M6 8h12",key:"6g4wlu"}],["path",{d:"m6 13 8.5 8",key:"u1kupk"}],["path",{d:"M6 13h3",key:"wdp6ag"}],["path",{d:"M9 13c6.667 0 6.667-10 0-10",key:"1nkvk2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GZ=Z("Infinity",[["path",{d:"M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z",key:"1z0uae"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VI=Z("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KZ=Z("InspectionPanel",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7h.01",key:"7u93v4"}],["path",{d:"M17 7h.01",key:"14a9sn"}],["path",{d:"M7 17h.01",key:"19xn7k"}],["path",{d:"M17 17h.01",key:"1sd3ek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yu=Z("Instagram",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mM=Z("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZZ=Z("IterationCcw",[["path",{d:"M20 10c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8h8",key:"4znkd0"}],["polyline",{points:"16 14 20 18 16 22",key:"11njsm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YZ=Z("IterationCw",[["path",{d:"M4 10c0-4.4 3.6-8 8-8s8 3.6 8 8-3.6 8-8 8H4",key:"tuf4su"}],["polyline",{points:"8 22 4 18 8 14",key:"evkj9s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XZ=Z("JapaneseYen",[["path",{d:"M12 9.5V21m0-11.5L6 3m6 6.5L18 3",key:"2ej80x"}],["path",{d:"M6 15h12",key:"1hwgt5"}],["path",{d:"M6 11h12",key:"wf4gp6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QZ=Z("Joystick",[["path",{d:"M21 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-2Z",key:"jg2n2t"}],["path",{d:"M6 15v-2",key:"gd6mvg"}],["path",{d:"M12 15V9",key:"8c7uyn"}],["circle",{cx:"12",cy:"6",r:"3",key:"1gm2ql"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i0=Z("Kanban",[["path",{d:"M6 5v11",key:"mdvv1e"}],["path",{d:"M12 5v6",key:"14ar3b"}],["path",{d:"M18 5v14",key:"7ji314"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q4=Z("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JZ=Z("KeySquare",[["path",{d:"M12.4 2.7a2.5 2.5 0 0 1 3.4 0l5.5 5.5a2.5 2.5 0 0 1 0 3.4l-3.7 3.7a2.5 2.5 0 0 1-3.4 0L8.7 9.8a2.5 2.5 0 0 1 0-3.4z",key:"165ttr"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"m9.4 10.6-6.814 6.814A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814",key:"1ubxi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vp=Z("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eY=Z("KeyboardMusic",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M6 8h4",key:"utf9t1"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"M6 12v4",key:"dy92yo"}],["path",{d:"M10 12v4",key:"1fxnav"}],["path",{d:"M14 12v4",key:"1hft58"}],["path",{d:"M18 12v4",key:"tjjnbz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tY=Z("KeyboardOff",[["path",{d:"M 20 4 A2 2 0 0 1 22 6",key:"1g1fkt"}],["path",{d:"M 22 6 L 22 16.41",key:"1qjg3w"}],["path",{d:"M 7 16 L 16 16",key:"n0yqwb"}],["path",{d:"M 9.69 4 L 20 4",key:"kbpcgx"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20 20H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2",key:"s23sx2"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M8 12h.01",key:"czm47f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sY=Z("Keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rY=Z("LampCeiling",[["path",{d:"M12 2v5",key:"nd4vlx"}],["path",{d:"M6 7h12l4 9H2l4-9Z",key:"123d64"}],["path",{d:"M9.17 16a3 3 0 1 0 5.66 0",key:"1061mw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nY=Z("LampDesk",[["path",{d:"m14 5-3 3 2 7 8-8-7-2Z",key:"1b0msb"}],["path",{d:"m14 5-3 3-3-3 3-3 3 3Z",key:"1uemms"}],["path",{d:"M9.5 6.5 4 12l3 6",key:"1bx08v"}],["path",{d:"M3 22v-2c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v2H3Z",key:"wap775"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aY=Z("LampFloor",[["path",{d:"M9 2h6l3 7H6l3-7Z",key:"wcx6mj"}],["path",{d:"M12 9v13",key:"3n1su1"}],["path",{d:"M9 22h6",key:"1rlq3v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iY=Z("LampWallDown",[["path",{d:"M11 13h6l3 7H8l3-7Z",key:"9n3qlo"}],["path",{d:"M14 13V8a2 2 0 0 0-2-2H8",key:"1hu4hb"}],["path",{d:"M4 9h2a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H4v6Z",key:"s053bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oY=Z("LampWallUp",[["path",{d:"M11 4h6l3 7H8l3-7Z",key:"11x1ee"}],["path",{d:"M14 11v5a2 2 0 0 1-2 2H8",key:"eutp5o"}],["path",{d:"M4 15h2a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2H4v-6Z",key:"1iuthr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lY=Z("Lamp",[["path",{d:"M8 2h8l4 10H4L8 2Z",key:"9dma5w"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M8 22v-2c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v2H8Z",key:"mwf4oh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cY=Z("LandPlot",[["path",{d:"m12 8 6-3-6-3v10",key:"mvpnpy"}],["path",{d:"m8 11.99-5.5 3.14a1 1 0 0 0 0 1.74l8.5 4.86a2 2 0 0 0 2 0l8.5-4.86a1 1 0 0 0 0-1.74L16 12",key:"ek95tt"}],["path",{d:"m6.49 12.85 11.02 6.3",key:"1kt42w"}],["path",{d:"M17.51 12.85 6.5 19.15",key:"v55bdg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dY=Z("Landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uY=Z("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hY=Z("LaptopMinimalCheck",[["path",{d:"M2 20h20",key:"owomy5"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}],["rect",{x:"3",y:"4",width:"18",height:"12",rx:"2",key:"8ur36m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uk=Z("LaptopMinimal",[["rect",{width:"18",height:"12",x:"3",y:"4",rx:"2",ry:"2",key:"1qhy41"}],["line",{x1:"2",x2:"22",y1:"20",y2:"20",key:"ni3hll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mY=Z("Laptop",[["path",{d:"M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16",key:"tarvll"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pY=Z("LassoSelect",[["path",{d:"M7 22a5 5 0 0 1-2-4",key:"umushi"}],["path",{d:"M7 16.93c.96.43 1.96.74 2.99.91",key:"ybbtv3"}],["path",{d:"M3.34 14A6.8 6.8 0 0 1 2 10c0-4.42 4.48-8 10-8s10 3.58 10 8a7.19 7.19 0 0 1-.33 2",key:"gt5e1w"}],["path",{d:"M5 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z",key:"bq3ynw"}],["path",{d:"M14.33 22h-.09a.35.35 0 0 1-.24-.32v-10a.34.34 0 0 1 .33-.34c.08 0 .15.03.21.08l7.34 6a.33.33 0 0 1-.21.59h-4.49l-2.57 3.85a.35.35 0 0 1-.28.14z",key:"72q637"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fY=Z("Lasso",[["path",{d:"M7 22a5 5 0 0 1-2-4",key:"umushi"}],["path",{d:"M3.3 14A6.8 6.8 0 0 1 2 10c0-4.4 4.5-8 10-8s10 3.6 10 8-4.5 8-10 8a12 12 0 0 1-5-1",key:"146dds"}],["path",{d:"M5 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z",key:"bq3ynw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gY=Z("Laugh",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M18 13a6 6 0 0 1-6 5 6 6 0 0 1-6-5h12Z",key:"b2q4dd"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xY=Z("Layers2",[["path",{d:"m16.02 12 5.48 3.13a1 1 0 0 1 0 1.74L13 21.74a2 2 0 0 1-2 0l-8.5-4.87a1 1 0 0 1 0-1.74L7.98 12",key:"1cuww1"}],["path",{d:"M13 13.74a2 2 0 0 1-2 0L2.5 8.87a1 1 0 0 1 0-1.74L11 2.26a2 2 0 0 1 2 0l8.5 4.87a1 1 0 0 1 0 1.74Z",key:"pdlvxu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yY=Z("Layers3",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m6.08 9.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1e5n1m"}],["path",{d:"m6.08 14.5-3.5 1.6a1 1 0 0 0 0 1.81l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9a1 1 0 0 0 0-1.83l-3.5-1.59",key:"1iwflc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vY=Z("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U4=Z("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lf=Z("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Y=Z("LayoutList",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bY=Z("LayoutPanelLeft",[["rect",{width:"7",height:"18",x:"3",y:"3",rx:"1",key:"2obqm"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wY=Z("LayoutPanelTop",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V4=Z("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jY=Z("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kY=Z("LeafyGreen",[["path",{d:"M2 22c1.25-.987 2.27-1.975 3.9-2.2a5.56 5.56 0 0 1 3.8 1.5 4 4 0 0 0 6.187-2.353 3.5 3.5 0 0 0 3.69-5.116A3.5 3.5 0 0 0 20.95 8 3.5 3.5 0 1 0 16 3.05a3.5 3.5 0 0 0-5.831 1.373 3.5 3.5 0 0 0-5.116 3.69 4 4 0 0 0-2.348 6.155C3.499 15.42 4.409 16.712 4.2 18.1 3.926 19.743 3.014 20.732 2 22",key:"1134nt"}],["path",{d:"M2 22 17 7",key:"1q7jp2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NY=Z("Lectern",[["path",{d:"M16 12h3a2 2 0 0 0 1.902-1.38l1.056-3.333A1 1 0 0 0 21 6H3a1 1 0 0 0-.958 1.287l1.056 3.334A2 2 0 0 0 5 12h3",key:"13jjxg"}],["path",{d:"M18 6V3a1 1 0 0 0-1-1h-3",key:"1550fe"}],["rect",{width:"8",height:"12",x:"8",y:"10",rx:"1",key:"qmu8b6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SY=Z("LetterText",[["path",{d:"M15 12h6",key:"upa0zy"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"m3 13 3.553-7.724a.5.5 0 0 1 .894 0L11 13",key:"blevx4"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M4 11h6",key:"olkgv1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CY=Z("LibraryBig",[["rect",{width:"8",height:"18",x:"3",y:"3",rx:"1",key:"oynpb5"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M20.4 18.9c.2.5-.1 1.1-.6 1.3l-1.9.7c-.5.2-1.1-.1-1.3-.6L11.1 5.1c-.2-.5.1-1.1.6-1.3l1.9-.7c.5-.2 1.1.1 1.3.6Z",key:"1qboyk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pM=Z("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fM=Z("LifeBuoy",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MY=Z("Ligature",[["path",{d:"M8 20V8c0-2.2 1.8-4 4-4 1.5 0 2.8.8 3.5 2",key:"1rtphz"}],["path",{d:"M6 12h4",key:"a4o3ry"}],["path",{d:"M14 12h2v8",key:"c1fccl"}],["path",{d:"M6 20h4",key:"1i6q5t"}],["path",{d:"M14 20h4",key:"lzx1xo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TY=Z("LightbulbOff",[["path",{d:"M16.8 11.2c.8-.9 1.2-2 1.2-3.2a6 6 0 0 0-9.3-5",key:"1fkcox"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M6.3 6.3a4.67 4.67 0 0 0 1.2 5.2c.7.7 1.3 1.5 1.5 2.5",key:"10m8kw"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ib=Z("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AY=Z("Link2Off",[["path",{d:"M9 17H7A5 5 0 0 1 7 7",key:"10o201"}],["path",{d:"M15 7h2a5 5 0 0 1 4 8",key:"1d3206"}],["line",{x1:"8",x2:"12",y1:"12",y2:"12",key:"rvw6j4"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sl=Z("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vo=Z("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _p=Z("Linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EY=Z("ListCheck",[["path",{d:"M11 18H3",key:"n3j2dh"}],["path",{d:"m15 18 2 2 4-4",key:"1szwhi"}],["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PY=Z("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IY=Z("ListCollapse",[["path",{d:"m3 10 2.5-2.5L3 5",key:"i6eama"}],["path",{d:"m3 19 2.5-2.5L3 14",key:"w2gmor"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LY=Z("ListEnd",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M10 18H3",key:"13769t"}],["path",{d:"M21 6v10a2 2 0 0 1-2 2h-5",key:"ilrcs8"}],["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DY=Z("ListFilter",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OY=Z("ListMinus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RY=Z("ListMusic",[["path",{d:"M21 15V6",key:"h1cx4g"}],["path",{d:"M18.5 18a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z",key:"8saifv"}],["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jv=Z("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FY=Z("ListPlus",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M18 9v6",key:"1twb98"}],["path",{d:"M21 12h-6",key:"bt1uis"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zY=Z("ListRestart",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M7 12H3",key:"13ou7f"}],["path",{d:"M7 18H3",key:"1sijw9"}],["path",{d:"M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14",key:"qth677"}],["path",{d:"M11 10v4h4",key:"172dkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BY=Z("ListStart",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M10 6H3",key:"lf8lx7"}],["path",{d:"M21 18V8a2 2 0 0 0-2-2h-5",key:"1hghli"}],["path",{d:"m16 8-2-2 2-2",key:"160uvd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Y=Z("ListTodo",[["rect",{x:"3",y:"5",width:"6",height:"6",rx:"1",key:"1defrl"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qY=Z("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UY=Z("ListVideo",[["path",{d:"M12 12H3",key:"18klou"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M12 18H3",key:"11ftsu"}],["path",{d:"m16 12 5 3-5 3v-6Z",key:"zpskkp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VY=Z("ListX",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mm=Z("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ss=Z("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HY=Z("LoaderPinwheel",[["path",{d:"M22 12a1 1 0 0 1-10 0 1 1 0 0 0-10 0",key:"1lzz15"}],["path",{d:"M7 20.7a1 1 0 1 1 5-8.7 1 1 0 1 0 5-8.6",key:"1gnrpi"}],["path",{d:"M7 3.3a1 1 0 1 1 5 8.6 1 1 0 1 0 5 8.6",key:"u9yy5q"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WY=Z("Loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GY=Z("LocateFixed",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KY=Z("LocateOff",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["path",{d:"M7.11 7.11C5.83 8.39 5 10.1 5 12c0 3.87 3.13 7 7 7 1.9 0 3.61-.83 4.89-2.11",key:"1oh7ia"}],["path",{d:"M18.71 13.96c.19-.63.29-1.29.29-1.96 0-3.87-3.13-7-7-7-.67 0-1.33.1-1.96.29",key:"3qdecy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZY=Z("Locate",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hk=Z("LockKeyholeOpen",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}],["path",{d:"M7 10V7a5 5 0 0 1 9.33-2.5",key:"car5b7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YY=Z("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mk=Z("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vh=Z("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gM=Z("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xM=Z("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XY=Z("Logs",[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QY=Z("Lollipop",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M11 11a2 2 0 0 0 4 0 4 4 0 0 0-8 0 6 6 0 0 0 12 0",key:"107gwy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JY=Z("Luggage",[["path",{d:"M6 20a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2",key:"1m57jg"}],["path",{d:"M8 18V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v14",key:"1l99gc"}],["path",{d:"M10 20h4",key:"ni2waw"}],["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eX=Z("Magnet",[["path",{d:"m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15",key:"1i3lhw"}],["path",{d:"m5 8 4 4",key:"j6kj7e"}],["path",{d:"m12 15 4 4",key:"lnac28"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tX=Z("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sX=Z("MailMinus",[["path",{d:"M22 15V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"fuxbkv"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M16 19h6",key:"xwg31i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rX=Z("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nX=Z("MailPlus",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M16 19h6",key:"xwg31i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aX=Z("MailQuestion",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 15.28c.2-.4.5-.8.9-1a2.1 2.1 0 0 1 2.6.4c.3.4.5.8.5 1.3 0 1.3-2 2-2 2",key:"7z9rxb"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iX=Z("MailSearch",[["path",{d:"M22 12.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h7.5",key:"w80f2v"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M18 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",key:"8lzu5m"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m22 22-1.5-1.5",key:"1x83k4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oX=Z("MailWarning",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M20 14v4",key:"1hm744"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HI=Z("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const br=Z("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lX=Z("Mailbox",[["path",{d:"M22 17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9.5C2 7 4 5 6.5 5H18c2.2 0 4 1.8 4 4v8Z",key:"1lbycx"}],["polyline",{points:"15,9 18,9 18,11",key:"1pm9c0"}],["path",{d:"M6.5 5C9 5 11 7 11 9.5V17a2 2 0 0 1-2 2",key:"15i455"}],["line",{x1:"6",x2:"7",y1:"10",y2:"10",key:"1e2scm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cX=Z("Mails",[["rect",{width:"16",height:"13",x:"6",y:"4",rx:"2",key:"1drq3f"}],["path",{d:"m22 7-7.1 3.78c-.57.3-1.23.3-1.8 0L6 7",key:"xn252p"}],["path",{d:"M2 8v11c0 1.1.9 2 2 2h14",key:"n13cji"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dX=Z("MapPinCheckInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uX=Z("MapPinCheck",[["path",{d:"M19.43 12.935c.357-.967.57-1.955.57-2.935a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32.197 32.197 0 0 0 .813-.728",key:"1dq61d"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"m16 18 2 2 4-4",key:"1mkfmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hX=Z("MapPinHouse",[["path",{d:"M15 22a1 1 0 0 1-1-1v-4a1 1 0 0 1 .445-.832l3-2a1 1 0 0 1 1.11 0l3 2A1 1 0 0 1 22 17v4a1 1 0 0 1-1 1z",key:"1p1rcz"}],["path",{d:"M18 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 .601.2",key:"mcbcs9"}],["path",{d:"M18 22v-3",key:"1t1ugv"}],["circle",{cx:"10",cy:"10",r:"3",key:"1ns7v1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mX=Z("MapPinMinusInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pX=Z("MapPinMinus",[["path",{d:"M18.977 14C19.6 12.701 20 11.343 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32 32 0 0 0 .824-.738",key:"11uxia"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M16 18h6",key:"987eiv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fX=Z("MapPinOff",[["path",{d:"M12.75 7.09a3 3 0 0 1 2.16 2.16",key:"1d4wjd"}],["path",{d:"M17.072 17.072c-1.634 2.17-3.527 3.912-4.471 4.727a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 1.432-4.568",key:"12yil7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.475 2.818A8 8 0 0 1 20 10c0 1.183-.31 2.377-.81 3.533",key:"lhrkcz"}],["path",{d:"M9.13 9.13a3 3 0 0 0 3.74 3.74",key:"13wojd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gX=Z("MapPinPlusInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xX=Z("MapPinPlus",[["path",{d:"M19.914 11.105A7.298 7.298 0 0 0 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 32 32 0 0 0 .824-.738",key:"fcdtly"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M16 18h6",key:"987eiv"}],["path",{d:"M19 15v6",key:"10aioa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yX=Z("MapPinXInside",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vX=Z("MapPinX",[["path",{d:"M19.752 11.901A7.78 7.78 0 0 0 20 10a8 8 0 0 0-16 0c0 4.993 5.539 10.193 7.399 11.799a1 1 0 0 0 1.202 0 19 19 0 0 0 .09-.077",key:"y0ewhp"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"m21.5 15.5-5 5",key:"11iqnx"}],["path",{d:"m21.5 20.5-5-5",key:"1bylgx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ui=Z("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _X=Z("MapPinned",[["path",{d:"M18 8c0 3.613-3.869 7.429-5.393 8.795a1 1 0 0 1-1.214 0C9.87 15.429 6 11.613 6 8a6 6 0 0 1 12 0",key:"11u0oz"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M8.714 14h-3.71a1 1 0 0 0-.948.683l-2.004 6A1 1 0 0 0 3 22h18a1 1 0 0 0 .948-1.316l-2-6a1 1 0 0 0-.949-.684h-3.712",key:"q8zwxj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bX=Z("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wX=Z("Martini",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M12 11v11",key:"ur9y6a"}],["path",{d:"m19 3-7 8-7-8Z",key:"1sgpiw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jX=Z("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WI=Z("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e1=Z("Medal",[["path",{d:"M7.21 15 2.66 7.14a2 2 0 0 1 .13-2.2L4.4 2.8A2 2 0 0 1 6 2h12a2 2 0 0 1 1.6.8l1.6 2.14a2 2 0 0 1 .14 2.2L16.79 15",key:"143lza"}],["path",{d:"M11 12 5.12 2.2",key:"qhuxz6"}],["path",{d:"m13 12 5.88-9.8",key:"hbye0f"}],["path",{d:"M8 7h8",key:"i86dvs"}],["circle",{cx:"12",cy:"17",r:"5",key:"qbz8iq"}],["path",{d:"M12 18v-2h-.5",key:"fawc4q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kX=Z("MegaphoneOff",[["path",{d:"M9.26 9.26 3 11v3l14.14 3.14",key:"3429n"}],["path",{d:"M21 15.34V6l-7.31 2.03",key:"4o1dh8"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bp=Z("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NX=Z("Meh",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"8",x2:"16",y1:"15",y2:"15",key:"1xb1d9"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SX=Z("MemoryStick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GI=Z("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CX=Z("Merge",[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MX=Z("MessageCircleCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22z",key:"k85zhp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TX=Z("MessageCircleDashed",[["path",{d:"M13.5 3.1c-.5 0-1-.1-1.5-.1s-1 .1-1.5.1",key:"16ll65"}],["path",{d:"M19.3 6.8a10.45 10.45 0 0 0-2.1-2.1",key:"1nq77a"}],["path",{d:"M20.9 13.5c.1-.5.1-1 .1-1.5s-.1-1-.1-1.5",key:"1sf7wn"}],["path",{d:"M17.2 19.3a10.45 10.45 0 0 0 2.1-2.1",key:"x1hs5g"}],["path",{d:"M10.5 20.9c.5.1 1 .1 1.5.1s1-.1 1.5-.1",key:"19m18z"}],["path",{d:"M3.5 17.5 2 22l4.5-1.5",key:"1f36qi"}],["path",{d:"M3.1 10.5c0 .5-.1 1-.1 1.5s.1 1 .1 1.5",key:"1vz3ju"}],["path",{d:"M6.8 4.7a10.45 10.45 0 0 0-2.1 2.1",key:"19f9do"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yM=Z("MessageCircleHeart",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M15.8 9.2a2.5 2.5 0 0 0-3.5 0l-.3.4-.35-.3a2.42 2.42 0 1 0-3.2 3.6l3.6 3.5 3.6-3.5c1.2-1.2 1.1-2.7.2-3.7",key:"43lnbm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AX=Z("MessageCircleMore",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EX=Z("MessageCircleOff",[["path",{d:"M20.5 14.9A9 9 0 0 0 9.1 3.5",key:"1iebmn"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.6 5.6C3 8.3 2.2 12.5 4 16l-2 6 6-2c3.4 1.8 7.6 1.1 10.3-1.7",key:"1ov8ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PX=Z("MessageCirclePlus",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KI=Z("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IX=Z("MessageCircleReply",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}],["path",{d:"M7 12h7a2 2 0 0 1 2 2v1",key:"1gheu4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LX=Z("MessageCircleWarning",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DX=Z("MessageCircleX",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ec=Z("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OX=Z("MessageSquareCode",[["path",{d:"M10 7.5 8 10l2 2.5",key:"xb17xw"}],["path",{d:"m14 7.5 2 2.5-2 2.5",key:"5rap1v"}],["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RX=Z("MessageSquareDashed",[["path",{d:"M10 17H7l-4 4v-7",key:"1r71xu"}],["path",{d:"M14 17h1",key:"nufu4t"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 14v1a2 2 0 0 1-2 2",key:"29akq3"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M9 3h1",key:"1yesri"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FX=Z("MessageSquareDiff",[["path",{d:"m5 19-2 2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2",key:"1xuzuj"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 17h6",key:"r8uit2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zX=Z("MessageSquareDot",[["path",{d:"M11.7 3H5a2 2 0 0 0-2 2v16l4-4h12a2 2 0 0 0 2-2v-2.7",key:"uodpkb"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BX=Z("MessageSquareHeart",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M14.8 7.5a1.84 1.84 0 0 0-2.6 0l-.2.3-.3-.3a1.84 1.84 0 1 0-2.4 2.8L12 13l2.7-2.7c.9-.9.8-2.1.1-2.8",key:"1blaws"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $X=Z("MessageSquareLock",[["path",{d:"M19 15v-2a2 2 0 1 0-4 0v2",key:"h3d1vz"}],["path",{d:"M9 17H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v3.5",key:"xsnnhn"}],["rect",{x:"13",y:"15",width:"8",height:"5",rx:"1",key:"1ccwuk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZI=Z("MessageSquareMore",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qX=Z("MessageSquareOff",[["path",{d:"M21 15V5a2 2 0 0 0-2-2H9",key:"43el77"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M3.6 3.6c-.4.3-.6.8-.6 1.4v16l4-4h10",key:"pwpm4a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vM=Z("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YI=Z("MessageSquareQuote",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 12a2 2 0 0 0 2-2V8H8",key:"1jfesj"}],["path",{d:"M14 12a2 2 0 0 0 2-2V8h-2",key:"1dq9mh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UX=Z("MessageSquareReply",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m10 7-3 3 3 3",key:"1eugdv"}],["path",{d:"M17 13v-1a2 2 0 0 0-2-2H7",key:"ernfh3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VX=Z("MessageSquareShare",[["path",{d:"M21 12v3a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h7",key:"tqtdkg"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"m16 8 5-5",key:"15mbrl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HX=Z("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WX=Z("MessageSquareWarning",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v2",key:"stiyo7"}],["path",{d:"M12 13h.01",key:"y0uutt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GX=Z("MessageSquareX",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m14.5 7.5-5 5",key:"3lb6iw"}],["path",{d:"m9.5 7.5 5 5",key:"ko136h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const po=Z("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KX=Z("MessagesSquare",[["path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z",key:"p1xzt8"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1",key:"1cx29u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZX=Z("MicOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pk=Z("MicVocal",[["path",{d:"m11 7.601-5.994 8.19a1 1 0 0 0 .1 1.298l.817.818a1 1 0 0 0 1.314.087L15.09 12",key:"80a601"}],["path",{d:"M16.5 21.174C15.5 20.5 14.372 20 13 20c-2.058 0-3.928 2.356-6 2-2.072-.356-2.775-3.369-1.5-4.5",key:"j0ngtp"}],["circle",{cx:"16",cy:"7",r:"5",key:"d08jfb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XI=Z("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YX=Z("Microchip",[["path",{d:"M18 12h2",key:"quuxs7"}],["path",{d:"M18 16h2",key:"zsn3lv"}],["path",{d:"M18 20h2",key:"9x5y9y"}],["path",{d:"M18 4h2",key:"1luxfb"}],["path",{d:"M18 8h2",key:"nxqzg"}],["path",{d:"M4 12h2",key:"1ltxp0"}],["path",{d:"M4 16h2",key:"8a5zha"}],["path",{d:"M4 20h2",key:"27dk57"}],["path",{d:"M4 4h2",key:"10groj"}],["path",{d:"M4 8h2",key:"18vq6w"}],["path",{d:"M8 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-1.5c-.276 0-.494.227-.562.495a2 2 0 0 1-3.876 0C9.994 2.227 9.776 2 9.5 2z",key:"1681fp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XX=Z("Microscope",[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QX=Z("Microwave",[["rect",{width:"20",height:"15",x:"2",y:"4",rx:"2",key:"2no95f"}],["rect",{width:"8",height:"7",x:"6",y:"8",rx:"1",key:"zh9wx"}],["path",{d:"M18 8v7",key:"o5zi4n"}],["path",{d:"M6 19v2",key:"1loha6"}],["path",{d:"M18 19v2",key:"1dawf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JX=Z("Milestone",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}],["path",{d:"M4 6a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h13a2 2 0 0 0 1.152-.365l3.424-2.317a1 1 0 0 0 0-1.635l-3.424-2.318A2 2 0 0 0 17 6z",key:"1btarq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eQ=Z("MilkOff",[["path",{d:"M8 2h8",key:"1ssgc1"}],["path",{d:"M9 2v1.343M15 2v2.789a4 4 0 0 0 .672 2.219l.656.984a4 4 0 0 1 .672 2.22v1.131M7.8 7.8l-.128.192A4 4 0 0 0 7 10.212V20a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-3",key:"y0ejgx"}],["path",{d:"M7 15a6.47 6.47 0 0 1 5 0 6.472 6.472 0 0 0 3.435.435",key:"iaxqsy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tQ=Z("Milk",[["path",{d:"M8 2h8",key:"1ssgc1"}],["path",{d:"M9 2v2.789a4 4 0 0 1-.672 2.219l-.656.984A4 4 0 0 0 7 10.212V20a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-9.789a4 4 0 0 0-.672-2.219l-.656-.984A4 4 0 0 1 15 4.788V2",key:"qtp12x"}],["path",{d:"M7 15a6.472 6.472 0 0 1 5 0 6.47 6.47 0 0 0 5 0",key:"ygeh44"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sQ=Z("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rQ=Z("Minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const t1=Z("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nQ=Z("MonitorCheck",[["path",{d:"m9 10 2 2 4-4",key:"1gnqz4"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aQ=Z("MonitorCog",[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m15.2 4.9-.9-.4",key:"12wd2u"}],["path",{d:"m15.2 7.1-.9.4",key:"1r2vl7"}],["path",{d:"m16.9 3.2-.4-.9",key:"3zbo91"}],["path",{d:"m16.9 8.8-.4.9",key:"1qr2dn"}],["path",{d:"m19.5 2.3-.4.9",key:"1rjrkq"}],["path",{d:"m19.5 9.7-.4-.9",key:"heryx5"}],["path",{d:"m21.7 4.5-.9.4",key:"17fqt1"}],["path",{d:"m21.7 7.5-.9-.4",key:"14zyni"}],["path",{d:"M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"1tnzv8"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iQ=Z("MonitorDot",[["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M22 12v3a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9",key:"1fet9y"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oQ=Z("MonitorDown",[["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"m15 10-3 3-3-3",key:"lzhmyn"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lQ=Z("MonitorOff",[["path",{d:"M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2",key:"k0q8oc"}],["path",{d:"M22 15V5a2 2 0 0 0-2-2H9",key:"cp1ac0"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cQ=Z("MonitorPause",[["path",{d:"M10 13V7",key:"1u13u9"}],["path",{d:"M14 13V7",key:"1vj9om"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dQ=Z("MonitorPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uQ=Z("MonitorSmartphone",[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hQ=Z("MonitorSpeaker",[["path",{d:"M5.5 20H8",key:"1k40s5"}],["path",{d:"M17 9h.01",key:"1j24nn"}],["rect",{width:"10",height:"16",x:"12",y:"4",rx:"2",key:"ixliua"}],["path",{d:"M8 6H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h4",key:"1mp6e1"}],["circle",{cx:"17",cy:"15",r:"1",key:"tqvash"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mQ=Z("MonitorStop",[["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}],["rect",{x:"9",y:"7",width:"6",height:"6",rx:"1",key:"5m2oou"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pQ=Z("MonitorUp",[["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}],["path",{d:"M12 13V7",key:"h0r20n"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fQ=Z("MonitorX",[["path",{d:"m14.5 12.5-5-5",key:"1jahn5"}],["path",{d:"m9.5 12.5 5-5",key:"1k2t7b"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H4=Z("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gQ=Z("MoonStar",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9",key:"4ay0iu"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xQ=Z("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yQ=Z("MountainSnow",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}],["path",{d:"M4.14 15.08c2.62-1.57 5.24-1.43 7.86.42 2.74 1.94 5.49 2 8.23.19",key:"1pvmmp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vQ=Z("Mountain",[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _Q=Z("MouseOff",[["path",{d:"M12 6v.343",key:"1gyhex"}],["path",{d:"M18.218 18.218A7 7 0 0 1 5 15V9a7 7 0 0 1 .782-3.218",key:"ukzz01"}],["path",{d:"M19 13.343V9A7 7 0 0 0 8.56 2.902",key:"104jy9"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bQ=Z("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wQ=Z("MousePointerBan",[["path",{d:"M2.034 2.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.944L8.204 7.545a1 1 0 0 0-.66.66l-1.066 3.443a.5.5 0 0 1-.944.033z",key:"11pp1i"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}],["path",{d:"m11.8 11.8 8.4 8.4",key:"oogvdj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lb=Z("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lh=Z("MousePointer",[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jQ=Z("Mouse",[["rect",{x:"5",y:"2",width:"14",height:"20",rx:"7",key:"11ol66"}],["path",{d:"M12 6v4",key:"16clxf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fk=Z("Move3d",[["path",{d:"M5 3v16h16",key:"1mqmf9"}],["path",{d:"m5 19 6-6",key:"jh6hbb"}],["path",{d:"m2 6 3-3 3 3",key:"tkyvxa"}],["path",{d:"m18 16 3 3-3 3",key:"1d4glt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kQ=Z("MoveDiagonal2",[["path",{d:"M19 13v6h-6",key:"1hxl6d"}],["path",{d:"M5 11V5h6",key:"12e2xe"}],["path",{d:"m5 5 14 14",key:"11anup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NQ=Z("MoveDiagonal",[["path",{d:"M11 19H5v-6",key:"8awifj"}],["path",{d:"M13 5h6v6",key:"7voy1q"}],["path",{d:"M19 5 5 19",key:"wwaj1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SQ=Z("MoveDownLeft",[["path",{d:"M11 19H5V13",key:"1akmht"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CQ=Z("MoveDownRight",[["path",{d:"M19 13V19H13",key:"10vkzq"}],["path",{d:"M5 5L19 19",key:"5zm2fv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MQ=Z("MoveDown",[["path",{d:"M8 18L12 22L16 18",key:"cskvfv"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TQ=Z("MoveHorizontal",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AQ=Z("MoveLeft",[["path",{d:"M6 8L2 12L6 16",key:"kyvwex"}],["path",{d:"M2 12H22",key:"1m8cig"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EQ=Z("MoveRight",[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PQ=Z("MoveUpLeft",[["path",{d:"M5 11V5H11",key:"3q78g9"}],["path",{d:"M5 5L19 19",key:"5zm2fv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IQ=Z("MoveUpRight",[["path",{d:"M13 5H19V11",key:"1n1gyv"}],["path",{d:"M19 5L5 19",key:"72u4yj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LQ=Z("MoveUp",[["path",{d:"M8 6L12 2L16 6",key:"1yvkyx"}],["path",{d:"M12 2V22",key:"r89rzk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DQ=Z("MoveVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OQ=Z("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RQ=Z("Music2",[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FQ=Z("Music3",[["circle",{cx:"12",cy:"18",r:"4",key:"m3r9ws"}],["path",{d:"M16 18V2",key:"40x2m5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zQ=Z("Music4",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["path",{d:"m9 9 12-2",key:"1e64n2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BQ=Z("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $Q=Z("Navigation2Off",[["path",{d:"M9.31 9.31 5 21l7-4 7 4-1.17-3.17",key:"qoq2o2"}],["path",{d:"M14.53 8.88 12 2l-1.17 3.17",key:"k3sjzy"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qQ=Z("Navigation2",[["polygon",{points:"12 2 19 21 12 17 5 21 12 2",key:"x8c0qg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UQ=Z("NavigationOff",[["path",{d:"M8.43 8.43 3 11l8 2 2 8 2.57-5.43",key:"1vdtb7"}],["path",{d:"M17.39 11.73 22 2l-9.73 4.61",key:"tya3r6"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VQ=Z("Navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HQ=Z("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const s1=Z("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WQ=Z("Nfc",[["path",{d:"M6 8.32a7.43 7.43 0 0 1 0 7.36",key:"9iaqei"}],["path",{d:"M9.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"1yha7l"}],["path",{d:"M12.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"4iu2gk"}],["path",{d:"M16.37 2a20.16 20.16 0 0 1 0 20",key:"sap9u2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GQ=Z("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KQ=Z("NotebookTabs",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M15 2v20",key:"dcj49h"}],["path",{d:"M15 7h5",key:"1xj5lc"}],["path",{d:"M15 12h5",key:"w5shd9"}],["path",{d:"M15 17h5",key:"1qaofu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZQ=Z("NotebookText",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M9.5 8h5",key:"11mslq"}],["path",{d:"M9.5 12H16",key:"ktog6x"}],["path",{d:"M9.5 16H14",key:"p1seyn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YQ=Z("Notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XQ=Z("NotepadTextDashed",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v2",key:"j91f56"}],["path",{d:"M20 12v2",key:"w8o0tu"}],["path",{d:"M20 18v2a2 2 0 0 1-2 2h-1",key:"1c9ggx"}],["path",{d:"M13 22h-2",key:"191ugt"}],["path",{d:"M7 22H6a2 2 0 0 1-2-2v-2",key:"1rt9px"}],["path",{d:"M4 14v-2",key:"1v0sqh"}],["path",{d:"M4 8V6a2 2 0 0 1 2-2h2",key:"1mwabg"}],["path",{d:"M8 10h6",key:"3oa6kw"}],["path",{d:"M8 14h8",key:"1fgep2"}],["path",{d:"M8 18h5",key:"17enja"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QQ=Z("NotepadText",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"16",height:"18",x:"4",y:"4",rx:"2",key:"1u9h20"}],["path",{d:"M8 10h6",key:"3oa6kw"}],["path",{d:"M8 14h8",key:"1fgep2"}],["path",{d:"M8 18h5",key:"17enja"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JQ=Z("NutOff",[["path",{d:"M12 4V2",key:"1k5q1u"}],["path",{d:"M5 10v4a7.004 7.004 0 0 0 5.277 6.787c.412.104.802.292 1.102.592L12 22l.621-.621c.3-.3.69-.488 1.102-.592a7.01 7.01 0 0 0 4.125-2.939",key:"1xcvy9"}],["path",{d:"M19 10v3.343",key:"163tfc"}],["path",{d:"M12 12c-1.349-.573-1.905-1.005-2.5-2-.546.902-1.048 1.353-2.5 2-1.018-.644-1.46-1.08-2-2-1.028.71-1.69.918-3 1 1.081-1.048 1.757-2.03 2-3 .194-.776.84-1.551 1.79-2.21m11.654 5.997c.887-.457 1.28-.891 1.556-1.787 1.032.916 1.683 1.157 3 1-1.297-1.036-1.758-2.03-2-3-.5-2-4-4-8-4-.74 0-1.461.068-2.15.192",key:"17914v"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eJ=Z("Nut",[["path",{d:"M12 4V2",key:"1k5q1u"}],["path",{d:"M5 10v4a7.004 7.004 0 0 0 5.277 6.787c.412.104.802.292 1.102.592L12 22l.621-.621c.3-.3.69-.488 1.102-.592A7.003 7.003 0 0 0 19 14v-4",key:"1tgyif"}],["path",{d:"M12 4C8 4 4.5 6 4 8c-.243.97-.919 1.952-2 3 1.31-.082 1.972-.29 3-1 .54.92.982 1.356 2 2 1.452-.647 1.954-1.098 2.5-2 .595.995 1.151 1.427 2.5 2 1.31-.621 1.862-1.058 2.5-2 .629.977 1.162 1.423 2.5 2 1.209-.548 1.68-.967 2-2 1.032.916 1.683 1.157 3 1-1.297-1.036-1.758-2.03-2-3-.5-2-4-4-8-4Z",key:"tnsqj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tv=Z("OctagonAlert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tJ=Z("OctagonMinus",[["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gk=Z("OctagonPause",[["path",{d:"M10 15V9",key:"1lckn7"}],["path",{d:"M14 15V9",key:"1muqhk"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xk=Z("OctagonX",[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sJ=Z("Octagon",[["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rJ=Z("Omega",[["path",{d:"M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21",key:"1x94xo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nJ=Z("Option",[["path",{d:"M3 3h6l6 18h6",key:"ph9rgk"}],["path",{d:"M14 3h7",key:"16f0ms"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aJ=Z("Orbit",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M10.4 21.9a10 10 0 0 0 9.941-15.416",key:"eohfx2"}],["path",{d:"M13.5 2.1a10 10 0 0 0-9.841 15.416",key:"19pvbm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iJ=Z("Origami",[["path",{d:"M12 12V4a1 1 0 0 1 1-1h6.297a1 1 0 0 1 .651 1.759l-4.696 4.025",key:"1bx4vc"}],["path",{d:"m12 21-7.414-7.414A2 2 0 0 1 4 12.172V6.415a1.002 1.002 0 0 1 1.707-.707L20 20.009",key:"1h3km6"}],["path",{d:"m12.214 3.381 8.414 14.966a1 1 0 0 1-.167 1.199l-1.168 1.163a1 1 0 0 1-.706.291H6.351a1 1 0 0 1-.625-.219L3.25 18.8a1 1 0 0 1 .631-1.781l4.165.027",key:"1hj4wg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oJ=Z("Package2",[["path",{d:"M3 9h18v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9Z",key:"1ront0"}],["path",{d:"m3 9 2.45-4.9A2 2 0 0 1 7.24 3h9.52a2 2 0 0 1 1.8 1.1L21 9",key:"19h2x1"}],["path",{d:"M12 3v6",key:"1holv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lJ=Z("PackageCheck",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cJ=Z("PackageMinus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dJ=Z("PackageOpen",[["path",{d:"M12 22v-9",key:"x3hkom"}],["path",{d:"M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z",key:"2ntwy6"}],["path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13",key:"1pmm1c"}],["path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z",key:"12ttoo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uJ=Z("PackagePlus",[["path",{d:"M16 16h6",key:"100bgy"}],["path",{d:"M19 13v6",key:"85cyf1"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hJ=Z("PackageSearch",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["circle",{cx:"18.5",cy:"15.5",r:"2.5",key:"b5zd12"}],["path",{d:"M20.27 17.27 22 19",key:"1l4muz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mJ=Z("PackageX",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["path",{d:"m17 13 5 5m-5 0 5-5",key:"im3w4b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bl=Z("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pJ=Z("PaintBucket",[["path",{d:"m19 11-8-8-8.6 8.6a2 2 0 0 0 0 2.8l5.2 5.2c.8.8 2 .8 2.8 0L19 11Z",key:"irua1i"}],["path",{d:"m5 2 5 5",key:"1lls2c"}],["path",{d:"M2 13h15",key:"1hkzvu"}],["path",{d:"M22 20a2 2 0 1 1-4 0c0-1.6 1.7-2.4 2-4 .3 1.6 2 2.4 2 4Z",key:"xk76lq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fJ=Z("PaintRoller",[["rect",{width:"16",height:"6",x:"2",y:"2",rx:"2",key:"jcyz7m"}],["path",{d:"M10 16v-2a2 2 0 0 1 2-2h8a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2",key:"1b9h7c"}],["rect",{width:"4",height:"6",x:"8",y:"16",rx:"1",key:"d6e7yl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yk=Z("PaintbrushVertical",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v4",key:"qmzblu"}],["path",{d:"M17 2a1 1 0 0 1 1 1v9H6V3a1 1 0 0 1 1-1z",key:"ycvu00"}],["path",{d:"M6 12a1 1 0 0 0-1 1v1a2 2 0 0 0 2 2h2a1 1 0 0 1 1 1v2.9a2 2 0 1 0 4 0V17a1 1 0 0 1 1-1h2a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1",key:"iw4wnp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gJ=Z("Paintbrush",[["path",{d:"m14.622 17.897-10.68-2.913",key:"vj2p1u"}],["path",{d:"M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z",key:"18tc5c"}],["path",{d:"M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15",key:"ytzfxy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ql=Z("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xJ=Z("PanelBottomClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m15 8-3 3-3-3",key:"1oxy1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vk=Z("PanelBottomDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M14 15h1",key:"171nev"}],["path",{d:"M19 15h2",key:"1vnucp"}],["path",{d:"M3 15h2",key:"8bym0q"}],["path",{d:"M9 15h1",key:"1tg3ks"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yJ=Z("PanelBottomOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vJ=Z("PanelBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _k=Z("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bk=Z("PanelLeftDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 14v1",key:"askpd8"}],["path",{d:"M9 19v2",key:"16tejx"}],["path",{d:"M9 3v2",key:"1noubl"}],["path",{d:"M9 9v1",key:"19ebxg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wk=Z("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jk=Z("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _J=Z("PanelRightClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kk=Z("PanelRightDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 14v1",key:"ilsfch"}],["path",{d:"M15 19v2",key:"1fst2f"}],["path",{d:"M15 3v2",key:"z204g4"}],["path",{d:"M15 9v1",key:"z2a8b1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bJ=Z("PanelRightOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wJ=Z("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jJ=Z("PanelTopClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m9 16 3-3 3 3",key:"1idcnm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nk=Z("PanelTopDashed",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M14 9h1",key:"l0svgy"}],["path",{d:"M19 9h2",key:"te2zfg"}],["path",{d:"M3 9h2",key:"1h4ldw"}],["path",{d:"M9 9h1",key:"15jzuz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kJ=Z("PanelTopOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m15 14-3 3-3-3",key:"g215vf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NJ=Z("PanelTop",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SJ=Z("PanelsLeftBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M9 15h12",key:"5ijen5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CJ=Z("PanelsRightBottom",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h12",key:"1wkqb3"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Av=Z("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W4=Z("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MJ=Z("Parentheses",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TJ=Z("ParkingMeter",[["path",{d:"M11 15h2",key:"199qp6"}],["path",{d:"M12 12v3",key:"158kv8"}],["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15.282 19a1 1 0 0 0 .948-.68l2.37-6.988a7 7 0 1 0-13.2 0l2.37 6.988a1 1 0 0 0 .948.68z",key:"1jofit"}],["path",{d:"M9 9a3 3 0 1 1 6 0",key:"jdoeu8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zd=Z("PartyPopper",[["path",{d:"M5.8 11.3 2 22l10.7-3.79",key:"gwxi1d"}],["path",{d:"M4 3h.01",key:"1vcuye"}],["path",{d:"M22 8h.01",key:"1mrtc2"}],["path",{d:"M15 2h.01",key:"1cjtqr"}],["path",{d:"M22 20h.01",key:"1mrys2"}],["path",{d:"m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10",key:"hbicv8"}],["path",{d:"m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17",key:"1i94pl"}],["path",{d:"m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7",key:"1cofks"}],["path",{d:"M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z",key:"4kbmks"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cf=Z("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AJ=Z("PawPrint",[["circle",{cx:"11",cy:"4",r:"2",key:"vol9p0"}],["circle",{cx:"18",cy:"8",r:"2",key:"17gozi"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}],["path",{d:"M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045Q6.52 17.48 4.46 16.84A3.5 3.5 0 0 1 5.5 10Z",key:"1ydw1z"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EJ=Z("PcCase",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",key:"1uq1d7"}],["path",{d:"M15 14h.01",key:"1kp3bh"}],["path",{d:"M9 6h6",key:"dgm16u"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ev=Z("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PJ=Z("PenOff",[["path",{d:"m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982",key:"bjo8r8"}],["path",{d:"m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353",key:"16h5ne"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Db=Z("PenTool",[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wy=Z("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IJ=Z("PencilLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}],["path",{d:"m15 5 3 3",key:"1w25hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LJ=Z("PencilOff",[["path",{d:"m10 10-6.157 6.162a2 2 0 0 0-.5.833l-1.322 4.36a.5.5 0 0 0 .622.624l4.358-1.323a2 2 0 0 0 .83-.5L14 13.982",key:"bjo8r8"}],["path",{d:"m12.829 7.172 4.359-4.346a1 1 0 1 1 3.986 3.986l-4.353 4.353",key:"16h5ne"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DJ=Z("PencilRuler",[["path",{d:"M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13",key:"orapub"}],["path",{d:"m8 6 2-2",key:"115y1s"}],["path",{d:"m18 16 2-2",key:"ee94s4"}],["path",{d:"m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17",key:"cfq27r"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $a=Z("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const OJ=Z("Pentagon",[["path",{d:"M10.83 2.38a2 2 0 0 1 2.34 0l8 5.74a2 2 0 0 1 .73 2.25l-3.04 9.26a2 2 0 0 1-1.9 1.37H7.04a2 2 0 0 1-1.9-1.37L2.1 10.37a2 2 0 0 1 .73-2.25z",key:"2hea0t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _M=Z("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RJ=Z("PersonStanding",[["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["path",{d:"m9 20 3-6 3 6",key:"se2kox"}],["path",{d:"m6 8 6 2 6-2",key:"4o3us4"}],["path",{d:"M12 10v4",key:"1kjpxc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FJ=Z("PhilippinePeso",[["path",{d:"M20 11H4",key:"6ut86h"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"M7 21V4a1 1 0 0 1 1-1h4a1 1 0 0 1 0 12H7",key:"1ana5r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zJ=Z("PhoneCall",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}],["path",{d:"M14.05 2a9 9 0 0 1 8 7.94",key:"vmijpz"}],["path",{d:"M14.05 6A5 5 0 0 1 18 10",key:"13nbpp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BJ=Z("PhoneForwarded",[["polyline",{points:"18 2 22 6 18 10",key:"6vjanh"}],["line",{x1:"14",x2:"22",y1:"6",y2:"6",key:"1jsywh"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $J=Z("PhoneIncoming",[["polyline",{points:"16 2 16 8 22 8",key:"1ygljm"}],["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qJ=Z("PhoneMissed",[["line",{x1:"22",x2:"16",y1:"2",y2:"8",key:"1xzwqn"}],["line",{x1:"16",x2:"22",y1:"2",y2:"8",key:"13zxdn"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UJ=Z("PhoneOff",[["path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91",key:"z86iuo"}],["line",{x1:"22",x2:"2",y1:"2",y2:"22",key:"11kh81"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VJ=Z("PhoneOutgoing",[["polyline",{points:"22 8 22 2 16 2",key:"1g204g"}],["line",{x1:"16",x2:"22",y1:"8",y2:"2",key:"1ggias"}],["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ea=Z("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HJ=Z("Pi",[["line",{x1:"9",x2:"9",y1:"4",y2:"20",key:"ovs5a5"}],["path",{d:"M4 7c0-1.7 1.3-3 3-3h13",key:"10pag4"}],["path",{d:"M18 20c-1.7 0-3-1.3-3-3V4",key:"1gaosr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WJ=Z("Piano",[["path",{d:"M18.5 8c-1.4 0-2.6-.8-3.2-2A6.87 6.87 0 0 0 2 9v11a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-8.5C22 9.6 20.4 8 18.5 8",key:"lag0yf"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M6 14v4",key:"9ng0ue"}],["path",{d:"M10 14v4",key:"1v8uk5"}],["path",{d:"M14 14v4",key:"1tqops"}],["path",{d:"M18 14v4",key:"18uqwm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GJ=Z("Pickaxe",[["path",{d:"M14.531 12.469 6.619 20.38a1 1 0 1 1-3-3l7.912-7.912",key:"we99rg"}],["path",{d:"M15.686 4.314A12.5 12.5 0 0 0 5.461 2.958 1 1 0 0 0 5.58 4.71a22 22 0 0 1 6.318 3.393",key:"1w6hck"}],["path",{d:"M17.7 3.7a1 1 0 0 0-1.4 0l-4.6 4.6a1 1 0 0 0 0 1.4l2.6 2.6a1 1 0 0 0 1.4 0l4.6-4.6a1 1 0 0 0 0-1.4z",key:"15hgfx"}],["path",{d:"M19.686 8.314a12.501 12.501 0 0 1 1.356 10.225 1 1 0 0 1-1.751-.119 22 22 0 0 0-3.393-6.319",key:"452b4h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const KJ=Z("PictureInPicture2",[["path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4",key:"daa4of"}],["rect",{width:"10",height:"7",x:"12",y:"13",rx:"2",key:"1nb8gs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ZJ=Z("PictureInPicture",[["path",{d:"M8 4.5v5H3m-1-6 6 6m13 0v-3c0-1.16-.84-2-2-2h-7m-9 9v2c0 1.05.95 2 2 2h3",key:"bcd8fb"}],["rect",{width:"10",height:"7",x:"12",y:"13.5",ry:"2",key:"136fx3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const YJ=Z("PiggyBank",[["path",{d:"M19 5c-1.5 0-2.8 1.4-3 2-3.5-1.5-11-.3-11 5 0 1.8 0 3 2 4.5V20h4v-2h3v2h4v-4c1-.5 1.7-1 2-2h2v-4h-2c0-1-.5-1.5-1-2V5z",key:"1ivx2i"}],["path",{d:"M2 9v1c0 1.1.9 2 2 2h1",key:"nm575m"}],["path",{d:"M16 11h.01",key:"xkw8gn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const XJ=Z("PilcrowLeft",[["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"M14 9h-3a3 3 0 0 1 0-6h9",key:"1ulc19"}],["path",{d:"M18 3v11",key:"1phi0r"}],["path",{d:"M22 18H2l4-4",key:"yt65j9"}],["path",{d:"m6 22-4-4",key:"6jgyf5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QJ=Z("PilcrowRight",[["path",{d:"M10 3v11",key:"o3l5kj"}],["path",{d:"M10 9H7a1 1 0 0 1 0-6h8",key:"1wb1nc"}],["path",{d:"M14 3v11",key:"mlfb7b"}],["path",{d:"m18 14 4 4H2",key:"4r8io1"}],["path",{d:"m22 18-4 4",key:"1hjjrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JJ=Z("Pilcrow",[["path",{d:"M13 4v16",key:"8vvj80"}],["path",{d:"M17 4v16",key:"7dpous"}],["path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13",key:"sh4n9v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eee=Z("PillBottle",[["path",{d:"M18 11h-4a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h4",key:"17ldeb"}],["path",{d:"M6 7v13a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7",key:"nc37y6"}],["rect",{width:"16",height:"5",x:"4",y:"2",rx:"1",key:"3jeezo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tee=Z("Pill",[["path",{d:"m10.5 20.5 10-10a4.95 4.95 0 1 0-7-7l-10 10a4.95 4.95 0 1 0 7 7Z",key:"wa1lgi"}],["path",{d:"m8.5 8.5 7 7",key:"rvfmvr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const QI=Z("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ob=Z("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const see=Z("Pipette",[["path",{d:"m2 22 1-1h3l9-9",key:"1sre89"}],["path",{d:"M3 21v-3l9-9",key:"hpe2y6"}],["path",{d:"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",key:"196du1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ree=Z("Pizza",[["path",{d:"m12 14-1 1",key:"11onhr"}],["path",{d:"m13.75 18.25-1.25 1.42",key:"1yisr3"}],["path",{d:"M17.775 5.654a15.68 15.68 0 0 0-12.121 12.12",key:"1qtqk6"}],["path",{d:"M18.8 9.3a1 1 0 0 0 2.1 7.7",key:"fbbbr2"}],["path",{d:"M21.964 20.732a1 1 0 0 1-1.232 1.232l-18-5a1 1 0 0 1-.695-1.232A19.68 19.68 0 0 1 15.732 2.037a1 1 0 0 1 1.232.695z",key:"1hyfdd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nee=Z("PlaneLanding",[["path",{d:"M2 22h20",key:"272qi7"}],["path",{d:"M3.77 10.77 2 9l2-4.5 1.1.55c.55.28.9.84.9 1.45s.35 1.17.9 1.45L8 8.5l3-6 1.05.53a2 2 0 0 1 1.09 1.52l.72 5.4a2 2 0 0 0 1.09 1.52l4.4 2.2c.42.22.78.55 1.01.96l.6 1.03c.49.88-.06 1.98-1.06 2.1l-1.18.15c-.47.06-.95-.02-1.37-.24L4.29 11.15a2 2 0 0 1-.52-.38Z",key:"1ma21e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aee=Z("PlaneTakeoff",[["path",{d:"M2 22h20",key:"272qi7"}],["path",{d:"M6.36 17.4 4 17l-2-4 1.1-.55a2 2 0 0 1 1.8 0l.17.1a2 2 0 0 0 1.8 0L8 12 5 6l.9-.45a2 2 0 0 1 2.09.2l4.02 3a2 2 0 0 0 2.1.2l4.19-2.06a2.41 2.41 0 0 1 1.73-.17L21 7a1.4 1.4 0 0 1 .87 1.99l-.38.76c-.23.46-.6.84-1.07 1.08L7.58 17.2a2 2 0 0 1-1.22.18Z",key:"fkigj9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iee=Z("Plane",[["path",{d:"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z",key:"1v9wt8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wl=Z("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oee=Z("Plug2",[["path",{d:"M9 2v6",key:"17ngun"}],["path",{d:"M15 2v6",key:"s7yy2p"}],["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M6 11V8h12v3a6 6 0 1 1-12 0Z",key:"wtfw2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sk=Z("PlugZap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const JI=Z("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zs=Z("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lee=Z("PocketKnife",[["path",{d:"M3 2v1c0 1 2 1 2 2S3 6 3 7s2 1 2 2-2 1-2 2 2 1 2 2",key:"19w3oe"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M20.83 8.83a4 4 0 0 0-5.66-5.66l-12 12a4 4 0 1 0 5.66 5.66Z",key:"6fykxj"}],["path",{d:"M18 11.66V22a4 4 0 0 0 4-4V6",key:"1utzek"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cee=Z("Pocket",[["path",{d:"M4 3h16a2 2 0 0 1 2 2v6a10 10 0 0 1-10 10A10 10 0 0 1 2 11V5a2 2 0 0 1 2-2z",key:"1mz881"}],["polyline",{points:"8 10 12 14 16 10",key:"w4mbv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dee=Z("Podcast",[["path",{d:"M16.85 18.58a9 9 0 1 0-9.7 0",key:"d71mpg"}],["path",{d:"M8 14a5 5 0 1 1 8 0",key:"fc81rn"}],["circle",{cx:"12",cy:"11",r:"1",key:"1gvufo"}],["path",{d:"M13 17a1 1 0 1 0-2 0l.5 4.5a.5.5 0 1 0 1 0Z",key:"za5kbj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uee=Z("PointerOff",[["path",{d:"M10 4.5V4a2 2 0 0 0-2.41-1.957",key:"jsi14n"}],["path",{d:"M13.9 8.4a2 2 0 0 0-1.26-1.295",key:"hirc7f"}],["path",{d:"M21.7 16.2A8 8 0 0 0 22 14v-3a2 2 0 1 0-4 0v-1a2 2 0 0 0-3.63-1.158",key:"1jxb2e"}],["path",{d:"m7 15-1.8-1.8a2 2 0 0 0-2.79 2.86L6 19.7a7.74 7.74 0 0 0 6 2.3h2a8 8 0 0 0 5.657-2.343",key:"10r7hm"}],["path",{d:"M6 6v8",key:"tv5xkp"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hee=Z("Pointer",[["path",{d:"M22 14a8 8 0 0 1-8 8",key:"56vcr3"}],["path",{d:"M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1agjmk"}],["path",{d:"M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1",key:"wdbh2u"}],["path",{d:"M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10",key:"1ibuk9"}],["path",{d:"M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"g6ys72"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mee=Z("Popcorn",[["path",{d:"M18 8a2 2 0 0 0 0-4 2 2 0 0 0-4 0 2 2 0 0 0-4 0 2 2 0 0 0-4 0 2 2 0 0 0 0 4",key:"10td1f"}],["path",{d:"M10 22 9 8",key:"yjptiv"}],["path",{d:"m14 22 1-14",key:"8jwc8b"}],["path",{d:"M20 8c.5 0 .9.4.8 1l-2.6 12c-.1.5-.7 1-1.2 1H7c-.6 0-1.1-.4-1.2-1L3.2 9c-.1-.6.3-1 .8-1Z",key:"1qo33t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pee=Z("Popsicle",[["path",{d:"M18.6 14.4c.8-.8.8-2 0-2.8l-8.1-8.1a4.95 4.95 0 1 0-7.1 7.1l8.1 8.1c.9.7 2.1.7 2.9-.1Z",key:"1o68ps"}],["path",{d:"m22 22-5.5-5.5",key:"17o70y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fee=Z("PoundSterling",[["path",{d:"M18 7c0-5.333-8-5.333-8 0",key:"1prm2n"}],["path",{d:"M10 7v14",key:"18tmcs"}],["path",{d:"M6 21h12",key:"4dkmi1"}],["path",{d:"M6 13h10",key:"ybwr4a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gee=Z("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eL=Z("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gx=Z("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xee=Z("PrinterCheck",[["path",{d:"M13.5 22H7a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v.5",key:"qeb09x"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}],["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v2",key:"1md90i"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tL=Z("Printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yee=Z("Projector",[["path",{d:"M5 7 3 5",key:"1yys58"}],["path",{d:"M9 6V3",key:"1ptz9u"}],["path",{d:"m13 7 2-2",key:"1w3vmq"}],["circle",{cx:"9",cy:"13",r:"3",key:"1mma13"}],["path",{d:"M11.83 12H20a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h2.17",key:"2frwzc"}],["path",{d:"M16 16h2",key:"dnq2od"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vee=Z("Proportions",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M12 9v11",key:"1fnkrn"}],["path",{d:"M2 9h13a2 2 0 0 1 2 2v9",key:"11z3ex"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ee=Z("Puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bee=Z("Pyramid",[["path",{d:"M2.5 16.88a1 1 0 0 1-.32-1.43l9-13.02a1 1 0 0 1 1.64 0l9 13.01a1 1 0 0 1-.32 1.44l-8.51 4.86a2 2 0 0 1-1.98 0Z",key:"aenxs0"}],["path",{d:"M12 2v20",key:"t6zp3m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const r1=Z("QrCode",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bM=Z("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wee=Z("Rabbit",[["path",{d:"M13 16a3 3 0 0 1 2.24 5",key:"1epib5"}],["path",{d:"M18 12h.01",key:"yjnet6"}],["path",{d:"M18 21h-8a4 4 0 0 1-4-4 7 7 0 0 1 7-7h.2L9.6 6.4a1 1 0 1 1 2.8-2.8L15.8 7h.2c3.3 0 6 2.7 6 6v1a2 2 0 0 1-2 2h-1a3 3 0 0 0-3 3",key:"ue9ozu"}],["path",{d:"M20 8.54V4a2 2 0 1 0-4 0v3",key:"49iql8"}],["path",{d:"M7.612 12.524a3 3 0 1 0-1.6 4.3",key:"1e33i0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jee=Z("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kee=Z("Radiation",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M7.5 4.2c-.3-.5-.9-.7-1.3-.4C3.9 5.5 2.3 8.1 2 11c-.1.5.4 1 1 1h5c0-1.5.8-2.8 2-3.4-1.1-1.9-2-3.5-2.5-4.4z",key:"wy49g3"}],["path",{d:"M21 12c.6 0 1-.4 1-1-.3-2.9-1.8-5.5-4.1-7.1-.4-.3-1.1-.2-1.3.3-.6.9-1.5 2.5-2.6 4.3 1.2.7 2 2 2 3.5h5z",key:"vklnvr"}],["path",{d:"M7.5 19.8c-.3.5-.1 1.1.4 1.3 2.6 1.2 5.6 1.2 8.2 0 .5-.2.7-.8.4-1.3-.5-.9-1.4-2.5-2.5-4.3-1.2.7-2.8.7-4 0-1.1 1.8-2 3.4-2.5 4.3z",key:"wkdf1o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nee=Z("Radical",[["path",{d:"M3 12h3.28a1 1 0 0 1 .948.684l2.298 7.934a.5.5 0 0 0 .96-.044L13.82 4.771A1 1 0 0 1 14.792 4H21",key:"1mqj8i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const See=Z("RadioReceiver",[["path",{d:"M5 16v2",key:"g5qcv5"}],["path",{d:"M19 16v2",key:"1gbaio"}],["rect",{width:"20",height:"8",x:"2",y:"8",rx:"2",key:"vjsjur"}],["path",{d:"M18 12h.01",key:"yjnet6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cee=Z("RadioTower",[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const n1=Z("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mee=Z("Radius",[["path",{d:"M20.34 17.52a10 10 0 1 0-2.82 2.82",key:"fydyku"}],["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["path",{d:"m13.41 13.41 4.18 4.18",key:"1gqbwc"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tee=Z("RailSymbol",[["path",{d:"M5 15h14",key:"m0yey3"}],["path",{d:"M5 9h14",key:"7tsvo6"}],["path",{d:"m14 20-5-5 6-6-5-5",key:"1jo42i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aee=Z("Rainbow",[["path",{d:"M22 17a10 10 0 0 0-20 0",key:"ozegv"}],["path",{d:"M6 17a6 6 0 0 1 12 0",key:"5giftw"}],["path",{d:"M10 17a2 2 0 0 1 4 0",key:"gnsikk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eee=Z("Rat",[["path",{d:"M17 5c0-1.7-1.3-3-3-3s-3 1.3-3 3c0 .8.3 1.5.8 2H11c-3.9 0-7 3.1-7 7c0 2.2 1.8 4 4 4",key:"1wq71c"}],["path",{d:"M16.8 3.9c.3-.3.6-.5 1-.7 1.5-.6 3.3.1 3.9 1.6.6 1.5-.1 3.3-1.6 3.9l1.6 2.8c.2.3.2.7.2 1-.2.8-.9 1.2-1.7 1.1 0 0-1.6-.3-2.7-.6H17c-1.7 0-3 1.3-3 3",key:"1crdmb"}],["path",{d:"M13.2 18a3 3 0 0 0-2.2-5",key:"1ol3lk"}],["path",{d:"M13 22H4a2 2 0 0 1 0-4h12",key:"bt3f23"}],["path",{d:"M16 9h.01",key:"1bdo4e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pee=Z("Ratio",[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iee=Z("ReceiptCent",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M12 6.5v11",key:"ecfhkf"}],["path",{d:"M15 9.4a4 4 0 1 0 0 5.2",key:"1makmb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lee=Z("ReceiptEuro",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 12h5",key:"1g6qi8"}],["path",{d:"M16 9.5a4 4 0 1 0 0 5.2",key:"b2px4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dee=Z("ReceiptIndianRupee",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 7h8",key:"i86dvs"}],["path",{d:"M12 17.5 8 15h1a4 4 0 0 0 0-8",key:"grpkl4"}],["path",{d:"M8 11h8",key:"vwpz6n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oee=Z("ReceiptJapaneseYen",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"m12 10 3-3",key:"1mc12w"}],["path",{d:"m9 7 3 3v7.5",key:"39i0xv"}],["path",{d:"M9 11h6",key:"1fldmi"}],["path",{d:"M9 15h6",key:"cctwl0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ree=Z("ReceiptPoundSterling",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 13h5",key:"1k9z8w"}],["path",{d:"M10 17V9.5a2.5 2.5 0 0 1 5 0",key:"1dzgp0"}],["path",{d:"M8 17h7",key:"8mjdqu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fee=Z("ReceiptRussianRuble",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M8 15h5",key:"vxg57a"}],["path",{d:"M8 11h5a2 2 0 1 0 0-4h-3v10",key:"1usi5u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zee=Z("ReceiptSwissFranc",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M10 17V7h5",key:"k7jq18"}],["path",{d:"M10 11h4",key:"1i0mka"}],["path",{d:"M8 15h5",key:"vxg57a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bee=Z("ReceiptText",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M13 16H8",key:"wsln4y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ee=Z("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ck=Z("RectangleEllipsis",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qee=Z("RectangleHorizontal",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uee=Z("RectangleVertical",[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vee=Z("Recycle",[["path",{d:"M7 19H4.815a1.83 1.83 0 0 1-1.57-.881 1.785 1.785 0 0 1-.004-1.784L7.196 9.5",key:"x6z5xu"}],["path",{d:"M11 19h8.203a1.83 1.83 0 0 0 1.556-.89 1.784 1.784 0 0 0 0-1.775l-1.226-2.12",key:"1x4zh5"}],["path",{d:"m14 16-3 3 3 3",key:"f6jyew"}],["path",{d:"M8.293 13.596 7.196 9.5 3.1 10.598",key:"wf1obh"}],["path",{d:"m9.344 5.811 1.093-1.892A1.83 1.83 0 0 1 11.985 3a1.784 1.784 0 0 1 1.546.888l3.943 6.843",key:"9tzpgr"}],["path",{d:"m13.378 9.633 4.096 1.098 1.097-4.096",key:"1oe83g"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hee=Z("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wee=Z("RedoDot",[["circle",{cx:"12",cy:"17",r:"1",key:"1ixnty"}],["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wM=Z("Redo",[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gee=Z("RefreshCcwDot",[["path",{d:"M3 2v6h6",key:"18ldww"}],["path",{d:"M21 12A9 9 0 0 0 6 5.3L3 8",key:"1pbrqz"}],["path",{d:"M21 22v-6h-6",key:"usdfbe"}],["path",{d:"M3 12a9 9 0 0 0 15 6.7l3-2.7",key:"1hosoe"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kee=Z("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zee=Z("RefreshCwOff",[["path",{d:"M21 8L18.74 5.74A9.75 9.75 0 0 0 12 3C11 3 10.03 3.16 9.13 3.47",key:"1krf6h"}],["path",{d:"M8 16H3v5",key:"1cv678"}],["path",{d:"M3 12C3 9.51 4 7.26 5.64 5.64",key:"ruvoct"}],["path",{d:"m3 16 2.26 2.26A9.75 9.75 0 0 0 12 21c2.49 0 4.74-1 6.36-2.64",key:"19q130"}],["path",{d:"M21 12c0 1-.16 1.97-.47 2.87",key:"4w8emr"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M22 22 2 2",key:"1r8tn9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bo=Z("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yee=Z("Refrigerator",[["path",{d:"M5 6a4 4 0 0 1 4-4h6a4 4 0 0 1 4 4v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6Z",key:"fpq118"}],["path",{d:"M5 10h14",key:"elsbfy"}],["path",{d:"M15 7v6",key:"1nx30x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xee=Z("Regex",[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qee=Z("RemoveFormatting",[["path",{d:"M4 7V4h16v3",key:"9msm58"}],["path",{d:"M5 20h6",key:"1h6pxn"}],["path",{d:"M13 4 8 20",key:"kqq6aj"}],["path",{d:"m15 15 5 5",key:"me55sn"}],["path",{d:"m20 15-5 5",key:"11p7ol"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jee=Z("Repeat1",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}],["path",{d:"M11 10h1v4",key:"70cz1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ete=Z("Repeat2",[["path",{d:"m2 9 3-3 3 3",key:"1ltn5i"}],["path",{d:"M13 18H7a2 2 0 0 1-2-2V6",key:"1r6tfw"}],["path",{d:"m22 15-3 3-3-3",key:"4rnwn2"}],["path",{d:"M11 6h6a2 2 0 0 1 2 2v10",key:"2f72bc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sL=Z("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tte=Z("ReplaceAll",[["path",{d:"M14 14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"1yyzbs"}],["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2",key:"zfj4xr"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a 3 3 0 0 1 3-3h1",key:"1ageje"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ste=Z("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rte=Z("ReplyAll",[["polyline",{points:"7 17 2 12 7 7",key:"t83bqg"}],["polyline",{points:"12 17 7 12 12 7",key:"1g4ajm"}],["path",{d:"M22 18v-2a4 4 0 0 0-4-4H7",key:"1fcyog"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rL=Z("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nte=Z("Rewind",[["polygon",{points:"11 19 2 12 11 5 11 19",key:"14yba5"}],["polygon",{points:"22 19 13 12 22 5 22 19",key:"1pi1cj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ate=Z("Ribbon",[["path",{d:"M12 11.22C11 9.997 10 9 10 8a2 2 0 0 1 4 0c0 1-.998 2.002-2.01 3.22",key:"1rnhq3"}],["path",{d:"m12 18 2.57-3.5",key:"116vt7"}],["path",{d:"M6.243 9.016a7 7 0 0 1 11.507-.009",key:"10dq0b"}],["path",{d:"M9.35 14.53 12 11.22",key:"tdsyp2"}],["path",{d:"M9.35 14.53C7.728 12.246 6 10.221 6 7a6 5 0 0 1 12 0c-.005 3.22-1.778 5.235-3.43 7.5l3.557 4.527a1 1 0 0 1-.203 1.43l-1.894 1.36a1 1 0 0 1-1.384-.215L12 18l-2.679 3.593a1 1 0 0 1-1.39.213l-1.865-1.353a1 1 0 0 1-.203-1.422z",key:"nmifey"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o0=Z("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ite=Z("RockingChair",[["polyline",{points:"3.5 2 6.5 12.5 18 12.5",key:"y3iy52"}],["line",{x1:"9.5",x2:"5.5",y1:"12.5",y2:"20",key:"19vg5i"}],["line",{x1:"15",x2:"18.5",y1:"12.5",y2:"20",key:"1inpmv"}],["path",{d:"M2.75 18a13 13 0 0 0 18.5 0",key:"1nquas"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ote=Z("RollerCoaster",[["path",{d:"M6 19V5",key:"1r845m"}],["path",{d:"M10 19V6.8",key:"9j2tfs"}],["path",{d:"M14 19v-7.8",key:"10s8qv"}],["path",{d:"M18 5v4",key:"1tajlv"}],["path",{d:"M18 19v-6",key:"ielfq3"}],["path",{d:"M22 19V9",key:"158nzp"}],["path",{d:"M2 19V9a4 4 0 0 1 4-4c2 0 4 1.33 6 4s4 4 6 4a4 4 0 1 0-3-6.65",key:"1930oh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mk=Z("Rotate3d",[["path",{d:"M16.466 7.5C15.643 4.237 13.952 2 12 2 9.239 2 7 6.477 7 12s2.239 10 5 10c.342 0 .677-.069 1-.2",key:"10n0gc"}],["path",{d:"m15.194 13.707 3.814 1.86-1.86 3.814",key:"16shm9"}],["path",{d:"M19 15.57c-1.804.885-4.274 1.43-7 1.43-5.523 0-10-2.239-10-5s4.477-5 10-5c4.838 0 8.873 1.718 9.8 4",key:"1lxi77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lte=Z("RotateCcwSquare",[["path",{d:"M20 9V7a2 2 0 0 0-2-2h-6",key:"19z8uc"}],["path",{d:"m15 2-3 3 3 3",key:"177bxs"}],["path",{d:"M20 13v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2",key:"d36hnl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const a1=Z("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cte=Z("RotateCwSquare",[["path",{d:"M12 5H6a2 2 0 0 0-2 2v3",key:"l96uqu"}],["path",{d:"m9 8 3-3-3-3",key:"1gzgc3"}],["path",{d:"M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2",key:"1w2k5h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nL=Z("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dte=Z("RouteOff",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5c.4 0 .9-.1 1.3-.2",key:"1effex"}],["path",{d:"M5.2 5.2A3.5 3.53 0 0 0 6.5 12H12",key:"k9y2ds"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M21 15.3a3.5 3.5 0 0 0-3.3-3.3",key:"11nlu2"}],["path",{d:"M15 5h-4.3",key:"6537je"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ute=Z("Route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hte=Z("Router",[["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6.01 18H6",key:"19vcac"}],["path",{d:"M10.01 18H10",key:"uamcmx"}],["path",{d:"M15 10v4",key:"qjz1xs"}],["path",{d:"M17.84 7.17a4 4 0 0 0-5.66 0",key:"1rif40"}],["path",{d:"M20.66 4.34a8 8 0 0 0-11.31 0",key:"6a5xfq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tk=Z("Rows2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ak=Z("Rows3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mte=Z("Rows4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 7.5H3",key:"1hm9pq"}],["path",{d:"M21 12H3",key:"2avoz0"}],["path",{d:"M21 16.5H3",key:"n7jzkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pte=Z("Rss",[["path",{d:"M4 11a9 9 0 0 1 9 9",key:"pv89mb"}],["path",{d:"M4 4a16 16 0 0 1 16 16",key:"k0647b"}],["circle",{cx:"5",cy:"19",r:"1",key:"bfqh0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aL=Z("Ruler",[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fte=Z("RussianRuble",[["path",{d:"M6 11h8a4 4 0 0 0 0-8H9v18",key:"18ai8t"}],["path",{d:"M6 15h8",key:"1y8f6l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gte=Z("Sailboat",[["path",{d:"M22 18H2a4 4 0 0 0 4 4h12a4 4 0 0 0 4-4Z",key:"1404fh"}],["path",{d:"M21 14 10 2 3 14h18Z",key:"1nzg7v"}],["path",{d:"M10 2v16",key:"1labyt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xte=Z("Salad",[["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 21a9 9 0 0 0 9-9H3a9 9 0 0 0 9 9Z",key:"4rw317"}],["path",{d:"M11.38 12a2.4 2.4 0 0 1-.4-4.77 2.4 2.4 0 0 1 3.2-2.77 2.4 2.4 0 0 1 3.47-.63 2.4 2.4 0 0 1 3.37 3.37 2.4 2.4 0 0 1-1.1 3.7 2.51 2.51 0 0 1 .03 1.1",key:"10xrj0"}],["path",{d:"m13 12 4-4",key:"1hckqy"}],["path",{d:"M10.9 7.25A3.99 3.99 0 0 0 4 10c0 .73.2 1.41.54 2",key:"1p4srx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yte=Z("Sandwich",[["path",{d:"m2.37 11.223 8.372-6.777a2 2 0 0 1 2.516 0l8.371 6.777",key:"f1wd0e"}],["path",{d:"M21 15a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-5.25",key:"1pfu07"}],["path",{d:"M3 15a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h9",key:"1oq9qw"}],["path",{d:"m6.67 15 6.13 4.6a2 2 0 0 0 2.8-.4l3.15-4.2",key:"1fnwu5"}],["rect",{width:"20",height:"4",x:"2",y:"11",rx:"1",key:"itshg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vte=Z("SatelliteDish",[["path",{d:"M4 10a7.31 7.31 0 0 0 10 10Z",key:"1fzpp3"}],["path",{d:"m9 15 3-3",key:"88sc13"}],["path",{d:"M17 13a6 6 0 0 0-6-6",key:"15cc6u"}],["path",{d:"M21 13A10 10 0 0 0 11 3",key:"11nf8s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _te=Z("Satellite",[["path",{d:"M13 7 9 3 5 7l4 4",key:"vyckw6"}],["path",{d:"m17 11 4 4-4 4-4-4",key:"rchckc"}],["path",{d:"m8 12 4 4 6-6-4-4Z",key:"1sshf7"}],["path",{d:"m16 8 3-3",key:"x428zp"}],["path",{d:"M9 21a6 6 0 0 0-6-6",key:"1iajcf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bte=Z("SaveAll",[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wte=Z("SaveOff",[["path",{d:"M13 13H8a1 1 0 0 0-1 1v7",key:"h8g396"}],["path",{d:"M14 8h1",key:"1lfen6"}],["path",{d:"M17 21v-4",key:"1yknxs"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M20.41 20.41A2 2 0 0 1 19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 .59-1.41",key:"1t4vdl"}],["path",{d:"M29.5 11.5s5 5 4 5",key:"zzn4i6"}],["path",{d:"M9 3h6.2a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V15",key:"24cby9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wu=Z("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ek=Z("Scale3d",[["path",{d:"M5 7v11a1 1 0 0 0 1 1h11",key:"13dt1j"}],["path",{d:"M5.293 18.707 11 13",key:"ezgbsx"}],["circle",{cx:"19",cy:"19",r:"2",key:"17f5cg"}],["circle",{cx:"5",cy:"5",r:"2",key:"1gwv83"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iL=Z("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jte=Z("Scaling",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M14 15H9v-5",key:"pi4jk9"}],["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M21 3 9 15",key:"15kdhq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kte=Z("ScanBarcode",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 7v10",key:"23sfjj"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M17 7v10",key:"578dap"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nte=Z("ScanEye",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ste=Z("ScanFace",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 9h.01",key:"x1ddxp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cte=Z("ScanLine",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mte=Z("ScanQrCode",[["path",{d:"M17 12v4a1 1 0 0 1-1 1h-4",key:"uk4fdo"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M17 8V7",key:"q2g9wo"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M7 17h.01",key:"19xn7k"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{x:"7",y:"7",width:"5",height:"5",rx:"1",key:"m9kyts"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tte=Z("ScanSearch",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ate=Z("ScanText",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 8h8",key:"1jbsf9"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h6",key:"1vyc9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ete=Z("Scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pte=Z("School",[["path",{d:"M14 22v-4a2 2 0 1 0-4 0v4",key:"hhkicm"}],["path",{d:"m18 10 3.447 1.724a1 1 0 0 1 .553.894V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-7.382a1 1 0 0 1 .553-.894L6 10",key:"1xqip1"}],["path",{d:"M18 5v17",key:"1sw6gf"}],["path",{d:"m4 6 7.106-3.553a2 2 0 0 1 1.788 0L20 6",key:"9d2mlk"}],["path",{d:"M6 5v17",key:"1xfsm0"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ite=Z("ScissorsLineDashed",[["path",{d:"M5.42 9.42 8 12",key:"12pkuq"}],["circle",{cx:"4",cy:"8",r:"2",key:"107mxr"}],["path",{d:"m14 6-8.58 8.58",key:"gvzu5l"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"M10.8 14.8 14 18",key:"ax7m9r"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lte=Z("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dte=Z("ScreenShareOff",[["path",{d:"M13 3H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-3",key:"i8wdob"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ote=Z("ScreenShare",[["path",{d:"M13 3H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-3",key:"i8wdob"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"m17 8 5-5",key:"fqif7o"}],["path",{d:"M17 3h5v5",key:"1o3tu8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rte=Z("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fte=Z("Scroll",[["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zte=Z("SearchCheck",[["path",{d:"m8 11 2 2 4-4",key:"1sed1v"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bte=Z("SearchCode",[["path",{d:"m13 13.5 2-2.5-2-2.5",key:"1rvxrh"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}],["path",{d:"M9 8.5 7 11l2 2.5",key:"6ffwbx"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $te=Z("SearchSlash",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oL=Z("SearchX",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xn=Z("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qte=Z("Section",[["path",{d:"M16 5a4 3 0 0 0-8 0c0 4 8 3 8 7a4 3 0 0 1-8 0",key:"vqan6v"}],["path",{d:"M8 19a4 3 0 0 0 8 0c0-4-8-3-8-7a4 3 0 0 1 8 0",key:"wdjd8o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pk=Z("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ute=Z("SendToBack",[["rect",{x:"14",y:"14",width:"8",height:"8",rx:"2",key:"1b0bso"}],["rect",{x:"2",y:"2",width:"8",height:"8",rx:"2",key:"1x09vl"}],["path",{d:"M7 14v1a2 2 0 0 0 2 2h1",key:"pao6x6"}],["path",{d:"M14 7h1a2 2 0 0 1 2 2v1",key:"19tdru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oa=Z("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vte=Z("SeparatorHorizontal",[["line",{x1:"3",x2:"21",y1:"12",y2:"12",key:"10d38w"}],["polyline",{points:"8 8 12 4 16 8",key:"zo8t4w"}],["polyline",{points:"16 16 12 20 8 16",key:"1oyrid"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hte=Z("SeparatorVertical",[["line",{x1:"12",x2:"12",y1:"3",y2:"21",key:"1efggb"}],["polyline",{points:"8 8 4 12 8 16",key:"bnfmv4"}],["polyline",{points:"16 16 20 12 16 8",key:"u90052"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wte=Z("ServerCog",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m15.7 13.4-.9-.3",key:"1jwmzr"}],["path",{d:"m9.2 10.9-.9-.3",key:"qapnim"}],["path",{d:"m10.6 15.7.3-.9",key:"quwk0k"}],["path",{d:"m13.6 15.7-.4-1",key:"cb9xp7"}],["path",{d:"m10.8 9.3-.4-1",key:"1uaiz5"}],["path",{d:"m8.3 13.6 1-.4",key:"s6srou"}],["path",{d:"m14.7 10.8 1-.4",key:"4d31cq"}],["path",{d:"m13.4 8.3-.3.9",key:"1bm987"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gte=Z("ServerCrash",[["path",{d:"M6 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-2",key:"4b9dqc"}],["path",{d:"M6 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-2",key:"22nnkd"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m13 6-4 6h6l-4 6",key:"14hqih"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kte=Z("ServerOff",[["path",{d:"M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5",key:"bt2siv"}],["path",{d:"M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z",key:"1hjrv1"}],["path",{d:"M22 17v-1a2 2 0 0 0-2-2h-1",key:"1iynyr"}],["path",{d:"M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z",key:"161ggg"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zte=Z("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lL=Z("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jl=Z("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yte=Z("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ad=Z("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cL=Z("Share",[["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["polyline",{points:"16 6 12 2 8 6",key:"m901s6"}],["line",{x1:"12",x2:"12",y1:"2",y2:"15",key:"1p0rca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xte=Z("Sheet",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qte=Z("Shell",[["path",{d:"M14 11a2 2 0 1 1-4 0 4 4 0 0 1 8 0 6 6 0 0 1-12 0 8 8 0 0 1 16 0 10 10 0 1 1-20 0 11.93 11.93 0 0 1 2.42-7.22 2 2 0 1 1 3.16 2.44",key:"1cn552"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jte=Z("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ese=Z("ShieldBan",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m4.243 5.21 14.39 12.472",key:"1c9a7c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dL=Z("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tse=Z("ShieldEllipsis",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sse=Z("ShieldHalf",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 22V2",key:"zs6s6o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rse=Z("ShieldMinus",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9 12h6",key:"1c52cq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nse=Z("ShieldOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ase=Z("ShieldPlus",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M12 9v6",key:"199k2o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ise=Z("ShieldQuestion",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ik=Z("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bh=Z("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ose=Z("ShipWheel",[["circle",{cx:"12",cy:"12",r:"8",key:"46899m"}],["path",{d:"M12 2v7.5",key:"1e5rl5"}],["path",{d:"m19 5-5.23 5.23",key:"1ezxxf"}],["path",{d:"M22 12h-7.5",key:"le1719"}],["path",{d:"m19 19-5.23-5.23",key:"p3fmgn"}],["path",{d:"M12 14.5V22",key:"dgcmos"}],["path",{d:"M10.23 13.77 5 19",key:"qwopd4"}],["path",{d:"M9.5 12H2",key:"r7bup8"}],["path",{d:"M10.23 10.23 5 5",key:"k2y7lj"}],["circle",{cx:"12",cy:"12",r:"2.5",key:"ix0uyj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lse=Z("Ship",[["path",{d:"M12 10.189V14",key:"1p8cqu"}],["path",{d:"M12 2v3",key:"qbqxhf"}],["path",{d:"M19 13V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6",key:"qpkstq"}],["path",{d:"M19.38 20A11.6 11.6 0 0 0 21 14l-8.188-3.639a2 2 0 0 0-1.624 0L3 14a11.6 11.6 0 0 0 2.81 7.76",key:"7tigtc"}],["path",{d:"M2 21c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1s1.2 1 2.5 1c2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"1924j5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cse=Z("Shirt",[["path",{d:"M20.38 3.46 16 2a4 4 0 0 1-8 0L3.62 3.46a2 2 0 0 0-1.34 2.23l.58 3.47a1 1 0 0 0 .99.84H6v10c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V10h2.15a1 1 0 0 0 .99-.84l.58-3.47a2 2 0 0 0-1.34-2.23z",key:"1wgbhj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const l0=Z("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dse=Z("ShoppingBasket",[["path",{d:"m15 11-1 9",key:"5wnq3a"}],["path",{d:"m19 11-4-7",key:"cnml18"}],["path",{d:"M2 11h20",key:"3eubbj"}],["path",{d:"m3.5 11 1.6 7.4a2 2 0 0 0 2 1.6h9.8a2 2 0 0 0 2-1.6l1.7-7.4",key:"yiazzp"}],["path",{d:"M4.5 15.5h15",key:"13mye1"}],["path",{d:"m5 11 4-7",key:"116ra9"}],["path",{d:"m9 11 1 9",key:"1ojof7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dp=Z("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const use=Z("Shovel",[["path",{d:"M2 22v-5l5-5 5 5-5 5z",key:"1fh25c"}],["path",{d:"M9.5 14.5 16 8",key:"1smz5x"}],["path",{d:"m17 2 5 5-.5.5a3.53 3.53 0 0 1-5 0s0 0 0 0a3.53 3.53 0 0 1 0-5L17 2",key:"1q8uv5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hse=Z("ShowerHead",[["path",{d:"m4 4 2.5 2.5",key:"uv2vmf"}],["path",{d:"M13.5 6.5a4.95 4.95 0 0 0-7 7",key:"frdkwv"}],["path",{d:"M15 5 5 15",key:"1ag8rq"}],["path",{d:"M14 17v.01",key:"eokfpp"}],["path",{d:"M10 16v.01",key:"14uyyl"}],["path",{d:"M13 13v.01",key:"1v1k97"}],["path",{d:"M16 10v.01",key:"5169yg"}],["path",{d:"M11 20v.01",key:"cj92p8"}],["path",{d:"M17 14v.01",key:"11cswd"}],["path",{d:"M20 11v.01",key:"19e0od"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mse=Z("Shrink",[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pse=Z("Shrub",[["path",{d:"M12 22v-7l-2-2",key:"eqv9mc"}],["path",{d:"M17 8v.8A6 6 0 0 1 13.8 20H10A6.5 6.5 0 0 1 7 8a5 5 0 0 1 10 0Z",key:"ubcgy"}],["path",{d:"m14 14-2 2",key:"847xa2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G4=Z("Shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fse=Z("Sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gse=Z("SignalHigh",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xse=Z("SignalLow",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yse=Z("SignalMedium",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vse=Z("SignalZero",[["path",{d:"M2 20h.01",key:"4haj6o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _se=Z("Signal",[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bse=Z("Signature",[["path",{d:"m21 17-2.156-1.868A.5.5 0 0 0 18 15.5v.5a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1c0-2.545-3.991-3.97-8.5-4a1 1 0 0 0 0 5c4.153 0 4.745-11.295 5.708-13.5a2.5 2.5 0 1 1 3.31 3.284",key:"y32ogt"}],["path",{d:"M3 21h18",key:"itz85i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wse=Z("SignpostBig",[["path",{d:"M10 9H4L2 7l2-2h6",key:"1hq7x2"}],["path",{d:"M14 5h6l2 2-2 2h-6",key:"bv62ej"}],["path",{d:"M10 22V4a2 2 0 1 1 4 0v18",key:"eqpcf2"}],["path",{d:"M8 22h8",key:"rmew8v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jse=Z("Signpost",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M12 3v3",key:"1n5kay"}],["path",{d:"M18 6a2 2 0 0 1 1.387.56l2.307 2.22a1 1 0 0 1 0 1.44l-2.307 2.22A2 2 0 0 1 18 13H6a2 2 0 0 1-1.387-.56l-2.306-2.22a1 1 0 0 1 0-1.44l2.306-2.22A2 2 0 0 1 6 6z",key:"gqqp9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kse=Z("Siren",[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nse=Z("SkipBack",[["polygon",{points:"19 20 9 12 19 4 19 20",key:"o2sva"}],["line",{x1:"5",x2:"5",y1:"19",y2:"5",key:"1ocqjk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sse=Z("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cse=Z("Skull",[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mse=Z("Slack",[["rect",{width:"3",height:"8",x:"13",y:"2",rx:"1.5",key:"diqz80"}],["path",{d:"M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5",key:"183iwg"}],["rect",{width:"3",height:"8",x:"8",y:"14",rx:"1.5",key:"hqg7r1"}],["path",{d:"M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5",key:"76g71w"}],["rect",{width:"8",height:"3",x:"14",y:"13",rx:"1.5",key:"1kmz0a"}],["path",{d:"M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5",key:"jc4sz0"}],["rect",{width:"8",height:"3",x:"2",y:"8",rx:"1.5",key:"1omvl4"}],["path",{d:"M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5",key:"16f3cl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tse=Z("Slash",[["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ase=Z("Slice",[["path",{d:"M11 16.586V19a1 1 0 0 1-1 1H2L18.37 3.63a1 1 0 1 1 3 3l-9.663 9.663a1 1 0 0 1-1.414 0L8 14",key:"1sllp5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uL=Z("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lk=Z("SlidersVertical",[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ese=Z("SmartphoneCharging",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12.667 8 10 12h4l-2.667 4",key:"h9lk2d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pse=Z("SmartphoneNfc",[["rect",{width:"7",height:"12",x:"2",y:"6",rx:"1",key:"5nje8w"}],["path",{d:"M13 8.32a7.43 7.43 0 0 1 0 7.36",key:"1g306n"}],["path",{d:"M16.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"uqvjvo"}],["path",{d:"M19.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"ujntz3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const i1=Z("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ise=Z("SmilePlus",[["path",{d:"M22 11v1a10 10 0 1 1-9-10",key:"ew0xw9"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}],["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lse=Z("Smile",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dse=Z("Snail",[["path",{d:"M2 13a6 6 0 1 0 12 0 4 4 0 1 0-8 0 2 2 0 0 0 4 0",key:"hneq2s"}],["circle",{cx:"10",cy:"13",r:"8",key:"194lz3"}],["path",{d:"M2 21h12c4.4 0 8-3.6 8-8V7a2 2 0 1 0-4 0v6",key:"ixqyt7"}],["path",{d:"M18 3 19.1 5.2",key:"9tjm43"}],["path",{d:"M22 3 20.9 5.2",key:"j3odrs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hb=Z("Snowflake",[["line",{x1:"2",x2:"22",y1:"12",y2:"12",key:"1dnqot"}],["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"m20 16-4-4 4-4",key:"rquw4f"}],["path",{d:"m4 8 4 4-4 4",key:"12s3z9"}],["path",{d:"m16 4-4 4-4-4",key:"1tumq1"}],["path",{d:"m8 20 4-4 4 4",key:"9p200w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ose=Z("Sofa",[["path",{d:"M20 9V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v3",key:"1dgpiv"}],["path",{d:"M2 16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v1.5a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5V11a2 2 0 0 0-4 0z",key:"xacw8m"}],["path",{d:"M4 18v2",key:"jwo5n2"}],["path",{d:"M20 18v2",key:"1ar1qi"}],["path",{d:"M12 4v9",key:"oqhhn3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rse=Z("Soup",[["path",{d:"M12 21a9 9 0 0 0 9-9H3a9 9 0 0 0 9 9Z",key:"4rw317"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M19.5 12 22 6",key:"shfsr5"}],["path",{d:"M16.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.73 1.62",key:"rpc6vp"}],["path",{d:"M11.25 3c.27.1.8.53.74 1.36-.05.83-.93 1.2-.98 2.02-.06.78.33 1.24.72 1.62",key:"1lf63m"}],["path",{d:"M6.25 3c.27.1.8.53.75 1.36-.06.83-.93 1.2-1 2.02-.05.78.34 1.24.74 1.62",key:"97tijn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fse=Z("Space",[["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zse=Z("Spade",[["path",{d:"M5 9c-1.5 1.5-3 3.2-3 5.5A5.5 5.5 0 0 0 7.5 20c1.8 0 3-.5 4.5-2 1.5 1.5 2.7 2 4.5 2a5.5 5.5 0 0 0 5.5-5.5c0-2.3-1.5-4-3-5.5l-7-7-7 7Z",key:"40bo9n"}],["path",{d:"M12 18v4",key:"jadmvz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bse=Z("Sparkle",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hn=Z("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $se=Z("Speaker",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["circle",{cx:"12",cy:"14",r:"4",key:"1jruaj"}],["path",{d:"M12 14h.01",key:"1etili"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qse=Z("Speech",[["path",{d:"M8.8 20v-4.1l1.9.2a2.3 2.3 0 0 0 2.164-2.1V8.3A5.37 5.37 0 0 0 2 8.25c0 2.8.656 3.054 1 4.55a5.77 5.77 0 0 1 .029 2.758L2 20",key:"11atix"}],["path",{d:"M19.8 17.8a7.5 7.5 0 0 0 .003-10.603",key:"yol142"}],["path",{d:"M17 15a3.5 3.5 0 0 0-.025-4.975",key:"ssbmkc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Use=Z("SpellCheck2",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M4 21c1.1 0 1.1-1 2.3-1s1.1 1 2.3 1c1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1",key:"8mdmtu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vse=Z("SpellCheck",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hse=Z("Spline",[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wse=Z("Split",[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gse=Z("SprayCan",[["path",{d:"M3 3h.01",key:"159qn6"}],["path",{d:"M7 5h.01",key:"1hq22a"}],["path",{d:"M11 7h.01",key:"1osv80"}],["path",{d:"M3 7h.01",key:"1xzrh3"}],["path",{d:"M7 9h.01",key:"19b3jx"}],["path",{d:"M3 11h.01",key:"1eifu7"}],["rect",{width:"4",height:"4",x:"15",y:"5",key:"mri9e4"}],["path",{d:"m19 9 2 2v10c0 .6-.4 1-1 1h-6c-.6 0-1-.4-1-1V11l2-2",key:"aib6hk"}],["path",{d:"m13 14 8-2",key:"1d7bmk"}],["path",{d:"m13 19 8-2",key:"1y2vml"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kse=Z("Sprout",[["path",{d:"M7 20h10",key:"e6iznv"}],["path",{d:"M10 20c5.5-2.5.8-6.4 3-10",key:"161w41"}],["path",{d:"M9.5 9.4c1.1.8 1.8 2.2 2.3 3.7-2 .4-3.5.4-4.8-.3-1.2-.6-2.3-1.9-3-4.2 2.8-.5 4.4 0 5.5.8z",key:"9gtqwd"}],["path",{d:"M14.1 6a7 7 0 0 0-1.1 4c1.9-.1 3.3-.6 4.3-1.4 1-1 1.6-2.3 1.7-4.6-2.7.1-4 1-4.9 2z",key:"bkxnd2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dk=Z("SquareActivity",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M17 12h-2l-2 5-2-10-2 5H7",key:"15hlnc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ok=Z("SquareArrowDownLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 8-8 8",key:"166keh"}],["path",{d:"M16 16H8V8",key:"1w2ppm"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rk=Z("SquareArrowDownRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"M16 8v8H8",key:"1lbpgo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fk=Z("SquareArrowDown",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zk=Z("SquareArrowLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m12 8-4 4 4 4",key:"15vm53"}],["path",{d:"M16 12H8",key:"1fr5h0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bk=Z("SquareArrowOutDownLeft",[["path",{d:"M13 21h6a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v6",key:"14qz4y"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $k=Z("SquareArrowOutDownRight",[["path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"14rsvq"}],["path",{d:"m21 21-9-9",key:"1et2py"}],["path",{d:"M21 15v6h-6",key:"1jko0i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qk=Z("SquareArrowOutUpLeft",[["path",{d:"M13 3h6a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-6",key:"14mv1t"}],["path",{d:"m3 3 9 9",key:"rks13r"}],["path",{d:"M3 9V3h6",key:"ira0h2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uk=Z("SquareArrowOutUpRight",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vk=Z("SquareArrowRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hk=Z("SquareArrowUpLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8h8",key:"19xb1h"}],["path",{d:"M16 16 8 8",key:"1qdy8n"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wk=Z("SquareArrowUpRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 8h8v8",key:"b65dnt"}],["path",{d:"m8 16 8-8",key:"13b9ih"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gk=Z("SquareArrowUp",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kk=Z("SquareAsterisk",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8.5 14 7-4",key:"12hpby"}],["path",{d:"m8.5 10 7 4",key:"wwy2dy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zk=Z("SquareBottomDashedScissors",[["path",{d:"M4 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2",key:"1vzg26"}],["path",{d:"M10 22H8",key:"euku7a"}],["path",{d:"M16 22h-2",key:"18d249"}],["circle",{cx:"8",cy:"8",r:"2",key:"14cg06"}],["path",{d:"M9.414 9.414 12 12",key:"qz4lzr"}],["path",{d:"M14.8 14.8 18 18",key:"11flf1"}],["circle",{cx:"8",cy:"16",r:"2",key:"1acxsx"}],["path",{d:"m18 6-8.586 8.586",key:"11kzk1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oy=Z("SquareChartGantt",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 8h7",key:"kbo1nt"}],["path",{d:"M8 12h6",key:"ikassy"}],["path",{d:"M11 16h5",key:"oq65wt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pv=Z("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yk=Z("SquareCheck",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xk=Z("SquareChevronDown",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qk=Z("SquareChevronLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m14 16-4-4 4-4",key:"ojs7w8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jk=Z("SquareChevronRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eN=Z("SquareChevronUp",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m8 14 4-4 4 4",key:"fy2ptz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tN=Z("SquareCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zse=Z("SquareDashedBottomCode",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yse=Z("SquareDashedBottom",[["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 21h1",key:"v9vybs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sN=Z("SquareDashedKanban",[["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M21 14v1",key:"169vum"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M3 9v1",key:"1r0deq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rN=Z("SquareDashedMousePointer",[["path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z",key:"xwnzip"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h2",key:"1qve2z"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v2",key:"p14lih"}],["path",{d:"M3 14v1",key:"vnatye"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nN=Z("SquareDashed",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aN=Z("SquareDivide",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}],["line",{x1:"12",x2:"12",y1:"16",y2:"16",key:"aqc6ln"}],["line",{x1:"12",x2:"12",y1:"8",y2:"8",key:"1mkcni"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iN=Z("SquareDot",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oN=Z("SquareEqual",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lN=Z("SquareFunction",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3",key:"m1af9g"}],["path",{d:"M9 11.2h5.7",key:"3zgcl2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cN=Z("SquareKanban",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dN=Z("SquareLibrary",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7v10",key:"d5nglc"}],["path",{d:"M11 7v10",key:"pptsnr"}],["path",{d:"m15 7 2 10",key:"1m7qm5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uN=Z("SquareM",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8l4 4 4-4v8",key:"141u4e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hN=Z("SquareMenu",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 8h10",key:"1jw688"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mN=Z("SquareMinus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pN=Z("SquareMousePointer",[["path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z",key:"xwnzip"}],["path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"14rsvq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fN=Z("SquareParkingOff",[["path",{d:"M3.6 3.6A2 2 0 0 1 5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-.59 1.41",key:"9l1ft6"}],["path",{d:"M3 8.7V19a2 2 0 0 0 2 2h10.3",key:"17knke"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M13 13a3 3 0 1 0 0-6H9v2",key:"uoagbd"}],["path",{d:"M9 17v-2.3",key:"1jxgo2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gN=Z("SquareParking",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 17V7h4a3 3 0 0 1 0 6H9",key:"1dfk2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rd=Z("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xN=Z("SquarePercent",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yN=Z("SquarePi",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 7h10",key:"udp07y"}],["path",{d:"M10 7v10",key:"i1d9ee"}],["path",{d:"M16 17a2 2 0 0 1-2-2V7",key:"ftwdc7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vN=Z("SquarePilcrow",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 12H9.5a2.5 2.5 0 0 1 0-5H17",key:"1l9586"}],["path",{d:"M12 7v10",key:"jspqdw"}],["path",{d:"M16 7v10",key:"lavkr4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _N=Z("SquarePlay",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 8 6 4-6 4Z",key:"f1r3lt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bN=Z("SquarePlus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wN=Z("SquarePower",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xse=Z("SquareRadical",[["path",{d:"M7 12h2l2 5 2-10h4",key:"1fxv6h"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jN=Z("SquareScissors",[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"2",key:"1btzen"}],["circle",{cx:"8",cy:"8",r:"2",key:"14cg06"}],["path",{d:"M9.414 9.414 12 12",key:"qz4lzr"}],["path",{d:"M14.8 14.8 18 18",key:"11flf1"}],["circle",{cx:"8",cy:"16",r:"2",key:"1acxsx"}],["path",{d:"m18 6-8.586 8.586",key:"11kzk1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kN=Z("SquareSigma",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M16 8.9V7H8l4 5-4 5h8v-1.9",key:"9nih0i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NN=Z("SquareSlash",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SN=Z("SquareSplitHorizontal",[["path",{d:"M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3",key:"lubmu8"}],["path",{d:"M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3",key:"1ag34g"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CN=Z("SquareSplitVertical",[["path",{d:"M5 8V5c0-1 1-2 2-2h10c1 0 2 1 2 2v3",key:"1pi83i"}],["path",{d:"M19 16v3c0 1-1 2-2 2H7c-1 0-2-1-2-2v-3",key:"ido5k7"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qse=Z("SquareSquare",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jse=Z("SquareStack",[["path",{d:"M4 10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"4i38lg"}],["path",{d:"M10 16c-1.1 0-2-.9-2-2v-4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"mlte4a"}],["rect",{width:"8",height:"8",x:"14",y:"14",rx:"2",key:"1fa9i4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const MN=Z("SquareTerminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const TN=Z("SquareUserRound",[["path",{d:"M18 21a6 6 0 0 0-12 0",key:"kaz2du"}],["circle",{cx:"12",cy:"11",r:"4",key:"1gt34v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const AN=Z("SquareUser",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 21v-2a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2",key:"1m6ac2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const EN=Z("SquareX",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c0=Z("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ere=Z("Squircle",[["path",{d:"M12 3c7.2 0 9 1.8 9 9s-1.8 9-9 9-9-1.8-9-9 1.8-9 9-9",key:"garfkc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tre=Z("Squirrel",[["path",{d:"M15.236 22a3 3 0 0 0-2.2-5",key:"21bitc"}],["path",{d:"M16 20a3 3 0 0 1 3-3h1a2 2 0 0 0 2-2v-2a4 4 0 0 0-4-4V4",key:"oh0fg0"}],["path",{d:"M18 13h.01",key:"9veqaj"}],["path",{d:"M18 6a4 4 0 0 0-4 4 7 7 0 0 0-7 7c0-5 4-5 4-10.5a4.5 4.5 0 1 0-9 0 2.5 2.5 0 0 0 5 0C7 10 3 11 3 17c0 2.8 2.2 5 5 5h10",key:"980v8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sre=Z("Stamp",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M19.27 13.73A2.5 2.5 0 0 0 17.5 13h-11A2.5 2.5 0 0 0 4 15.5V17a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-1.5c0-.66-.26-1.3-.73-1.77Z",key:"1sy9ra"}],["path",{d:"M14 13V8.5C14 7 15 7 15 5a3 3 0 0 0-3-3c-1.66 0-3 1-3 3s1 2 1 3.5V13",key:"cnxgux"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rre=Z("StarHalf",[["path",{d:"M12 18.338a2.1 2.1 0 0 0-.987.244L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.12 2.12 0 0 0 1.597-1.16l2.309-4.679A.53.53 0 0 1 12 2",key:"2ksp49"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nre=Z("StarOff",[["path",{d:"M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43",key:"16m0ql"}],["path",{d:"M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91",key:"1vt8nq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kn=Z("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const are=Z("StepBack",[["line",{x1:"18",x2:"18",y1:"20",y2:"4",key:"cun8e5"}],["polygon",{points:"14,20 4,12 14,4",key:"ypakod"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ire=Z("StepForward",[["line",{x1:"6",x2:"6",y1:"4",y2:"20",key:"fy8qot"}],["polygon",{points:"10,4 20,12 10,20",key:"1mc1pf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ore=Z("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lre=Z("Sticker",[["path",{d:"M15.5 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2V8.5L15.5 3Z",key:"1wis1t"}],["path",{d:"M14 3v4a2 2 0 0 0 2 2h4",key:"36rjfy"}],["path",{d:"M8 13h.01",key:"1sbv64"}],["path",{d:"M16 13h.01",key:"wip0gl"}],["path",{d:"M10 16s.8 1 2 1c1.3 0 2-1 2-1",key:"1vvgv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cre=Z("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dre=Z("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ure=Z("StretchHorizontal",[["rect",{width:"20",height:"6",x:"2",y:"4",rx:"2",key:"qdearl"}],["rect",{width:"20",height:"6",x:"2",y:"14",rx:"2",key:"1xrn6j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hre=Z("StretchVertical",[["rect",{width:"6",height:"20",x:"4",y:"2",rx:"2",key:"19qu7m"}],["rect",{width:"6",height:"20",x:"14",y:"2",rx:"2",key:"24v0nk"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mre=Z("Strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pre=Z("Subscript",[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fre=Z("SunDim",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 4h.01",key:"1ujb9j"}],["path",{d:"M20 12h.01",key:"1ykeid"}],["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M4 12h.01",key:"158zrr"}],["path",{d:"M17.657 6.343h.01",key:"31pqzk"}],["path",{d:"M17.657 17.657h.01",key:"jehnf4"}],["path",{d:"M6.343 17.657h.01",key:"gdk6ow"}],["path",{d:"M6.343 6.343h.01",key:"1uurf0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gre=Z("SunMedium",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 3v1",key:"1asbbs"}],["path",{d:"M12 20v1",key:"1wcdkc"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M20 12h1",key:"1vloll"}],["path",{d:"m18.364 5.636-.707.707",key:"1hakh0"}],["path",{d:"m6.343 17.657-.707.707",key:"18m9nf"}],["path",{d:"m5.636 5.636.707.707",key:"1xv1c5"}],["path",{d:"m17.657 17.657.707.707",key:"vl76zb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xre=Z("SunMoon",[["path",{d:"M12 8a2.83 2.83 0 0 0 4 4 4 4 0 1 1-4-4",key:"1fu5g2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.9 4.9 1.4 1.4",key:"b9915j"}],["path",{d:"m17.7 17.7 1.4 1.4",key:"qc3ed3"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.3 17.7-1.4 1.4",key:"5gca6"}],["path",{d:"m19.1 4.9-1.4 1.4",key:"wpu9u6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yre=Z("SunSnow",[["path",{d:"M10 9a3 3 0 1 0 0 6",key:"6zmtdl"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M14 21V3",key:"1llu3z"}],["path",{d:"M10 4V3",key:"pkzwkn"}],["path",{d:"M10 21v-1",key:"1u8rkd"}],["path",{d:"m3.64 18.36.7-.7",key:"105rm9"}],["path",{d:"m4.34 6.34-.7-.7",key:"d3unjp"}],["path",{d:"M14 12h8",key:"4f43i9"}],["path",{d:"m17 4-3 3",key:"15jcng"}],["path",{d:"m14 17 3 3",key:"6tlq38"}],["path",{d:"m21 15-3-3 3-3",key:"1nlnje"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rb=Z("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vre=Z("Sunrise",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _re=Z("Sunset",[["path",{d:"M12 10V2",key:"16sf7g"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bre=Z("Superscript",[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wre=Z("SwatchBook",[["path",{d:"M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z",key:"1ldrpk"}],["path",{d:"M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7",key:"11i5po"}],["path",{d:"M 7 17h.01",key:"1euzgo"}],["path",{d:"m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8",key:"o2gii7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jre=Z("SwissFranc",[["path",{d:"M10 21V3h8",key:"br2l0g"}],["path",{d:"M6 16h9",key:"2py0wn"}],["path",{d:"M10 9.5h7",key:"13dmhz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kre=Z("SwitchCamera",[["path",{d:"M11 19H4a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5",key:"mtk2lu"}],["path",{d:"M13 5h7a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-5",key:"120jsl"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m18 22-3-3 3-3",key:"kgdoj7"}],["path",{d:"m6 2 3 3-3 3",key:"1fnbkv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nre=Z("Sword",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sre=Z("Swords",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cre=Z("Syringe",[["path",{d:"m18 2 4 4",key:"22kx64"}],["path",{d:"m17 7 3-3",key:"1w1zoj"}],["path",{d:"M19 9 8.7 19.3c-1 1-2.5 1-3.4 0l-.6-.6c-1-1-1-2.5 0-3.4L15 5",key:"1exhtz"}],["path",{d:"m9 11 4 4",key:"rovt3i"}],["path",{d:"m5 19-3 3",key:"59f2uf"}],["path",{d:"m14 4 6 6",key:"yqp9t2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jM=Z("Table2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mre=Z("TableCellsMerge",[["path",{d:"M12 21v-6",key:"lihzve"}],["path",{d:"M12 9V3",key:"da5inc"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tre=Z("TableCellsSplit",[["path",{d:"M12 15V9",key:"8c7uyn"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M3 9h18",key:"1pudct"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Are=Z("TableColumnsSplit",[["path",{d:"M14 14v2",key:"w2a1xv"}],["path",{d:"M14 20v2",key:"1lq872"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M14 8v2",key:"i67w9a"}],["path",{d:"M2 15h8",key:"82wtch"}],["path",{d:"M2 3h6a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H2",key:"up0l64"}],["path",{d:"M2 9h8",key:"yelfik"}],["path",{d:"M22 15h-4",key:"1es58f"}],["path",{d:"M22 3h-2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h2",key:"pdjoqf"}],["path",{d:"M22 9h-4",key:"1luja7"}],["path",{d:"M5 3v18",key:"14hmio"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ere=Z("TableOfContents",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M21 12h.01",key:"msek7k"}],["path",{d:"M21 18h.01",key:"1e8rq1"}],["path",{d:"M21 6h.01",key:"1koanj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pre=Z("TableProperties",[["path",{d:"M15 3v18",key:"14nvp0"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ire=Z("TableRowsSplit",[["path",{d:"M14 10h2",key:"1lstlu"}],["path",{d:"M15 22v-8",key:"1fwwgm"}],["path",{d:"M15 2v4",key:"1044rn"}],["path",{d:"M2 10h2",key:"1r8dkt"}],["path",{d:"M20 10h2",key:"1ug425"}],["path",{d:"M3 19h18",key:"awlh7x"}],["path",{d:"M3 22v-6a2 2 135 0 1 2-2h14a2 2 45 0 1 2 2v6",key:"ibqhof"}],["path",{d:"M3 2v2a2 2 45 0 0 2 2h14a2 2 135 0 0 2-2V2",key:"1uenja"}],["path",{d:"M8 10h2",key:"66od0"}],["path",{d:"M9 22v-8",key:"fmnu31"}],["path",{d:"M9 2v4",key:"j1yeou"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hL=Z("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lre=Z("TabletSmartphone",[["rect",{width:"10",height:"14",x:"3",y:"8",rx:"2",key:"1vrsiq"}],["path",{d:"M5 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2h-2.4",key:"1j4zmg"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dre=Z("Tablet",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ore=Z("Tablets",[["circle",{cx:"7",cy:"7",r:"5",key:"x29byf"}],["circle",{cx:"17",cy:"17",r:"5",key:"1op1d2"}],["path",{d:"M12 17h10",key:"ls21zv"}],["path",{d:"m3.46 10.54 7.08-7.08",key:"1rehiu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tm=Z("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rre=Z("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fre=Z("Tally1",[["path",{d:"M4 4v16",key:"6qkkli"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zre=Z("Tally2",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bre=Z("Tally3",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $re=Z("Tally4",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}],["path",{d:"M19 4v16",key:"8ij5ei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qre=Z("Tally5",[["path",{d:"M4 4v16",key:"6qkkli"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"M14 4v16",key:"12vmem"}],["path",{d:"M19 4v16",key:"8ij5ei"}],["path",{d:"M22 6 2 18",key:"h9moai"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ure=Z("Tangent",[["circle",{cx:"17",cy:"4",r:"2",key:"y5j2s2"}],["path",{d:"M15.59 5.41 5.41 15.59",key:"l0vprr"}],["circle",{cx:"4",cy:"17",r:"2",key:"9p4efm"}],["path",{d:"M12 22s-4-9-1.5-11.5S22 12 22 12",key:"1twk4o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Am=Z("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vre=Z("Telescope",[["path",{d:"m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44",key:"k4qptu"}],["path",{d:"m13.56 11.747 4.332-.924",key:"19l80z"}],["path",{d:"m16 21-3.105-6.21",key:"7oh9d"}],["path",{d:"M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z",key:"m7xp4m"}],["path",{d:"m6.158 8.633 1.114 4.456",key:"74o979"}],["path",{d:"m8 21 3.105-6.21",key:"1fvxut"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hre=Z("TentTree",[["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}],["path",{d:"m14 5 3-3 3 3",key:"1sorif"}],["path",{d:"m14 10 3-3 3 3",key:"1jyi9h"}],["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M17 14H7l-5 8h20Z",key:"13ar7p"}],["path",{d:"M8 14v8",key:"1ghmqk"}],["path",{d:"m9 14 5 8",key:"13pgi6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wre=Z("Tent",[["path",{d:"M3.5 21 14 3",key:"1szst5"}],["path",{d:"M20.5 21 10 3",key:"1310c3"}],["path",{d:"M15.5 21 12 15l-3.5 6",key:"1ddtfw"}],["path",{d:"M2 21h20",key:"1nyx9w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gre=Z("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const PN=Z("TestTubeDiagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kre=Z("TestTube",[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zre=Z("TestTubes",[["path",{d:"M9 2v17.5A2.5 2.5 0 0 1 6.5 22A2.5 2.5 0 0 1 4 19.5V2",key:"1hjrqt"}],["path",{d:"M20 2v17.5a2.5 2.5 0 0 1-2.5 2.5a2.5 2.5 0 0 1-2.5-2.5V2",key:"16lc8n"}],["path",{d:"M3 2h7",key:"7s29d5"}],["path",{d:"M14 2h7",key:"7sicin"}],["path",{d:"M9 16H4",key:"1bfye3"}],["path",{d:"M20 16h-5",key:"ddnjpe"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yre=Z("TextCursorInput",[["path",{d:"M5 4h1a3 3 0 0 1 3 3 3 3 0 0 1 3-3h1",key:"18xjzo"}],["path",{d:"M13 20h-1a3 3 0 0 1-3-3 3 3 0 0 1-3 3H5",key:"fj48gi"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M9 7v10",key:"1vc8ob"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xre=Z("TextCursor",[["path",{d:"M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1",key:"uvaxm9"}],["path",{d:"M7 22h1a4 4 0 0 0 4-4v-1",key:"11xy8d"}],["path",{d:"M7 2h1a4 4 0 0 1 4 4v1",key:"1uw06m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qre=Z("TextQuote",[["path",{d:"M17 6H3",key:"16j9eg"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 18H8",key:"1wfozv"}],["path",{d:"M3 12v6",key:"fv4c87"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jre=Z("TextSearch",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const IN=Z("TextSelect",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}],["line",{x1:"7",x2:"15",y1:"8",y2:"8",key:"1758g8"}],["line",{x1:"7",x2:"17",y1:"12",y2:"12",key:"197423"}],["line",{x1:"7",x2:"13",y1:"16",y2:"16",key:"37cgm6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ene=Z("Text",[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tne=Z("Theater",[["path",{d:"M2 10s3-3 3-8",key:"3xiif0"}],["path",{d:"M22 10s-3-3-3-8",key:"ioaa5q"}],["path",{d:"M10 2c0 4.4-3.6 8-8 8",key:"16fkpi"}],["path",{d:"M14 2c0 4.4 3.6 8 8 8",key:"b9eulq"}],["path",{d:"M2 10s2 2 2 5",key:"1au1lb"}],["path",{d:"M22 10s-2 2-2 5",key:"qi2y5e"}],["path",{d:"M8 15h8",key:"45n4r"}],["path",{d:"M2 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1",key:"1vsc2m"}],["path",{d:"M14 22v-1a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v1",key:"hrha4u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sne=Z("ThermometerSnowflake",[["path",{d:"M2 12h10",key:"19562f"}],["path",{d:"M9 4v16",key:"81ygyz"}],["path",{d:"m3 9 3 3-3 3",key:"1sas0l"}],["path",{d:"M12 6 9 9 6 6",key:"pfrgxu"}],["path",{d:"m6 18 3-3 1.5 1.5",key:"1e277p"}],["path",{d:"M20 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"iof6y5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rne=Z("ThermometerSun",[["path",{d:"M12 9a4 4 0 0 0-2 7.5",key:"1jvsq6"}],["path",{d:"M12 3v2",key:"1w22ol"}],["path",{d:"m6.6 18.4-1.4 1.4",key:"w2yidj"}],["path",{d:"M20 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"iof6y5"}],["path",{d:"M4 13H2",key:"118le4"}],["path",{d:"M6.34 7.34 4.93 5.93",key:"1brd51"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nne=Z("Thermometer",[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mL=Z("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gu=Z("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ane=Z("TicketCheck",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ine=Z("TicketMinus",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M9 12h6",key:"1c52cq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const one=Z("TicketPercent",[["path",{d:"M2 9a3 3 0 1 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 1 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"1l48ns"}],["path",{d:"M9 9h.01",key:"1q5me6"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M15 15h.01",key:"lqbp3k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lne=Z("TicketPlus",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M9 12h6",key:"1c52cq"}],["path",{d:"M12 9v6",key:"199k2o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cne=Z("TicketSlash",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dne=Z("TicketX",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pL=Z("Ticket",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const une=Z("TicketsPlane",[["path",{d:"M10.5 17h1.227a2 2 0 0 0 1.345-.52L18 12",key:"16muxl"}],["path",{d:"m12 13.5 3.75.5",key:"1i9qhk"}],["path",{d:"m4.5 8 10.58-5.06a1 1 0 0 1 1.342.488L18.5 8",key:"12lg5p"}],["path",{d:"M6 10V8",key:"1y41hn"}],["path",{d:"M6 14v1",key:"cao2tf"}],["path",{d:"M6 19v2",key:"1loha6"}],["rect",{x:"2",y:"8",width:"20",height:"13",rx:"2",key:"p3bz5l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hne=Z("Tickets",[["path",{d:"m4.5 8 10.58-5.06a1 1 0 0 1 1.342.488L18.5 8",key:"12lg5p"}],["path",{d:"M6 10V8",key:"1y41hn"}],["path",{d:"M6 14v1",key:"cao2tf"}],["path",{d:"M6 19v2",key:"1loha6"}],["rect",{x:"2",y:"8",width:"20",height:"13",rx:"2",key:"p3bz5l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mne=Z("TimerOff",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7",key:"10he05"}],["path",{d:"M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2",key:"15f7sh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M12 12v-2",key:"fwoke6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pne=Z("TimerReset",[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M12 14v-4",key:"1evpnu"}],["path",{d:"M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6",key:"1ts96g"}],["path",{d:"M9 17H4v5",key:"8t5av"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fne=Z("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gne=Z("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xne=Z("ToggleRight",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yne=Z("Toilet",[["path",{d:"M7 12h13a1 1 0 0 1 1 1 5 5 0 0 1-5 5h-.598a.5.5 0 0 0-.424.765l1.544 2.47a.5.5 0 0 1-.424.765H5.402a.5.5 0 0 1-.424-.765L7 18",key:"kc4kqr"}],["path",{d:"M8 18a5 5 0 0 1-5-5V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8",key:"1tqs57"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vne=Z("Tornado",[["path",{d:"M21 4H3",key:"1hwok0"}],["path",{d:"M18 8H6",key:"41n648"}],["path",{d:"M19 12H9",key:"1g4lpz"}],["path",{d:"M16 16h-6",key:"1j5d54"}],["path",{d:"M11 20H9",key:"39obr8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ne=Z("Torus",[["ellipse",{cx:"12",cy:"11",rx:"3",ry:"2",key:"1b2qxu"}],["ellipse",{cx:"12",cy:"12.5",rx:"10",ry:"8.5",key:"h8emeu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bne=Z("TouchpadOff",[["path",{d:"M4 4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16",key:"lnt0bk"}],["path",{d:"M2 14h12",key:"d8icqz"}],["path",{d:"M22 14h-2",key:"jrx26d"}],["path",{d:"M12 20v-6",key:"1rm09r"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M22 16V6a2 2 0 0 0-2-2H10",key:"11y8e4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wne=Z("Touchpad",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M12 20v-6",key:"1rm09r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jne=Z("TowerControl",[["path",{d:"M18.2 12.27 20 6H4l1.8 6.27a1 1 0 0 0 .95.73h10.5a1 1 0 0 0 .96-.73Z",key:"1pledb"}],["path",{d:"M8 13v9",key:"hmv0ci"}],["path",{d:"M16 22v-9",key:"ylnf1u"}],["path",{d:"m9 6 1 7",key:"dpdgam"}],["path",{d:"m15 6-1 7",key:"ls7zgu"}],["path",{d:"M12 6V2",key:"1pj48d"}],["path",{d:"M13 2h-2",key:"mj6ths"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kne=Z("ToyBrick",[["rect",{width:"18",height:"12",x:"3",y:"8",rx:"1",key:"158fvp"}],["path",{d:"M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3",key:"s0042v"}],["path",{d:"M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3",key:"9wmeh2"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nne=Z("Tractor",[["path",{d:"m10 11 11 .9a1 1 0 0 1 .8 1.1l-.665 4.158a1 1 0 0 1-.988.842H20",key:"she1j9"}],["path",{d:"M16 18h-5",key:"bq60fd"}],["path",{d:"M18 5a1 1 0 0 0-1 1v5.573",key:"1kv8ia"}],["path",{d:"M3 4h8.129a1 1 0 0 1 .99.863L13 11.246",key:"1q1ert"}],["path",{d:"M4 11V4",key:"9ft8pt"}],["path",{d:"M7 15h.01",key:"k5ht0j"}],["path",{d:"M8 10.1V4",key:"1jgyzo"}],["circle",{cx:"18",cy:"18",r:"2",key:"1emm8v"}],["circle",{cx:"7",cy:"15",r:"5",key:"ddtuc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sne=Z("TrafficCone",[["path",{d:"M9.3 6.2a4.55 4.55 0 0 0 5.4 0",key:"flyxqv"}],["path",{d:"M7.9 10.7c.9.8 2.4 1.3 4.1 1.3s3.2-.5 4.1-1.3",key:"1nlxxg"}],["path",{d:"M13.9 3.5a1.93 1.93 0 0 0-3.8-.1l-3 10c-.1.2-.1.4-.1.6 0 1.7 2.2 3 5 3s5-1.3 5-3c0-.2 0-.4-.1-.5Z",key:"vz7x1l"}],["path",{d:"m7.5 12.2-4.7 2.7c-.5.3-.8.7-.8 1.1s.3.8.8 1.1l7.6 4.5c.9.5 2.1.5 3 0l7.6-4.5c.7-.3 1-.7 1-1.1s-.3-.8-.8-1.1l-4.7-2.8",key:"1xfzlw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cne=Z("TrainFrontTunnel",[["path",{d:"M2 22V12a10 10 0 1 1 20 0v10",key:"o0fyp0"}],["path",{d:"M15 6.8v1.4a3 2.8 0 1 1-6 0V6.8",key:"m8q3n9"}],["path",{d:"M10 15h.01",key:"44in9x"}],["path",{d:"M14 15h.01",key:"5mohn5"}],["path",{d:"M10 19a4 4 0 0 1-4-4v-3a6 6 0 1 1 12 0v3a4 4 0 0 1-4 4Z",key:"hckbmu"}],["path",{d:"m9 19-2 3",key:"iij7hm"}],["path",{d:"m15 19 2 3",key:"npx8sa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mne=Z("TrainFront",[["path",{d:"M8 3.1V7a4 4 0 0 0 8 0V3.1",key:"1v71zp"}],["path",{d:"m9 15-1-1",key:"1yrq24"}],["path",{d:"m15 15 1-1",key:"1t0d6s"}],["path",{d:"M9 19c-2.8 0-5-2.2-5-5v-4a8 8 0 0 1 16 0v4c0 2.8-2.2 5-5 5Z",key:"1p0hjs"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m16 19 2 3",key:"xo31yx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tne=Z("TrainTrack",[["path",{d:"M2 17 17 2",key:"18b09t"}],["path",{d:"m2 14 8 8",key:"1gv9hu"}],["path",{d:"m5 11 8 8",key:"189pqp"}],["path",{d:"m8 8 8 8",key:"1imecy"}],["path",{d:"m11 5 8 8",key:"ummqn6"}],["path",{d:"m14 2 8 8",key:"1vk7dn"}],["path",{d:"M7 22 22 7",key:"15mb1i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const LN=Z("TramFront",[["rect",{width:"16",height:"16",x:"4",y:"3",rx:"2",key:"1wxw4b"}],["path",{d:"M4 11h16",key:"mpoxn0"}],["path",{d:"M12 3v8",key:"1h2ygw"}],["path",{d:"m8 19-2 3",key:"13i0xs"}],["path",{d:"m18 22-2-3",key:"1p0ohu"}],["path",{d:"M8 15h.01",key:"a7atzg"}],["path",{d:"M16 15h.01",key:"rnfrdf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jr=Z("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ane=Z("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ene=Z("TreeDeciduous",[["path",{d:"M8 19a4 4 0 0 1-2.24-7.32A3.5 3.5 0 0 1 9 6.03V6a3 3 0 1 1 6 0v.04a3.5 3.5 0 0 1 3.24 5.65A4 4 0 0 1 16 19Z",key:"oadzkq"}],["path",{d:"M12 19v3",key:"npa21l"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const DN=Z("TreePalm",[["path",{d:"M13 8c0-2.76-2.46-5-5.5-5S2 5.24 2 8h2l1-1 1 1h4",key:"foxbe7"}],["path",{d:"M13 7.14A5.82 5.82 0 0 1 16.5 6c3.04 0 5.5 2.24 5.5 5h-3l-1-1-1 1h-3",key:"18arnh"}],["path",{d:"M5.89 9.71c-2.15 2.15-2.3 5.47-.35 7.43l4.24-4.25.7-.7.71-.71 2.12-2.12c-1.95-1.96-5.27-1.8-7.42.35",key:"ywahnh"}],["path",{d:"M11 15.5c.5 2.5-.17 4.5-1 6.5h4c2-5.5-.5-12-1-14",key:"ft0feo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fb=Z("TreePine",[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pne=Z("Trees",[["path",{d:"M10 10v.2A3 3 0 0 1 8.9 16H5a3 3 0 0 1-1-5.8V10a3 3 0 0 1 6 0Z",key:"1l6gj6"}],["path",{d:"M7 16v6",key:"1a82de"}],["path",{d:"M13 19v3",key:"13sx9i"}],["path",{d:"M12 19h8.3a1 1 0 0 0 .7-1.7L18 14h.3a1 1 0 0 0 .7-1.7L16 9h.2a1 1 0 0 0 .8-1.7L13 3l-1.4 1.5",key:"1sj9kv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ine=Z("Trello",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["rect",{width:"3",height:"9",x:"7",y:"7",key:"14n3xi"}],["rect",{width:"3",height:"5",x:"14",y:"7",key:"s4azjd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K4=Z("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lne=Z("TrendingUpDown",[["path",{d:"M14.828 14.828 21 21",key:"ar5fw7"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"m21 3-9 9-4-4-6 6",key:"1h02xo"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xc=Z("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uh=Z("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dne=Z("TriangleRight",[["path",{d:"M22 18a2 2 0 0 1-2 2H3c-1.1 0-1.3-.6-.4-1.3L20.4 4.3c.9-.7 1.6-.4 1.6.7Z",key:"183wce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const One=Z("Triangle",[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mo=Z("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fL=Z("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rne=Z("Turtle",[["path",{d:"m12 10 2 4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a8 8 0 1 0-16 0v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3l2-4h4Z",key:"1lbbv7"}],["path",{d:"M4.82 7.9 8 10",key:"m9wose"}],["path",{d:"M15.18 7.9 12 10",key:"p8dp2u"}],["path",{d:"M16.93 10H20a2 2 0 0 1 0 4H2",key:"12nsm7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fne=Z("TvMinimalPlay",[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ON=Z("TvMinimal",[["path",{d:"M7 21h10",key:"1b0cd5"}],["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zne=Z("Tv",[["rect",{width:"20",height:"15",x:"2",y:"7",rx:"2",ry:"2",key:"10ag99"}],["polyline",{points:"17 2 12 7 7 2",key:"11pgbg"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bne=Z("Twitch",[["path",{d:"M21 2H3v16h5v4l4-4h5l4-4V2zm-10 9V7m5 4V7",key:"c0yzno"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ne=Z("Twitter",[["path",{d:"M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z",key:"pff0z6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qne=Z("TypeOutline",[["path",{d:"M14 16.5a.5.5 0 0 0 .5.5h.5a2 2 0 0 1 0 4H9a2 2 0 0 1 0-4h.5a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5V8a2 2 0 0 1-4 0V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3a2 2 0 0 1-4 0v-.5a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5Z",key:"1reda3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Une=Z("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vne=Z("UmbrellaOff",[["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"M15.5 21a1.85 1.85 0 0 1-3.5-1v-8H2a10 10 0 0 1 3.428-6.575",key:"eki10q"}],["path",{d:"M17.5 12H22A10 10 0 0 0 9.004 3.455",key:"n2ayka"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hne=Z("Umbrella",[["path",{d:"M22 12a10.06 10.06 1 0 0-20 0Z",key:"1teyop"}],["path",{d:"M12 12v8a2 2 0 0 0 4 0",key:"ulpmoc"}],["path",{d:"M12 2v1",key:"11qlp1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wne=Z("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gne=Z("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kne=Z("UndoDot",[["path",{d:"M21 17a9 9 0 0 0-15-6.7L3 13",key:"8mp6z9"}],["path",{d:"M3 7v6h6",key:"1v2h90"}],["circle",{cx:"12",cy:"17",r:"1",key:"1ixnty"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kM=Z("Undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zne=Z("UnfoldHorizontal",[["path",{d:"M16 12h6",key:"15xry1"}],["path",{d:"M8 12H2",key:"1jqql6"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m19 15 3-3-3-3",key:"wjy7rq"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yne=Z("UnfoldVertical",[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xne=Z("Ungroup",[["rect",{width:"8",height:"6",x:"5",y:"4",rx:"1",key:"nzclkv"}],["rect",{width:"8",height:"6",x:"11",y:"14",rx:"1",key:"4tytwb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const RN=Z("University",[["circle",{cx:"12",cy:"10",r:"1",key:"1gnqs8"}],["path",{d:"M22 20V8h-4l-6-4-6 4H2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"1qj5sn"}],["path",{d:"M6 17v.01",key:"roodi6"}],["path",{d:"M6 13v.01",key:"67c122"}],["path",{d:"M18 17v.01",key:"12ktxm"}],["path",{d:"M18 13v.01",key:"tn1rt1"}],["path",{d:"M14 22v-5a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"11g7fi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qne=Z("Unlink2",[["path",{d:"M15 7h2a5 5 0 0 1 0 10h-2m-6 0H7A5 5 0 0 1 7 7h2",key:"1re2ne"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z4=Z("Unlink",[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Jne=Z("Unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ni=Z("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eae=Z("Usb",[["circle",{cx:"10",cy:"7",r:"1",key:"dypaad"}],["circle",{cx:"4",cy:"20",r:"1",key:"22iqad"}],["path",{d:"M4.7 19.3 19 5",key:"1enqfc"}],["path",{d:"m21 3-3 1 2 2Z",key:"d3ov82"}],["path",{d:"M9.26 7.68 5 12l2 5",key:"1esawj"}],["path",{d:"m10 14 5 2 3.5-3.5",key:"v8oal5"}],["path",{d:"m18 12 1-1 1 1-1 1Z",key:"1bh22v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zb=Z("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gL=Z("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xL=Z("UserMinus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tae=Z("UserPen",[["path",{d:"M11.5 15H7a4 4 0 0 0-4 4v2",key:"15lzij"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pc=Z("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const FN=Z("UserRoundCheck",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zN=Z("UserRoundCog",[["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m19.5 14.3-.4.9",key:"1eb35c"}],["path",{d:"m16.9 20.8-.4.9",key:"dfjc4z"}],["path",{d:"m21.7 19.5-.9-.4",key:"q4dx6b"}],["path",{d:"m15.2 16.9-.9-.4",key:"1r0w5f"}],["path",{d:"m21.7 16.5-.9.4",key:"1knoei"}],["path",{d:"m15.2 19.1-.9.4",key:"j188fs"}],["path",{d:"m19.5 21.7-.4-.9",key:"1tonu5"}],["path",{d:"m16.9 15.2-.4-.9",key:"699xu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const BN=Z("UserRoundMinus",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 19h-6",key:"vcuq98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sae=Z("UserRoundPen",[["path",{d:"M2 21a8 8 0 0 1 10.821-7.487",key:"1c8h7z"}],["path",{d:"M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1817ys"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $N=Z("UserRoundPlus",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M22 19h-6",key:"vcuq98"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rae=Z("UserRoundSearch",[["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M2 21a8 8 0 0 1 10.434-7.62",key:"1yezr2"}],["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["path",{d:"m22 22-1.9-1.9",key:"1e5ubv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qN=Z("UserRoundX",[["path",{d:"M2 21a8 8 0 0 1 11.873-7",key:"74fkxq"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m17 17 5 5",key:"p7ous7"}],["path",{d:"m22 17-5 5",key:"gqnmv0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const UN=Z("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nae=Z("UserSearch",[["circle",{cx:"10",cy:"7",r:"4",key:"e45bow"}],["path",{d:"M10.3 15H7a4 4 0 0 0-4 4v2",key:"3bnktk"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aae=Z("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const ro=Z("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const VN=Z("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mr=Z("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const HN=Z("UtensilsCrossed",[["path",{d:"m16 2-2.3 2.3a3 3 0 0 0 0 4.2l1.8 1.8a3 3 0 0 0 4.2 0L22 8",key:"n7qcjb"}],["path",{d:"M15 15 3.3 3.3a4.2 4.2 0 0 0 0 6l7.3 7.3c.7.7 2 .7 2.8 0L15 15Zm0 0 7 7",key:"d0u48b"}],["path",{d:"m2.1 21.8 6.4-6.3",key:"yn04lh"}],["path",{d:"m19 5-7 7",key:"194lzd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const WN=Z("Utensils",[["path",{d:"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2",key:"cjf0a3"}],["path",{d:"M7 2v20",key:"1473qp"}],["path",{d:"M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7",key:"j28e5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iae=Z("UtilityPole",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M3 3v2",key:"9imdir"}],["path",{d:"M7 3v2",key:"n0os7"}],["path",{d:"M17 3v2",key:"1l2re6"}],["path",{d:"M21 3v2",key:"1duuac"}],["path",{d:"m19 5-7 7-7-7",key:"133zxf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yL=Z("Variable",[["path",{d:"M8 21s-4-3-4-9 4-9 4-9",key:"uto9ud"}],["path",{d:"M16 3s4 3 4 9-4 9-4 9",key:"4w2vsq"}],["line",{x1:"15",x2:"9",y1:"9",y2:"15",key:"f7djnv"}],["line",{x1:"9",x2:"15",y1:"9",y2:"15",key:"1shsy8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oae=Z("Vault",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["path",{d:"m7.9 7.9 2.7 2.7",key:"hpeyl3"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}],["path",{d:"m13.4 10.6 2.7-2.7",key:"264c1n"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["path",{d:"m7.9 16.1 2.7-2.7",key:"p81g5e"}],["circle",{cx:"16.5",cy:"16.5",r:".5",fill:"currentColor",key:"fubopw"}],["path",{d:"m13.4 13.4 2.7 2.7",key:"abhel3"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lae=Z("Vegan",[["path",{d:"M16 8q6 0 6-6-6 0-6 6",key:"qsyyc4"}],["path",{d:"M17.41 3.59a10 10 0 1 0 3 3",key:"41m9h7"}],["path",{d:"M2 2a26.6 26.6 0 0 1 10 20c.9-6.82 1.5-9.5 4-14",key:"qiv7li"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cae=Z("VenetianMask",[["path",{d:"M18 11c-1.5 0-2.5.5-3 2",key:"1fod00"}],["path",{d:"M4 6a2 2 0 0 0-2 2v4a5 5 0 0 0 5 5 8 8 0 0 1 5 2 8 8 0 0 1 5-2 5 5 0 0 0 5-5V8a2 2 0 0 0-2-2h-3a8 8 0 0 0-5 2 8 8 0 0 0-5-2z",key:"d70hit"}],["path",{d:"M6 11c1.5 0 2.5.5 3 2",key:"136fht"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dae=Z("VibrateOff",[["path",{d:"m2 8 2 2-2 2 2 2-2 2",key:"sv1b1"}],["path",{d:"m22 8-2 2 2 2-2 2 2 2",key:"101i4y"}],["path",{d:"M8 8v10c0 .55.45 1 1 1h6c.55 0 1-.45 1-1v-2",key:"1hbad5"}],["path",{d:"M16 10.34V6c0-.55-.45-1-1-1h-4.34",key:"1x5tf0"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uae=Z("Vibrate",[["path",{d:"m2 8 2 2-2 2 2 2-2 2",key:"sv1b1"}],["path",{d:"m22 8-2 2 2 2-2 2 2 2",key:"101i4y"}],["rect",{width:"8",height:"14",x:"8",y:"5",rx:"1",key:"1oyrl4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hae=Z("VideoOff",[["path",{d:"M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196",key:"w8jjjt"}],["path",{d:"M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"1xawa7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nn=Z("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mae=Z("Videotape",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 8h20",key:"d11cs7"}],["circle",{cx:"8",cy:"14",r:"2",key:"1k2qr5"}],["path",{d:"M8 12h8",key:"1wcyev"}],["circle",{cx:"16",cy:"14",r:"2",key:"14k7lr"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pae=Z("View",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fae=Z("Voicemail",[["circle",{cx:"6",cy:"12",r:"4",key:"1ehtga"}],["circle",{cx:"18",cy:"12",r:"4",key:"4vafl8"}],["line",{x1:"6",x2:"18",y1:"16",y2:"16",key:"pmt8us"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gae=Z("Volleyball",[["path",{d:"M11.1 7.1a16.55 16.55 0 0 1 10.9 4",key:"2880wi"}],["path",{d:"M12 12a12.6 12.6 0 0 1-8.7 5",key:"113sja"}],["path",{d:"M16.8 13.6a16.55 16.55 0 0 1-9 7.5",key:"1qmsgl"}],["path",{d:"M20.7 17a12.8 12.8 0 0 0-8.7-5 13.3 13.3 0 0 1 0-10",key:"1bmeqp"}],["path",{d:"M6.3 3.8a16.55 16.55 0 0 0 1.9 11.5",key:"iekzv9"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xae=Z("Volume1",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yae=Z("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vae=Z("VolumeOff",[["path",{d:"M16 9a5 5 0 0 1 .95 2.293",key:"1fgyg8"}],["path",{d:"M19.364 5.636a9 9 0 0 1 1.889 9.96",key:"l3zxae"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m7 7-.587.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298V11",key:"1gbwow"}],["path",{d:"M9.828 4.172A.686.686 0 0 1 11 4.657v.686",key:"s2je0y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const _ae=Z("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bae=Z("Volume",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wae=Z("Vote",[["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}],["path",{d:"M5 7c0-1.1.9-2 2-2h10a2 2 0 0 1 2 2v12H5V7Z",key:"1ezoue"}],["path",{d:"M22 19H2",key:"nuriw5"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jae=Z("WalletCards",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2",key:"4125el"}],["path",{d:"M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21",key:"1dpki6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const GN=Z("WalletMinimal",[["path",{d:"M17 14h.01",key:"7oqj8z"}],["path",{d:"M7 7h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14",key:"u1rqew"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vL=Z("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kae=Z("Wallpaper",[["circle",{cx:"8",cy:"9",r:"2",key:"gjzl9d"}],["path",{d:"m9 17 6.1-6.1a2 2 0 0 1 2.81.01L22 15V5a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"69xh40"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["path",{d:"M12 17v4",key:"1riwvh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iv=Z("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nae=Z("Wand",[["path",{d:"M15 4V2",key:"z1p9b7"}],["path",{d:"M15 16v-2",key:"px0unx"}],["path",{d:"M8 9h2",key:"1g203m"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M17.8 11.8 19 13",key:"yihg8r"}],["path",{d:"M15 9h.01",key:"x1ddxp"}],["path",{d:"M17.8 6.2 19 5",key:"fd4us0"}],["path",{d:"m3 21 9-9",key:"1jfql5"}],["path",{d:"M12.2 6.2 11 5",key:"i3da3b"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sae=Z("Warehouse",[["path",{d:"M22 8.35V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8.35A2 2 0 0 1 3.26 6.5l8-3.2a2 2 0 0 1 1.48 0l8 3.2A2 2 0 0 1 22 8.35Z",key:"gksnxg"}],["path",{d:"M6 18h12",key:"9pbo8z"}],["path",{d:"M6 14h12",key:"4cwo0f"}],["rect",{width:"12",height:"12",x:"6",y:"10",key:"apd30q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cae=Z("WashingMachine",[["path",{d:"M3 6h3",key:"155dbl"}],["path",{d:"M17 6h.01",key:"e2y6kg"}],["rect",{width:"18",height:"20",x:"3",y:"2",rx:"2",key:"od3kk9"}],["circle",{cx:"12",cy:"13",r:"5",key:"nlbqau"}],["path",{d:"M12 18a2.5 2.5 0 0 0 0-5 2.5 2.5 0 0 1 0-5",key:"17lach"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Mae=Z("Watch",[["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["polyline",{points:"12 10 12 12 13 13",key:"19dquz"}],["path",{d:"m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05",key:"18k57s"}],["path",{d:"m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05",key:"16ny36"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Tae=Z("Waves",[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Aae=Z("Waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Eae=Z("Webcam",[["circle",{cx:"12",cy:"10",r:"8",key:"1gshiw"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 22h10",key:"10w4w3"}],["path",{d:"M12 22v-4",key:"1utk9m"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Pae=Z("WebhookOff",[["path",{d:"M17 17h-5c-1.09-.02-1.94.92-2.5 1.9A3 3 0 1 1 2.57 15",key:"1tvl6x"}],["path",{d:"M9 3.4a4 4 0 0 1 6.52.66",key:"q04jfq"}],["path",{d:"m6 17 3.1-5.8a2.5 2.5 0 0 0 .057-2.05",key:"azowf0"}],["path",{d:"M20.3 20.3a4 4 0 0 1-2.3.7",key:"5joiws"}],["path",{d:"M18.6 13a4 4 0 0 1 3.357 3.414",key:"cangb8"}],["path",{d:"m12 6 .6 1",key:"tpjl1n"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Iae=Z("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lae=Z("Weight",[["circle",{cx:"12",cy:"5",r:"3",key:"rqqgnr"}],["path",{d:"M6.5 8a2 2 0 0 0-1.905 1.46L2.1 18.5A2 2 0 0 0 4 21h16a2 2 0 0 0 1.925-2.54L19.4 9.5A2 2 0 0 0 17.48 8Z",key:"56o5sh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Dae=Z("WheatOff",[["path",{d:"m2 22 10-10",key:"28ilpk"}],["path",{d:"m16 8-1.17 1.17",key:"1qqm82"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"m8 8-.53.53a3.5 3.5 0 0 0 0 4.94L9 15l1.53-1.53c.55-.55.88-1.25.98-1.97",key:"4wz8re"}],["path",{d:"M10.91 5.26c.15-.26.34-.51.56-.73L13 3l1.53 1.53a3.5 3.5 0 0 1 .28 4.62",key:"rves66"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"m16 16-.53.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.49 3.49 0 0 1 1.97-.98",key:"ak46r"}],["path",{d:"M18.74 13.09c.26-.15.51-.34.73-.56L21 11l-1.53-1.53a3.5 3.5 0 0 0-4.62-.28",key:"1tw520"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Oae=Z("Wheat",[["path",{d:"M2 22 16 8",key:"60hf96"}],["path",{d:"M3.47 12.53 5 11l1.53 1.53a3.5 3.5 0 0 1 0 4.94L5 19l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1rdhi6"}],["path",{d:"M7.47 8.53 9 7l1.53 1.53a3.5 3.5 0 0 1 0 4.94L9 15l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"1sdzmb"}],["path",{d:"M11.47 4.53 13 3l1.53 1.53a3.5 3.5 0 0 1 0 4.94L13 11l-1.53-1.53a3.5 3.5 0 0 1 0-4.94Z",key:"eoatbi"}],["path",{d:"M20 2h2v2a4 4 0 0 1-4 4h-2V6a4 4 0 0 1 4-4Z",key:"19rau1"}],["path",{d:"M11.47 17.47 13 19l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L5 19l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"tc8ph9"}],["path",{d:"M15.47 13.47 17 15l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L9 15l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"2m8kc5"}],["path",{d:"M19.47 9.47 21 11l-1.53 1.53a3.5 3.5 0 0 1-4.94 0L13 11l1.53-1.53a3.5 3.5 0 0 1 4.94 0Z",key:"vex3ng"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rae=Z("WholeWord",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Fae=Z("WifiHigh",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zae=Z("WifiLow",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bae=Z("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $ae=Z("WifiZero",[["path",{d:"M12 20h.01",key:"zekei9"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qae=Z("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Uae=Z("WindArrowDown",[["path",{d:"M10 2v8",key:"d4bbey"}],["path",{d:"M12.8 21.6A2 2 0 1 0 14 18H2",key:"19kp1d"}],["path",{d:"M17.5 10a2.5 2.5 0 1 1 2 4H2",key:"19kpjc"}],["path",{d:"m6 6 4 4 4-4",key:"k13n16"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vae=Z("Wind",[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hae=Z("WineOff",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h3m7 0h-1.343",key:"v48bem"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M7.307 7.307A12.33 12.33 0 0 0 7 10a5 5 0 0 0 7.391 4.391M8.638 2.981C8.75 2.668 8.872 2.34 9 2h6c1.5 4 2 6 2 8 0 .407-.05.809-.145 1.198",key:"1ymjlu"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wae=Z("Wine",[["path",{d:"M8 22h8",key:"rmew8v"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M12 15v7",key:"t2xh3l"}],["path",{d:"M12 15a5 5 0 0 0 5-5c0-2-.5-4-2-8H9c-1.5 4-2 6-2 8a5 5 0 0 0 5 5Z",key:"10ffi3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gae=Z("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kae=Z("Worm",[["path",{d:"m19 12-1.5 3",key:"9bcu4o"}],["path",{d:"M19.63 18.81 22 20",key:"121v98"}],["path",{d:"M6.47 8.23a1.68 1.68 0 0 1 2.44 1.93l-.64 2.08a6.76 6.76 0 0 0 10.16 7.67l.42-.27a1 1 0 1 0-2.73-4.21l-.42.27a1.76 1.76 0 0 1-2.63-1.99l.64-2.08A6.66 6.66 0 0 0 3.94 3.9l-.7.4a1 1 0 1 0 2.55 4.34z",key:"1tij6q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Zae=Z("WrapText",[["line",{x1:"3",x2:"21",y1:"6",y2:"6",key:"4m8b97"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["polyline",{points:"16 16 14 18 16 20",key:"1jznyi"}],["line",{x1:"3",x2:"10",y1:"18",y2:"18",key:"1h33wv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kx=Z("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ur=Z("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yae=Z("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Xae=Z("ZapOff",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wp=Z("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bb=Z("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NM=Z("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Kft=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:Xz,AArrowUp:Qz,ALargeSmall:Jz,Accessibility:e9,Activity:gp,AirVent:t9,Airplay:s9,AlarmClock:n9,AlarmClockCheck:Fw,AlarmClockMinus:zw,AlarmClockOff:r9,AlarmClockPlus:Bw,AlarmSmoke:a9,Album:i9,AlignCenter:sM,AlignCenterHorizontal:o9,AlignCenterVertical:l9,AlignEndHorizontal:c9,AlignEndVertical:d9,AlignHorizontalDistributeCenter:u9,AlignHorizontalDistributeEnd:h9,AlignHorizontalDistributeStart:m9,AlignHorizontalJustifyCenter:p9,AlignHorizontalJustifyEnd:f9,AlignHorizontalJustifyStart:g9,AlignHorizontalSpaceAround:x9,AlignHorizontalSpaceBetween:y9,AlignJustify:v9,AlignLeft:rM,AlignRight:nM,AlignStartHorizontal:_9,AlignStartVertical:b9,AlignVerticalDistributeCenter:w9,AlignVerticalDistributeEnd:j9,AlignVerticalDistributeStart:k9,AlignVerticalJustifyCenter:N9,AlignVerticalJustifyEnd:S9,AlignVerticalJustifyStart:C9,AlignVerticalSpaceAround:M9,AlignVerticalSpaceBetween:T9,Ambulance:A9,Ampersand:E9,Ampersands:P9,Amphora:I9,Anchor:L9,Angry:D9,Annoyed:O9,Antenna:R9,Anvil:F9,Aperture:z9,AppWindow:NI,AppWindowMac:B9,Apple:$9,Archive:aM,ArchiveRestore:SI,ArchiveX:q9,Armchair:U9,ArrowBigDown:H9,ArrowBigDownDash:V9,ArrowBigLeft:G9,ArrowBigLeftDash:W9,ArrowBigRight:Z9,ArrowBigRightDash:K9,ArrowBigUp:X9,ArrowBigUpDash:Y9,ArrowDown:Oh,ArrowDown01:Q9,ArrowDown10:J9,ArrowDownAZ:$w,ArrowDownFromLine:eB,ArrowDownLeft:tB,ArrowDownNarrowWide:sB,ArrowDownRight:CI,ArrowDownToDot:rB,ArrowDownToLine:nB,ArrowDownUp:aB,ArrowDownWideNarrow:qw,ArrowDownZA:Uw,ArrowLeft:di,ArrowLeftFromLine:iB,ArrowLeftRight:oB,ArrowLeftToLine:lB,ArrowRight:Ki,ArrowRightFromLine:cB,ArrowRightLeft:Gv,ArrowRightToLine:dB,ArrowUp:gu,ArrowUp01:uB,ArrowUp10:hB,ArrowUpAZ:Vw,ArrowUpDown:ud,ArrowUpFromDot:mB,ArrowUpFromLine:pB,ArrowUpLeft:fB,ArrowUpNarrowWide:Hw,ArrowUpRight:MI,ArrowUpToLine:gB,ArrowUpWideNarrow:xB,ArrowUpZA:Ww,ArrowsUpFromLine:yB,Asterisk:vB,AtSign:_B,Atom:bB,AudioLines:wB,AudioWaveform:jB,Award:fc,Axe:kB,Axis3d:Gw,Baby:NB,Backpack:SB,Badge:qB,BadgeAlert:CB,BadgeCent:MB,BadgeCheck:Kw,BadgeDollarSign:TB,BadgeEuro:AB,BadgeHelp:EB,BadgeIndianRupee:PB,BadgeInfo:IB,BadgeJapaneseYen:LB,BadgeMinus:DB,BadgePercent:OB,BadgePlus:RB,BadgePoundSterling:FB,BadgeRussianRuble:zB,BadgeSwissFranc:BB,BadgeX:$B,BaggageClaim:UB,Ban:TI,Banana:VB,Bandage:HB,Banknote:WB,Barcode:GB,Baseline:KB,Bath:n0,Battery:e$,BatteryCharging:ZB,BatteryFull:YB,BatteryLow:XB,BatteryMedium:QB,BatteryWarning:JB,Beaker:t$,Bean:r$,BeanOff:s$,Bed:Kv,BedDouble:AI,BedSingle:n$,Beef:a$,Beer:o$,BeerOff:i$,Bell:gg,BellDot:l$,BellElectric:c$,BellMinus:d$,BellOff:Mb,BellPlus:u$,BellRing:h$,BetweenHorizontalEnd:Zw,BetweenHorizontalStart:Yw,BetweenVerticalEnd:m$,BetweenVerticalStart:p$,BicepsFlexed:f$,Bike:g$,Binary:x$,Binoculars:y$,Biohazard:v$,Bird:_$,Bitcoin:b$,Blend:w$,Blinds:j$,Blocks:k$,Bluetooth:M$,BluetoothConnected:N$,BluetoothOff:S$,BluetoothSearching:C$,Bold:iM,Bolt:T$,Bomb:A$,Bone:E$,Book:J$,BookA:P$,BookAudio:I$,BookCheck:L$,BookCopy:D$,BookDashed:Xw,BookDown:O$,BookHeadphones:R$,BookHeart:F$,BookImage:z$,BookKey:B$,BookLock:$$,BookMarked:q$,BookMinus:U$,BookOpen:gh,BookOpenCheck:V$,BookOpenText:H$,BookPlus:W$,BookText:G$,BookType:K$,BookUp:Y$,BookUp2:Z$,BookUser:X$,BookX:Q$,Bookmark:Ux,BookmarkCheck:eq,BookmarkMinus:tq,BookmarkPlus:EI,BookmarkX:sq,BoomBox:rq,Bot:oM,BotMessageSquare:nq,BotOff:aq,Box:iq,Boxes:oq,Braces:Qw,Brackets:lq,Brain:PI,BrainCircuit:cq,BrainCog:dq,BrickWall:uq,Briefcase:Rh,BriefcaseBusiness:hq,BriefcaseConveyorBelt:mq,BriefcaseMedical:pq,BringToFront:fq,Brush:gq,Bug:vq,BugOff:xq,BugPlay:yq,Building:R4,Building2:La,Bus:bq,BusFront:_q,Cable:jq,CableCar:wq,Cake:xh,CakeSlice:kq,Calculator:Nq,Calendar:on,Calendar1:Sq,CalendarArrowDown:Cq,CalendarArrowUp:Mq,CalendarCheck:II,CalendarCheck2:Tq,CalendarClock:LI,CalendarCog:Aq,CalendarDays:Md,CalendarFold:Eq,CalendarHeart:Pq,CalendarMinus:Lq,CalendarMinus2:Iq,CalendarOff:DI,CalendarPlus:Tb,CalendarPlus2:Dq,CalendarRange:Oq,CalendarSearch:Rq,CalendarSync:Fq,CalendarX:Bq,CalendarX2:zq,Camera:Vx,CameraOff:$q,Candy:Vq,CandyCane:qq,CandyOff:Uq,Cannabis:Hq,Captions:Jw,CaptionsOff:Wq,Car:Zq,CarFront:Gq,CarTaxiFront:Kq,Caravan:Yq,Carrot:Xq,CaseLower:Qq,CaseSensitive:Jq,CaseUpper:eU,CassetteTape:tU,Cast:sU,Castle:rU,Cat:nU,Cctv:aU,ChartArea:ej,ChartBar:sj,ChartBarBig:tj,ChartBarDecreasing:iU,ChartBarIncreasing:oU,ChartBarStacked:lU,ChartCandlestick:rj,ChartColumn:xl,ChartColumnBig:nj,ChartColumnDecreasing:cU,ChartColumnIncreasing:aj,ChartColumnStacked:dU,ChartGantt:uU,ChartLine:ij,ChartNetwork:hU,ChartNoAxesColumn:lj,ChartNoAxesColumnDecreasing:mU,ChartNoAxesColumnIncreasing:oj,ChartNoAxesCombined:pU,ChartNoAxesGantt:cj,ChartPie:dj,ChartScatter:uj,ChartSpline:fU,Check:ma,CheckCheck:gU,ChefHat:xU,Cherry:yU,ChevronDown:tl,ChevronFirst:vU,ChevronLast:_U,ChevronLeft:Xl,ChevronRight:Xa,ChevronUp:Hx,ChevronsDown:wU,ChevronsDownUp:bU,ChevronsLeft:NU,ChevronsLeftRight:kU,ChevronsLeftRightEllipsis:jU,ChevronsRight:CU,ChevronsRightLeft:SU,ChevronsUp:MU,ChevronsUpDown:xg,Chrome:TU,Church:AU,Cigarette:PU,CigaretteOff:EU,Circle:pd,CircleAlert:yl,CircleArrowDown:hj,CircleArrowLeft:mj,CircleArrowOutDownLeft:pj,CircleArrowOutDownRight:fj,CircleArrowOutUpLeft:gj,CircleArrowOutUpRight:xj,CircleArrowRight:yj,CircleArrowUp:vj,CircleCheck:ha,CircleCheckBig:vi,CircleChevronDown:_j,CircleChevronLeft:bj,CircleChevronRight:wj,CircleChevronUp:jj,CircleDashed:IU,CircleDivide:kj,CircleDollarSign:LU,CircleDot:OU,CircleDotDashed:DU,CircleEllipsis:RU,CircleEqual:FU,CircleFadingArrowUp:zU,CircleFadingPlus:BU,CircleGauge:Nj,CircleHelp:Mv,CircleMinus:Sj,CircleOff:$U,CircleParking:Mj,CircleParkingOff:Cj,CirclePause:Tj,CirclePercent:Aj,CirclePlay:ap,CirclePlus:Ej,CirclePower:Pj,CircleSlash:qU,CircleSlash2:Ij,CircleStop:Lj,CircleUser:Oj,CircleUserRound:Dj,CircleX:$c,CircuitBoard:UU,Citrus:VU,Clapperboard:HU,Clipboard:QU,ClipboardCheck:lM,ClipboardCopy:WU,ClipboardList:Ab,ClipboardMinus:GU,ClipboardPaste:KU,ClipboardPen:Fj,ClipboardPenLine:Rj,ClipboardPlus:ZU,ClipboardType:YU,ClipboardX:XU,Clock:Tn,Clock1:JU,Clock10:eV,Clock11:tV,Clock12:sV,Clock2:rV,Clock3:nV,Clock4:aV,Clock5:iV,Clock6:oV,Clock7:lV,Clock8:cV,Clock9:dV,ClockAlert:uV,ClockArrowDown:hV,ClockArrowUp:mV,Cloud:MV,CloudAlert:pV,CloudCog:fV,CloudDownload:zj,CloudDrizzle:gV,CloudFog:xV,CloudHail:yV,CloudLightning:vV,CloudMoon:bV,CloudMoonRain:_V,CloudOff:wV,CloudRain:kV,CloudRainWind:jV,CloudSnow:NV,CloudSun:CV,CloudSunRain:SV,CloudUpload:Bj,Cloudy:TV,Clover:$v,Club:AV,Code:F4,CodeXml:$j,Codepen:EV,Codesandbox:PV,Coffee:z4,Cog:IV,Coins:OI,Columns2:qj,Columns3:Uj,Columns4:LV,Combine:DV,Command:OV,Compass:RV,Component:FV,Computer:zV,ConciergeBell:BV,Cone:$V,Construction:qV,Contact:B4,ContactRound:Vj,Container:UV,Contrast:VV,Cookie:HV,CookingPot:WV,Copy:mi,CopyCheck:GV,CopyMinus:KV,CopyPlus:ZV,CopySlash:YV,CopyX:XV,Copyleft:QV,Copyright:JV,CornerDownLeft:eH,CornerDownRight:tH,CornerLeftDown:sH,CornerLeftUp:rH,CornerRightDown:nH,CornerRightUp:aH,CornerUpLeft:iH,CornerUpRight:oH,Cpu:lH,CreativeCommons:cH,CreditCard:yg,Croissant:dH,Crop:uH,Cross:hH,Crosshair:mH,Crown:Sm,Cuboid:pH,CupSoda:fH,Currency:gH,Cylinder:xH,Dam:yH,Database:bH,DatabaseBackup:vH,DatabaseZap:_H,Delete:wH,Dessert:jH,Diameter:kH,Diamond:CH,DiamondMinus:NH,DiamondPercent:Hj,DiamondPlus:SH,Dice1:MH,Dice2:TH,Dice3:AH,Dice4:EH,Dice5:PH,Dice6:IH,Dices:LH,Diff:DH,Disc:zH,Disc2:OH,Disc3:RH,DiscAlbum:FH,Divide:BH,Dna:qH,DnaOff:$H,Dock:UH,Dog:VH,DollarSign:Td,Donut:HH,DoorClosed:WH,DoorOpen:Zv,Dot:GH,Download:ki,DraftingCompass:KH,Drama:ZH,Dribbble:YH,Drill:XH,Droplet:QH,Droplets:Wx,Drum:JH,Drumstick:eW,Dumbbell:tW,Ear:rW,EarOff:sW,Earth:Wj,EarthLock:nW,Eclipse:aW,Egg:cM,EggFried:iW,EggOff:oW,Ellipsis:ig,EllipsisVertical:ag,Equal:dW,EqualApproximately:lW,EqualNot:cW,Eraser:uW,EthernetPort:hW,Euro:mW,Expand:pW,ExternalLink:rn,Eye:va,EyeClosed:fW,EyeOff:xp,Facebook:xu,Factory:gW,Fan:xW,FastForward:yW,Feather:vW,Fence:_W,FerrisWheel:bW,Figma:wW,File:dM,FileArchive:jW,FileAudio:NW,FileAudio2:kW,FileAxis3d:Gj,FileBadge:CW,FileBadge2:SW,FileBox:MW,FileChartColumn:Zj,FileChartColumnIncreasing:Kj,FileChartLine:Yj,FileChartPie:Xj,FileCheck:AW,FileCheck2:TW,FileClock:EW,FileCode:IW,FileCode2:PW,FileCog:Qj,FileDiff:LW,FileDigit:DW,FileDown:OW,FileHeart:RW,FileImage:Eb,FileInput:FW,FileJson:BW,FileJson2:zW,FileKey:qW,FileKey2:$W,FileLock:VW,FileLock2:UW,FileMinus:WW,FileMinus2:HW,FileMusic:GW,FileOutput:KW,FilePen:ek,FilePenLine:Jj,FilePlus:YW,FilePlus2:ZW,FileQuestion:XW,FileScan:QW,FileSearch:eG,FileSearch2:JW,FileSliders:tG,FileSpreadsheet:Yv,FileStack:RI,FileSymlink:sG,FileTerminal:rG,FileText:In,FileType:aG,FileType2:nG,FileUp:iG,FileUser:oG,FileVideo:cG,FileVideo2:lG,FileVolume:uG,FileVolume2:dG,FileWarning:hG,FileX:pG,FileX2:mG,Files:fG,Film:Fu,Filter:a0,FilterX:gG,Fingerprint:xG,FireExtinguisher:yG,Fish:bG,FishOff:vG,FishSymbol:_G,Flag:Xv,FlagOff:wG,FlagTriangleLeft:jG,FlagTriangleRight:kG,Flame:Fh,FlameKindling:NG,Flashlight:CG,FlashlightOff:SG,FlaskConical:Pb,FlaskConicalOff:MG,FlaskRound:TG,FlipHorizontal:FI,FlipHorizontal2:AG,FlipVertical:PG,FlipVertical2:EG,Flower:IG,Flower2:Fx,Focus:LG,FoldHorizontal:DG,FoldVertical:OG,Folder:cK,FolderArchive:RG,FolderCheck:FG,FolderClock:zG,FolderClosed:BG,FolderCode:$G,FolderCog:tk,FolderDot:qG,FolderDown:UG,FolderGit:HG,FolderGit2:VG,FolderHeart:WG,FolderInput:GG,FolderKanban:KG,FolderKey:ZG,FolderLock:YG,FolderMinus:XG,FolderOpen:Cm,FolderOpenDot:QG,FolderOutput:JG,FolderPen:sk,FolderPlus:eK,FolderRoot:tK,FolderSearch:rK,FolderSearch2:sK,FolderSymlink:nK,FolderSync:aK,FolderTree:iK,FolderUp:oK,FolderX:lK,Folders:dK,Footprints:uK,Forklift:hK,Forward:mK,Frame:pK,Framer:fK,Frown:gK,Fuel:xK,Fullscreen:yK,GalleryHorizontal:_K,GalleryHorizontalEnd:vK,GalleryThumbnails:bK,GalleryVertical:jK,GalleryVerticalEnd:wK,Gamepad:NK,Gamepad2:kK,Gauge:SK,Gavel:CK,Gem:MK,Ghost:$4,Gift:bo,GitBranch:AK,GitBranchPlus:TK,GitCommitHorizontal:rk,GitCommitVertical:EK,GitCompare:IK,GitCompareArrows:PK,GitFork:LK,GitGraph:DK,GitMerge:OK,GitPullRequest:qK,GitPullRequestArrow:RK,GitPullRequestClosed:FK,GitPullRequestCreate:BK,GitPullRequestCreateArrow:zK,GitPullRequestDraft:$K,Github:UK,Gitlab:VK,GlassWater:HK,Glasses:WK,Globe:yp,GlobeLock:GK,Goal:KK,Grab:ZK,GraduationCap:zh,Grape:YK,Grid2x2:ak,Grid2x2Check:XK,Grid2x2Plus:nk,Grid2x2X:QK,Grid3x3:Yf,Grip:eZ,GripHorizontal:JK,GripVertical:yh,Group:tZ,Guitar:sZ,Ham:rZ,Hammer:nZ,Hand:zI,HandCoins:aZ,HandHeart:iZ,HandHelping:ik,HandMetal:oZ,HandPlatter:lZ,Handshake:BI,HardDrive:$I,HardDriveDownload:cZ,HardDriveUpload:dZ,HardHat:uZ,Hash:uM,Haze:hZ,HdmiPort:mZ,Heading:yZ,Heading1:qI,Heading2:UI,Heading3:pZ,Heading4:fZ,Heading5:gZ,Heading6:xZ,HeadphoneOff:vZ,Headphones:_Z,Headset:bZ,Heart:Ii,HeartCrack:wZ,HeartHandshake:jZ,HeartOff:kZ,HeartPulse:NZ,Heater:SZ,Hexagon:CZ,Highlighter:MZ,History:hM,Hop:AZ,HopOff:TZ,Hospital:EZ,Hotel:PZ,Hourglass:IZ,House:Rn,HousePlug:LZ,HousePlus:DZ,IceCreamBowl:ok,IceCreamCone:lk,IdCard:OZ,Image:cl,ImageDown:RZ,ImageMinus:FZ,ImageOff:zZ,ImagePlay:BZ,ImagePlus:Qv,ImageUp:$Z,ImageUpscale:qZ,Images:UZ,Import:VZ,Inbox:HZ,IndentDecrease:ck,IndentIncrease:dk,IndianRupee:WZ,Infinity:GZ,Info:VI,InspectionPanel:KZ,Instagram:yu,Italic:mM,IterationCcw:ZZ,IterationCw:YZ,JapaneseYen:XZ,Joystick:QZ,Kanban:i0,Key:vp,KeyRound:q4,KeySquare:JZ,Keyboard:sY,KeyboardMusic:eY,KeyboardOff:tY,Lamp:lY,LampCeiling:rY,LampDesk:nY,LampFloor:aY,LampWallDown:iY,LampWallUp:oY,LandPlot:cY,Landmark:dY,Languages:uY,Laptop:mY,LaptopMinimal:uk,LaptopMinimalCheck:hY,Lasso:fY,LassoSelect:pY,Laugh:gY,Layers:vY,Layers2:xY,Layers3:yY,LayoutDashboard:U4,LayoutGrid:lf,LayoutList:_Y,LayoutPanelLeft:bY,LayoutPanelTop:wY,LayoutTemplate:V4,Leaf:jY,LeafyGreen:kY,Lectern:NY,LetterText:SY,Library:pM,LibraryBig:CY,LifeBuoy:fM,Ligature:MY,Lightbulb:Ib,LightbulbOff:TY,Link:Vo,Link2:sl,Link2Off:AY,Linkedin:_p,List:Mm,ListCheck:EY,ListChecks:PY,ListCollapse:IY,ListEnd:LY,ListFilter:DY,ListMinus:OY,ListMusic:RY,ListOrdered:Jv,ListPlus:FY,ListRestart:zY,ListStart:BY,ListTodo:$Y,ListTree:qY,ListVideo:UY,ListX:VY,Loader:WY,LoaderCircle:Ss,LoaderPinwheel:HY,Locate:ZY,LocateFixed:GY,LocateOff:KY,Lock:vh,LockKeyhole:YY,LockKeyholeOpen:hk,LockOpen:mk,LogIn:gM,LogOut:xM,Logs:XY,Lollipop:QY,Luggage:JY,Magnet:eX,Mail:br,MailCheck:tX,MailMinus:sX,MailOpen:rX,MailPlus:nX,MailQuestion:aX,MailSearch:iX,MailWarning:oX,MailX:HI,Mailbox:lX,Mails:cX,Map:bX,MapPin:Ui,MapPinCheck:uX,MapPinCheckInside:dX,MapPinHouse:hX,MapPinMinus:pX,MapPinMinusInside:mX,MapPinOff:fX,MapPinPlus:xX,MapPinPlusInside:gX,MapPinX:vX,MapPinXInside:yX,MapPinned:_X,Martini:wX,Maximize:WI,Maximize2:jX,Medal:e1,Megaphone:bp,MegaphoneOff:kX,Meh:NX,MemoryStick:SX,Menu:GI,Merge:CX,MessageCircle:Ec,MessageCircleCode:MX,MessageCircleDashed:TX,MessageCircleHeart:yM,MessageCircleMore:AX,MessageCircleOff:EX,MessageCirclePlus:PX,MessageCircleQuestion:KI,MessageCircleReply:IX,MessageCircleWarning:LX,MessageCircleX:DX,MessageSquare:po,MessageSquareCode:OX,MessageSquareDashed:RX,MessageSquareDiff:FX,MessageSquareDot:zX,MessageSquareHeart:BX,MessageSquareLock:$X,MessageSquareMore:ZI,MessageSquareOff:qX,MessageSquarePlus:vM,MessageSquareQuote:YI,MessageSquareReply:UX,MessageSquareShare:VX,MessageSquareText:HX,MessageSquareWarning:WX,MessageSquareX:GX,MessagesSquare:KX,Mic:XI,MicOff:ZX,MicVocal:pk,Microchip:YX,Microscope:XX,Microwave:QX,Milestone:JX,Milk:tQ,MilkOff:eQ,Minimize:rQ,Minimize2:sQ,Minus:t1,Monitor:H4,MonitorCheck:nQ,MonitorCog:aQ,MonitorDot:iQ,MonitorDown:oQ,MonitorOff:lQ,MonitorPause:cQ,MonitorPlay:dQ,MonitorSmartphone:uQ,MonitorSpeaker:hQ,MonitorStop:mQ,MonitorUp:pQ,MonitorX:fQ,Moon:xQ,MoonStar:gQ,Mountain:vQ,MountainSnow:yQ,Mouse:jQ,MouseOff:_Q,MousePointer:Lh,MousePointer2:bQ,MousePointerBan:wQ,MousePointerClick:Lb,Move:OQ,Move3d:fk,MoveDiagonal:NQ,MoveDiagonal2:kQ,MoveDown:MQ,MoveDownLeft:SQ,MoveDownRight:CQ,MoveHorizontal:TQ,MoveLeft:AQ,MoveRight:EQ,MoveUp:LQ,MoveUpLeft:PQ,MoveUpRight:IQ,MoveVertical:DQ,Music:BQ,Music2:RQ,Music3:FQ,Music4:zQ,Navigation:VQ,Navigation2:qQ,Navigation2Off:$Q,NavigationOff:UQ,Network:HQ,Newspaper:s1,Nfc:WQ,Notebook:YQ,NotebookPen:GQ,NotebookTabs:KQ,NotebookText:ZQ,NotepadText:QQ,NotepadTextDashed:XQ,Nut:eJ,NutOff:JQ,Octagon:sJ,OctagonAlert:Tv,OctagonMinus:tJ,OctagonPause:gk,OctagonX:xk,Omega:rJ,Option:nJ,Orbit:aJ,Origami:iJ,Package:bl,Package2:oJ,PackageCheck:lJ,PackageMinus:cJ,PackageOpen:dJ,PackagePlus:uJ,PackageSearch:hJ,PackageX:mJ,PaintBucket:pJ,PaintRoller:fJ,Paintbrush:gJ,PaintbrushVertical:yk,Palette:Ql,PanelBottom:vJ,PanelBottomClose:xJ,PanelBottomDashed:vk,PanelBottomOpen:yJ,PanelLeft:jk,PanelLeftClose:_k,PanelLeftDashed:bk,PanelLeftOpen:wk,PanelRight:wJ,PanelRightClose:_J,PanelRightDashed:kk,PanelRightOpen:bJ,PanelTop:NJ,PanelTopClose:jJ,PanelTopDashed:Nk,PanelTopOpen:kJ,PanelsLeftBottom:SJ,PanelsRightBottom:CJ,PanelsTopLeft:Av,Paperclip:W4,Parentheses:MJ,ParkingMeter:TJ,PartyPopper:Zd,Pause:cf,PawPrint:AJ,PcCase:EJ,Pen:Wy,PenLine:Ev,PenOff:PJ,PenTool:Db,Pencil:$a,PencilLine:IJ,PencilOff:LJ,PencilRuler:DJ,Pentagon:OJ,Percent:_M,PersonStanding:RJ,PhilippinePeso:FJ,Phone:ea,PhoneCall:zJ,PhoneForwarded:BJ,PhoneIncoming:$J,PhoneMissed:qJ,PhoneOff:UJ,PhoneOutgoing:VJ,Pi:HJ,Piano:WJ,Pickaxe:GJ,PictureInPicture:ZJ,PictureInPicture2:KJ,PiggyBank:YJ,Pilcrow:JJ,PilcrowLeft:XJ,PilcrowRight:QJ,Pill:tee,PillBottle:eee,Pin:Ob,PinOff:QI,Pipette:see,Pizza:ree,Plane:iee,PlaneLanding:nee,PlaneTakeoff:aee,Play:wl,Plug:JI,Plug2:oee,PlugZap:Sk,Plus:Zs,Pocket:cee,PocketKnife:lee,Podcast:dee,Pointer:hee,PointerOff:uee,Popcorn:mee,Popsicle:pee,PoundSterling:fee,Power:eL,PowerOff:gee,Presentation:Gx,Printer:tL,PrinterCheck:xee,Projector:yee,Proportions:vee,Puzzle:_ee,Pyramid:bee,QrCode:r1,Quote:bM,Rabbit:wee,Radar:jee,Radiation:kee,Radical:Nee,Radio:n1,RadioReceiver:See,RadioTower:Cee,Radius:Mee,RailSymbol:Tee,Rainbow:Aee,Rat:Eee,Ratio:Pee,Receipt:$ee,ReceiptCent:Iee,ReceiptEuro:Lee,ReceiptIndianRupee:Dee,ReceiptJapaneseYen:Oee,ReceiptPoundSterling:Ree,ReceiptRussianRuble:Fee,ReceiptSwissFranc:zee,ReceiptText:Bee,RectangleEllipsis:Ck,RectangleHorizontal:qee,RectangleVertical:Uee,Recycle:Vee,Redo:wM,Redo2:Hee,RedoDot:Wee,RefreshCcw:Kee,RefreshCcwDot:Gee,RefreshCw:Bo,RefreshCwOff:Zee,Refrigerator:Yee,Regex:Xee,RemoveFormatting:Qee,Repeat:sL,Repeat1:Jee,Repeat2:ete,Replace:ste,ReplaceAll:tte,Reply:rL,ReplyAll:rte,Rewind:nte,Ribbon:ate,Rocket:o0,RockingChair:ite,RollerCoaster:ote,Rotate3d:Mk,RotateCcw:a1,RotateCcwSquare:lte,RotateCw:nL,RotateCwSquare:cte,Route:ute,RouteOff:dte,Router:hte,Rows2:Tk,Rows3:Ak,Rows4:mte,Rss:pte,Ruler:aL,RussianRuble:fte,Sailboat:gte,Salad:xte,Sandwich:yte,Satellite:_te,SatelliteDish:vte,Save:Wu,SaveAll:bte,SaveOff:wte,Scale:iL,Scale3d:Ek,Scaling:jte,Scan:Ete,ScanBarcode:kte,ScanEye:Nte,ScanFace:Ste,ScanLine:Cte,ScanQrCode:Mte,ScanSearch:Tte,ScanText:Ate,School:Pte,Scissors:Lte,ScissorsLineDashed:Ite,ScreenShare:Ote,ScreenShareOff:Dte,Scroll:Fte,ScrollText:Rte,Search:xn,SearchCheck:zte,SearchCode:Bte,SearchSlash:$te,SearchX:oL,Section:qte,Send:oa,SendHorizontal:Pk,SendToBack:Ute,SeparatorHorizontal:Vte,SeparatorVertical:Hte,Server:Zte,ServerCog:Wte,ServerCrash:Gte,ServerOff:Kte,Settings:Jl,Settings2:lL,Shapes:Yte,Share:cL,Share2:Ad,Sheet:Xte,Shell:Qte,Shield:Bh,ShieldAlert:Jte,ShieldBan:ese,ShieldCheck:dL,ShieldEllipsis:tse,ShieldHalf:sse,ShieldMinus:rse,ShieldOff:nse,ShieldPlus:ase,ShieldQuestion:ise,ShieldX:Ik,Ship:lse,ShipWheel:ose,Shirt:cse,ShoppingBag:l0,ShoppingBasket:dse,ShoppingCart:dp,Shovel:use,ShowerHead:hse,Shrink:mse,Shrub:pse,Shuffle:G4,Sigma:fse,Signal:_se,SignalHigh:gse,SignalLow:xse,SignalMedium:yse,SignalZero:vse,Signature:bse,Signpost:jse,SignpostBig:wse,Siren:kse,SkipBack:Nse,SkipForward:Sse,Skull:Cse,Slack:Mse,Slash:Tse,Slice:Ase,SlidersHorizontal:uL,SlidersVertical:Lk,Smartphone:i1,SmartphoneCharging:Ese,SmartphoneNfc:Pse,Smile:Lse,SmilePlus:Ise,Snail:Dse,Snowflake:hb,Sofa:Ose,Soup:Rse,Space:Fse,Spade:zse,Sparkle:Bse,Sparkles:hn,Speaker:$se,Speech:qse,SpellCheck:Vse,SpellCheck2:Use,Spline:Hse,Split:Wse,SprayCan:Gse,Sprout:Kse,Square:c0,SquareActivity:Dk,SquareArrowDown:Fk,SquareArrowDownLeft:Ok,SquareArrowDownRight:Rk,SquareArrowLeft:zk,SquareArrowOutDownLeft:Bk,SquareArrowOutDownRight:$k,SquareArrowOutUpLeft:qk,SquareArrowOutUpRight:Uk,SquareArrowRight:Vk,SquareArrowUp:Gk,SquareArrowUpLeft:Hk,SquareArrowUpRight:Wk,SquareAsterisk:Kk,SquareBottomDashedScissors:Zk,SquareChartGantt:Oy,SquareCheck:Yk,SquareCheckBig:Pv,SquareChevronDown:Xk,SquareChevronLeft:Qk,SquareChevronRight:Jk,SquareChevronUp:eN,SquareCode:tN,SquareDashed:nN,SquareDashedBottom:Yse,SquareDashedBottomCode:Zse,SquareDashedKanban:sN,SquareDashedMousePointer:rN,SquareDivide:aN,SquareDot:iN,SquareEqual:oN,SquareFunction:lN,SquareKanban:cN,SquareLibrary:dN,SquareM:uN,SquareMenu:hN,SquareMinus:mN,SquareMousePointer:pN,SquareParking:gN,SquareParkingOff:fN,SquarePen:rd,SquarePercent:xN,SquarePi:yN,SquarePilcrow:vN,SquarePlay:_N,SquarePlus:bN,SquarePower:wN,SquareRadical:Xse,SquareScissors:jN,SquareSigma:kN,SquareSlash:NN,SquareSplitHorizontal:SN,SquareSplitVertical:CN,SquareSquare:Qse,SquareStack:Jse,SquareTerminal:MN,SquareUser:AN,SquareUserRound:TN,SquareX:EN,Squircle:ere,Squirrel:tre,Stamp:sre,Star:Kn,StarHalf:rre,StarOff:nre,StepBack:are,StepForward:ire,Stethoscope:ore,Sticker:lre,StickyNote:cre,Store:dre,StretchHorizontal:ure,StretchVertical:hre,Strikethrough:mre,Subscript:pre,Sun:Rb,SunDim:fre,SunMedium:gre,SunMoon:xre,SunSnow:yre,Sunrise:vre,Sunset:_re,Superscript:bre,SwatchBook:wre,SwissFranc:jre,SwitchCamera:kre,Sword:Nre,Swords:Sre,Syringe:Cre,Table:hL,Table2:jM,TableCellsMerge:Mre,TableCellsSplit:Tre,TableColumnsSplit:Are,TableOfContents:Ere,TableProperties:Pre,TableRowsSplit:Ire,Tablet:Dre,TabletSmartphone:Lre,Tablets:Ore,Tag:Tm,Tags:Rre,Tally1:Fre,Tally2:zre,Tally3:Bre,Tally4:$re,Tally5:qre,Tangent:Ure,Target:Am,Telescope:Vre,Tent:Wre,TentTree:Hre,Terminal:Gre,TestTube:Kre,TestTubeDiagonal:PN,TestTubes:Zre,Text:ene,TextCursor:Xre,TextCursorInput:Yre,TextQuote:Qre,TextSearch:Jre,TextSelect:IN,Theater:tne,Thermometer:nne,ThermometerSnowflake:sne,ThermometerSun:rne,ThumbsDown:mL,ThumbsUp:Gu,Ticket:pL,TicketCheck:ane,TicketMinus:ine,TicketPercent:one,TicketPlus:lne,TicketSlash:cne,TicketX:dne,Tickets:hne,TicketsPlane:une,Timer:fne,TimerOff:mne,TimerReset:pne,ToggleLeft:gne,ToggleRight:xne,Toilet:yne,Tornado:vne,Torus:_ne,Touchpad:wne,TouchpadOff:bne,TowerControl:jne,ToyBrick:kne,Tractor:Nne,TrafficCone:Sne,TrainFront:Mne,TrainFrontTunnel:Cne,TrainTrack:Tne,TramFront:LN,Trash:Ane,Trash2:jr,TreeDeciduous:Ene,TreePalm:DN,TreePine:Fb,Trees:Pne,Trello:Ine,TrendingDown:K4,TrendingUp:xc,TrendingUpDown:Lne,Triangle:One,TriangleAlert:uh,TriangleRight:Dne,Trophy:mo,Truck:fL,Turtle:Rne,Tv:zne,TvMinimal:ON,TvMinimalPlay:Fne,Twitch:Bne,Twitter:$ne,Type:Une,TypeOutline:qne,Umbrella:Hne,UmbrellaOff:Vne,Underline:Wne,Undo:kM,Undo2:Gne,UndoDot:Kne,UnfoldHorizontal:Zne,UnfoldVertical:Yne,Ungroup:Xne,University:RN,Unlink:Z4,Unlink2:Qne,Unplug:Jne,Upload:ni,Usb:eae,User:ro,UserCheck:zb,UserCog:gL,UserMinus:xL,UserPen:tae,UserPlus:Pc,UserRound:UN,UserRoundCheck:FN,UserRoundCog:zN,UserRoundMinus:BN,UserRoundPen:sae,UserRoundPlus:$N,UserRoundSearch:rae,UserRoundX:qN,UserSearch:nae,UserX:aae,Users:mr,UsersRound:VN,Utensils:WN,UtensilsCrossed:HN,UtilityPole:iae,Variable:yL,Vault:oae,Vegan:lae,VenetianMask:cae,Vibrate:uae,VibrateOff:dae,Video:Nn,VideoOff:hae,Videotape:mae,View:pae,Voicemail:fae,Volleyball:gae,Volume:bae,Volume1:xae,Volume2:yae,VolumeOff:vae,VolumeX:_ae,Vote:wae,Wallet:vL,WalletCards:jae,WalletMinimal:GN,Wallpaper:kae,Wand:Nae,WandSparkles:Iv,Warehouse:Sae,WashingMachine:Cae,Watch:Mae,Waves:Tae,Waypoints:Aae,Webcam:Eae,Webhook:Iae,WebhookOff:Pae,Weight:Lae,Wheat:Oae,WheatOff:Dae,WholeWord:Rae,Wifi:qae,WifiHigh:Fae,WifiLow:zae,WifiOff:Bae,WifiZero:$ae,Wind:Vae,WindArrowDown:Uae,Wine:Wae,WineOff:Hae,Workflow:Gae,Worm:Kae,WrapText:Zae,Wrench:Kx,X:Ur,Youtube:Yae,Zap:wp,ZapOff:Xae,ZoomIn:Bb,ZoomOut:NM},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 nwe=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:Xz,AArrowDownIcon:Xz,AArrowUp:Qz,AArrowUpIcon:Qz,ALargeSmall:Jz,ALargeSmallIcon:Jz,Accessibility:e9,AccessibilityIcon:e9,Activity:gp,ActivityIcon:gp,ActivitySquare:Dk,ActivitySquareIcon:Dk,AirVent:t9,AirVentIcon:t9,Airplay:s9,AirplayIcon:s9,AlarmCheck:Fw,AlarmCheckIcon:Fw,AlarmClock:n9,AlarmClockCheck:Fw,AlarmClockCheckIcon:Fw,AlarmClockIcon:n9,AlarmClockMinus:zw,AlarmClockMinusIcon:zw,AlarmClockOff:r9,AlarmClockOffIcon:r9,AlarmClockPlus:Bw,AlarmClockPlusIcon:Bw,AlarmMinus:zw,AlarmMinusIcon:zw,AlarmPlus:Bw,AlarmPlusIcon:Bw,AlarmSmoke:a9,AlarmSmokeIcon:a9,Album:i9,AlbumIcon:i9,AlertCircle:yl,AlertCircleIcon:yl,AlertOctagon:Tv,AlertOctagonIcon:Tv,AlertTriangle:uh,AlertTriangleIcon:uh,AlignCenter:sM,AlignCenterHorizontal:o9,AlignCenterHorizontalIcon:o9,AlignCenterIcon:sM,AlignCenterVertical:l9,AlignCenterVerticalIcon:l9,AlignEndHorizontal:c9,AlignEndHorizontalIcon:c9,AlignEndVertical:d9,AlignEndVerticalIcon:d9,AlignHorizontalDistributeCenter:u9,AlignHorizontalDistributeCenterIcon:u9,AlignHorizontalDistributeEnd:h9,AlignHorizontalDistributeEndIcon:h9,AlignHorizontalDistributeStart:m9,AlignHorizontalDistributeStartIcon:m9,AlignHorizontalJustifyCenter:p9,AlignHorizontalJustifyCenterIcon:p9,AlignHorizontalJustifyEnd:f9,AlignHorizontalJustifyEndIcon:f9,AlignHorizontalJustifyStart:g9,AlignHorizontalJustifyStartIcon:g9,AlignHorizontalSpaceAround:x9,AlignHorizontalSpaceAroundIcon:x9,AlignHorizontalSpaceBetween:y9,AlignHorizontalSpaceBetweenIcon:y9,AlignJustify:v9,AlignJustifyIcon:v9,AlignLeft:rM,AlignLeftIcon:rM,AlignRight:nM,AlignRightIcon:nM,AlignStartHorizontal:_9,AlignStartHorizontalIcon:_9,AlignStartVertical:b9,AlignStartVerticalIcon:b9,AlignVerticalDistributeCenter:w9,AlignVerticalDistributeCenterIcon:w9,AlignVerticalDistributeEnd:j9,AlignVerticalDistributeEndIcon:j9,AlignVerticalDistributeStart:k9,AlignVerticalDistributeStartIcon:k9,AlignVerticalJustifyCenter:N9,AlignVerticalJustifyCenterIcon:N9,AlignVerticalJustifyEnd:S9,AlignVerticalJustifyEndIcon:S9,AlignVerticalJustifyStart:C9,AlignVerticalJustifyStartIcon:C9,AlignVerticalSpaceAround:M9,AlignVerticalSpaceAroundIcon:M9,AlignVerticalSpaceBetween:T9,AlignVerticalSpaceBetweenIcon:T9,Ambulance:A9,AmbulanceIcon:A9,Ampersand:E9,AmpersandIcon:E9,Ampersands:P9,AmpersandsIcon:P9,Amphora:I9,AmphoraIcon:I9,Anchor:L9,AnchorIcon:L9,Angry:D9,AngryIcon:D9,Annoyed:O9,AnnoyedIcon:O9,Antenna:R9,AntennaIcon:R9,Anvil:F9,AnvilIcon:F9,Aperture:z9,ApertureIcon:z9,AppWindow:NI,AppWindowIcon:NI,AppWindowMac:B9,AppWindowMacIcon:B9,Apple:$9,AppleIcon:$9,Archive:aM,ArchiveIcon:aM,ArchiveRestore:SI,ArchiveRestoreIcon:SI,ArchiveX:q9,ArchiveXIcon:q9,AreaChart:ej,AreaChartIcon:ej,Armchair:U9,ArmchairIcon:U9,ArrowBigDown:H9,ArrowBigDownDash:V9,ArrowBigDownDashIcon:V9,ArrowBigDownIcon:H9,ArrowBigLeft:G9,ArrowBigLeftDash:W9,ArrowBigLeftDashIcon:W9,ArrowBigLeftIcon:G9,ArrowBigRight:Z9,ArrowBigRightDash:K9,ArrowBigRightDashIcon:K9,ArrowBigRightIcon:Z9,ArrowBigUp:X9,ArrowBigUpDash:Y9,ArrowBigUpDashIcon:Y9,ArrowBigUpIcon:X9,ArrowDown:Oh,ArrowDown01:Q9,ArrowDown01Icon:Q9,ArrowDown10:J9,ArrowDown10Icon:J9,ArrowDownAZ:$w,ArrowDownAZIcon:$w,ArrowDownAz:$w,ArrowDownAzIcon:$w,ArrowDownCircle:hj,ArrowDownCircleIcon:hj,ArrowDownFromLine:eB,ArrowDownFromLineIcon:eB,ArrowDownIcon:Oh,ArrowDownLeft:tB,ArrowDownLeftFromCircle:pj,ArrowDownLeftFromCircleIcon:pj,ArrowDownLeftFromSquare:Bk,ArrowDownLeftFromSquareIcon:Bk,ArrowDownLeftIcon:tB,ArrowDownLeftSquare:Ok,ArrowDownLeftSquareIcon:Ok,ArrowDownNarrowWide:sB,ArrowDownNarrowWideIcon:sB,ArrowDownRight:CI,ArrowDownRightFromCircle:fj,ArrowDownRightFromCircleIcon:fj,ArrowDownRightFromSquare:$k,ArrowDownRightFromSquareIcon:$k,ArrowDownRightIcon:CI,ArrowDownRightSquare:Rk,ArrowDownRightSquareIcon:Rk,ArrowDownSquare:Fk,ArrowDownSquareIcon:Fk,ArrowDownToDot:rB,ArrowDownToDotIcon:rB,ArrowDownToLine:nB,ArrowDownToLineIcon:nB,ArrowDownUp:aB,ArrowDownUpIcon:aB,ArrowDownWideNarrow:qw,ArrowDownWideNarrowIcon:qw,ArrowDownZA:Uw,ArrowDownZAIcon:Uw,ArrowDownZa:Uw,ArrowDownZaIcon:Uw,ArrowLeft:di,ArrowLeftCircle:mj,ArrowLeftCircleIcon:mj,ArrowLeftFromLine:iB,ArrowLeftFromLineIcon:iB,ArrowLeftIcon:di,ArrowLeftRight:oB,ArrowLeftRightIcon:oB,ArrowLeftSquare:zk,ArrowLeftSquareIcon:zk,ArrowLeftToLine:lB,ArrowLeftToLineIcon:lB,ArrowRight:Ki,ArrowRightCircle:yj,ArrowRightCircleIcon:yj,ArrowRightFromLine:cB,ArrowRightFromLineIcon:cB,ArrowRightIcon:Ki,ArrowRightLeft:Gv,ArrowRightLeftIcon:Gv,ArrowRightSquare:Vk,ArrowRightSquareIcon:Vk,ArrowRightToLine:dB,ArrowRightToLineIcon:dB,ArrowUp:gu,ArrowUp01:uB,ArrowUp01Icon:uB,ArrowUp10:hB,ArrowUp10Icon:hB,ArrowUpAZ:Vw,ArrowUpAZIcon:Vw,ArrowUpAz:Vw,ArrowUpAzIcon:Vw,ArrowUpCircle:vj,ArrowUpCircleIcon:vj,ArrowUpDown:ud,ArrowUpDownIcon:ud,ArrowUpFromDot:mB,ArrowUpFromDotIcon:mB,ArrowUpFromLine:pB,ArrowUpFromLineIcon:pB,ArrowUpIcon:gu,ArrowUpLeft:fB,ArrowUpLeftFromCircle:gj,ArrowUpLeftFromCircleIcon:gj,ArrowUpLeftFromSquare:qk,ArrowUpLeftFromSquareIcon:qk,ArrowUpLeftIcon:fB,ArrowUpLeftSquare:Hk,ArrowUpLeftSquareIcon:Hk,ArrowUpNarrowWide:Hw,ArrowUpNarrowWideIcon:Hw,ArrowUpRight:MI,ArrowUpRightFromCircle:xj,ArrowUpRightFromCircleIcon:xj,ArrowUpRightFromSquare:Uk,ArrowUpRightFromSquareIcon:Uk,ArrowUpRightIcon:MI,ArrowUpRightSquare:Wk,ArrowUpRightSquareIcon:Wk,ArrowUpSquare:Gk,ArrowUpSquareIcon:Gk,ArrowUpToLine:gB,ArrowUpToLineIcon:gB,ArrowUpWideNarrow:xB,ArrowUpWideNarrowIcon:xB,ArrowUpZA:Ww,ArrowUpZAIcon:Ww,ArrowUpZa:Ww,ArrowUpZaIcon:Ww,ArrowsUpFromLine:yB,ArrowsUpFromLineIcon:yB,Asterisk:vB,AsteriskIcon:vB,AsteriskSquare:Kk,AsteriskSquareIcon:Kk,AtSign:_B,AtSignIcon:_B,Atom:bB,AtomIcon:bB,AudioLines:wB,AudioLinesIcon:wB,AudioWaveform:jB,AudioWaveformIcon:jB,Award:fc,AwardIcon:fc,Axe:kB,AxeIcon:kB,Axis3D:Gw,Axis3DIcon:Gw,Axis3d:Gw,Axis3dIcon:Gw,Baby:NB,BabyIcon:NB,Backpack:SB,BackpackIcon:SB,Badge:qB,BadgeAlert:CB,BadgeAlertIcon:CB,BadgeCent:MB,BadgeCentIcon:MB,BadgeCheck:Kw,BadgeCheckIcon:Kw,BadgeDollarSign:TB,BadgeDollarSignIcon:TB,BadgeEuro:AB,BadgeEuroIcon:AB,BadgeHelp:EB,BadgeHelpIcon:EB,BadgeIcon:qB,BadgeIndianRupee:PB,BadgeIndianRupeeIcon:PB,BadgeInfo:IB,BadgeInfoIcon:IB,BadgeJapaneseYen:LB,BadgeJapaneseYenIcon:LB,BadgeMinus:DB,BadgeMinusIcon:DB,BadgePercent:OB,BadgePercentIcon:OB,BadgePlus:RB,BadgePlusIcon:RB,BadgePoundSterling:FB,BadgePoundSterlingIcon:FB,BadgeRussianRuble:zB,BadgeRussianRubleIcon:zB,BadgeSwissFranc:BB,BadgeSwissFrancIcon:BB,BadgeX:$B,BadgeXIcon:$B,BaggageClaim:UB,BaggageClaimIcon:UB,Ban:TI,BanIcon:TI,Banana:VB,BananaIcon:VB,Bandage:HB,BandageIcon:HB,Banknote:WB,BanknoteIcon:WB,BarChart:oj,BarChart2:lj,BarChart2Icon:lj,BarChart3:xl,BarChart3Icon:xl,BarChart4:aj,BarChart4Icon:aj,BarChartBig:nj,BarChartBigIcon:nj,BarChartHorizontal:sj,BarChartHorizontalBig:tj,BarChartHorizontalBigIcon:tj,BarChartHorizontalIcon:sj,BarChartIcon:oj,Barcode:GB,BarcodeIcon:GB,Baseline:KB,BaselineIcon:KB,Bath:n0,BathIcon:n0,Battery:e$,BatteryCharging:ZB,BatteryChargingIcon:ZB,BatteryFull:YB,BatteryFullIcon:YB,BatteryIcon:e$,BatteryLow:XB,BatteryLowIcon:XB,BatteryMedium:QB,BatteryMediumIcon:QB,BatteryWarning:JB,BatteryWarningIcon:JB,Beaker:t$,BeakerIcon:t$,Bean:r$,BeanIcon:r$,BeanOff:s$,BeanOffIcon:s$,Bed:Kv,BedDouble:AI,BedDoubleIcon:AI,BedIcon:Kv,BedSingle:n$,BedSingleIcon:n$,Beef:a$,BeefIcon:a$,Beer:o$,BeerIcon:o$,BeerOff:i$,BeerOffIcon:i$,Bell:gg,BellDot:l$,BellDotIcon:l$,BellElectric:c$,BellElectricIcon:c$,BellIcon:gg,BellMinus:d$,BellMinusIcon:d$,BellOff:Mb,BellOffIcon:Mb,BellPlus:u$,BellPlusIcon:u$,BellRing:h$,BellRingIcon:h$,BetweenHorizonalEnd:Zw,BetweenHorizonalEndIcon:Zw,BetweenHorizonalStart:Yw,BetweenHorizonalStartIcon:Yw,BetweenHorizontalEnd:Zw,BetweenHorizontalEndIcon:Zw,BetweenHorizontalStart:Yw,BetweenHorizontalStartIcon:Yw,BetweenVerticalEnd:m$,BetweenVerticalEndIcon:m$,BetweenVerticalStart:p$,BetweenVerticalStartIcon:p$,BicepsFlexed:f$,BicepsFlexedIcon:f$,Bike:g$,BikeIcon:g$,Binary:x$,BinaryIcon:x$,Binoculars:y$,BinocularsIcon:y$,Biohazard:v$,BiohazardIcon:v$,Bird:_$,BirdIcon:_$,Bitcoin:b$,BitcoinIcon:b$,Blend:w$,BlendIcon:w$,Blinds:j$,BlindsIcon:j$,Blocks:k$,BlocksIcon:k$,Bluetooth:M$,BluetoothConnected:N$,BluetoothConnectedIcon:N$,BluetoothIcon:M$,BluetoothOff:S$,BluetoothOffIcon:S$,BluetoothSearching:C$,BluetoothSearchingIcon:C$,Bold:iM,BoldIcon:iM,Bolt:T$,BoltIcon:T$,Bomb:A$,BombIcon:A$,Bone:E$,BoneIcon:E$,Book:J$,BookA:P$,BookAIcon:P$,BookAudio:I$,BookAudioIcon:I$,BookCheck:L$,BookCheckIcon:L$,BookCopy:D$,BookCopyIcon:D$,BookDashed:Xw,BookDashedIcon:Xw,BookDown:O$,BookDownIcon:O$,BookHeadphones:R$,BookHeadphonesIcon:R$,BookHeart:F$,BookHeartIcon:F$,BookIcon:J$,BookImage:z$,BookImageIcon:z$,BookKey:B$,BookKeyIcon:B$,BookLock:$$,BookLockIcon:$$,BookMarked:q$,BookMarkedIcon:q$,BookMinus:U$,BookMinusIcon:U$,BookOpen:gh,BookOpenCheck:V$,BookOpenCheckIcon:V$,BookOpenIcon:gh,BookOpenText:H$,BookOpenTextIcon:H$,BookPlus:W$,BookPlusIcon:W$,BookTemplate:Xw,BookTemplateIcon:Xw,BookText:G$,BookTextIcon:G$,BookType:K$,BookTypeIcon:K$,BookUp:Y$,BookUp2:Z$,BookUp2Icon:Z$,BookUpIcon:Y$,BookUser:X$,BookUserIcon:X$,BookX:Q$,BookXIcon:Q$,Bookmark:Ux,BookmarkCheck:eq,BookmarkCheckIcon:eq,BookmarkIcon:Ux,BookmarkMinus:tq,BookmarkMinusIcon:tq,BookmarkPlus:EI,BookmarkPlusIcon:EI,BookmarkX:sq,BookmarkXIcon:sq,BoomBox:rq,BoomBoxIcon:rq,Bot:oM,BotIcon:oM,BotMessageSquare:nq,BotMessageSquareIcon:nq,BotOff:aq,BotOffIcon:aq,Box:iq,BoxIcon:iq,BoxSelect:nN,BoxSelectIcon:nN,Boxes:oq,BoxesIcon:oq,Braces:Qw,BracesIcon:Qw,Brackets:lq,BracketsIcon:lq,Brain:PI,BrainCircuit:cq,BrainCircuitIcon:cq,BrainCog:dq,BrainCogIcon:dq,BrainIcon:PI,BrickWall:uq,BrickWallIcon:uq,Briefcase:Rh,BriefcaseBusiness:hq,BriefcaseBusinessIcon:hq,BriefcaseConveyorBelt:mq,BriefcaseConveyorBeltIcon:mq,BriefcaseIcon:Rh,BriefcaseMedical:pq,BriefcaseMedicalIcon:pq,BringToFront:fq,BringToFrontIcon:fq,Brush:gq,BrushIcon:gq,Bug:vq,BugIcon:vq,BugOff:xq,BugOffIcon:xq,BugPlay:yq,BugPlayIcon:yq,Building:R4,Building2:La,Building2Icon:La,BuildingIcon:R4,Bus:bq,BusFront:_q,BusFrontIcon:_q,BusIcon:bq,Cable:jq,CableCar:wq,CableCarIcon:wq,CableIcon:jq,Cake:xh,CakeIcon:xh,CakeSlice:kq,CakeSliceIcon:kq,Calculator:Nq,CalculatorIcon:Nq,Calendar:on,Calendar1:Sq,Calendar1Icon:Sq,CalendarArrowDown:Cq,CalendarArrowDownIcon:Cq,CalendarArrowUp:Mq,CalendarArrowUpIcon:Mq,CalendarCheck:II,CalendarCheck2:Tq,CalendarCheck2Icon:Tq,CalendarCheckIcon:II,CalendarClock:LI,CalendarClockIcon:LI,CalendarCog:Aq,CalendarCogIcon:Aq,CalendarDays:Md,CalendarDaysIcon:Md,CalendarFold:Eq,CalendarFoldIcon:Eq,CalendarHeart:Pq,CalendarHeartIcon:Pq,CalendarIcon:on,CalendarMinus:Lq,CalendarMinus2:Iq,CalendarMinus2Icon:Iq,CalendarMinusIcon:Lq,CalendarOff:DI,CalendarOffIcon:DI,CalendarPlus:Tb,CalendarPlus2:Dq,CalendarPlus2Icon:Dq,CalendarPlusIcon:Tb,CalendarRange:Oq,CalendarRangeIcon:Oq,CalendarSearch:Rq,CalendarSearchIcon:Rq,CalendarSync:Fq,CalendarSyncIcon:Fq,CalendarX:Bq,CalendarX2:zq,CalendarX2Icon:zq,CalendarXIcon:Bq,Camera:Vx,CameraIcon:Vx,CameraOff:$q,CameraOffIcon:$q,CandlestickChart:rj,CandlestickChartIcon:rj,Candy:Vq,CandyCane:qq,CandyCaneIcon:qq,CandyIcon:Vq,CandyOff:Uq,CandyOffIcon:Uq,Cannabis:Hq,CannabisIcon:Hq,Captions:Jw,CaptionsIcon:Jw,CaptionsOff:Wq,CaptionsOffIcon:Wq,Car:Zq,CarFront:Gq,CarFrontIcon:Gq,CarIcon:Zq,CarTaxiFront:Kq,CarTaxiFrontIcon:Kq,Caravan:Yq,CaravanIcon:Yq,Carrot:Xq,CarrotIcon:Xq,CaseLower:Qq,CaseLowerIcon:Qq,CaseSensitive:Jq,CaseSensitiveIcon:Jq,CaseUpper:eU,CaseUpperIcon:eU,CassetteTape:tU,CassetteTapeIcon:tU,Cast:sU,CastIcon:sU,Castle:rU,CastleIcon:rU,Cat:nU,CatIcon:nU,Cctv:aU,CctvIcon:aU,ChartArea:ej,ChartAreaIcon:ej,ChartBar:sj,ChartBarBig:tj,ChartBarBigIcon:tj,ChartBarDecreasing:iU,ChartBarDecreasingIcon:iU,ChartBarIcon:sj,ChartBarIncreasing:oU,ChartBarIncreasingIcon:oU,ChartBarStacked:lU,ChartBarStackedIcon:lU,ChartCandlestick:rj,ChartCandlestickIcon:rj,ChartColumn:xl,ChartColumnBig:nj,ChartColumnBigIcon:nj,ChartColumnDecreasing:cU,ChartColumnDecreasingIcon:cU,ChartColumnIcon:xl,ChartColumnIncreasing:aj,ChartColumnIncreasingIcon:aj,ChartColumnStacked:dU,ChartColumnStackedIcon:dU,ChartGantt:uU,ChartGanttIcon:uU,ChartLine:ij,ChartLineIcon:ij,ChartNetwork:hU,ChartNetworkIcon:hU,ChartNoAxesColumn:lj,ChartNoAxesColumnDecreasing:mU,ChartNoAxesColumnDecreasingIcon:mU,ChartNoAxesColumnIcon:lj,ChartNoAxesColumnIncreasing:oj,ChartNoAxesColumnIncreasingIcon:oj,ChartNoAxesCombined:pU,ChartNoAxesCombinedIcon:pU,ChartNoAxesGantt:cj,ChartNoAxesGanttIcon:cj,ChartPie:dj,ChartPieIcon:dj,ChartScatter:uj,ChartScatterIcon:uj,ChartSpline:fU,ChartSplineIcon:fU,Check:ma,CheckCheck:gU,CheckCheckIcon:gU,CheckCircle:vi,CheckCircle2:ha,CheckCircle2Icon:ha,CheckCircleIcon:vi,CheckIcon:ma,CheckSquare:Pv,CheckSquare2:Yk,CheckSquare2Icon:Yk,CheckSquareIcon:Pv,ChefHat:xU,ChefHatIcon:xU,Cherry:yU,CherryIcon:yU,ChevronDown:tl,ChevronDownCircle:_j,ChevronDownCircleIcon:_j,ChevronDownIcon:tl,ChevronDownSquare:Xk,ChevronDownSquareIcon:Xk,ChevronFirst:vU,ChevronFirstIcon:vU,ChevronLast:_U,ChevronLastIcon:_U,ChevronLeft:Xl,ChevronLeftCircle:bj,ChevronLeftCircleIcon:bj,ChevronLeftIcon:Xl,ChevronLeftSquare:Qk,ChevronLeftSquareIcon:Qk,ChevronRight:Xa,ChevronRightCircle:wj,ChevronRightCircleIcon:wj,ChevronRightIcon:Xa,ChevronRightSquare:Jk,ChevronRightSquareIcon:Jk,ChevronUp:Hx,ChevronUpCircle:jj,ChevronUpCircleIcon:jj,ChevronUpIcon:Hx,ChevronUpSquare:eN,ChevronUpSquareIcon:eN,ChevronsDown:wU,ChevronsDownIcon:wU,ChevronsDownUp:bU,ChevronsDownUpIcon:bU,ChevronsLeft:NU,ChevronsLeftIcon:NU,ChevronsLeftRight:kU,ChevronsLeftRightEllipsis:jU,ChevronsLeftRightEllipsisIcon:jU,ChevronsLeftRightIcon:kU,ChevronsRight:CU,ChevronsRightIcon:CU,ChevronsRightLeft:SU,ChevronsRightLeftIcon:SU,ChevronsUp:MU,ChevronsUpDown:xg,ChevronsUpDownIcon:xg,ChevronsUpIcon:MU,Chrome:TU,ChromeIcon:TU,Church:AU,ChurchIcon:AU,Cigarette:PU,CigaretteIcon:PU,CigaretteOff:EU,CigaretteOffIcon:EU,Circle:pd,CircleAlert:yl,CircleAlertIcon:yl,CircleArrowDown:hj,CircleArrowDownIcon:hj,CircleArrowLeft:mj,CircleArrowLeftIcon:mj,CircleArrowOutDownLeft:pj,CircleArrowOutDownLeftIcon:pj,CircleArrowOutDownRight:fj,CircleArrowOutDownRightIcon:fj,CircleArrowOutUpLeft:gj,CircleArrowOutUpLeftIcon:gj,CircleArrowOutUpRight:xj,CircleArrowOutUpRightIcon:xj,CircleArrowRight:yj,CircleArrowRightIcon:yj,CircleArrowUp:vj,CircleArrowUpIcon:vj,CircleCheck:ha,CircleCheckBig:vi,CircleCheckBigIcon:vi,CircleCheckIcon:ha,CircleChevronDown:_j,CircleChevronDownIcon:_j,CircleChevronLeft:bj,CircleChevronLeftIcon:bj,CircleChevronRight:wj,CircleChevronRightIcon:wj,CircleChevronUp:jj,CircleChevronUpIcon:jj,CircleDashed:IU,CircleDashedIcon:IU,CircleDivide:kj,CircleDivideIcon:kj,CircleDollarSign:LU,CircleDollarSignIcon:LU,CircleDot:OU,CircleDotDashed:DU,CircleDotDashedIcon:DU,CircleDotIcon:OU,CircleEllipsis:RU,CircleEllipsisIcon:RU,CircleEqual:FU,CircleEqualIcon:FU,CircleFadingArrowUp:zU,CircleFadingArrowUpIcon:zU,CircleFadingPlus:BU,CircleFadingPlusIcon:BU,CircleGauge:Nj,CircleGaugeIcon:Nj,CircleHelp:Mv,CircleHelpIcon:Mv,CircleIcon:pd,CircleMinus:Sj,CircleMinusIcon:Sj,CircleOff:$U,CircleOffIcon:$U,CircleParking:Mj,CircleParkingIcon:Mj,CircleParkingOff:Cj,CircleParkingOffIcon:Cj,CirclePause:Tj,CirclePauseIcon:Tj,CirclePercent:Aj,CirclePercentIcon:Aj,CirclePlay:ap,CirclePlayIcon:ap,CirclePlus:Ej,CirclePlusIcon:Ej,CirclePower:Pj,CirclePowerIcon:Pj,CircleSlash:qU,CircleSlash2:Ij,CircleSlash2Icon:Ij,CircleSlashIcon:qU,CircleSlashed:Ij,CircleSlashedIcon:Ij,CircleStop:Lj,CircleStopIcon:Lj,CircleUser:Oj,CircleUserIcon:Oj,CircleUserRound:Dj,CircleUserRoundIcon:Dj,CircleX:$c,CircleXIcon:$c,CircuitBoard:UU,CircuitBoardIcon:UU,Citrus:VU,CitrusIcon:VU,Clapperboard:HU,ClapperboardIcon:HU,Clipboard:QU,ClipboardCheck:lM,ClipboardCheckIcon:lM,ClipboardCopy:WU,ClipboardCopyIcon:WU,ClipboardEdit:Fj,ClipboardEditIcon:Fj,ClipboardIcon:QU,ClipboardList:Ab,ClipboardListIcon:Ab,ClipboardMinus:GU,ClipboardMinusIcon:GU,ClipboardPaste:KU,ClipboardPasteIcon:KU,ClipboardPen:Fj,ClipboardPenIcon:Fj,ClipboardPenLine:Rj,ClipboardPenLineIcon:Rj,ClipboardPlus:ZU,ClipboardPlusIcon:ZU,ClipboardSignature:Rj,ClipboardSignatureIcon:Rj,ClipboardType:YU,ClipboardTypeIcon:YU,ClipboardX:XU,ClipboardXIcon:XU,Clock:Tn,Clock1:JU,Clock10:eV,Clock10Icon:eV,Clock11:tV,Clock11Icon:tV,Clock12:sV,Clock12Icon:sV,Clock1Icon:JU,Clock2:rV,Clock2Icon:rV,Clock3:nV,Clock3Icon:nV,Clock4:aV,Clock4Icon:aV,Clock5:iV,Clock5Icon:iV,Clock6:oV,Clock6Icon:oV,Clock7:lV,Clock7Icon:lV,Clock8:cV,Clock8Icon:cV,Clock9:dV,Clock9Icon:dV,ClockAlert:uV,ClockAlertIcon:uV,ClockArrowDown:hV,ClockArrowDownIcon:hV,ClockArrowUp:mV,ClockArrowUpIcon:mV,ClockIcon:Tn,Cloud:MV,CloudAlert:pV,CloudAlertIcon:pV,CloudCog:fV,CloudCogIcon:fV,CloudDownload:zj,CloudDownloadIcon:zj,CloudDrizzle:gV,CloudDrizzleIcon:gV,CloudFog:xV,CloudFogIcon:xV,CloudHail:yV,CloudHailIcon:yV,CloudIcon:MV,CloudLightning:vV,CloudLightningIcon:vV,CloudMoon:bV,CloudMoonIcon:bV,CloudMoonRain:_V,CloudMoonRainIcon:_V,CloudOff:wV,CloudOffIcon:wV,CloudRain:kV,CloudRainIcon:kV,CloudRainWind:jV,CloudRainWindIcon:jV,CloudSnow:NV,CloudSnowIcon:NV,CloudSun:CV,CloudSunIcon:CV,CloudSunRain:SV,CloudSunRainIcon:SV,CloudUpload:Bj,CloudUploadIcon:Bj,Cloudy:TV,CloudyIcon:TV,Clover:$v,CloverIcon:$v,Club:AV,ClubIcon:AV,Code:F4,Code2:$j,Code2Icon:$j,CodeIcon:F4,CodeSquare:tN,CodeSquareIcon:tN,CodeXml:$j,CodeXmlIcon:$j,Codepen:EV,CodepenIcon:EV,Codesandbox:PV,CodesandboxIcon:PV,Coffee:z4,CoffeeIcon:z4,Cog:IV,CogIcon:IV,Coins:OI,CoinsIcon:OI,Columns:qj,Columns2:qj,Columns2Icon:qj,Columns3:Uj,Columns3Icon:Uj,Columns4:LV,Columns4Icon:LV,ColumnsIcon:qj,Combine:DV,CombineIcon:DV,Command:OV,CommandIcon:OV,Compass:RV,CompassIcon:RV,Component:FV,ComponentIcon:FV,Computer:zV,ComputerIcon:zV,ConciergeBell:BV,ConciergeBellIcon:BV,Cone:$V,ConeIcon:$V,Construction:qV,ConstructionIcon:qV,Contact:B4,Contact2:Vj,Contact2Icon:Vj,ContactIcon:B4,ContactRound:Vj,ContactRoundIcon:Vj,Container:UV,ContainerIcon:UV,Contrast:VV,ContrastIcon:VV,Cookie:HV,CookieIcon:HV,CookingPot:WV,CookingPotIcon:WV,Copy:mi,CopyCheck:GV,CopyCheckIcon:GV,CopyIcon:mi,CopyMinus:KV,CopyMinusIcon:KV,CopyPlus:ZV,CopyPlusIcon:ZV,CopySlash:YV,CopySlashIcon:YV,CopyX:XV,CopyXIcon:XV,Copyleft:QV,CopyleftIcon:QV,Copyright:JV,CopyrightIcon:JV,CornerDownLeft:eH,CornerDownLeftIcon:eH,CornerDownRight:tH,CornerDownRightIcon:tH,CornerLeftDown:sH,CornerLeftDownIcon:sH,CornerLeftUp:rH,CornerLeftUpIcon:rH,CornerRightDown:nH,CornerRightDownIcon:nH,CornerRightUp:aH,CornerRightUpIcon:aH,CornerUpLeft:iH,CornerUpLeftIcon:iH,CornerUpRight:oH,CornerUpRightIcon:oH,Cpu:lH,CpuIcon:lH,CreativeCommons:cH,CreativeCommonsIcon:cH,CreditCard:yg,CreditCardIcon:yg,Croissant:dH,CroissantIcon:dH,Crop:uH,CropIcon:uH,Cross:hH,CrossIcon:hH,Crosshair:mH,CrosshairIcon:mH,Crown:Sm,CrownIcon:Sm,Cuboid:pH,CuboidIcon:pH,CupSoda:fH,CupSodaIcon:fH,CurlyBraces:Qw,CurlyBracesIcon:Qw,Currency:gH,CurrencyIcon:gH,Cylinder:xH,CylinderIcon:xH,Dam:yH,DamIcon:yH,Database:bH,DatabaseBackup:vH,DatabaseBackupIcon:vH,DatabaseIcon:bH,DatabaseZap:_H,DatabaseZapIcon:_H,Delete:wH,DeleteIcon:wH,Dessert:jH,DessertIcon:jH,Diameter:kH,DiameterIcon:kH,Diamond:CH,DiamondIcon:CH,DiamondMinus:NH,DiamondMinusIcon:NH,DiamondPercent:Hj,DiamondPercentIcon:Hj,DiamondPlus:SH,DiamondPlusIcon:SH,Dice1:MH,Dice1Icon:MH,Dice2:TH,Dice2Icon:TH,Dice3:AH,Dice3Icon:AH,Dice4:EH,Dice4Icon:EH,Dice5:PH,Dice5Icon:PH,Dice6:IH,Dice6Icon:IH,Dices:LH,DicesIcon:LH,Diff:DH,DiffIcon:DH,Disc:zH,Disc2:OH,Disc2Icon:OH,Disc3:RH,Disc3Icon:RH,DiscAlbum:FH,DiscAlbumIcon:FH,DiscIcon:zH,Divide:BH,DivideCircle:kj,DivideCircleIcon:kj,DivideIcon:BH,DivideSquare:aN,DivideSquareIcon:aN,Dna:qH,DnaIcon:qH,DnaOff:$H,DnaOffIcon:$H,Dock:UH,DockIcon:UH,Dog:VH,DogIcon:VH,DollarSign:Td,DollarSignIcon:Td,Donut:HH,DonutIcon:HH,DoorClosed:WH,DoorClosedIcon:WH,DoorOpen:Zv,DoorOpenIcon:Zv,Dot:GH,DotIcon:GH,DotSquare:iN,DotSquareIcon:iN,Download:ki,DownloadCloud:zj,DownloadCloudIcon:zj,DownloadIcon:ki,DraftingCompass:KH,DraftingCompassIcon:KH,Drama:ZH,DramaIcon:ZH,Dribbble:YH,DribbbleIcon:YH,Drill:XH,DrillIcon:XH,Droplet:QH,DropletIcon:QH,Droplets:Wx,DropletsIcon:Wx,Drum:JH,DrumIcon:JH,Drumstick:eW,DrumstickIcon:eW,Dumbbell:tW,DumbbellIcon:tW,Ear:rW,EarIcon:rW,EarOff:sW,EarOffIcon:sW,Earth:Wj,EarthIcon:Wj,EarthLock:nW,EarthLockIcon:nW,Eclipse:aW,EclipseIcon:aW,Edit:rd,Edit2:Wy,Edit2Icon:Wy,Edit3:Ev,Edit3Icon:Ev,EditIcon:rd,Egg:cM,EggFried:iW,EggFriedIcon:iW,EggIcon:cM,EggOff:oW,EggOffIcon:oW,Ellipsis:ig,EllipsisIcon:ig,EllipsisVertical:ag,EllipsisVerticalIcon:ag,Equal:dW,EqualApproximately:lW,EqualApproximatelyIcon:lW,EqualIcon:dW,EqualNot:cW,EqualNotIcon:cW,EqualSquare:oN,EqualSquareIcon:oN,Eraser:uW,EraserIcon:uW,EthernetPort:hW,EthernetPortIcon:hW,Euro:mW,EuroIcon:mW,Expand:pW,ExpandIcon:pW,ExternalLink:rn,ExternalLinkIcon:rn,Eye:va,EyeClosed:fW,EyeClosedIcon:fW,EyeIcon:va,EyeOff:xp,EyeOffIcon:xp,Facebook:xu,FacebookIcon:xu,Factory:gW,FactoryIcon:gW,Fan:xW,FanIcon:xW,FastForward:yW,FastForwardIcon:yW,Feather:vW,FeatherIcon:vW,Fence:_W,FenceIcon:_W,FerrisWheel:bW,FerrisWheelIcon:bW,Figma:wW,FigmaIcon:wW,File:dM,FileArchive:jW,FileArchiveIcon:jW,FileAudio:NW,FileAudio2:kW,FileAudio2Icon:kW,FileAudioIcon:NW,FileAxis3D:Gj,FileAxis3DIcon:Gj,FileAxis3d:Gj,FileAxis3dIcon:Gj,FileBadge:CW,FileBadge2:SW,FileBadge2Icon:SW,FileBadgeIcon:CW,FileBarChart:Kj,FileBarChart2:Zj,FileBarChart2Icon:Zj,FileBarChartIcon:Kj,FileBox:MW,FileBoxIcon:MW,FileChartColumn:Zj,FileChartColumnIcon:Zj,FileChartColumnIncreasing:Kj,FileChartColumnIncreasingIcon:Kj,FileChartLine:Yj,FileChartLineIcon:Yj,FileChartPie:Xj,FileChartPieIcon:Xj,FileCheck:AW,FileCheck2:TW,FileCheck2Icon:TW,FileCheckIcon:AW,FileClock:EW,FileClockIcon:EW,FileCode:IW,FileCode2:PW,FileCode2Icon:PW,FileCodeIcon:IW,FileCog:Qj,FileCog2:Qj,FileCog2Icon:Qj,FileCogIcon:Qj,FileDiff:LW,FileDiffIcon:LW,FileDigit:DW,FileDigitIcon:DW,FileDown:OW,FileDownIcon:OW,FileEdit:ek,FileEditIcon:ek,FileHeart:RW,FileHeartIcon:RW,FileIcon:dM,FileImage:Eb,FileImageIcon:Eb,FileInput:FW,FileInputIcon:FW,FileJson:BW,FileJson2:zW,FileJson2Icon:zW,FileJsonIcon:BW,FileKey:qW,FileKey2:$W,FileKey2Icon:$W,FileKeyIcon:qW,FileLineChart:Yj,FileLineChartIcon:Yj,FileLock:VW,FileLock2:UW,FileLock2Icon:UW,FileLockIcon:VW,FileMinus:WW,FileMinus2:HW,FileMinus2Icon:HW,FileMinusIcon:WW,FileMusic:GW,FileMusicIcon:GW,FileOutput:KW,FileOutputIcon:KW,FilePen:ek,FilePenIcon:ek,FilePenLine:Jj,FilePenLineIcon:Jj,FilePieChart:Xj,FilePieChartIcon:Xj,FilePlus:YW,FilePlus2:ZW,FilePlus2Icon:ZW,FilePlusIcon:YW,FileQuestion:XW,FileQuestionIcon:XW,FileScan:QW,FileScanIcon:QW,FileSearch:eG,FileSearch2:JW,FileSearch2Icon:JW,FileSearchIcon:eG,FileSignature:Jj,FileSignatureIcon:Jj,FileSliders:tG,FileSlidersIcon:tG,FileSpreadsheet:Yv,FileSpreadsheetIcon:Yv,FileStack:RI,FileStackIcon:RI,FileSymlink:sG,FileSymlinkIcon:sG,FileTerminal:rG,FileTerminalIcon:rG,FileText:In,FileTextIcon:In,FileType:aG,FileType2:nG,FileType2Icon:nG,FileTypeIcon:aG,FileUp:iG,FileUpIcon:iG,FileUser:oG,FileUserIcon:oG,FileVideo:cG,FileVideo2:lG,FileVideo2Icon:lG,FileVideoIcon:cG,FileVolume:uG,FileVolume2:dG,FileVolume2Icon:dG,FileVolumeIcon:uG,FileWarning:hG,FileWarningIcon:hG,FileX:pG,FileX2:mG,FileX2Icon:mG,FileXIcon:pG,Files:fG,FilesIcon:fG,Film:Fu,FilmIcon:Fu,Filter:a0,FilterIcon:a0,FilterX:gG,FilterXIcon:gG,Fingerprint:xG,FingerprintIcon:xG,FireExtinguisher:yG,FireExtinguisherIcon:yG,Fish:bG,FishIcon:bG,FishOff:vG,FishOffIcon:vG,FishSymbol:_G,FishSymbolIcon:_G,Flag:Xv,FlagIcon:Xv,FlagOff:wG,FlagOffIcon:wG,FlagTriangleLeft:jG,FlagTriangleLeftIcon:jG,FlagTriangleRight:kG,FlagTriangleRightIcon:kG,Flame:Fh,FlameIcon:Fh,FlameKindling:NG,FlameKindlingIcon:NG,Flashlight:CG,FlashlightIcon:CG,FlashlightOff:SG,FlashlightOffIcon:SG,FlaskConical:Pb,FlaskConicalIcon:Pb,FlaskConicalOff:MG,FlaskConicalOffIcon:MG,FlaskRound:TG,FlaskRoundIcon:TG,FlipHorizontal:FI,FlipHorizontal2:AG,FlipHorizontal2Icon:AG,FlipHorizontalIcon:FI,FlipVertical:PG,FlipVertical2:EG,FlipVertical2Icon:EG,FlipVerticalIcon:PG,Flower:IG,Flower2:Fx,Flower2Icon:Fx,FlowerIcon:IG,Focus:LG,FocusIcon:LG,FoldHorizontal:DG,FoldHorizontalIcon:DG,FoldVertical:OG,FoldVerticalIcon:OG,Folder:cK,FolderArchive:RG,FolderArchiveIcon:RG,FolderCheck:FG,FolderCheckIcon:FG,FolderClock:zG,FolderClockIcon:zG,FolderClosed:BG,FolderClosedIcon:BG,FolderCode:$G,FolderCodeIcon:$G,FolderCog:tk,FolderCog2:tk,FolderCog2Icon:tk,FolderCogIcon:tk,FolderDot:qG,FolderDotIcon:qG,FolderDown:UG,FolderDownIcon:UG,FolderEdit:sk,FolderEditIcon:sk,FolderGit:HG,FolderGit2:VG,FolderGit2Icon:VG,FolderGitIcon:HG,FolderHeart:WG,FolderHeartIcon:WG,FolderIcon:cK,FolderInput:GG,FolderInputIcon:GG,FolderKanban:KG,FolderKanbanIcon:KG,FolderKey:ZG,FolderKeyIcon:ZG,FolderLock:YG,FolderLockIcon:YG,FolderMinus:XG,FolderMinusIcon:XG,FolderOpen:Cm,FolderOpenDot:QG,FolderOpenDotIcon:QG,FolderOpenIcon:Cm,FolderOutput:JG,FolderOutputIcon:JG,FolderPen:sk,FolderPenIcon:sk,FolderPlus:eK,FolderPlusIcon:eK,FolderRoot:tK,FolderRootIcon:tK,FolderSearch:rK,FolderSearch2:sK,FolderSearch2Icon:sK,FolderSearchIcon:rK,FolderSymlink:nK,FolderSymlinkIcon:nK,FolderSync:aK,FolderSyncIcon:aK,FolderTree:iK,FolderTreeIcon:iK,FolderUp:oK,FolderUpIcon:oK,FolderX:lK,FolderXIcon:lK,Folders:dK,FoldersIcon:dK,Footprints:uK,FootprintsIcon:uK,ForkKnife:WN,ForkKnifeCrossed:HN,ForkKnifeCrossedIcon:HN,ForkKnifeIcon:WN,Forklift:hK,ForkliftIcon:hK,FormInput:Ck,FormInputIcon:Ck,Forward:mK,ForwardIcon:mK,Frame:pK,FrameIcon:pK,Framer:fK,FramerIcon:fK,Frown:gK,FrownIcon:gK,Fuel:xK,FuelIcon:xK,Fullscreen:yK,FullscreenIcon:yK,FunctionSquare:lN,FunctionSquareIcon:lN,GalleryHorizontal:_K,GalleryHorizontalEnd:vK,GalleryHorizontalEndIcon:vK,GalleryHorizontalIcon:_K,GalleryThumbnails:bK,GalleryThumbnailsIcon:bK,GalleryVertical:jK,GalleryVerticalEnd:wK,GalleryVerticalEndIcon:wK,GalleryVerticalIcon:jK,Gamepad:NK,Gamepad2:kK,Gamepad2Icon:kK,GamepadIcon:NK,GanttChart:cj,GanttChartIcon:cj,GanttChartSquare:Oy,GanttChartSquareIcon:Oy,Gauge:SK,GaugeCircle:Nj,GaugeCircleIcon:Nj,GaugeIcon:SK,Gavel:CK,GavelIcon:CK,Gem:MK,GemIcon:MK,Ghost:$4,GhostIcon:$4,Gift:bo,GiftIcon:bo,GitBranch:AK,GitBranchIcon:AK,GitBranchPlus:TK,GitBranchPlusIcon:TK,GitCommit:rk,GitCommitHorizontal:rk,GitCommitHorizontalIcon:rk,GitCommitIcon:rk,GitCommitVertical:EK,GitCommitVerticalIcon:EK,GitCompare:IK,GitCompareArrows:PK,GitCompareArrowsIcon:PK,GitCompareIcon:IK,GitFork:LK,GitForkIcon:LK,GitGraph:DK,GitGraphIcon:DK,GitMerge:OK,GitMergeIcon:OK,GitPullRequest:qK,GitPullRequestArrow:RK,GitPullRequestArrowIcon:RK,GitPullRequestClosed:FK,GitPullRequestClosedIcon:FK,GitPullRequestCreate:BK,GitPullRequestCreateArrow:zK,GitPullRequestCreateArrowIcon:zK,GitPullRequestCreateIcon:BK,GitPullRequestDraft:$K,GitPullRequestDraftIcon:$K,GitPullRequestIcon:qK,Github:UK,GithubIcon:UK,Gitlab:VK,GitlabIcon:VK,GlassWater:HK,GlassWaterIcon:HK,Glasses:WK,GlassesIcon:WK,Globe:yp,Globe2:Wj,Globe2Icon:Wj,GlobeIcon:yp,GlobeLock:GK,GlobeLockIcon:GK,Goal:KK,GoalIcon:KK,Grab:ZK,GrabIcon:ZK,GraduationCap:zh,GraduationCapIcon:zh,Grape:YK,GrapeIcon:YK,Grid:Yf,Grid2X2:ak,Grid2X2Icon:ak,Grid2X2Plus:nk,Grid2X2PlusIcon:nk,Grid2x2:ak,Grid2x2Check:XK,Grid2x2CheckIcon:XK,Grid2x2Icon:ak,Grid2x2Plus:nk,Grid2x2PlusIcon:nk,Grid2x2X:QK,Grid2x2XIcon:QK,Grid3X3:Yf,Grid3X3Icon:Yf,Grid3x3:Yf,Grid3x3Icon:Yf,GridIcon:Yf,Grip:eZ,GripHorizontal:JK,GripHorizontalIcon:JK,GripIcon:eZ,GripVertical:yh,GripVerticalIcon:yh,Group:tZ,GroupIcon:tZ,Guitar:sZ,GuitarIcon:sZ,Ham:rZ,HamIcon:rZ,Hammer:nZ,HammerIcon:nZ,Hand:zI,HandCoins:aZ,HandCoinsIcon:aZ,HandHeart:iZ,HandHeartIcon:iZ,HandHelping:ik,HandHelpingIcon:ik,HandIcon:zI,HandMetal:oZ,HandMetalIcon:oZ,HandPlatter:lZ,HandPlatterIcon:lZ,Handshake:BI,HandshakeIcon:BI,HardDrive:$I,HardDriveDownload:cZ,HardDriveDownloadIcon:cZ,HardDriveIcon:$I,HardDriveUpload:dZ,HardDriveUploadIcon:dZ,HardHat:uZ,HardHatIcon:uZ,Hash:uM,HashIcon:uM,Haze:hZ,HazeIcon:hZ,HdmiPort:mZ,HdmiPortIcon:mZ,Heading:yZ,Heading1:qI,Heading1Icon:qI,Heading2:UI,Heading2Icon:UI,Heading3:pZ,Heading3Icon:pZ,Heading4:fZ,Heading4Icon:fZ,Heading5:gZ,Heading5Icon:gZ,Heading6:xZ,Heading6Icon:xZ,HeadingIcon:yZ,HeadphoneOff:vZ,HeadphoneOffIcon:vZ,Headphones:_Z,HeadphonesIcon:_Z,Headset:bZ,HeadsetIcon:bZ,Heart:Ii,HeartCrack:wZ,HeartCrackIcon:wZ,HeartHandshake:jZ,HeartHandshakeIcon:jZ,HeartIcon:Ii,HeartOff:kZ,HeartOffIcon:kZ,HeartPulse:NZ,HeartPulseIcon:NZ,Heater:SZ,HeaterIcon:SZ,HelpCircle:Mv,HelpCircleIcon:Mv,HelpingHand:ik,HelpingHandIcon:ik,Hexagon:CZ,HexagonIcon:CZ,Highlighter:MZ,HighlighterIcon:MZ,History:hM,HistoryIcon:hM,Home:Rn,HomeIcon:Rn,Hop:AZ,HopIcon:AZ,HopOff:TZ,HopOffIcon:TZ,Hospital:EZ,HospitalIcon:EZ,Hotel:PZ,HotelIcon:PZ,Hourglass:IZ,HourglassIcon:IZ,House:Rn,HouseIcon:Rn,HousePlug:LZ,HousePlugIcon:LZ,HousePlus:DZ,HousePlusIcon:DZ,IceCream:lk,IceCream2:ok,IceCream2Icon:ok,IceCreamBowl:ok,IceCreamBowlIcon:ok,IceCreamCone:lk,IceCreamConeIcon:lk,IceCreamIcon:lk,Icon:k$e,IdCard:OZ,IdCardIcon:OZ,Image:cl,ImageDown:RZ,ImageDownIcon:RZ,ImageIcon:cl,ImageMinus:FZ,ImageMinusIcon:FZ,ImageOff:zZ,ImageOffIcon:zZ,ImagePlay:BZ,ImagePlayIcon:BZ,ImagePlus:Qv,ImagePlusIcon:Qv,ImageUp:$Z,ImageUpIcon:$Z,ImageUpscale:qZ,ImageUpscaleIcon:qZ,Images:UZ,ImagesIcon:UZ,Import:VZ,ImportIcon:VZ,Inbox:HZ,InboxIcon:HZ,Indent:dk,IndentDecrease:ck,IndentDecreaseIcon:ck,IndentIcon:dk,IndentIncrease:dk,IndentIncreaseIcon:dk,IndianRupee:WZ,IndianRupeeIcon:WZ,Infinity:GZ,InfinityIcon:GZ,Info:VI,InfoIcon:VI,Inspect:pN,InspectIcon:pN,InspectionPanel:KZ,InspectionPanelIcon:KZ,Instagram:yu,InstagramIcon:yu,Italic:mM,ItalicIcon:mM,IterationCcw:ZZ,IterationCcwIcon:ZZ,IterationCw:YZ,IterationCwIcon:YZ,JapaneseYen:XZ,JapaneseYenIcon:XZ,Joystick:QZ,JoystickIcon:QZ,Kanban:i0,KanbanIcon:i0,KanbanSquare:cN,KanbanSquareDashed:sN,KanbanSquareDashedIcon:sN,KanbanSquareIcon:cN,Key:vp,KeyIcon:vp,KeyRound:q4,KeyRoundIcon:q4,KeySquare:JZ,KeySquareIcon:JZ,Keyboard:sY,KeyboardIcon:sY,KeyboardMusic:eY,KeyboardMusicIcon:eY,KeyboardOff:tY,KeyboardOffIcon:tY,Lamp:lY,LampCeiling:rY,LampCeilingIcon:rY,LampDesk:nY,LampDeskIcon:nY,LampFloor:aY,LampFloorIcon:aY,LampIcon:lY,LampWallDown:iY,LampWallDownIcon:iY,LampWallUp:oY,LampWallUpIcon:oY,LandPlot:cY,LandPlotIcon:cY,Landmark:dY,LandmarkIcon:dY,Languages:uY,LanguagesIcon:uY,Laptop:mY,Laptop2:uk,Laptop2Icon:uk,LaptopIcon:mY,LaptopMinimal:uk,LaptopMinimalCheck:hY,LaptopMinimalCheckIcon:hY,LaptopMinimalIcon:uk,Lasso:fY,LassoIcon:fY,LassoSelect:pY,LassoSelectIcon:pY,Laugh:gY,LaughIcon:gY,Layers:vY,Layers2:xY,Layers2Icon:xY,Layers3:yY,Layers3Icon:yY,LayersIcon:vY,Layout:Av,LayoutDashboard:U4,LayoutDashboardIcon:U4,LayoutGrid:lf,LayoutGridIcon:lf,LayoutIcon:Av,LayoutList:_Y,LayoutListIcon:_Y,LayoutPanelLeft:bY,LayoutPanelLeftIcon:bY,LayoutPanelTop:wY,LayoutPanelTopIcon:wY,LayoutTemplate:V4,LayoutTemplateIcon:V4,Leaf:jY,LeafIcon:jY,LeafyGreen:kY,LeafyGreenIcon:kY,Lectern:NY,LecternIcon:NY,LetterText:SY,LetterTextIcon:SY,Library:pM,LibraryBig:CY,LibraryBigIcon:CY,LibraryIcon:pM,LibrarySquare:dN,LibrarySquareIcon:dN,LifeBuoy:fM,LifeBuoyIcon:fM,Ligature:MY,LigatureIcon:MY,Lightbulb:Ib,LightbulbIcon:Ib,LightbulbOff:TY,LightbulbOffIcon:TY,LineChart:ij,LineChartIcon:ij,Link:Vo,Link2:sl,Link2Icon:sl,Link2Off:AY,Link2OffIcon:AY,LinkIcon:Vo,Linkedin:_p,LinkedinIcon:_p,List:Mm,ListCheck:EY,ListCheckIcon:EY,ListChecks:PY,ListChecksIcon:PY,ListCollapse:IY,ListCollapseIcon:IY,ListEnd:LY,ListEndIcon:LY,ListFilter:DY,ListFilterIcon:DY,ListIcon:Mm,ListMinus:OY,ListMinusIcon:OY,ListMusic:RY,ListMusicIcon:RY,ListOrdered:Jv,ListOrderedIcon:Jv,ListPlus:FY,ListPlusIcon:FY,ListRestart:zY,ListRestartIcon:zY,ListStart:BY,ListStartIcon:BY,ListTodo:$Y,ListTodoIcon:$Y,ListTree:qY,ListTreeIcon:qY,ListVideo:UY,ListVideoIcon:UY,ListX:VY,ListXIcon:VY,Loader:WY,Loader2:Ss,Loader2Icon:Ss,LoaderCircle:Ss,LoaderCircleIcon:Ss,LoaderIcon:WY,LoaderPinwheel:HY,LoaderPinwheelIcon:HY,Locate:ZY,LocateFixed:GY,LocateFixedIcon:GY,LocateIcon:ZY,LocateOff:KY,LocateOffIcon:KY,Lock:vh,LockIcon:vh,LockKeyhole:YY,LockKeyholeIcon:YY,LockKeyholeOpen:hk,LockKeyholeOpenIcon:hk,LockOpen:mk,LockOpenIcon:mk,LogIn:gM,LogInIcon:gM,LogOut:xM,LogOutIcon:xM,Logs:XY,LogsIcon:XY,Lollipop:QY,LollipopIcon:QY,LucideAArrowDown:Xz,LucideAArrowUp:Qz,LucideALargeSmall:Jz,LucideAccessibility:e9,LucideActivity:gp,LucideActivitySquare:Dk,LucideAirVent:t9,LucideAirplay:s9,LucideAlarmCheck:Fw,LucideAlarmClock:n9,LucideAlarmClockCheck:Fw,LucideAlarmClockMinus:zw,LucideAlarmClockOff:r9,LucideAlarmClockPlus:Bw,LucideAlarmMinus:zw,LucideAlarmPlus:Bw,LucideAlarmSmoke:a9,LucideAlbum:i9,LucideAlertCircle:yl,LucideAlertOctagon:Tv,LucideAlertTriangle:uh,LucideAlignCenter:sM,LucideAlignCenterHorizontal:o9,LucideAlignCenterVertical:l9,LucideAlignEndHorizontal:c9,LucideAlignEndVertical:d9,LucideAlignHorizontalDistributeCenter:u9,LucideAlignHorizontalDistributeEnd:h9,LucideAlignHorizontalDistributeStart:m9,LucideAlignHorizontalJustifyCenter:p9,LucideAlignHorizontalJustifyEnd:f9,LucideAlignHorizontalJustifyStart:g9,LucideAlignHorizontalSpaceAround:x9,LucideAlignHorizontalSpaceBetween:y9,LucideAlignJustify:v9,LucideAlignLeft:rM,LucideAlignRight:nM,LucideAlignStartHorizontal:_9,LucideAlignStartVertical:b9,LucideAlignVerticalDistributeCenter:w9,LucideAlignVerticalDistributeEnd:j9,LucideAlignVerticalDistributeStart:k9,LucideAlignVerticalJustifyCenter:N9,LucideAlignVerticalJustifyEnd:S9,LucideAlignVerticalJustifyStart:C9,LucideAlignVerticalSpaceAround:M9,LucideAlignVerticalSpaceBetween:T9,LucideAmbulance:A9,LucideAmpersand:E9,LucideAmpersands:P9,LucideAmphora:I9,LucideAnchor:L9,LucideAngry:D9,LucideAnnoyed:O9,LucideAntenna:R9,LucideAnvil:F9,LucideAperture:z9,LucideAppWindow:NI,LucideAppWindowMac:B9,LucideApple:$9,LucideArchive:aM,LucideArchiveRestore:SI,LucideArchiveX:q9,LucideAreaChart:ej,LucideArmchair:U9,LucideArrowBigDown:H9,LucideArrowBigDownDash:V9,LucideArrowBigLeft:G9,LucideArrowBigLeftDash:W9,LucideArrowBigRight:Z9,LucideArrowBigRightDash:K9,LucideArrowBigUp:X9,LucideArrowBigUpDash:Y9,LucideArrowDown:Oh,LucideArrowDown01:Q9,LucideArrowDown10:J9,LucideArrowDownAZ:$w,LucideArrowDownAz:$w,LucideArrowDownCircle:hj,LucideArrowDownFromLine:eB,LucideArrowDownLeft:tB,LucideArrowDownLeftFromCircle:pj,LucideArrowDownLeftFromSquare:Bk,LucideArrowDownLeftSquare:Ok,LucideArrowDownNarrowWide:sB,LucideArrowDownRight:CI,LucideArrowDownRightFromCircle:fj,LucideArrowDownRightFromSquare:$k,LucideArrowDownRightSquare:Rk,LucideArrowDownSquare:Fk,LucideArrowDownToDot:rB,LucideArrowDownToLine:nB,LucideArrowDownUp:aB,LucideArrowDownWideNarrow:qw,LucideArrowDownZA:Uw,LucideArrowDownZa:Uw,LucideArrowLeft:di,LucideArrowLeftCircle:mj,LucideArrowLeftFromLine:iB,LucideArrowLeftRight:oB,LucideArrowLeftSquare:zk,LucideArrowLeftToLine:lB,LucideArrowRight:Ki,LucideArrowRightCircle:yj,LucideArrowRightFromLine:cB,LucideArrowRightLeft:Gv,LucideArrowRightSquare:Vk,LucideArrowRightToLine:dB,LucideArrowUp:gu,LucideArrowUp01:uB,LucideArrowUp10:hB,LucideArrowUpAZ:Vw,LucideArrowUpAz:Vw,LucideArrowUpCircle:vj,LucideArrowUpDown:ud,LucideArrowUpFromDot:mB,LucideArrowUpFromLine:pB,LucideArrowUpLeft:fB,LucideArrowUpLeftFromCircle:gj,LucideArrowUpLeftFromSquare:qk,LucideArrowUpLeftSquare:Hk,LucideArrowUpNarrowWide:Hw,LucideArrowUpRight:MI,LucideArrowUpRightFromCircle:xj,LucideArrowUpRightFromSquare:Uk,LucideArrowUpRightSquare:Wk,LucideArrowUpSquare:Gk,LucideArrowUpToLine:gB,LucideArrowUpWideNarrow:xB,LucideArrowUpZA:Ww,LucideArrowUpZa:Ww,LucideArrowsUpFromLine:yB,LucideAsterisk:vB,LucideAsteriskSquare:Kk,LucideAtSign:_B,LucideAtom:bB,LucideAudioLines:wB,LucideAudioWaveform:jB,LucideAward:fc,LucideAxe:kB,LucideAxis3D:Gw,LucideAxis3d:Gw,LucideBaby:NB,LucideBackpack:SB,LucideBadge:qB,LucideBadgeAlert:CB,LucideBadgeCent:MB,LucideBadgeCheck:Kw,LucideBadgeDollarSign:TB,LucideBadgeEuro:AB,LucideBadgeHelp:EB,LucideBadgeIndianRupee:PB,LucideBadgeInfo:IB,LucideBadgeJapaneseYen:LB,LucideBadgeMinus:DB,LucideBadgePercent:OB,LucideBadgePlus:RB,LucideBadgePoundSterling:FB,LucideBadgeRussianRuble:zB,LucideBadgeSwissFranc:BB,LucideBadgeX:$B,LucideBaggageClaim:UB,LucideBan:TI,LucideBanana:VB,LucideBandage:HB,LucideBanknote:WB,LucideBarChart:oj,LucideBarChart2:lj,LucideBarChart3:xl,LucideBarChart4:aj,LucideBarChartBig:nj,LucideBarChartHorizontal:sj,LucideBarChartHorizontalBig:tj,LucideBarcode:GB,LucideBaseline:KB,LucideBath:n0,LucideBattery:e$,LucideBatteryCharging:ZB,LucideBatteryFull:YB,LucideBatteryLow:XB,LucideBatteryMedium:QB,LucideBatteryWarning:JB,LucideBeaker:t$,LucideBean:r$,LucideBeanOff:s$,LucideBed:Kv,LucideBedDouble:AI,LucideBedSingle:n$,LucideBeef:a$,LucideBeer:o$,LucideBeerOff:i$,LucideBell:gg,LucideBellDot:l$,LucideBellElectric:c$,LucideBellMinus:d$,LucideBellOff:Mb,LucideBellPlus:u$,LucideBellRing:h$,LucideBetweenHorizonalEnd:Zw,LucideBetweenHorizonalStart:Yw,LucideBetweenHorizontalEnd:Zw,LucideBetweenHorizontalStart:Yw,LucideBetweenVerticalEnd:m$,LucideBetweenVerticalStart:p$,LucideBicepsFlexed:f$,LucideBike:g$,LucideBinary:x$,LucideBinoculars:y$,LucideBiohazard:v$,LucideBird:_$,LucideBitcoin:b$,LucideBlend:w$,LucideBlinds:j$,LucideBlocks:k$,LucideBluetooth:M$,LucideBluetoothConnected:N$,LucideBluetoothOff:S$,LucideBluetoothSearching:C$,LucideBold:iM,LucideBolt:T$,LucideBomb:A$,LucideBone:E$,LucideBook:J$,LucideBookA:P$,LucideBookAudio:I$,LucideBookCheck:L$,LucideBookCopy:D$,LucideBookDashed:Xw,LucideBookDown:O$,LucideBookHeadphones:R$,LucideBookHeart:F$,LucideBookImage:z$,LucideBookKey:B$,LucideBookLock:$$,LucideBookMarked:q$,LucideBookMinus:U$,LucideBookOpen:gh,LucideBookOpenCheck:V$,LucideBookOpenText:H$,LucideBookPlus:W$,LucideBookTemplate:Xw,LucideBookText:G$,LucideBookType:K$,LucideBookUp:Y$,LucideBookUp2:Z$,LucideBookUser:X$,LucideBookX:Q$,LucideBookmark:Ux,LucideBookmarkCheck:eq,LucideBookmarkMinus:tq,LucideBookmarkPlus:EI,LucideBookmarkX:sq,LucideBoomBox:rq,LucideBot:oM,LucideBotMessageSquare:nq,LucideBotOff:aq,LucideBox:iq,LucideBoxSelect:nN,LucideBoxes:oq,LucideBraces:Qw,LucideBrackets:lq,LucideBrain:PI,LucideBrainCircuit:cq,LucideBrainCog:dq,LucideBrickWall:uq,LucideBriefcase:Rh,LucideBriefcaseBusiness:hq,LucideBriefcaseConveyorBelt:mq,LucideBriefcaseMedical:pq,LucideBringToFront:fq,LucideBrush:gq,LucideBug:vq,LucideBugOff:xq,LucideBugPlay:yq,LucideBuilding:R4,LucideBuilding2:La,LucideBus:bq,LucideBusFront:_q,LucideCable:jq,LucideCableCar:wq,LucideCake:xh,LucideCakeSlice:kq,LucideCalculator:Nq,LucideCalendar:on,LucideCalendar1:Sq,LucideCalendarArrowDown:Cq,LucideCalendarArrowUp:Mq,LucideCalendarCheck:II,LucideCalendarCheck2:Tq,LucideCalendarClock:LI,LucideCalendarCog:Aq,LucideCalendarDays:Md,LucideCalendarFold:Eq,LucideCalendarHeart:Pq,LucideCalendarMinus:Lq,LucideCalendarMinus2:Iq,LucideCalendarOff:DI,LucideCalendarPlus:Tb,LucideCalendarPlus2:Dq,LucideCalendarRange:Oq,LucideCalendarSearch:Rq,LucideCalendarSync:Fq,LucideCalendarX:Bq,LucideCalendarX2:zq,LucideCamera:Vx,LucideCameraOff:$q,LucideCandlestickChart:rj,LucideCandy:Vq,LucideCandyCane:qq,LucideCandyOff:Uq,LucideCannabis:Hq,LucideCaptions:Jw,LucideCaptionsOff:Wq,LucideCar:Zq,LucideCarFront:Gq,LucideCarTaxiFront:Kq,LucideCaravan:Yq,LucideCarrot:Xq,LucideCaseLower:Qq,LucideCaseSensitive:Jq,LucideCaseUpper:eU,LucideCassetteTape:tU,LucideCast:sU,LucideCastle:rU,LucideCat:nU,LucideCctv:aU,LucideChartArea:ej,LucideChartBar:sj,LucideChartBarBig:tj,LucideChartBarDecreasing:iU,LucideChartBarIncreasing:oU,LucideChartBarStacked:lU,LucideChartCandlestick:rj,LucideChartColumn:xl,LucideChartColumnBig:nj,LucideChartColumnDecreasing:cU,LucideChartColumnIncreasing:aj,LucideChartColumnStacked:dU,LucideChartGantt:uU,LucideChartLine:ij,LucideChartNetwork:hU,LucideChartNoAxesColumn:lj,LucideChartNoAxesColumnDecreasing:mU,LucideChartNoAxesColumnIncreasing:oj,LucideChartNoAxesCombined:pU,LucideChartNoAxesGantt:cj,LucideChartPie:dj,LucideChartScatter:uj,LucideChartSpline:fU,LucideCheck:ma,LucideCheckCheck:gU,LucideCheckCircle:vi,LucideCheckCircle2:ha,LucideCheckSquare:Pv,LucideCheckSquare2:Yk,LucideChefHat:xU,LucideCherry:yU,LucideChevronDown:tl,LucideChevronDownCircle:_j,LucideChevronDownSquare:Xk,LucideChevronFirst:vU,LucideChevronLast:_U,LucideChevronLeft:Xl,LucideChevronLeftCircle:bj,LucideChevronLeftSquare:Qk,LucideChevronRight:Xa,LucideChevronRightCircle:wj,LucideChevronRightSquare:Jk,LucideChevronUp:Hx,LucideChevronUpCircle:jj,LucideChevronUpSquare:eN,LucideChevronsDown:wU,LucideChevronsDownUp:bU,LucideChevronsLeft:NU,LucideChevronsLeftRight:kU,LucideChevronsLeftRightEllipsis:jU,LucideChevronsRight:CU,LucideChevronsRightLeft:SU,LucideChevronsUp:MU,LucideChevronsUpDown:xg,LucideChrome:TU,LucideChurch:AU,LucideCigarette:PU,LucideCigaretteOff:EU,LucideCircle:pd,LucideCircleAlert:yl,LucideCircleArrowDown:hj,LucideCircleArrowLeft:mj,LucideCircleArrowOutDownLeft:pj,LucideCircleArrowOutDownRight:fj,LucideCircleArrowOutUpLeft:gj,LucideCircleArrowOutUpRight:xj,LucideCircleArrowRight:yj,LucideCircleArrowUp:vj,LucideCircleCheck:ha,LucideCircleCheckBig:vi,LucideCircleChevronDown:_j,LucideCircleChevronLeft:bj,LucideCircleChevronRight:wj,LucideCircleChevronUp:jj,LucideCircleDashed:IU,LucideCircleDivide:kj,LucideCircleDollarSign:LU,LucideCircleDot:OU,LucideCircleDotDashed:DU,LucideCircleEllipsis:RU,LucideCircleEqual:FU,LucideCircleFadingArrowUp:zU,LucideCircleFadingPlus:BU,LucideCircleGauge:Nj,LucideCircleHelp:Mv,LucideCircleMinus:Sj,LucideCircleOff:$U,LucideCircleParking:Mj,LucideCircleParkingOff:Cj,LucideCirclePause:Tj,LucideCirclePercent:Aj,LucideCirclePlay:ap,LucideCirclePlus:Ej,LucideCirclePower:Pj,LucideCircleSlash:qU,LucideCircleSlash2:Ij,LucideCircleSlashed:Ij,LucideCircleStop:Lj,LucideCircleUser:Oj,LucideCircleUserRound:Dj,LucideCircleX:$c,LucideCircuitBoard:UU,LucideCitrus:VU,LucideClapperboard:HU,LucideClipboard:QU,LucideClipboardCheck:lM,LucideClipboardCopy:WU,LucideClipboardEdit:Fj,LucideClipboardList:Ab,LucideClipboardMinus:GU,LucideClipboardPaste:KU,LucideClipboardPen:Fj,LucideClipboardPenLine:Rj,LucideClipboardPlus:ZU,LucideClipboardSignature:Rj,LucideClipboardType:YU,LucideClipboardX:XU,LucideClock:Tn,LucideClock1:JU,LucideClock10:eV,LucideClock11:tV,LucideClock12:sV,LucideClock2:rV,LucideClock3:nV,LucideClock4:aV,LucideClock5:iV,LucideClock6:oV,LucideClock7:lV,LucideClock8:cV,LucideClock9:dV,LucideClockAlert:uV,LucideClockArrowDown:hV,LucideClockArrowUp:mV,LucideCloud:MV,LucideCloudAlert:pV,LucideCloudCog:fV,LucideCloudDownload:zj,LucideCloudDrizzle:gV,LucideCloudFog:xV,LucideCloudHail:yV,LucideCloudLightning:vV,LucideCloudMoon:bV,LucideCloudMoonRain:_V,LucideCloudOff:wV,LucideCloudRain:kV,LucideCloudRainWind:jV,LucideCloudSnow:NV,LucideCloudSun:CV,LucideCloudSunRain:SV,LucideCloudUpload:Bj,LucideCloudy:TV,LucideClover:$v,LucideClub:AV,LucideCode:F4,LucideCode2:$j,LucideCodeSquare:tN,LucideCodeXml:$j,LucideCodepen:EV,LucideCodesandbox:PV,LucideCoffee:z4,LucideCog:IV,LucideCoins:OI,LucideColumns:qj,LucideColumns2:qj,LucideColumns3:Uj,LucideColumns4:LV,LucideCombine:DV,LucideCommand:OV,LucideCompass:RV,LucideComponent:FV,LucideComputer:zV,LucideConciergeBell:BV,LucideCone:$V,LucideConstruction:qV,LucideContact:B4,LucideContact2:Vj,LucideContactRound:Vj,LucideContainer:UV,LucideContrast:VV,LucideCookie:HV,LucideCookingPot:WV,LucideCopy:mi,LucideCopyCheck:GV,LucideCopyMinus:KV,LucideCopyPlus:ZV,LucideCopySlash:YV,LucideCopyX:XV,LucideCopyleft:QV,LucideCopyright:JV,LucideCornerDownLeft:eH,LucideCornerDownRight:tH,LucideCornerLeftDown:sH,LucideCornerLeftUp:rH,LucideCornerRightDown:nH,LucideCornerRightUp:aH,LucideCornerUpLeft:iH,LucideCornerUpRight:oH,LucideCpu:lH,LucideCreativeCommons:cH,LucideCreditCard:yg,LucideCroissant:dH,LucideCrop:uH,LucideCross:hH,LucideCrosshair:mH,LucideCrown:Sm,LucideCuboid:pH,LucideCupSoda:fH,LucideCurlyBraces:Qw,LucideCurrency:gH,LucideCylinder:xH,LucideDam:yH,LucideDatabase:bH,LucideDatabaseBackup:vH,LucideDatabaseZap:_H,LucideDelete:wH,LucideDessert:jH,LucideDiameter:kH,LucideDiamond:CH,LucideDiamondMinus:NH,LucideDiamondPercent:Hj,LucideDiamondPlus:SH,LucideDice1:MH,LucideDice2:TH,LucideDice3:AH,LucideDice4:EH,LucideDice5:PH,LucideDice6:IH,LucideDices:LH,LucideDiff:DH,LucideDisc:zH,LucideDisc2:OH,LucideDisc3:RH,LucideDiscAlbum:FH,LucideDivide:BH,LucideDivideCircle:kj,LucideDivideSquare:aN,LucideDna:qH,LucideDnaOff:$H,LucideDock:UH,LucideDog:VH,LucideDollarSign:Td,LucideDonut:HH,LucideDoorClosed:WH,LucideDoorOpen:Zv,LucideDot:GH,LucideDotSquare:iN,LucideDownload:ki,LucideDownloadCloud:zj,LucideDraftingCompass:KH,LucideDrama:ZH,LucideDribbble:YH,LucideDrill:XH,LucideDroplet:QH,LucideDroplets:Wx,LucideDrum:JH,LucideDrumstick:eW,LucideDumbbell:tW,LucideEar:rW,LucideEarOff:sW,LucideEarth:Wj,LucideEarthLock:nW,LucideEclipse:aW,LucideEdit:rd,LucideEdit2:Wy,LucideEdit3:Ev,LucideEgg:cM,LucideEggFried:iW,LucideEggOff:oW,LucideEllipsis:ig,LucideEllipsisVertical:ag,LucideEqual:dW,LucideEqualApproximately:lW,LucideEqualNot:cW,LucideEqualSquare:oN,LucideEraser:uW,LucideEthernetPort:hW,LucideEuro:mW,LucideExpand:pW,LucideExternalLink:rn,LucideEye:va,LucideEyeClosed:fW,LucideEyeOff:xp,LucideFacebook:xu,LucideFactory:gW,LucideFan:xW,LucideFastForward:yW,LucideFeather:vW,LucideFence:_W,LucideFerrisWheel:bW,LucideFigma:wW,LucideFile:dM,LucideFileArchive:jW,LucideFileAudio:NW,LucideFileAudio2:kW,LucideFileAxis3D:Gj,LucideFileAxis3d:Gj,LucideFileBadge:CW,LucideFileBadge2:SW,LucideFileBarChart:Kj,LucideFileBarChart2:Zj,LucideFileBox:MW,LucideFileChartColumn:Zj,LucideFileChartColumnIncreasing:Kj,LucideFileChartLine:Yj,LucideFileChartPie:Xj,LucideFileCheck:AW,LucideFileCheck2:TW,LucideFileClock:EW,LucideFileCode:IW,LucideFileCode2:PW,LucideFileCog:Qj,LucideFileCog2:Qj,LucideFileDiff:LW,LucideFileDigit:DW,LucideFileDown:OW,LucideFileEdit:ek,LucideFileHeart:RW,LucideFileImage:Eb,LucideFileInput:FW,LucideFileJson:BW,LucideFileJson2:zW,LucideFileKey:qW,LucideFileKey2:$W,LucideFileLineChart:Yj,LucideFileLock:VW,LucideFileLock2:UW,LucideFileMinus:WW,LucideFileMinus2:HW,LucideFileMusic:GW,LucideFileOutput:KW,LucideFilePen:ek,LucideFilePenLine:Jj,LucideFilePieChart:Xj,LucideFilePlus:YW,LucideFilePlus2:ZW,LucideFileQuestion:XW,LucideFileScan:QW,LucideFileSearch:eG,LucideFileSearch2:JW,LucideFileSignature:Jj,LucideFileSliders:tG,LucideFileSpreadsheet:Yv,LucideFileStack:RI,LucideFileSymlink:sG,LucideFileTerminal:rG,LucideFileText:In,LucideFileType:aG,LucideFileType2:nG,LucideFileUp:iG,LucideFileUser:oG,LucideFileVideo:cG,LucideFileVideo2:lG,LucideFileVolume:uG,LucideFileVolume2:dG,LucideFileWarning:hG,LucideFileX:pG,LucideFileX2:mG,LucideFiles:fG,LucideFilm:Fu,LucideFilter:a0,LucideFilterX:gG,LucideFingerprint:xG,LucideFireExtinguisher:yG,LucideFish:bG,LucideFishOff:vG,LucideFishSymbol:_G,LucideFlag:Xv,LucideFlagOff:wG,LucideFlagTriangleLeft:jG,LucideFlagTriangleRight:kG,LucideFlame:Fh,LucideFlameKindling:NG,LucideFlashlight:CG,LucideFlashlightOff:SG,LucideFlaskConical:Pb,LucideFlaskConicalOff:MG,LucideFlaskRound:TG,LucideFlipHorizontal:FI,LucideFlipHorizontal2:AG,LucideFlipVertical:PG,LucideFlipVertical2:EG,LucideFlower:IG,LucideFlower2:Fx,LucideFocus:LG,LucideFoldHorizontal:DG,LucideFoldVertical:OG,LucideFolder:cK,LucideFolderArchive:RG,LucideFolderCheck:FG,LucideFolderClock:zG,LucideFolderClosed:BG,LucideFolderCode:$G,LucideFolderCog:tk,LucideFolderCog2:tk,LucideFolderDot:qG,LucideFolderDown:UG,LucideFolderEdit:sk,LucideFolderGit:HG,LucideFolderGit2:VG,LucideFolderHeart:WG,LucideFolderInput:GG,LucideFolderKanban:KG,LucideFolderKey:ZG,LucideFolderLock:YG,LucideFolderMinus:XG,LucideFolderOpen:Cm,LucideFolderOpenDot:QG,LucideFolderOutput:JG,LucideFolderPen:sk,LucideFolderPlus:eK,LucideFolderRoot:tK,LucideFolderSearch:rK,LucideFolderSearch2:sK,LucideFolderSymlink:nK,LucideFolderSync:aK,LucideFolderTree:iK,LucideFolderUp:oK,LucideFolderX:lK,LucideFolders:dK,LucideFootprints:uK,LucideForkKnife:WN,LucideForkKnifeCrossed:HN,LucideForklift:hK,LucideFormInput:Ck,LucideForward:mK,LucideFrame:pK,LucideFramer:fK,LucideFrown:gK,LucideFuel:xK,LucideFullscreen:yK,LucideFunctionSquare:lN,LucideGalleryHorizontal:_K,LucideGalleryHorizontalEnd:vK,LucideGalleryThumbnails:bK,LucideGalleryVertical:jK,LucideGalleryVerticalEnd:wK,LucideGamepad:NK,LucideGamepad2:kK,LucideGanttChart:cj,LucideGanttChartSquare:Oy,LucideGauge:SK,LucideGaugeCircle:Nj,LucideGavel:CK,LucideGem:MK,LucideGhost:$4,LucideGift:bo,LucideGitBranch:AK,LucideGitBranchPlus:TK,LucideGitCommit:rk,LucideGitCommitHorizontal:rk,LucideGitCommitVertical:EK,LucideGitCompare:IK,LucideGitCompareArrows:PK,LucideGitFork:LK,LucideGitGraph:DK,LucideGitMerge:OK,LucideGitPullRequest:qK,LucideGitPullRequestArrow:RK,LucideGitPullRequestClosed:FK,LucideGitPullRequestCreate:BK,LucideGitPullRequestCreateArrow:zK,LucideGitPullRequestDraft:$K,LucideGithub:UK,LucideGitlab:VK,LucideGlassWater:HK,LucideGlasses:WK,LucideGlobe:yp,LucideGlobe2:Wj,LucideGlobeLock:GK,LucideGoal:KK,LucideGrab:ZK,LucideGraduationCap:zh,LucideGrape:YK,LucideGrid:Yf,LucideGrid2X2:ak,LucideGrid2X2Plus:nk,LucideGrid2x2:ak,LucideGrid2x2Check:XK,LucideGrid2x2Plus:nk,LucideGrid2x2X:QK,LucideGrid3X3:Yf,LucideGrid3x3:Yf,LucideGrip:eZ,LucideGripHorizontal:JK,LucideGripVertical:yh,LucideGroup:tZ,LucideGuitar:sZ,LucideHam:rZ,LucideHammer:nZ,LucideHand:zI,LucideHandCoins:aZ,LucideHandHeart:iZ,LucideHandHelping:ik,LucideHandMetal:oZ,LucideHandPlatter:lZ,LucideHandshake:BI,LucideHardDrive:$I,LucideHardDriveDownload:cZ,LucideHardDriveUpload:dZ,LucideHardHat:uZ,LucideHash:uM,LucideHaze:hZ,LucideHdmiPort:mZ,LucideHeading:yZ,LucideHeading1:qI,LucideHeading2:UI,LucideHeading3:pZ,LucideHeading4:fZ,LucideHeading5:gZ,LucideHeading6:xZ,LucideHeadphoneOff:vZ,LucideHeadphones:_Z,LucideHeadset:bZ,LucideHeart:Ii,LucideHeartCrack:wZ,LucideHeartHandshake:jZ,LucideHeartOff:kZ,LucideHeartPulse:NZ,LucideHeater:SZ,LucideHelpCircle:Mv,LucideHelpingHand:ik,LucideHexagon:CZ,LucideHighlighter:MZ,LucideHistory:hM,LucideHome:Rn,LucideHop:AZ,LucideHopOff:TZ,LucideHospital:EZ,LucideHotel:PZ,LucideHourglass:IZ,LucideHouse:Rn,LucideHousePlug:LZ,LucideHousePlus:DZ,LucideIceCream:lk,LucideIceCream2:ok,LucideIceCreamBowl:ok,LucideIceCreamCone:lk,LucideIdCard:OZ,LucideImage:cl,LucideImageDown:RZ,LucideImageMinus:FZ,LucideImageOff:zZ,LucideImagePlay:BZ,LucideImagePlus:Qv,LucideImageUp:$Z,LucideImageUpscale:qZ,LucideImages:UZ,LucideImport:VZ,LucideInbox:HZ,LucideIndent:dk,LucideIndentDecrease:ck,LucideIndentIncrease:dk,LucideIndianRupee:WZ,LucideInfinity:GZ,LucideInfo:VI,LucideInspect:pN,LucideInspectionPanel:KZ,LucideInstagram:yu,LucideItalic:mM,LucideIterationCcw:ZZ,LucideIterationCw:YZ,LucideJapaneseYen:XZ,LucideJoystick:QZ,LucideKanban:i0,LucideKanbanSquare:cN,LucideKanbanSquareDashed:sN,LucideKey:vp,LucideKeyRound:q4,LucideKeySquare:JZ,LucideKeyboard:sY,LucideKeyboardMusic:eY,LucideKeyboardOff:tY,LucideLamp:lY,LucideLampCeiling:rY,LucideLampDesk:nY,LucideLampFloor:aY,LucideLampWallDown:iY,LucideLampWallUp:oY,LucideLandPlot:cY,LucideLandmark:dY,LucideLanguages:uY,LucideLaptop:mY,LucideLaptop2:uk,LucideLaptopMinimal:uk,LucideLaptopMinimalCheck:hY,LucideLasso:fY,LucideLassoSelect:pY,LucideLaugh:gY,LucideLayers:vY,LucideLayers2:xY,LucideLayers3:yY,LucideLayout:Av,LucideLayoutDashboard:U4,LucideLayoutGrid:lf,LucideLayoutList:_Y,LucideLayoutPanelLeft:bY,LucideLayoutPanelTop:wY,LucideLayoutTemplate:V4,LucideLeaf:jY,LucideLeafyGreen:kY,LucideLectern:NY,LucideLetterText:SY,LucideLibrary:pM,LucideLibraryBig:CY,LucideLibrarySquare:dN,LucideLifeBuoy:fM,LucideLigature:MY,LucideLightbulb:Ib,LucideLightbulbOff:TY,LucideLineChart:ij,LucideLink:Vo,LucideLink2:sl,LucideLink2Off:AY,LucideLinkedin:_p,LucideList:Mm,LucideListCheck:EY,LucideListChecks:PY,LucideListCollapse:IY,LucideListEnd:LY,LucideListFilter:DY,LucideListMinus:OY,LucideListMusic:RY,LucideListOrdered:Jv,LucideListPlus:FY,LucideListRestart:zY,LucideListStart:BY,LucideListTodo:$Y,LucideListTree:qY,LucideListVideo:UY,LucideListX:VY,LucideLoader:WY,LucideLoader2:Ss,LucideLoaderCircle:Ss,LucideLoaderPinwheel:HY,LucideLocate:ZY,LucideLocateFixed:GY,LucideLocateOff:KY,LucideLock:vh,LucideLockKeyhole:YY,LucideLockKeyholeOpen:hk,LucideLockOpen:mk,LucideLogIn:gM,LucideLogOut:xM,LucideLogs:XY,LucideLollipop:QY,LucideLuggage:JY,LucideMSquare:uN,LucideMagnet:eX,LucideMail:br,LucideMailCheck:tX,LucideMailMinus:sX,LucideMailOpen:rX,LucideMailPlus:nX,LucideMailQuestion:aX,LucideMailSearch:iX,LucideMailWarning:oX,LucideMailX:HI,LucideMailbox:lX,LucideMails:cX,LucideMap:bX,LucideMapPin:Ui,LucideMapPinCheck:uX,LucideMapPinCheckInside:dX,LucideMapPinHouse:hX,LucideMapPinMinus:pX,LucideMapPinMinusInside:mX,LucideMapPinOff:fX,LucideMapPinPlus:xX,LucideMapPinPlusInside:gX,LucideMapPinX:vX,LucideMapPinXInside:yX,LucideMapPinned:_X,LucideMartini:wX,LucideMaximize:WI,LucideMaximize2:jX,LucideMedal:e1,LucideMegaphone:bp,LucideMegaphoneOff:kX,LucideMeh:NX,LucideMemoryStick:SX,LucideMenu:GI,LucideMenuSquare:hN,LucideMerge:CX,LucideMessageCircle:Ec,LucideMessageCircleCode:MX,LucideMessageCircleDashed:TX,LucideMessageCircleHeart:yM,LucideMessageCircleMore:AX,LucideMessageCircleOff:EX,LucideMessageCirclePlus:PX,LucideMessageCircleQuestion:KI,LucideMessageCircleReply:IX,LucideMessageCircleWarning:LX,LucideMessageCircleX:DX,LucideMessageSquare:po,LucideMessageSquareCode:OX,LucideMessageSquareDashed:RX,LucideMessageSquareDiff:FX,LucideMessageSquareDot:zX,LucideMessageSquareHeart:BX,LucideMessageSquareLock:$X,LucideMessageSquareMore:ZI,LucideMessageSquareOff:qX,LucideMessageSquarePlus:vM,LucideMessageSquareQuote:YI,LucideMessageSquareReply:UX,LucideMessageSquareShare:VX,LucideMessageSquareText:HX,LucideMessageSquareWarning:WX,LucideMessageSquareX:GX,LucideMessagesSquare:KX,LucideMic:XI,LucideMic2:pk,LucideMicOff:ZX,LucideMicVocal:pk,LucideMicrochip:YX,LucideMicroscope:XX,LucideMicrowave:QX,LucideMilestone:JX,LucideMilk:tQ,LucideMilkOff:eQ,LucideMinimize:rQ,LucideMinimize2:sQ,LucideMinus:t1,LucideMinusCircle:Sj,LucideMinusSquare:mN,LucideMonitor:H4,LucideMonitorCheck:nQ,LucideMonitorCog:aQ,LucideMonitorDot:iQ,LucideMonitorDown:oQ,LucideMonitorOff:lQ,LucideMonitorPause:cQ,LucideMonitorPlay:dQ,LucideMonitorSmartphone:uQ,LucideMonitorSpeaker:hQ,LucideMonitorStop:mQ,LucideMonitorUp:pQ,LucideMonitorX:fQ,LucideMoon:xQ,LucideMoonStar:gQ,LucideMoreHorizontal:ig,LucideMoreVertical:ag,LucideMountain:vQ,LucideMountainSnow:yQ,LucideMouse:jQ,LucideMouseOff:_Q,LucideMousePointer:Lh,LucideMousePointer2:bQ,LucideMousePointerBan:wQ,LucideMousePointerClick:Lb,LucideMousePointerSquareDashed:rN,LucideMove:OQ,LucideMove3D:fk,LucideMove3d:fk,LucideMoveDiagonal:NQ,LucideMoveDiagonal2:kQ,LucideMoveDown:MQ,LucideMoveDownLeft:SQ,LucideMoveDownRight:CQ,LucideMoveHorizontal:TQ,LucideMoveLeft:AQ,LucideMoveRight:EQ,LucideMoveUp:LQ,LucideMoveUpLeft:PQ,LucideMoveUpRight:IQ,LucideMoveVertical:DQ,LucideMusic:BQ,LucideMusic2:RQ,LucideMusic3:FQ,LucideMusic4:zQ,LucideNavigation:VQ,LucideNavigation2:qQ,LucideNavigation2Off:$Q,LucideNavigationOff:UQ,LucideNetwork:HQ,LucideNewspaper:s1,LucideNfc:WQ,LucideNotebook:YQ,LucideNotebookPen:GQ,LucideNotebookTabs:KQ,LucideNotebookText:ZQ,LucideNotepadText:QQ,LucideNotepadTextDashed:XQ,LucideNut:eJ,LucideNutOff:JQ,LucideOctagon:sJ,LucideOctagonAlert:Tv,LucideOctagonMinus:tJ,LucideOctagonPause:gk,LucideOctagonX:xk,LucideOmega:rJ,LucideOption:nJ,LucideOrbit:aJ,LucideOrigami:iJ,LucideOutdent:ck,LucidePackage:bl,LucidePackage2:oJ,LucidePackageCheck:lJ,LucidePackageMinus:cJ,LucidePackageOpen:dJ,LucidePackagePlus:uJ,LucidePackageSearch:hJ,LucidePackageX:mJ,LucidePaintBucket:pJ,LucidePaintRoller:fJ,LucidePaintbrush:gJ,LucidePaintbrush2:yk,LucidePaintbrushVertical:yk,LucidePalette:Ql,LucidePalmtree:DN,LucidePanelBottom:vJ,LucidePanelBottomClose:xJ,LucidePanelBottomDashed:vk,LucidePanelBottomInactive:vk,LucidePanelBottomOpen:yJ,LucidePanelLeft:jk,LucidePanelLeftClose:_k,LucidePanelLeftDashed:bk,LucidePanelLeftInactive:bk,LucidePanelLeftOpen:wk,LucidePanelRight:wJ,LucidePanelRightClose:_J,LucidePanelRightDashed:kk,LucidePanelRightInactive:kk,LucidePanelRightOpen:bJ,LucidePanelTop:NJ,LucidePanelTopClose:jJ,LucidePanelTopDashed:Nk,LucidePanelTopInactive:Nk,LucidePanelTopOpen:kJ,LucidePanelsLeftBottom:SJ,LucidePanelsLeftRight:Uj,LucidePanelsRightBottom:CJ,LucidePanelsTopBottom:Ak,LucidePanelsTopLeft:Av,LucidePaperclip:W4,LucideParentheses:MJ,LucideParkingCircle:Mj,LucideParkingCircleOff:Cj,LucideParkingMeter:TJ,LucideParkingSquare:gN,LucideParkingSquareOff:fN,LucidePartyPopper:Zd,LucidePause:cf,LucidePauseCircle:Tj,LucidePauseOctagon:gk,LucidePawPrint:AJ,LucidePcCase:EJ,LucidePen:Wy,LucidePenBox:rd,LucidePenLine:Ev,LucidePenOff:PJ,LucidePenSquare:rd,LucidePenTool:Db,LucidePencil:$a,LucidePencilLine:IJ,LucidePencilOff:LJ,LucidePencilRuler:DJ,LucidePentagon:OJ,LucidePercent:_M,LucidePercentCircle:Aj,LucidePercentDiamond:Hj,LucidePercentSquare:xN,LucidePersonStanding:RJ,LucidePhilippinePeso:FJ,LucidePhone:ea,LucidePhoneCall:zJ,LucidePhoneForwarded:BJ,LucidePhoneIncoming:$J,LucidePhoneMissed:qJ,LucidePhoneOff:UJ,LucidePhoneOutgoing:VJ,LucidePi:HJ,LucidePiSquare:yN,LucidePiano:WJ,LucidePickaxe:GJ,LucidePictureInPicture:ZJ,LucidePictureInPicture2:KJ,LucidePieChart:dj,LucidePiggyBank:YJ,LucidePilcrow:JJ,LucidePilcrowLeft:XJ,LucidePilcrowRight:QJ,LucidePilcrowSquare:vN,LucidePill:tee,LucidePillBottle:eee,LucidePin:Ob,LucidePinOff:QI,LucidePipette:see,LucidePizza:ree,LucidePlane:iee,LucidePlaneLanding:nee,LucidePlaneTakeoff:aee,LucidePlay:wl,LucidePlayCircle:ap,LucidePlaySquare:_N,LucidePlug:JI,LucidePlug2:oee,LucidePlugZap:Sk,LucidePlugZap2:Sk,LucidePlus:Zs,LucidePlusCircle:Ej,LucidePlusSquare:bN,LucidePocket:cee,LucidePocketKnife:lee,LucidePodcast:dee,LucidePointer:hee,LucidePointerOff:uee,LucidePopcorn:mee,LucidePopsicle:pee,LucidePoundSterling:fee,LucidePower:eL,LucidePowerCircle:Pj,LucidePowerOff:gee,LucidePowerSquare:wN,LucidePresentation:Gx,LucidePrinter:tL,LucidePrinterCheck:xee,LucideProjector:yee,LucideProportions:vee,LucidePuzzle:_ee,LucidePyramid:bee,LucideQrCode:r1,LucideQuote:bM,LucideRabbit:wee,LucideRadar:jee,LucideRadiation:kee,LucideRadical:Nee,LucideRadio:n1,LucideRadioReceiver:See,LucideRadioTower:Cee,LucideRadius:Mee,LucideRailSymbol:Tee,LucideRainbow:Aee,LucideRat:Eee,LucideRatio:Pee,LucideReceipt:$ee,LucideReceiptCent:Iee,LucideReceiptEuro:Lee,LucideReceiptIndianRupee:Dee,LucideReceiptJapaneseYen:Oee,LucideReceiptPoundSterling:Ree,LucideReceiptRussianRuble:Fee,LucideReceiptSwissFranc:zee,LucideReceiptText:Bee,LucideRectangleEllipsis:Ck,LucideRectangleHorizontal:qee,LucideRectangleVertical:Uee,LucideRecycle:Vee,LucideRedo:wM,LucideRedo2:Hee,LucideRedoDot:Wee,LucideRefreshCcw:Kee,LucideRefreshCcwDot:Gee,LucideRefreshCw:Bo,LucideRefreshCwOff:Zee,LucideRefrigerator:Yee,LucideRegex:Xee,LucideRemoveFormatting:Qee,LucideRepeat:sL,LucideRepeat1:Jee,LucideRepeat2:ete,LucideReplace:ste,LucideReplaceAll:tte,LucideReply:rL,LucideReplyAll:rte,LucideRewind:nte,LucideRibbon:ate,LucideRocket:o0,LucideRockingChair:ite,LucideRollerCoaster:ote,LucideRotate3D:Mk,LucideRotate3d:Mk,LucideRotateCcw:a1,LucideRotateCcwSquare:lte,LucideRotateCw:nL,LucideRotateCwSquare:cte,LucideRoute:ute,LucideRouteOff:dte,LucideRouter:hte,LucideRows:Tk,LucideRows2:Tk,LucideRows3:Ak,LucideRows4:mte,LucideRss:pte,LucideRuler:aL,LucideRussianRuble:fte,LucideSailboat:gte,LucideSalad:xte,LucideSandwich:yte,LucideSatellite:_te,LucideSatelliteDish:vte,LucideSave:Wu,LucideSaveAll:bte,LucideSaveOff:wte,LucideScale:iL,LucideScale3D:Ek,LucideScale3d:Ek,LucideScaling:jte,LucideScan:Ete,LucideScanBarcode:kte,LucideScanEye:Nte,LucideScanFace:Ste,LucideScanLine:Cte,LucideScanQrCode:Mte,LucideScanSearch:Tte,LucideScanText:Ate,LucideScatterChart:uj,LucideSchool:Pte,LucideSchool2:RN,LucideScissors:Lte,LucideScissorsLineDashed:Ite,LucideScissorsSquare:jN,LucideScissorsSquareDashedBottom:Zk,LucideScreenShare:Ote,LucideScreenShareOff:Dte,LucideScroll:Fte,LucideScrollText:Rte,LucideSearch:xn,LucideSearchCheck:zte,LucideSearchCode:Bte,LucideSearchSlash:$te,LucideSearchX:oL,LucideSection:qte,LucideSend:oa,LucideSendHorizonal:Pk,LucideSendHorizontal:Pk,LucideSendToBack:Ute,LucideSeparatorHorizontal:Vte,LucideSeparatorVertical:Hte,LucideServer:Zte,LucideServerCog:Wte,LucideServerCrash:Gte,LucideServerOff:Kte,LucideSettings:Jl,LucideSettings2:lL,LucideShapes:Yte,LucideShare:cL,LucideShare2:Ad,LucideSheet:Xte,LucideShell:Qte,LucideShield:Bh,LucideShieldAlert:Jte,LucideShieldBan:ese,LucideShieldCheck:dL,LucideShieldClose:Ik,LucideShieldEllipsis:tse,LucideShieldHalf:sse,LucideShieldMinus:rse,LucideShieldOff:nse,LucideShieldPlus:ase,LucideShieldQuestion:ise,LucideShieldX:Ik,LucideShip:lse,LucideShipWheel:ose,LucideShirt:cse,LucideShoppingBag:l0,LucideShoppingBasket:dse,LucideShoppingCart:dp,LucideShovel:use,LucideShowerHead:hse,LucideShrink:mse,LucideShrub:pse,LucideShuffle:G4,LucideSidebar:jk,LucideSidebarClose:_k,LucideSidebarOpen:wk,LucideSigma:fse,LucideSigmaSquare:kN,LucideSignal:_se,LucideSignalHigh:gse,LucideSignalLow:xse,LucideSignalMedium:yse,LucideSignalZero:vse,LucideSignature:bse,LucideSignpost:jse,LucideSignpostBig:wse,LucideSiren:kse,LucideSkipBack:Nse,LucideSkipForward:Sse,LucideSkull:Cse,LucideSlack:Mse,LucideSlash:Tse,LucideSlashSquare:NN,LucideSlice:Ase,LucideSliders:Lk,LucideSlidersHorizontal:uL,LucideSlidersVertical:Lk,LucideSmartphone:i1,LucideSmartphoneCharging:Ese,LucideSmartphoneNfc:Pse,LucideSmile:Lse,LucideSmilePlus:Ise,LucideSnail:Dse,LucideSnowflake:hb,LucideSofa:Ose,LucideSortAsc:Hw,LucideSortDesc:qw,LucideSoup:Rse,LucideSpace:Fse,LucideSpade:zse,LucideSparkle:Bse,LucideSparkles:hn,LucideSpeaker:$se,LucideSpeech:qse,LucideSpellCheck:Vse,LucideSpellCheck2:Use,LucideSpline:Hse,LucideSplit:Wse,LucideSplitSquareHorizontal:SN,LucideSplitSquareVertical:CN,LucideSprayCan:Gse,LucideSprout:Kse,LucideSquare:c0,LucideSquareActivity:Dk,LucideSquareArrowDown:Fk,LucideSquareArrowDownLeft:Ok,LucideSquareArrowDownRight:Rk,LucideSquareArrowLeft:zk,LucideSquareArrowOutDownLeft:Bk,LucideSquareArrowOutDownRight:$k,LucideSquareArrowOutUpLeft:qk,LucideSquareArrowOutUpRight:Uk,LucideSquareArrowRight:Vk,LucideSquareArrowUp:Gk,LucideSquareArrowUpLeft:Hk,LucideSquareArrowUpRight:Wk,LucideSquareAsterisk:Kk,LucideSquareBottomDashedScissors:Zk,LucideSquareChartGantt:Oy,LucideSquareCheck:Yk,LucideSquareCheckBig:Pv,LucideSquareChevronDown:Xk,LucideSquareChevronLeft:Qk,LucideSquareChevronRight:Jk,LucideSquareChevronUp:eN,LucideSquareCode:tN,LucideSquareDashed:nN,LucideSquareDashedBottom:Yse,LucideSquareDashedBottomCode:Zse,LucideSquareDashedKanban:sN,LucideSquareDashedMousePointer:rN,LucideSquareDivide:aN,LucideSquareDot:iN,LucideSquareEqual:oN,LucideSquareFunction:lN,LucideSquareGanttChart:Oy,LucideSquareKanban:cN,LucideSquareLibrary:dN,LucideSquareM:uN,LucideSquareMenu:hN,LucideSquareMinus:mN,LucideSquareMousePointer:pN,LucideSquareParking:gN,LucideSquareParkingOff:fN,LucideSquarePen:rd,LucideSquarePercent:xN,LucideSquarePi:yN,LucideSquarePilcrow:vN,LucideSquarePlay:_N,LucideSquarePlus:bN,LucideSquarePower:wN,LucideSquareRadical:Xse,LucideSquareScissors:jN,LucideSquareSigma:kN,LucideSquareSlash:NN,LucideSquareSplitHorizontal:SN,LucideSquareSplitVertical:CN,LucideSquareSquare:Qse,LucideSquareStack:Jse,LucideSquareTerminal:MN,LucideSquareUser:AN,LucideSquareUserRound:TN,LucideSquareX:EN,LucideSquircle:ere,LucideSquirrel:tre,LucideStamp:sre,LucideStar:Kn,LucideStarHalf:rre,LucideStarOff:nre,LucideStars:hn,LucideStepBack:are,LucideStepForward:ire,LucideStethoscope:ore,LucideSticker:lre,LucideStickyNote:cre,LucideStopCircle:Lj,LucideStore:dre,LucideStretchHorizontal:ure,LucideStretchVertical:hre,LucideStrikethrough:mre,LucideSubscript:pre,LucideSubtitles:Jw,LucideSun:Rb,LucideSunDim:fre,LucideSunMedium:gre,LucideSunMoon:xre,LucideSunSnow:yre,LucideSunrise:vre,LucideSunset:_re,LucideSuperscript:bre,LucideSwatchBook:wre,LucideSwissFranc:jre,LucideSwitchCamera:kre,LucideSword:Nre,LucideSwords:Sre,LucideSyringe:Cre,LucideTable:hL,LucideTable2:jM,LucideTableCellsMerge:Mre,LucideTableCellsSplit:Tre,LucideTableColumnsSplit:Are,LucideTableOfContents:Ere,LucideTableProperties:Pre,LucideTableRowsSplit:Ire,LucideTablet:Dre,LucideTabletSmartphone:Lre,LucideTablets:Ore,LucideTag:Tm,LucideTags:Rre,LucideTally1:Fre,LucideTally2:zre,LucideTally3:Bre,LucideTally4:$re,LucideTally5:qre,LucideTangent:Ure,LucideTarget:Am,LucideTelescope:Vre,LucideTent:Wre,LucideTentTree:Hre,LucideTerminal:Gre,LucideTerminalSquare:MN,LucideTestTube:Kre,LucideTestTube2:PN,LucideTestTubeDiagonal:PN,LucideTestTubes:Zre,LucideText:ene,LucideTextCursor:Xre,LucideTextCursorInput:Yre,LucideTextQuote:Qre,LucideTextSearch:Jre,LucideTextSelect:IN,LucideTextSelection:IN,LucideTheater:tne,LucideThermometer:nne,LucideThermometerSnowflake:sne,LucideThermometerSun:rne,LucideThumbsDown:mL,LucideThumbsUp:Gu,LucideTicket:pL,LucideTicketCheck:ane,LucideTicketMinus:ine,LucideTicketPercent:one,LucideTicketPlus:lne,LucideTicketSlash:cne,LucideTicketX:dne,LucideTickets:hne,LucideTicketsPlane:une,LucideTimer:fne,LucideTimerOff:mne,LucideTimerReset:pne,LucideToggleLeft:gne,LucideToggleRight:xne,LucideToilet:yne,LucideTornado:vne,LucideTorus:_ne,LucideTouchpad:wne,LucideTouchpadOff:bne,LucideTowerControl:jne,LucideToyBrick:kne,LucideTractor:Nne,LucideTrafficCone:Sne,LucideTrain:LN,LucideTrainFront:Mne,LucideTrainFrontTunnel:Cne,LucideTrainTrack:Tne,LucideTramFront:LN,LucideTrash:Ane,LucideTrash2:jr,LucideTreeDeciduous:Ene,LucideTreePalm:DN,LucideTreePine:Fb,LucideTrees:Pne,LucideTrello:Ine,LucideTrendingDown:K4,LucideTrendingUp:xc,LucideTrendingUpDown:Lne,LucideTriangle:One,LucideTriangleAlert:uh,LucideTriangleRight:Dne,LucideTrophy:mo,LucideTruck:fL,LucideTurtle:Rne,LucideTv:zne,LucideTv2:ON,LucideTvMinimal:ON,LucideTvMinimalPlay:Fne,LucideTwitch:Bne,LucideTwitter:$ne,LucideType:Une,LucideTypeOutline:qne,LucideUmbrella:Hne,LucideUmbrellaOff:Vne,LucideUnderline:Wne,LucideUndo:kM,LucideUndo2:Gne,LucideUndoDot:Kne,LucideUnfoldHorizontal:Zne,LucideUnfoldVertical:Yne,LucideUngroup:Xne,LucideUniversity:RN,LucideUnlink:Z4,LucideUnlink2:Qne,LucideUnlock:mk,LucideUnlockKeyhole:hk,LucideUnplug:Jne,LucideUpload:ni,LucideUploadCloud:Bj,LucideUsb:eae,LucideUser:ro,LucideUser2:UN,LucideUserCheck:zb,LucideUserCheck2:FN,LucideUserCircle:Oj,LucideUserCircle2:Dj,LucideUserCog:gL,LucideUserCog2:zN,LucideUserMinus:xL,LucideUserMinus2:BN,LucideUserPen:tae,LucideUserPlus:Pc,LucideUserPlus2:$N,LucideUserRound:UN,LucideUserRoundCheck:FN,LucideUserRoundCog:zN,LucideUserRoundMinus:BN,LucideUserRoundPen:sae,LucideUserRoundPlus:$N,LucideUserRoundSearch:rae,LucideUserRoundX:qN,LucideUserSearch:nae,LucideUserSquare:AN,LucideUserSquare2:TN,LucideUserX:aae,LucideUserX2:qN,LucideUsers:mr,LucideUsers2:VN,LucideUsersRound:VN,LucideUtensils:WN,LucideUtensilsCrossed:HN,LucideUtilityPole:iae,LucideVariable:yL,LucideVault:oae,LucideVegan:lae,LucideVenetianMask:cae,LucideVerified:Kw,LucideVibrate:uae,LucideVibrateOff:dae,LucideVideo:Nn,LucideVideoOff:hae,LucideVideotape:mae,LucideView:pae,LucideVoicemail:fae,LucideVolleyball:gae,LucideVolume:bae,LucideVolume1:xae,LucideVolume2:yae,LucideVolumeOff:vae,LucideVolumeX:_ae,LucideVote:wae,LucideWallet:vL,LucideWallet2:GN,LucideWalletCards:jae,LucideWalletMinimal:GN,LucideWallpaper:kae,LucideWand:Nae,LucideWand2:Iv,LucideWandSparkles:Iv,LucideWarehouse:Sae,LucideWashingMachine:Cae,LucideWatch:Mae,LucideWaves:Tae,LucideWaypoints:Aae,LucideWebcam:Eae,LucideWebhook:Iae,LucideWebhookOff:Pae,LucideWeight:Lae,LucideWheat:Oae,LucideWheatOff:Dae,LucideWholeWord:Rae,LucideWifi:qae,LucideWifiHigh:Fae,LucideWifiLow:zae,LucideWifiOff:Bae,LucideWifiZero:$ae,LucideWind:Vae,LucideWindArrowDown:Uae,LucideWine:Wae,LucideWineOff:Hae,LucideWorkflow:Gae,LucideWorm:Kae,LucideWrapText:Zae,LucideWrench:Kx,LucideX:Ur,LucideXCircle:$c,LucideXOctagon:xk,LucideXSquare:EN,LucideYoutube:Yae,LucideZap:wp,LucideZapOff:Xae,LucideZoomIn:Bb,LucideZoomOut:NM,Luggage:JY,LuggageIcon:JY,MSquare:uN,MSquareIcon:uN,Magnet:eX,MagnetIcon:eX,Mail:br,MailCheck:tX,MailCheckIcon:tX,MailIcon:br,MailMinus:sX,MailMinusIcon:sX,MailOpen:rX,MailOpenIcon:rX,MailPlus:nX,MailPlusIcon:nX,MailQuestion:aX,MailQuestionIcon:aX,MailSearch:iX,MailSearchIcon:iX,MailWarning:oX,MailWarningIcon:oX,MailX:HI,MailXIcon:HI,Mailbox:lX,MailboxIcon:lX,Mails:cX,MailsIcon:cX,Map:bX,MapIcon:bX,MapPin:Ui,MapPinCheck:uX,MapPinCheckIcon:uX,MapPinCheckInside:dX,MapPinCheckInsideIcon:dX,MapPinHouse:hX,MapPinHouseIcon:hX,MapPinIcon:Ui,MapPinMinus:pX,MapPinMinusIcon:pX,MapPinMinusInside:mX,MapPinMinusInsideIcon:mX,MapPinOff:fX,MapPinOffIcon:fX,MapPinPlus:xX,MapPinPlusIcon:xX,MapPinPlusInside:gX,MapPinPlusInsideIcon:gX,MapPinX:vX,MapPinXIcon:vX,MapPinXInside:yX,MapPinXInsideIcon:yX,MapPinned:_X,MapPinnedIcon:_X,Martini:wX,MartiniIcon:wX,Maximize:WI,Maximize2:jX,Maximize2Icon:jX,MaximizeIcon:WI,Medal:e1,MedalIcon:e1,Megaphone:bp,MegaphoneIcon:bp,MegaphoneOff:kX,MegaphoneOffIcon:kX,Meh:NX,MehIcon:NX,MemoryStick:SX,MemoryStickIcon:SX,Menu:GI,MenuIcon:GI,MenuSquare:hN,MenuSquareIcon:hN,Merge:CX,MergeIcon:CX,MessageCircle:Ec,MessageCircleCode:MX,MessageCircleCodeIcon:MX,MessageCircleDashed:TX,MessageCircleDashedIcon:TX,MessageCircleHeart:yM,MessageCircleHeartIcon:yM,MessageCircleIcon:Ec,MessageCircleMore:AX,MessageCircleMoreIcon:AX,MessageCircleOff:EX,MessageCircleOffIcon:EX,MessageCirclePlus:PX,MessageCirclePlusIcon:PX,MessageCircleQuestion:KI,MessageCircleQuestionIcon:KI,MessageCircleReply:IX,MessageCircleReplyIcon:IX,MessageCircleWarning:LX,MessageCircleWarningIcon:LX,MessageCircleX:DX,MessageCircleXIcon:DX,MessageSquare:po,MessageSquareCode:OX,MessageSquareCodeIcon:OX,MessageSquareDashed:RX,MessageSquareDashedIcon:RX,MessageSquareDiff:FX,MessageSquareDiffIcon:FX,MessageSquareDot:zX,MessageSquareDotIcon:zX,MessageSquareHeart:BX,MessageSquareHeartIcon:BX,MessageSquareIcon:po,MessageSquareLock:$X,MessageSquareLockIcon:$X,MessageSquareMore:ZI,MessageSquareMoreIcon:ZI,MessageSquareOff:qX,MessageSquareOffIcon:qX,MessageSquarePlus:vM,MessageSquarePlusIcon:vM,MessageSquareQuote:YI,MessageSquareQuoteIcon:YI,MessageSquareReply:UX,MessageSquareReplyIcon:UX,MessageSquareShare:VX,MessageSquareShareIcon:VX,MessageSquareText:HX,MessageSquareTextIcon:HX,MessageSquareWarning:WX,MessageSquareWarningIcon:WX,MessageSquareX:GX,MessageSquareXIcon:GX,MessagesSquare:KX,MessagesSquareIcon:KX,Mic:XI,Mic2:pk,Mic2Icon:pk,MicIcon:XI,MicOff:ZX,MicOffIcon:ZX,MicVocal:pk,MicVocalIcon:pk,Microchip:YX,MicrochipIcon:YX,Microscope:XX,MicroscopeIcon:XX,Microwave:QX,MicrowaveIcon:QX,Milestone:JX,MilestoneIcon:JX,Milk:tQ,MilkIcon:tQ,MilkOff:eQ,MilkOffIcon:eQ,Minimize:rQ,Minimize2:sQ,Minimize2Icon:sQ,MinimizeIcon:rQ,Minus:t1,MinusCircle:Sj,MinusCircleIcon:Sj,MinusIcon:t1,MinusSquare:mN,MinusSquareIcon:mN,Monitor:H4,MonitorCheck:nQ,MonitorCheckIcon:nQ,MonitorCog:aQ,MonitorCogIcon:aQ,MonitorDot:iQ,MonitorDotIcon:iQ,MonitorDown:oQ,MonitorDownIcon:oQ,MonitorIcon:H4,MonitorOff:lQ,MonitorOffIcon:lQ,MonitorPause:cQ,MonitorPauseIcon:cQ,MonitorPlay:dQ,MonitorPlayIcon:dQ,MonitorSmartphone:uQ,MonitorSmartphoneIcon:uQ,MonitorSpeaker:hQ,MonitorSpeakerIcon:hQ,MonitorStop:mQ,MonitorStopIcon:mQ,MonitorUp:pQ,MonitorUpIcon:pQ,MonitorX:fQ,MonitorXIcon:fQ,Moon:xQ,MoonIcon:xQ,MoonStar:gQ,MoonStarIcon:gQ,MoreHorizontal:ig,MoreHorizontalIcon:ig,MoreVertical:ag,MoreVerticalIcon:ag,Mountain:vQ,MountainIcon:vQ,MountainSnow:yQ,MountainSnowIcon:yQ,Mouse:jQ,MouseIcon:jQ,MouseOff:_Q,MouseOffIcon:_Q,MousePointer:Lh,MousePointer2:bQ,MousePointer2Icon:bQ,MousePointerBan:wQ,MousePointerBanIcon:wQ,MousePointerClick:Lb,MousePointerClickIcon:Lb,MousePointerIcon:Lh,MousePointerSquareDashed:rN,MousePointerSquareDashedIcon:rN,Move:OQ,Move3D:fk,Move3DIcon:fk,Move3d:fk,Move3dIcon:fk,MoveDiagonal:NQ,MoveDiagonal2:kQ,MoveDiagonal2Icon:kQ,MoveDiagonalIcon:NQ,MoveDown:MQ,MoveDownIcon:MQ,MoveDownLeft:SQ,MoveDownLeftIcon:SQ,MoveDownRight:CQ,MoveDownRightIcon:CQ,MoveHorizontal:TQ,MoveHorizontalIcon:TQ,MoveIcon:OQ,MoveLeft:AQ,MoveLeftIcon:AQ,MoveRight:EQ,MoveRightIcon:EQ,MoveUp:LQ,MoveUpIcon:LQ,MoveUpLeft:PQ,MoveUpLeftIcon:PQ,MoveUpRight:IQ,MoveUpRightIcon:IQ,MoveVertical:DQ,MoveVerticalIcon:DQ,Music:BQ,Music2:RQ,Music2Icon:RQ,Music3:FQ,Music3Icon:FQ,Music4:zQ,Music4Icon:zQ,MusicIcon:BQ,Navigation:VQ,Navigation2:qQ,Navigation2Icon:qQ,Navigation2Off:$Q,Navigation2OffIcon:$Q,NavigationIcon:VQ,NavigationOff:UQ,NavigationOffIcon:UQ,Network:HQ,NetworkIcon:HQ,Newspaper:s1,NewspaperIcon:s1,Nfc:WQ,NfcIcon:WQ,Notebook:YQ,NotebookIcon:YQ,NotebookPen:GQ,NotebookPenIcon:GQ,NotebookTabs:KQ,NotebookTabsIcon:KQ,NotebookText:ZQ,NotebookTextIcon:ZQ,NotepadText:QQ,NotepadTextDashed:XQ,NotepadTextDashedIcon:XQ,NotepadTextIcon:QQ,Nut:eJ,NutIcon:eJ,NutOff:JQ,NutOffIcon:JQ,Octagon:sJ,OctagonAlert:Tv,OctagonAlertIcon:Tv,OctagonIcon:sJ,OctagonMinus:tJ,OctagonMinusIcon:tJ,OctagonPause:gk,OctagonPauseIcon:gk,OctagonX:xk,OctagonXIcon:xk,Omega:rJ,OmegaIcon:rJ,Option:nJ,OptionIcon:nJ,Orbit:aJ,OrbitIcon:aJ,Origami:iJ,OrigamiIcon:iJ,Outdent:ck,OutdentIcon:ck,Package:bl,Package2:oJ,Package2Icon:oJ,PackageCheck:lJ,PackageCheckIcon:lJ,PackageIcon:bl,PackageMinus:cJ,PackageMinusIcon:cJ,PackageOpen:dJ,PackageOpenIcon:dJ,PackagePlus:uJ,PackagePlusIcon:uJ,PackageSearch:hJ,PackageSearchIcon:hJ,PackageX:mJ,PackageXIcon:mJ,PaintBucket:pJ,PaintBucketIcon:pJ,PaintRoller:fJ,PaintRollerIcon:fJ,Paintbrush:gJ,Paintbrush2:yk,Paintbrush2Icon:yk,PaintbrushIcon:gJ,PaintbrushVertical:yk,PaintbrushVerticalIcon:yk,Palette:Ql,PaletteIcon:Ql,Palmtree:DN,PalmtreeIcon:DN,PanelBottom:vJ,PanelBottomClose:xJ,PanelBottomCloseIcon:xJ,PanelBottomDashed:vk,PanelBottomDashedIcon:vk,PanelBottomIcon:vJ,PanelBottomInactive:vk,PanelBottomInactiveIcon:vk,PanelBottomOpen:yJ,PanelBottomOpenIcon:yJ,PanelLeft:jk,PanelLeftClose:_k,PanelLeftCloseIcon:_k,PanelLeftDashed:bk,PanelLeftDashedIcon:bk,PanelLeftIcon:jk,PanelLeftInactive:bk,PanelLeftInactiveIcon:bk,PanelLeftOpen:wk,PanelLeftOpenIcon:wk,PanelRight:wJ,PanelRightClose:_J,PanelRightCloseIcon:_J,PanelRightDashed:kk,PanelRightDashedIcon:kk,PanelRightIcon:wJ,PanelRightInactive:kk,PanelRightInactiveIcon:kk,PanelRightOpen:bJ,PanelRightOpenIcon:bJ,PanelTop:NJ,PanelTopClose:jJ,PanelTopCloseIcon:jJ,PanelTopDashed:Nk,PanelTopDashedIcon:Nk,PanelTopIcon:NJ,PanelTopInactive:Nk,PanelTopInactiveIcon:Nk,PanelTopOpen:kJ,PanelTopOpenIcon:kJ,PanelsLeftBottom:SJ,PanelsLeftBottomIcon:SJ,PanelsLeftRight:Uj,PanelsLeftRightIcon:Uj,PanelsRightBottom:CJ,PanelsRightBottomIcon:CJ,PanelsTopBottom:Ak,PanelsTopBottomIcon:Ak,PanelsTopLeft:Av,PanelsTopLeftIcon:Av,Paperclip:W4,PaperclipIcon:W4,Parentheses:MJ,ParenthesesIcon:MJ,ParkingCircle:Mj,ParkingCircleIcon:Mj,ParkingCircleOff:Cj,ParkingCircleOffIcon:Cj,ParkingMeter:TJ,ParkingMeterIcon:TJ,ParkingSquare:gN,ParkingSquareIcon:gN,ParkingSquareOff:fN,ParkingSquareOffIcon:fN,PartyPopper:Zd,PartyPopperIcon:Zd,Pause:cf,PauseCircle:Tj,PauseCircleIcon:Tj,PauseIcon:cf,PauseOctagon:gk,PauseOctagonIcon:gk,PawPrint:AJ,PawPrintIcon:AJ,PcCase:EJ,PcCaseIcon:EJ,Pen:Wy,PenBox:rd,PenBoxIcon:rd,PenIcon:Wy,PenLine:Ev,PenLineIcon:Ev,PenOff:PJ,PenOffIcon:PJ,PenSquare:rd,PenSquareIcon:rd,PenTool:Db,PenToolIcon:Db,Pencil:$a,PencilIcon:$a,PencilLine:IJ,PencilLineIcon:IJ,PencilOff:LJ,PencilOffIcon:LJ,PencilRuler:DJ,PencilRulerIcon:DJ,Pentagon:OJ,PentagonIcon:OJ,Percent:_M,PercentCircle:Aj,PercentCircleIcon:Aj,PercentDiamond:Hj,PercentDiamondIcon:Hj,PercentIcon:_M,PercentSquare:xN,PercentSquareIcon:xN,PersonStanding:RJ,PersonStandingIcon:RJ,PhilippinePeso:FJ,PhilippinePesoIcon:FJ,Phone:ea,PhoneCall:zJ,PhoneCallIcon:zJ,PhoneForwarded:BJ,PhoneForwardedIcon:BJ,PhoneIcon:ea,PhoneIncoming:$J,PhoneIncomingIcon:$J,PhoneMissed:qJ,PhoneMissedIcon:qJ,PhoneOff:UJ,PhoneOffIcon:UJ,PhoneOutgoing:VJ,PhoneOutgoingIcon:VJ,Pi:HJ,PiIcon:HJ,PiSquare:yN,PiSquareIcon:yN,Piano:WJ,PianoIcon:WJ,Pickaxe:GJ,PickaxeIcon:GJ,PictureInPicture:ZJ,PictureInPicture2:KJ,PictureInPicture2Icon:KJ,PictureInPictureIcon:ZJ,PieChart:dj,PieChartIcon:dj,PiggyBank:YJ,PiggyBankIcon:YJ,Pilcrow:JJ,PilcrowIcon:JJ,PilcrowLeft:XJ,PilcrowLeftIcon:XJ,PilcrowRight:QJ,PilcrowRightIcon:QJ,PilcrowSquare:vN,PilcrowSquareIcon:vN,Pill:tee,PillBottle:eee,PillBottleIcon:eee,PillIcon:tee,Pin:Ob,PinIcon:Ob,PinOff:QI,PinOffIcon:QI,Pipette:see,PipetteIcon:see,Pizza:ree,PizzaIcon:ree,Plane:iee,PlaneIcon:iee,PlaneLanding:nee,PlaneLandingIcon:nee,PlaneTakeoff:aee,PlaneTakeoffIcon:aee,Play:wl,PlayCircle:ap,PlayCircleIcon:ap,PlayIcon:wl,PlaySquare:_N,PlaySquareIcon:_N,Plug:JI,Plug2:oee,Plug2Icon:oee,PlugIcon:JI,PlugZap:Sk,PlugZap2:Sk,PlugZap2Icon:Sk,PlugZapIcon:Sk,Plus:Zs,PlusCircle:Ej,PlusCircleIcon:Ej,PlusIcon:Zs,PlusSquare:bN,PlusSquareIcon:bN,Pocket:cee,PocketIcon:cee,PocketKnife:lee,PocketKnifeIcon:lee,Podcast:dee,PodcastIcon:dee,Pointer:hee,PointerIcon:hee,PointerOff:uee,PointerOffIcon:uee,Popcorn:mee,PopcornIcon:mee,Popsicle:pee,PopsicleIcon:pee,PoundSterling:fee,PoundSterlingIcon:fee,Power:eL,PowerCircle:Pj,PowerCircleIcon:Pj,PowerIcon:eL,PowerOff:gee,PowerOffIcon:gee,PowerSquare:wN,PowerSquareIcon:wN,Presentation:Gx,PresentationIcon:Gx,Printer:tL,PrinterCheck:xee,PrinterCheckIcon:xee,PrinterIcon:tL,Projector:yee,ProjectorIcon:yee,Proportions:vee,ProportionsIcon:vee,Puzzle:_ee,PuzzleIcon:_ee,Pyramid:bee,PyramidIcon:bee,QrCode:r1,QrCodeIcon:r1,Quote:bM,QuoteIcon:bM,Rabbit:wee,RabbitIcon:wee,Radar:jee,RadarIcon:jee,Radiation:kee,RadiationIcon:kee,Radical:Nee,RadicalIcon:Nee,Radio:n1,RadioIcon:n1,RadioReceiver:See,RadioReceiverIcon:See,RadioTower:Cee,RadioTowerIcon:Cee,Radius:Mee,RadiusIcon:Mee,RailSymbol:Tee,RailSymbolIcon:Tee,Rainbow:Aee,RainbowIcon:Aee,Rat:Eee,RatIcon:Eee,Ratio:Pee,RatioIcon:Pee,Receipt:$ee,ReceiptCent:Iee,ReceiptCentIcon:Iee,ReceiptEuro:Lee,ReceiptEuroIcon:Lee,ReceiptIcon:$ee,ReceiptIndianRupee:Dee,ReceiptIndianRupeeIcon:Dee,ReceiptJapaneseYen:Oee,ReceiptJapaneseYenIcon:Oee,ReceiptPoundSterling:Ree,ReceiptPoundSterlingIcon:Ree,ReceiptRussianRuble:Fee,ReceiptRussianRubleIcon:Fee,ReceiptSwissFranc:zee,ReceiptSwissFrancIcon:zee,ReceiptText:Bee,ReceiptTextIcon:Bee,RectangleEllipsis:Ck,RectangleEllipsisIcon:Ck,RectangleHorizontal:qee,RectangleHorizontalIcon:qee,RectangleVertical:Uee,RectangleVerticalIcon:Uee,Recycle:Vee,RecycleIcon:Vee,Redo:wM,Redo2:Hee,Redo2Icon:Hee,RedoDot:Wee,RedoDotIcon:Wee,RedoIcon:wM,RefreshCcw:Kee,RefreshCcwDot:Gee,RefreshCcwDotIcon:Gee,RefreshCcwIcon:Kee,RefreshCw:Bo,RefreshCwIcon:Bo,RefreshCwOff:Zee,RefreshCwOffIcon:Zee,Refrigerator:Yee,RefrigeratorIcon:Yee,Regex:Xee,RegexIcon:Xee,RemoveFormatting:Qee,RemoveFormattingIcon:Qee,Repeat:sL,Repeat1:Jee,Repeat1Icon:Jee,Repeat2:ete,Repeat2Icon:ete,RepeatIcon:sL,Replace:ste,ReplaceAll:tte,ReplaceAllIcon:tte,ReplaceIcon:ste,Reply:rL,ReplyAll:rte,ReplyAllIcon:rte,ReplyIcon:rL,Rewind:nte,RewindIcon:nte,Ribbon:ate,RibbonIcon:ate,Rocket:o0,RocketIcon:o0,RockingChair:ite,RockingChairIcon:ite,RollerCoaster:ote,RollerCoasterIcon:ote,Rotate3D:Mk,Rotate3DIcon:Mk,Rotate3d:Mk,Rotate3dIcon:Mk,RotateCcw:a1,RotateCcwIcon:a1,RotateCcwSquare:lte,RotateCcwSquareIcon:lte,RotateCw:nL,RotateCwIcon:nL,RotateCwSquare:cte,RotateCwSquareIcon:cte,Route:ute,RouteIcon:ute,RouteOff:dte,RouteOffIcon:dte,Router:hte,RouterIcon:hte,Rows:Tk,Rows2:Tk,Rows2Icon:Tk,Rows3:Ak,Rows3Icon:Ak,Rows4:mte,Rows4Icon:mte,RowsIcon:Tk,Rss:pte,RssIcon:pte,Ruler:aL,RulerIcon:aL,RussianRuble:fte,RussianRubleIcon:fte,Sailboat:gte,SailboatIcon:gte,Salad:xte,SaladIcon:xte,Sandwich:yte,SandwichIcon:yte,Satellite:_te,SatelliteDish:vte,SatelliteDishIcon:vte,SatelliteIcon:_te,Save:Wu,SaveAll:bte,SaveAllIcon:bte,SaveIcon:Wu,SaveOff:wte,SaveOffIcon:wte,Scale:iL,Scale3D:Ek,Scale3DIcon:Ek,Scale3d:Ek,Scale3dIcon:Ek,ScaleIcon:iL,Scaling:jte,ScalingIcon:jte,Scan:Ete,ScanBarcode:kte,ScanBarcodeIcon:kte,ScanEye:Nte,ScanEyeIcon:Nte,ScanFace:Ste,ScanFaceIcon:Ste,ScanIcon:Ete,ScanLine:Cte,ScanLineIcon:Cte,ScanQrCode:Mte,ScanQrCodeIcon:Mte,ScanSearch:Tte,ScanSearchIcon:Tte,ScanText:Ate,ScanTextIcon:Ate,ScatterChart:uj,ScatterChartIcon:uj,School:Pte,School2:RN,School2Icon:RN,SchoolIcon:Pte,Scissors:Lte,ScissorsIcon:Lte,ScissorsLineDashed:Ite,ScissorsLineDashedIcon:Ite,ScissorsSquare:jN,ScissorsSquareDashedBottom:Zk,ScissorsSquareDashedBottomIcon:Zk,ScissorsSquareIcon:jN,ScreenShare:Ote,ScreenShareIcon:Ote,ScreenShareOff:Dte,ScreenShareOffIcon:Dte,Scroll:Fte,ScrollIcon:Fte,ScrollText:Rte,ScrollTextIcon:Rte,Search:xn,SearchCheck:zte,SearchCheckIcon:zte,SearchCode:Bte,SearchCodeIcon:Bte,SearchIcon:xn,SearchSlash:$te,SearchSlashIcon:$te,SearchX:oL,SearchXIcon:oL,Section:qte,SectionIcon:qte,Send:oa,SendHorizonal:Pk,SendHorizonalIcon:Pk,SendHorizontal:Pk,SendHorizontalIcon:Pk,SendIcon:oa,SendToBack:Ute,SendToBackIcon:Ute,SeparatorHorizontal:Vte,SeparatorHorizontalIcon:Vte,SeparatorVertical:Hte,SeparatorVerticalIcon:Hte,Server:Zte,ServerCog:Wte,ServerCogIcon:Wte,ServerCrash:Gte,ServerCrashIcon:Gte,ServerIcon:Zte,ServerOff:Kte,ServerOffIcon:Kte,Settings:Jl,Settings2:lL,Settings2Icon:lL,SettingsIcon:Jl,Shapes:Yte,ShapesIcon:Yte,Share:cL,Share2:Ad,Share2Icon:Ad,ShareIcon:cL,Sheet:Xte,SheetIcon:Xte,Shell:Qte,ShellIcon:Qte,Shield:Bh,ShieldAlert:Jte,ShieldAlertIcon:Jte,ShieldBan:ese,ShieldBanIcon:ese,ShieldCheck:dL,ShieldCheckIcon:dL,ShieldClose:Ik,ShieldCloseIcon:Ik,ShieldEllipsis:tse,ShieldEllipsisIcon:tse,ShieldHalf:sse,ShieldHalfIcon:sse,ShieldIcon:Bh,ShieldMinus:rse,ShieldMinusIcon:rse,ShieldOff:nse,ShieldOffIcon:nse,ShieldPlus:ase,ShieldPlusIcon:ase,ShieldQuestion:ise,ShieldQuestionIcon:ise,ShieldX:Ik,ShieldXIcon:Ik,Ship:lse,ShipIcon:lse,ShipWheel:ose,ShipWheelIcon:ose,Shirt:cse,ShirtIcon:cse,ShoppingBag:l0,ShoppingBagIcon:l0,ShoppingBasket:dse,ShoppingBasketIcon:dse,ShoppingCart:dp,ShoppingCartIcon:dp,Shovel:use,ShovelIcon:use,ShowerHead:hse,ShowerHeadIcon:hse,Shrink:mse,ShrinkIcon:mse,Shrub:pse,ShrubIcon:pse,Shuffle:G4,ShuffleIcon:G4,Sidebar:jk,SidebarClose:_k,SidebarCloseIcon:_k,SidebarIcon:jk,SidebarOpen:wk,SidebarOpenIcon:wk,Sigma:fse,SigmaIcon:fse,SigmaSquare:kN,SigmaSquareIcon:kN,Signal:_se,SignalHigh:gse,SignalHighIcon:gse,SignalIcon:_se,SignalLow:xse,SignalLowIcon:xse,SignalMedium:yse,SignalMediumIcon:yse,SignalZero:vse,SignalZeroIcon:vse,Signature:bse,SignatureIcon:bse,Signpost:jse,SignpostBig:wse,SignpostBigIcon:wse,SignpostIcon:jse,Siren:kse,SirenIcon:kse,SkipBack:Nse,SkipBackIcon:Nse,SkipForward:Sse,SkipForwardIcon:Sse,Skull:Cse,SkullIcon:Cse,Slack:Mse,SlackIcon:Mse,Slash:Tse,SlashIcon:Tse,SlashSquare:NN,SlashSquareIcon:NN,Slice:Ase,SliceIcon:Ase,Sliders:Lk,SlidersHorizontal:uL,SlidersHorizontalIcon:uL,SlidersIcon:Lk,SlidersVertical:Lk,SlidersVerticalIcon:Lk,Smartphone:i1,SmartphoneCharging:Ese,SmartphoneChargingIcon:Ese,SmartphoneIcon:i1,SmartphoneNfc:Pse,SmartphoneNfcIcon:Pse,Smile:Lse,SmileIcon:Lse,SmilePlus:Ise,SmilePlusIcon:Ise,Snail:Dse,SnailIcon:Dse,Snowflake:hb,SnowflakeIcon:hb,Sofa:Ose,SofaIcon:Ose,SortAsc:Hw,SortAscIcon:Hw,SortDesc:qw,SortDescIcon:qw,Soup:Rse,SoupIcon:Rse,Space:Fse,SpaceIcon:Fse,Spade:zse,SpadeIcon:zse,Sparkle:Bse,SparkleIcon:Bse,Sparkles:hn,SparklesIcon:hn,Speaker:$se,SpeakerIcon:$se,Speech:qse,SpeechIcon:qse,SpellCheck:Vse,SpellCheck2:Use,SpellCheck2Icon:Use,SpellCheckIcon:Vse,Spline:Hse,SplineIcon:Hse,Split:Wse,SplitIcon:Wse,SplitSquareHorizontal:SN,SplitSquareHorizontalIcon:SN,SplitSquareVertical:CN,SplitSquareVerticalIcon:CN,SprayCan:Gse,SprayCanIcon:Gse,Sprout:Kse,SproutIcon:Kse,Square:c0,SquareActivity:Dk,SquareActivityIcon:Dk,SquareArrowDown:Fk,SquareArrowDownIcon:Fk,SquareArrowDownLeft:Ok,SquareArrowDownLeftIcon:Ok,SquareArrowDownRight:Rk,SquareArrowDownRightIcon:Rk,SquareArrowLeft:zk,SquareArrowLeftIcon:zk,SquareArrowOutDownLeft:Bk,SquareArrowOutDownLeftIcon:Bk,SquareArrowOutDownRight:$k,SquareArrowOutDownRightIcon:$k,SquareArrowOutUpLeft:qk,SquareArrowOutUpLeftIcon:qk,SquareArrowOutUpRight:Uk,SquareArrowOutUpRightIcon:Uk,SquareArrowRight:Vk,SquareArrowRightIcon:Vk,SquareArrowUp:Gk,SquareArrowUpIcon:Gk,SquareArrowUpLeft:Hk,SquareArrowUpLeftIcon:Hk,SquareArrowUpRight:Wk,SquareArrowUpRightIcon:Wk,SquareAsterisk:Kk,SquareAsteriskIcon:Kk,SquareBottomDashedScissors:Zk,SquareBottomDashedScissorsIcon:Zk,SquareChartGantt:Oy,SquareChartGanttIcon:Oy,SquareCheck:Yk,SquareCheckBig:Pv,SquareCheckBigIcon:Pv,SquareCheckIcon:Yk,SquareChevronDown:Xk,SquareChevronDownIcon:Xk,SquareChevronLeft:Qk,SquareChevronLeftIcon:Qk,SquareChevronRight:Jk,SquareChevronRightIcon:Jk,SquareChevronUp:eN,SquareChevronUpIcon:eN,SquareCode:tN,SquareCodeIcon:tN,SquareDashed:nN,SquareDashedBottom:Yse,SquareDashedBottomCode:Zse,SquareDashedBottomCodeIcon:Zse,SquareDashedBottomIcon:Yse,SquareDashedIcon:nN,SquareDashedKanban:sN,SquareDashedKanbanIcon:sN,SquareDashedMousePointer:rN,SquareDashedMousePointerIcon:rN,SquareDivide:aN,SquareDivideIcon:aN,SquareDot:iN,SquareDotIcon:iN,SquareEqual:oN,SquareEqualIcon:oN,SquareFunction:lN,SquareFunctionIcon:lN,SquareGanttChart:Oy,SquareGanttChartIcon:Oy,SquareIcon:c0,SquareKanban:cN,SquareKanbanIcon:cN,SquareLibrary:dN,SquareLibraryIcon:dN,SquareM:uN,SquareMIcon:uN,SquareMenu:hN,SquareMenuIcon:hN,SquareMinus:mN,SquareMinusIcon:mN,SquareMousePointer:pN,SquareMousePointerIcon:pN,SquareParking:gN,SquareParkingIcon:gN,SquareParkingOff:fN,SquareParkingOffIcon:fN,SquarePen:rd,SquarePenIcon:rd,SquarePercent:xN,SquarePercentIcon:xN,SquarePi:yN,SquarePiIcon:yN,SquarePilcrow:vN,SquarePilcrowIcon:vN,SquarePlay:_N,SquarePlayIcon:_N,SquarePlus:bN,SquarePlusIcon:bN,SquarePower:wN,SquarePowerIcon:wN,SquareRadical:Xse,SquareRadicalIcon:Xse,SquareScissors:jN,SquareScissorsIcon:jN,SquareSigma:kN,SquareSigmaIcon:kN,SquareSlash:NN,SquareSlashIcon:NN,SquareSplitHorizontal:SN,SquareSplitHorizontalIcon:SN,SquareSplitVertical:CN,SquareSplitVerticalIcon:CN,SquareSquare:Qse,SquareSquareIcon:Qse,SquareStack:Jse,SquareStackIcon:Jse,SquareTerminal:MN,SquareTerminalIcon:MN,SquareUser:AN,SquareUserIcon:AN,SquareUserRound:TN,SquareUserRoundIcon:TN,SquareX:EN,SquareXIcon:EN,Squircle:ere,SquircleIcon:ere,Squirrel:tre,SquirrelIcon:tre,Stamp:sre,StampIcon:sre,Star:Kn,StarHalf:rre,StarHalfIcon:rre,StarIcon:Kn,StarOff:nre,StarOffIcon:nre,Stars:hn,StarsIcon:hn,StepBack:are,StepBackIcon:are,StepForward:ire,StepForwardIcon:ire,Stethoscope:ore,StethoscopeIcon:ore,Sticker:lre,StickerIcon:lre,StickyNote:cre,StickyNoteIcon:cre,StopCircle:Lj,StopCircleIcon:Lj,Store:dre,StoreIcon:dre,StretchHorizontal:ure,StretchHorizontalIcon:ure,StretchVertical:hre,StretchVerticalIcon:hre,Strikethrough:mre,StrikethroughIcon:mre,Subscript:pre,SubscriptIcon:pre,Subtitles:Jw,SubtitlesIcon:Jw,Sun:Rb,SunDim:fre,SunDimIcon:fre,SunIcon:Rb,SunMedium:gre,SunMediumIcon:gre,SunMoon:xre,SunMoonIcon:xre,SunSnow:yre,SunSnowIcon:yre,Sunrise:vre,SunriseIcon:vre,Sunset:_re,SunsetIcon:_re,Superscript:bre,SuperscriptIcon:bre,SwatchBook:wre,SwatchBookIcon:wre,SwissFranc:jre,SwissFrancIcon:jre,SwitchCamera:kre,SwitchCameraIcon:kre,Sword:Nre,SwordIcon:Nre,Swords:Sre,SwordsIcon:Sre,Syringe:Cre,SyringeIcon:Cre,Table:hL,Table2:jM,Table2Icon:jM,TableCellsMerge:Mre,TableCellsMergeIcon:Mre,TableCellsSplit:Tre,TableCellsSplitIcon:Tre,TableColumnsSplit:Are,TableColumnsSplitIcon:Are,TableIcon:hL,TableOfContents:Ere,TableOfContentsIcon:Ere,TableProperties:Pre,TablePropertiesIcon:Pre,TableRowsSplit:Ire,TableRowsSplitIcon:Ire,Tablet:Dre,TabletIcon:Dre,TabletSmartphone:Lre,TabletSmartphoneIcon:Lre,Tablets:Ore,TabletsIcon:Ore,Tag:Tm,TagIcon:Tm,Tags:Rre,TagsIcon:Rre,Tally1:Fre,Tally1Icon:Fre,Tally2:zre,Tally2Icon:zre,Tally3:Bre,Tally3Icon:Bre,Tally4:$re,Tally4Icon:$re,Tally5:qre,Tally5Icon:qre,Tangent:Ure,TangentIcon:Ure,Target:Am,TargetIcon:Am,Telescope:Vre,TelescopeIcon:Vre,Tent:Wre,TentIcon:Wre,TentTree:Hre,TentTreeIcon:Hre,Terminal:Gre,TerminalIcon:Gre,TerminalSquare:MN,TerminalSquareIcon:MN,TestTube:Kre,TestTube2:PN,TestTube2Icon:PN,TestTubeDiagonal:PN,TestTubeDiagonalIcon:PN,TestTubeIcon:Kre,TestTubes:Zre,TestTubesIcon:Zre,Text:ene,TextCursor:Xre,TextCursorIcon:Xre,TextCursorInput:Yre,TextCursorInputIcon:Yre,TextIcon:ene,TextQuote:Qre,TextQuoteIcon:Qre,TextSearch:Jre,TextSearchIcon:Jre,TextSelect:IN,TextSelectIcon:IN,TextSelection:IN,TextSelectionIcon:IN,Theater:tne,TheaterIcon:tne,Thermometer:nne,ThermometerIcon:nne,ThermometerSnowflake:sne,ThermometerSnowflakeIcon:sne,ThermometerSun:rne,ThermometerSunIcon:rne,ThumbsDown:mL,ThumbsDownIcon:mL,ThumbsUp:Gu,ThumbsUpIcon:Gu,Ticket:pL,TicketCheck:ane,TicketCheckIcon:ane,TicketIcon:pL,TicketMinus:ine,TicketMinusIcon:ine,TicketPercent:one,TicketPercentIcon:one,TicketPlus:lne,TicketPlusIcon:lne,TicketSlash:cne,TicketSlashIcon:cne,TicketX:dne,TicketXIcon:dne,Tickets:hne,TicketsIcon:hne,TicketsPlane:une,TicketsPlaneIcon:une,Timer:fne,TimerIcon:fne,TimerOff:mne,TimerOffIcon:mne,TimerReset:pne,TimerResetIcon:pne,ToggleLeft:gne,ToggleLeftIcon:gne,ToggleRight:xne,ToggleRightIcon:xne,Toilet:yne,ToiletIcon:yne,Tornado:vne,TornadoIcon:vne,Torus:_ne,TorusIcon:_ne,Touchpad:wne,TouchpadIcon:wne,TouchpadOff:bne,TouchpadOffIcon:bne,TowerControl:jne,TowerControlIcon:jne,ToyBrick:kne,ToyBrickIcon:kne,Tractor:Nne,TractorIcon:Nne,TrafficCone:Sne,TrafficConeIcon:Sne,Train:LN,TrainFront:Mne,TrainFrontIcon:Mne,TrainFrontTunnel:Cne,TrainFrontTunnelIcon:Cne,TrainIcon:LN,TrainTrack:Tne,TrainTrackIcon:Tne,TramFront:LN,TramFrontIcon:LN,Trash:Ane,Trash2:jr,Trash2Icon:jr,TrashIcon:Ane,TreeDeciduous:Ene,TreeDeciduousIcon:Ene,TreePalm:DN,TreePalmIcon:DN,TreePine:Fb,TreePineIcon:Fb,Trees:Pne,TreesIcon:Pne,Trello:Ine,TrelloIcon:Ine,TrendingDown:K4,TrendingDownIcon:K4,TrendingUp:xc,TrendingUpDown:Lne,TrendingUpDownIcon:Lne,TrendingUpIcon:xc,Triangle:One,TriangleAlert:uh,TriangleAlertIcon:uh,TriangleIcon:One,TriangleRight:Dne,TriangleRightIcon:Dne,Trophy:mo,TrophyIcon:mo,Truck:fL,TruckIcon:fL,Turtle:Rne,TurtleIcon:Rne,Tv:zne,Tv2:ON,Tv2Icon:ON,TvIcon:zne,TvMinimal:ON,TvMinimalIcon:ON,TvMinimalPlay:Fne,TvMinimalPlayIcon:Fne,Twitch:Bne,TwitchIcon:Bne,Twitter:$ne,TwitterIcon:$ne,Type:Une,TypeIcon:Une,TypeOutline:qne,TypeOutlineIcon:qne,Umbrella:Hne,UmbrellaIcon:Hne,UmbrellaOff:Vne,UmbrellaOffIcon:Vne,Underline:Wne,UnderlineIcon:Wne,Undo:kM,Undo2:Gne,Undo2Icon:Gne,UndoDot:Kne,UndoDotIcon:Kne,UndoIcon:kM,UnfoldHorizontal:Zne,UnfoldHorizontalIcon:Zne,UnfoldVertical:Yne,UnfoldVerticalIcon:Yne,Ungroup:Xne,UngroupIcon:Xne,University:RN,UniversityIcon:RN,Unlink:Z4,Unlink2:Qne,Unlink2Icon:Qne,UnlinkIcon:Z4,Unlock:mk,UnlockIcon:mk,UnlockKeyhole:hk,UnlockKeyholeIcon:hk,Unplug:Jne,UnplugIcon:Jne,Upload:ni,UploadCloud:Bj,UploadCloudIcon:Bj,UploadIcon:ni,Usb:eae,UsbIcon:eae,User:ro,User2:UN,User2Icon:UN,UserCheck:zb,UserCheck2:FN,UserCheck2Icon:FN,UserCheckIcon:zb,UserCircle:Oj,UserCircle2:Dj,UserCircle2Icon:Dj,UserCircleIcon:Oj,UserCog:gL,UserCog2:zN,UserCog2Icon:zN,UserCogIcon:gL,UserIcon:ro,UserMinus:xL,UserMinus2:BN,UserMinus2Icon:BN,UserMinusIcon:xL,UserPen:tae,UserPenIcon:tae,UserPlus:Pc,UserPlus2:$N,UserPlus2Icon:$N,UserPlusIcon:Pc,UserRound:UN,UserRoundCheck:FN,UserRoundCheckIcon:FN,UserRoundCog:zN,UserRoundCogIcon:zN,UserRoundIcon:UN,UserRoundMinus:BN,UserRoundMinusIcon:BN,UserRoundPen:sae,UserRoundPenIcon:sae,UserRoundPlus:$N,UserRoundPlusIcon:$N,UserRoundSearch:rae,UserRoundSearchIcon:rae,UserRoundX:qN,UserRoundXIcon:qN,UserSearch:nae,UserSearchIcon:nae,UserSquare:AN,UserSquare2:TN,UserSquare2Icon:TN,UserSquareIcon:AN,UserX:aae,UserX2:qN,UserX2Icon:qN,UserXIcon:aae,Users:mr,Users2:VN,Users2Icon:VN,UsersIcon:mr,UsersRound:VN,UsersRoundIcon:VN,Utensils:WN,UtensilsCrossed:HN,UtensilsCrossedIcon:HN,UtensilsIcon:WN,UtilityPole:iae,UtilityPoleIcon:iae,Variable:yL,VariableIcon:yL,Vault:oae,VaultIcon:oae,Vegan:lae,VeganIcon:lae,VenetianMask:cae,VenetianMaskIcon:cae,Verified:Kw,VerifiedIcon:Kw,Vibrate:uae,VibrateIcon:uae,VibrateOff:dae,VibrateOffIcon:dae,Video:Nn,VideoIcon:Nn,VideoOff:hae,VideoOffIcon:hae,Videotape:mae,VideotapeIcon:mae,View:pae,ViewIcon:pae,Voicemail:fae,VoicemailIcon:fae,Volleyball:gae,VolleyballIcon:gae,Volume:bae,Volume1:xae,Volume1Icon:xae,Volume2:yae,Volume2Icon:yae,VolumeIcon:bae,VolumeOff:vae,VolumeOffIcon:vae,VolumeX:_ae,VolumeXIcon:_ae,Vote:wae,VoteIcon:wae,Wallet:vL,Wallet2:GN,Wallet2Icon:GN,WalletCards:jae,WalletCardsIcon:jae,WalletIcon:vL,WalletMinimal:GN,WalletMinimalIcon:GN,Wallpaper:kae,WallpaperIcon:kae,Wand:Nae,Wand2:Iv,Wand2Icon:Iv,WandIcon:Nae,WandSparkles:Iv,WandSparklesIcon:Iv,Warehouse:Sae,WarehouseIcon:Sae,WashingMachine:Cae,WashingMachineIcon:Cae,Watch:Mae,WatchIcon:Mae,Waves:Tae,WavesIcon:Tae,Waypoints:Aae,WaypointsIcon:Aae,Webcam:Eae,WebcamIcon:Eae,Webhook:Iae,WebhookIcon:Iae,WebhookOff:Pae,WebhookOffIcon:Pae,Weight:Lae,WeightIcon:Lae,Wheat:Oae,WheatIcon:Oae,WheatOff:Dae,WheatOffIcon:Dae,WholeWord:Rae,WholeWordIcon:Rae,Wifi:qae,WifiHigh:Fae,WifiHighIcon:Fae,WifiIcon:qae,WifiLow:zae,WifiLowIcon:zae,WifiOff:Bae,WifiOffIcon:Bae,WifiZero:$ae,WifiZeroIcon:$ae,Wind:Vae,WindArrowDown:Uae,WindArrowDownIcon:Uae,WindIcon:Vae,Wine:Wae,WineIcon:Wae,WineOff:Hae,WineOffIcon:Hae,Workflow:Gae,WorkflowIcon:Gae,Worm:Kae,WormIcon:Kae,WrapText:Zae,WrapTextIcon:Zae,Wrench:Kx,WrenchIcon:Kx,X:Ur,XCircle:$c,XCircleIcon:$c,XIcon:Ur,XOctagon:xk,XOctagonIcon:xk,XSquare:EN,XSquareIcon:EN,Youtube:Yae,YoutubeIcon:Yae,Zap:wp,ZapIcon:wp,ZapOff:Xae,ZapOffIcon:Xae,ZoomIn:Bb,ZoomInIcon:Bb,ZoomOut:NM,ZoomOutIcon:NM,createLucideIcon:Z,icons:Kft},Symbol.toStringTag,{value:"Module"})),awe="-",Zft=t=>{const s=Xft(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split(awe);return i[0]===""&&i.length!==1&&i.shift(),N$e(i,s)||Yft(l)},getConflictingClassGroupIds:(l,i)=>{const c=r[l]||[];return i&&n[l]?[...c,...n[l]]:c}}},N$e=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?N$e(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join(awe);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},nAe=/^\[(.+)\]$/,Yft=t=>{if(nAe.test(t)){const s=nAe.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},Xft=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return Jft(Object.entries(t.classGroups),r).forEach(([o,l])=>{b0e(l,n,o,s)}),n},b0e=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:aAe(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(Qft(a)){b0e(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{b0e(l,aAe(s,o),r,n)})})},aAe=(t,s)=>{let r=t;return s.split(awe).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},Qft=t=>t.isThemeGetter,Jft=(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,egt=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)}}},S$e="!",tgt=t=>{const{separator:s,experimentalParseClassName:r}=t,n=s.length===1,a=s[0],o=s.length,l=i=>{const c=[];let u=0,p=0,f;for(let j=0;jp?f-p:void 0;return{modifiers:c,hasImportantModifier:_,baseClassName:b,maybePostfixModifierPosition:w}};return r?i=>r({className:i,parseClassName:l}):l},sgt=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},rgt=t=>({cache:egt(t.cacheSize),parseClassName:tgt(t),...Zft(t)}),ngt=/\s+/,agt=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(ngt);let i="";for(let c=l.length-1;c>=0;c-=1){const u=l[c],{modifiers:p,hasImportantModifier:f,baseClassName:y,maybePostfixModifierPosition:_}=r(u);let b=!!_,w=n(b?y.substring(0,_):y);if(!w){if(!b){i=u+(i.length>0?" "+i:i);continue}if(w=n(y),!w){i=u+(i.length>0?" "+i:i);continue}b=!1}const j=sgt(p).join(":"),N=f?j+S$e:j,S=N+w;if(o.includes(S))continue;o.push(S);const T=a(w,b);for(let I=0;I0?" "+i:i)}return i};function igt(){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=rgt(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=agt(c,r);return a(c,p),p}return function(){return o(igt.apply(null,arguments))}}const ic=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},M$e=/^\[(?:([a-z-]+):)?(.+)\]$/i,lgt=/^\d+\/\d+$/,cgt=new Set(["px","full","screen"]),dgt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ugt=/\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$/,hgt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,mgt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,pgt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,hv=t=>SM(t)||cgt.has(t)||lgt.test(t),__=t=>_A(t,"length",wgt),SM=t=>!!t&&!Number.isNaN(Number(t)),$fe=t=>_A(t,"number",SM),v6=t=>!!t&&Number.isInteger(Number(t)),fgt=t=>t.endsWith("%")&&SM(t.slice(0,-1)),Gi=t=>M$e.test(t),b_=t=>dgt.test(t),ggt=new Set(["length","size","percentage"]),xgt=t=>_A(t,ggt,T$e),ygt=t=>_A(t,"position",T$e),vgt=new Set(["image","url"]),_gt=t=>_A(t,vgt,kgt),bgt=t=>_A(t,"",jgt),_6=()=>!0,_A=(t,s,r)=>{const n=M$e.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},wgt=t=>ugt.test(t)&&!hgt.test(t),T$e=()=>!1,jgt=t=>mgt.test(t),kgt=t=>pgt.test(t),Ngt=()=>{const t=ic("colors"),s=ic("spacing"),r=ic("blur"),n=ic("brightness"),a=ic("borderColor"),o=ic("borderRadius"),l=ic("borderSpacing"),i=ic("borderWidth"),c=ic("contrast"),u=ic("grayscale"),p=ic("hueRotate"),f=ic("invert"),y=ic("gap"),_=ic("gradientColorStops"),b=ic("gradientColorStopPositions"),w=ic("inset"),j=ic("margin"),N=ic("opacity"),S=ic("padding"),T=ic("saturate"),I=ic("scale"),L=ic("sepia"),R=ic("skew"),$=ic("space"),q=ic("translate"),U=()=>["auto","contain","none"],V=()=>["auto","hidden","clip","visible","scroll"],X=()=>["auto",Gi,s],se=()=>[Gi,s],ee=()=>["",hv,__],Q=()=>["auto",SM,Gi],de=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],re=()=>["solid","dashed","dotted","double","none"],ne=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>["start","end","center","between","around","evenly","stretch"],he=()=>["","0",Gi],we=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ye=()=>[SM,Gi];return{cacheSize:500,separator:":",theme:{colors:[_6],spacing:[hv,__],blur:["none","",b_,Gi],brightness:ye(),borderColor:[t],borderRadius:["none","","full",b_,Gi],borderSpacing:se(),borderWidth:ee(),contrast:ye(),grayscale:he(),hueRotate:ye(),invert:he(),gap:se(),gradientColorStops:[t],gradientColorStopPositions:[fgt,__],inset:X(),margin:X(),opacity:ye(),padding:se(),saturate:ye(),scale:ye(),sepia:he(),skew:ye(),space:se(),translate:se()},classGroups:{aspect:[{aspect:["auto","square","video",Gi]}],container:["container"],columns:[{columns:[b_]}],"break-after":[{"break-after":we()}],"break-before":[{"break-before":we()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...de(),Gi]}],overflow:[{overflow:V()}],"overflow-x":[{"overflow-x":V()}],"overflow-y":[{"overflow-y":V()}],overscroll:[{overscroll:U()}],"overscroll-x":[{"overscroll-x":U()}],"overscroll-y":[{"overscroll-y":U()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[w]}],"inset-x":[{"inset-x":[w]}],"inset-y":[{"inset-y":[w]}],start:[{start:[w]}],end:[{end:[w]}],top:[{top:[w]}],right:[{right:[w]}],bottom:[{bottom:[w]}],left:[{left:[w]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",v6,Gi]}],basis:[{basis:X()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Gi]}],grow:[{grow:he()}],shrink:[{shrink:he()}],order:[{order:["first","last","none",v6,Gi]}],"grid-cols":[{"grid-cols":[_6]}],"col-start-end":[{col:["auto",{span:["full",v6,Gi]},Gi]}],"col-start":[{"col-start":Q()}],"col-end":[{"col-end":Q()}],"grid-rows":[{"grid-rows":[_6]}],"row-start-end":[{row:["auto",{span:[v6,Gi]},Gi]}],"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",Gi]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Gi]}],gap:[{gap:[y]}],"gap-x":[{"gap-x":[y]}],"gap-y":[{"gap-y":[y]}],"justify-content":[{justify:["normal",...le()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...le(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...le(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[S]}],px:[{px:[S]}],py:[{py:[S]}],ps:[{ps:[S]}],pe:[{pe:[S]}],pt:[{pt:[S]}],pr:[{pr:[S]}],pb:[{pb:[S]}],pl:[{pl:[S]}],m:[{m:[j]}],mx:[{mx:[j]}],my:[{my:[j]}],ms:[{ms:[j]}],me:[{me:[j]}],mt:[{mt:[j]}],mr:[{mr:[j]}],mb:[{mb:[j]}],ml:[{ml:[j]}],"space-x":[{"space-x":[$]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[$]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Gi,s]}],"min-w":[{"min-w":[Gi,s,"min","max","fit"]}],"max-w":[{"max-w":[Gi,s,"none","full","min","max","fit","prose",{screen:[b_]},b_]}],h:[{h:[Gi,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Gi,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Gi,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Gi,s,"auto","min","max","fit"]}],"font-size":[{text:["base",b_,__]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",$fe]}],"font-family":[{font:[_6]}],"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",Gi]}],"line-clamp":[{"line-clamp":["none",SM,$fe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",hv,Gi]}],"list-image":[{"list-image":["none",Gi]}],"list-style-type":[{list:["none","disc","decimal",Gi]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[N]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[N]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...re(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",hv,__]}],"underline-offset":[{"underline-offset":["auto",hv,Gi]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:se()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Gi]}],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",Gi]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[N]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...de(),ygt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",xgt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},_gt]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[_]}],"gradient-via":[{via:[_]}],"gradient-to":[{to:[_]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-l":[{"border-l":[i]}],"border-opacity":[{"border-opacity":[N]}],"border-style":[{border:[...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":[N]}],"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":[hv,Gi]}],"outline-w":[{outline:[hv,__]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:ee()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[N]}],"ring-offset-w":[{"ring-offset":[hv,__]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",b_,bgt]}],"shadow-color":[{shadow:[_6]}],opacity:[{opacity:[N]}],"mix-blend":[{"mix-blend":[...ne(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ne()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",b_,Gi]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[f]}],saturate:[{saturate:[T]}],sepia:[{sepia:[L]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[N]}],"backdrop-saturate":[{"backdrop-saturate":[T]}],"backdrop-sepia":[{"backdrop-sepia":[L]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[l]}],"border-spacing-x":[{"border-spacing-x":[l]}],"border-spacing-y":[{"border-spacing-y":[l]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Gi]}],duration:[{duration:ye()}],ease:[{ease:["linear","in","out","in-out",Gi]}],delay:[{delay:ye()}],animate:[{animate:["none","spin","ping","pulse","bounce",Gi]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[I]}],"scale-x":[{"scale-x":[I]}],"scale-y":[{"scale-y":[I]}],rotate:[{rotate:[v6,Gi]}],"translate-x":[{"translate-x":[q]}],"translate-y":[{"translate-y":[q]}],"skew-x":[{"skew-x":[R]}],"skew-y":[{"skew-y":[R]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Gi]}],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",Gi]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":se()}],"scroll-mx":[{"scroll-mx":se()}],"scroll-my":[{"scroll-my":se()}],"scroll-ms":[{"scroll-ms":se()}],"scroll-me":[{"scroll-me":se()}],"scroll-mt":[{"scroll-mt":se()}],"scroll-mr":[{"scroll-mr":se()}],"scroll-mb":[{"scroll-mb":se()}],"scroll-ml":[{"scroll-ml":se()}],"scroll-p":[{"scroll-p":se()}],"scroll-px":[{"scroll-px":se()}],"scroll-py":[{"scroll-py":se()}],"scroll-ps":[{"scroll-ps":se()}],"scroll-pe":[{"scroll-pe":se()}],"scroll-pt":[{"scroll-pt":se()}],"scroll-pr":[{"scroll-pr":se()}],"scroll-pb":[{"scroll-pb":se()}],"scroll-pl":[{"scroll-pl":se()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Gi]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[hv,__,$fe]}],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"]}}},Sgt=ogt(Ngt);function At(...t){return Sgt(Bi(t))}function $l(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 mde(t){return t?t.replace(/<[^>]*>/g,""):""}const Cgt=Hft,A$e=C.forwardRef(({className:t,...s},r)=>e.jsx(g$e,{ref:r,className:At("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}));A$e.displayName=g$e.displayName;const Mgt=HS("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"}}),E$e=C.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(x$e,{ref:n,className:At(Mgt({variant:s}),t),...r}));E$e.displayName=x$e.displayName;const Tgt=C.forwardRef(({className:t,...s},r)=>e.jsx(_$e,{ref:r,className:At("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}));Tgt.displayName=_$e.displayName;const P$e=C.forwardRef(({className:t,...s},r)=>e.jsx(b$e,{ref:r,className:At("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...s,children:e.jsx(Ur,{className:"h-4 w-4"})}));P$e.displayName=b$e.displayName;const I$e=C.forwardRef(({className:t,...s},r)=>e.jsx(y$e,{ref:r,className:At("text-sm font-semibold",t),...s}));I$e.displayName=y$e.displayName;const L$e=C.forwardRef(({className:t,...s},r)=>e.jsx(v$e,{ref:r,className:At("text-sm opacity-90",t),...s}));L$e.displayName=v$e.displayName;function Agt(){const{toasts:t}=Ra();return e.jsxs(Cgt,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(E$e,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(I$e,{children:r}),n&&e.jsx(L$e,{children:n})]}),a,e.jsx(P$e,{})]},s)}),e.jsx(A$e,{})]})}var oAe=["light","dark"],Egt="(prefers-color-scheme: dark)",Pgt=C.createContext(void 0),Igt={setTheme:t=>{},themes:[]},Lgt=()=>{var t;return(t=C.useContext(Pgt))!=null?t:Igt};C.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(b=>`'${b}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,f=a?oAe.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",y=(b,w=!1,j=!0)=>{let N=l?l[b]:b,S=w?b+"|| ''":`'${N}'`,T="";return a&&j&&!w&&oAe.includes(b)&&(T+=`d.style.colorScheme = '${b}';`),r==="class"?w||N?T+=`c.add(${S})`:T+="null":N&&(T+=`d[s](n,${S})`),T},_=t?`!function(){${p}${y(t)}}()`:n?`!function(){try{${p}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${Egt}',m=window.matchMedia(t);if(m.media!==t||m.matches){${y("dark")}}else{${y("light")}}}else if(e){${l?`var x=${JSON.stringify(l)};`:""}${y(l?"x[e]":"e",!0)}}${u?"":"else{"+y(o,!1,!1)+"}"}${f}}catch(e){}}()`:`!function(){try{${p}var e=localStorage.getItem('${s}');if(e){${l?`var x=${JSON.stringify(l)};`:""}${y(l?"x[e]":"e",!0)}}else{${y(o,!1,!1)};}${f}}catch(t){}}();`;return C.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:_}})});var Dgt=t=>{switch(t){case"success":return Fgt;case"info":return Bgt;case"warning":return zgt;case"error":return $gt;default:return null}},Ogt=Array(12).fill(0),Rgt=({visible:t,className:s})=>ht.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},ht.createElement("div",{className:"sonner-spinner"},Ogt.map((r,n)=>ht.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),Fgt=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"})),zgt=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"})),Bgt=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"})),$gt=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"})),qgt=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"})),Ugt=()=>{let[t,s]=ht.useState(document.hidden);return ht.useEffect(()=>{let r=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},w0e=1,Vgt=class{constructor(){this.subscribe=s=>(this.subscribers.push(s),()=>{let r=this.subscribers.indexOf(s);this.subscribers.splice(r,1)}),this.publish=s=>{this.subscribers.forEach(r=>r(s))},this.addToast=s=>{this.publish(s),this.toasts=[...this.toasts,s]},this.create=s=>{var r;let{message:n,...a}=s,o=typeof(s==null?void 0:s.id)=="number"||((r=s.id)==null?void 0:r.length)>0?s.id:w0e++,l=this.toasts.find(c=>c.id===o),i=s.dismissible===void 0?!0:s.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),l?this.toasts=this.toasts.map(c=>c.id===o?(this.publish({...c,...s,id:o,title:n}),{...c,...s,id:o,dismissible:i,title:n}):c):this.addToast({title:n,...a,dismissible:i,id:o}),o},this.dismiss=s=>(this.dismissedToasts.add(s),s||this.toasts.forEach(r=>{this.subscribers.forEach(n=>n({id:r.id,dismiss:!0}))}),this.subscribers.forEach(r=>r({id:s,dismiss:!0})),s),this.message=(s,r)=>this.create({...r,message:s}),this.error=(s,r)=>this.create({...r,message:s,type:"error"}),this.success=(s,r)=>this.create({...r,type:"success",message:s}),this.info=(s,r)=>this.create({...r,type:"info",message:s}),this.warning=(s,r)=>this.create({...r,type:"warning",message:s}),this.loading=(s,r)=>this.create({...r,type:"loading",message:s}),this.promise=(s,r)=>{if(!r)return;let n;r.loading!==void 0&&(n=this.create({...r,promise:s,type:"loading",message:r.loading,description:typeof r.description!="function"?r.description:void 0}));let a=s instanceof Promise?s:s(),o=n!==void 0,l,i=a.then(async u=>{if(l=["resolve",u],ht.isValidElement(u))o=!1,this.create({id:n,type:"default",message:u});else if(Wgt(u)&&!u.ok){o=!1;let p=typeof r.error=="function"?await r.error(`HTTP error! status: ${u.status}`):r.error,f=typeof r.description=="function"?await r.description(`HTTP error! status: ${u.status}`):r.description;this.create({id:n,type:"error",message:p,description:f})}else if(r.success!==void 0){o=!1;let p=typeof r.success=="function"?await r.success(u):r.success,f=typeof r.description=="function"?await r.description(u):r.description;this.create({id:n,type:"success",message:p,description:f})}}).catch(async u=>{if(l=["reject",u],r.error!==void 0){o=!1;let p=typeof r.error=="function"?await r.error(u):r.error,f=typeof r.description=="function"?await r.description(u):r.description;this.create({id:n,type:"error",message:p,description:f})}}).finally(()=>{var u;o&&(this.dismiss(n),n=void 0),(u=r.finally)==null||u.call(r)}),c=()=>new Promise((u,p)=>i.then(()=>l[0]==="reject"?p(l[1]):u(l[1])).catch(p));return typeof n!="string"&&typeof n!="number"?{unwrap:c}:Object.assign(n,{unwrap:c})},this.custom=(s,r)=>{let n=(r==null?void 0:r.id)||w0e++;return this.create({jsx:s(n),id:n,...r}),n},this.getActiveToasts=()=>this.toasts.filter(s=>!this.dismissedToasts.has(s.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},sp=new Vgt,Hgt=(t,s)=>{let r=(s==null?void 0:s.id)||w0e++;return sp.addToast({title:t,...s,id:r}),r},Wgt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",Ggt=Hgt,Kgt=()=>sp.toasts,Zgt=()=>sp.getActiveToasts(),me=Object.assign(Ggt,{success:sp.success,info:sp.info,warning:sp.warning,error:sp.error,custom:sp.custom,message:sp.message,promise:sp.promise,dismiss:sp.dismiss,loading:sp.loading},{getHistory:Kgt,getToasts:Zgt});function Ygt(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))}Ygt(`: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 f7(t){return t.label!==void 0}var Xgt=3,Qgt="32px",Jgt="16px",lAe=4e3,ext=356,txt=14,sxt=20,rxt=200;function gx(...t){return t.filter(Boolean).join(" ")}function nxt(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var axt=t=>{var s,r,n,a,o,l,i,c,u,p,f;let{invert:y,toast:_,unstyled:b,interacting:w,setHeights:j,visibleToasts:N,heights:S,index:T,toasts:I,expanded:L,removeToast:R,defaultRichColors:$,closeButton:q,style:U,cancelButtonStyle:V,actionButtonStyle:X,className:se="",descriptionClassName:ee="",duration:Q,position:de,gap:re,loadingIcon:ne,expandByDefault:le,classNames:he,icons:we,closeButtonAriaLabel:ye="Close toast",pauseWhenPageIsHidden:je}=t,[ke,We]=ht.useState(null),[be,Me]=ht.useState(null),[Ae,Re]=ht.useState(!1),[Te,qe]=ht.useState(!1),[ct,De]=ht.useState(!1),[Rt,pe]=ht.useState(!1),[Je,lt]=ht.useState(!1),[rt,Se]=ht.useState(0),[it,$e]=ht.useState(0),ot=ht.useRef(_.duration||Q||lAe),Ue=ht.useRef(null),Ke=ht.useRef(null),Xe=T===0,He=T+1<=N,Ye=_.type,tt=_.dismissible!==!1,Et=_.className||"",qt=_.descriptionClassName||"",ms=ht.useMemo(()=>S.findIndex(mn=>mn.toastId===_.id)||0,[S,_.id]),Xt=ht.useMemo(()=>{var mn;return(mn=_.closeButton)!=null?mn:q},[_.closeButton,q]),rs=ht.useMemo(()=>_.duration||Q||lAe,[_.duration,Q]),ps=ht.useRef(0),Ms=ht.useRef(0),jt=ht.useRef(0),As=ht.useRef(null),[Ps,ar]=de.split("-"),Dn=ht.useMemo(()=>S.reduce((mn,Gn,Zt)=>Zt>=ms?mn:mn+Gn.height,0),[S,ms]),Va=Ugt(),pa=_.invert||y,qa=Ye==="loading";Ms.current=ht.useMemo(()=>ms*re+Dn,[ms,Dn]),ht.useEffect(()=>{ot.current=rs},[rs]),ht.useEffect(()=>{Re(!0)},[]),ht.useEffect(()=>{let mn=Ke.current;if(mn){let Gn=mn.getBoundingClientRect().height;return $e(Gn),j(Zt=>[{toastId:_.id,height:Gn,position:_.position},...Zt]),()=>j(Zt=>Zt.filter($r=>$r.toastId!==_.id))}},[j,_.id]),ht.useLayoutEffect(()=>{if(!Ae)return;let mn=Ke.current,Gn=mn.style.height;mn.style.height="auto";let Zt=mn.getBoundingClientRect().height;mn.style.height=Gn,$e(Zt),j($r=>$r.find(es=>es.toastId===_.id)?$r.map(es=>es.toastId===_.id?{...es,height:Zt}:es):[{toastId:_.id,height:Zt,position:_.position},...$r])},[Ae,_.title,_.description,j,_.id]);let Kr=ht.useCallback(()=>{qe(!0),Se(Ms.current),j(mn=>mn.filter(Gn=>Gn.toastId!==_.id)),setTimeout(()=>{R(_)},rxt)},[_,R,j,Ms]);ht.useEffect(()=>{if(_.promise&&Ye==="loading"||_.duration===1/0||_.type==="loading")return;let mn;return L||w||je&&Va?(()=>{if(jt.current{var Gn;(Gn=_.onAutoClose)==null||Gn.call(_,_),Kr()},ot.current)),()=>clearTimeout(mn)},[L,w,_,Ye,je,Va,Kr]),ht.useEffect(()=>{_.delete&&Kr()},[Kr,_.delete]);function Yn(){var mn,Gn,Zt;return we!=null&&we.loading?ht.createElement("div",{className:gx(he==null?void 0:he.loader,(mn=_==null?void 0:_.classNames)==null?void 0:mn.loader,"sonner-loader"),"data-visible":Ye==="loading"},we.loading):ne?ht.createElement("div",{className:gx(he==null?void 0:he.loader,(Gn=_==null?void 0:_.classNames)==null?void 0:Gn.loader,"sonner-loader"),"data-visible":Ye==="loading"},ne):ht.createElement(Rgt,{className:gx(he==null?void 0:he.loader,(Zt=_==null?void 0:_.classNames)==null?void 0:Zt.loader),visible:Ye==="loading"})}return ht.createElement("li",{tabIndex:0,ref:Ke,className:gx(se,Et,he==null?void 0:he.toast,(s=_==null?void 0:_.classNames)==null?void 0:s.toast,he==null?void 0:he.default,he==null?void 0:he[Ye],(r=_==null?void 0:_.classNames)==null?void 0:r[Ye]),"data-sonner-toast":"","data-rich-colors":(n=_.richColors)!=null?n:$,"data-styled":!(_.jsx||_.unstyled||b),"data-mounted":Ae,"data-promise":!!_.promise,"data-swiped":Je,"data-removed":Te,"data-visible":He,"data-y-position":Ps,"data-x-position":ar,"data-index":T,"data-front":Xe,"data-swiping":ct,"data-dismissible":tt,"data-type":Ye,"data-invert":pa,"data-swipe-out":Rt,"data-swipe-direction":be,"data-expanded":!!(L||le&&Ae),style:{"--index":T,"--toasts-before":T,"--z-index":I.length-T,"--offset":`${Te?rt:Ms.current}px`,"--initial-height":le?"auto":`${it}px`,...U,..._.style},onDragEnd:()=>{De(!1),We(null),As.current=null},onPointerDown:mn=>{qa||!tt||(Ue.current=new Date,Se(Ms.current),mn.target.setPointerCapture(mn.pointerId),mn.target.tagName!=="BUTTON"&&(De(!0),As.current={x:mn.clientX,y:mn.clientY}))},onPointerUp:()=>{var mn,Gn,Zt,$r;if(Rt||!tt)return;As.current=null;let es=Number(((mn=Ke.current)==null?void 0:mn.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),an=Number(((Gn=Ke.current)==null?void 0:Gn.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ha=new Date().getTime()-((Zt=Ue.current)==null?void 0:Zt.getTime()),Xn=ke==="x"?es:an,Ir=Math.abs(Xn)/Ha;if(Math.abs(Xn)>=sxt||Ir>.11){Se(Ms.current),($r=_.onDismiss)==null||$r.call(_,_),Me(ke==="x"?es>0?"right":"left":an>0?"down":"up"),Kr(),pe(!0),lt(!1);return}De(!1),We(null)},onPointerMove:mn=>{var Gn,Zt,$r,es;if(!As.current||!tt||((Gn=window.getSelection())==null?void 0:Gn.toString().length)>0)return;let an=mn.clientY-As.current.y,Ha=mn.clientX-As.current.x,Xn=(Zt=t.swipeDirections)!=null?Zt:nxt(de);!ke&&(Math.abs(Ha)>1||Math.abs(an)>1)&&We(Math.abs(Ha)>Math.abs(an)?"x":"y");let Ir={x:0,y:0};ke==="y"?(Xn.includes("top")||Xn.includes("bottom"))&&(Xn.includes("top")&&an<0||Xn.includes("bottom")&&an>0)&&(Ir.y=an):ke==="x"&&(Xn.includes("left")||Xn.includes("right"))&&(Xn.includes("left")&&Ha<0||Xn.includes("right")&&Ha>0)&&(Ir.x=Ha),(Math.abs(Ir.x)>0||Math.abs(Ir.y)>0)&<(!0),($r=Ke.current)==null||$r.style.setProperty("--swipe-amount-x",`${Ir.x}px`),(es=Ke.current)==null||es.style.setProperty("--swipe-amount-y",`${Ir.y}px`)}},Xt&&!_.jsx?ht.createElement("button",{"aria-label":ye,"data-disabled":qa,"data-close-button":!0,onClick:qa||!tt?()=>{}:()=>{var mn;Kr(),(mn=_.onDismiss)==null||mn.call(_,_)},className:gx(he==null?void 0:he.closeButton,(a=_==null?void 0:_.classNames)==null?void 0:a.closeButton)},(o=we==null?void 0:we.close)!=null?o:qgt):null,_.jsx||C.isValidElement(_.title)?_.jsx?_.jsx:typeof _.title=="function"?_.title():_.title:ht.createElement(ht.Fragment,null,Ye||_.icon||_.promise?ht.createElement("div",{"data-icon":"",className:gx(he==null?void 0:he.icon,(l=_==null?void 0:_.classNames)==null?void 0:l.icon)},_.promise||_.type==="loading"&&!_.icon?_.icon||Yn():null,_.type!=="loading"?_.icon||(we==null?void 0:we[Ye])||Dgt(Ye):null):null,ht.createElement("div",{"data-content":"",className:gx(he==null?void 0:he.content,(i=_==null?void 0:_.classNames)==null?void 0:i.content)},ht.createElement("div",{"data-title":"",className:gx(he==null?void 0:he.title,(c=_==null?void 0:_.classNames)==null?void 0:c.title)},typeof _.title=="function"?_.title():_.title),_.description?ht.createElement("div",{"data-description":"",className:gx(ee,qt,he==null?void 0:he.description,(u=_==null?void 0:_.classNames)==null?void 0:u.description)},typeof _.description=="function"?_.description():_.description):null),C.isValidElement(_.cancel)?_.cancel:_.cancel&&f7(_.cancel)?ht.createElement("button",{"data-button":!0,"data-cancel":!0,style:_.cancelButtonStyle||V,onClick:mn=>{var Gn,Zt;f7(_.cancel)&&tt&&((Zt=(Gn=_.cancel).onClick)==null||Zt.call(Gn,mn),Kr())},className:gx(he==null?void 0:he.cancelButton,(p=_==null?void 0:_.classNames)==null?void 0:p.cancelButton)},_.cancel.label):null,C.isValidElement(_.action)?_.action:_.action&&f7(_.action)?ht.createElement("button",{"data-button":!0,"data-action":!0,style:_.actionButtonStyle||X,onClick:mn=>{var Gn,Zt;f7(_.action)&&((Zt=(Gn=_.action).onClick)==null||Zt.call(Gn,mn),!mn.defaultPrevented&&Kr())},className:gx(he==null?void 0:he.actionButton,(f=_==null?void 0:_.classNames)==null?void 0:f.actionButton)},_.action.label):null))};function cAe(){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 ixt(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?Jgt: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 oxt=C.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:y,style:_,visibleToasts:b=Xgt,toastOptions:w,dir:j=cAe(),gap:N=txt,loadingIcon:S,icons:T,containerAriaLabel:I="Notifications",pauseWhenPageIsHidden:L}=t,[R,$]=ht.useState([]),q=ht.useMemo(()=>Array.from(new Set([n].concat(R.filter(je=>je.position).map(je=>je.position)))),[R,n]),[U,V]=ht.useState([]),[X,se]=ht.useState(!1),[ee,Q]=ht.useState(!1),[de,re]=ht.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),ne=ht.useRef(null),le=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),he=ht.useRef(null),we=ht.useRef(!1),ye=ht.useCallback(je=>{$(ke=>{var We;return(We=ke.find(be=>be.id===je.id))!=null&&We.delete||sp.dismiss(je.id),ke.filter(({id:be})=>be!==je.id)})},[]);return ht.useEffect(()=>sp.subscribe(je=>{if(je.dismiss){$(ke=>ke.map(We=>We.id===je.id?{...We,delete:!0}:We));return}setTimeout(()=>{Q2e.flushSync(()=>{$(ke=>{let We=ke.findIndex(be=>be.id===je.id);return We!==-1?[...ke.slice(0,We),{...ke[We],...je},...ke.slice(We+1)]:[je,...ke]})})})}),[]),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 je=window.matchMedia("(prefers-color-scheme: dark)");try{je.addEventListener("change",({matches:ke})=>{re(ke?"dark":"light")})}catch{je.addListener(({matches:We})=>{try{re(We?"dark":"light")}catch(be){console.error(be)}})}},[p]),ht.useEffect(()=>{R.length<=1&&se(!1)},[R]),ht.useEffect(()=>{let je=ke=>{var We,be;a.every(Me=>ke[Me]||ke.code===Me)&&(se(!0),(We=ne.current)==null||We.focus()),ke.code==="Escape"&&(document.activeElement===ne.current||(be=ne.current)!=null&&be.contains(document.activeElement))&&se(!1)};return document.addEventListener("keydown",je),()=>document.removeEventListener("keydown",je)},[a]),ht.useEffect(()=>{if(ne.current)return()=>{he.current&&(he.current.focus({preventScroll:!0}),he.current=null,we.current=!1)}},[ne.current]),ht.createElement("section",{ref:s,"aria-label":`${I} ${le}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},q.map((je,ke)=>{var We;let[be,Me]=je.split("-");return R.length?ht.createElement("ol",{key:je,dir:j==="auto"?cAe():j,tabIndex:-1,ref:ne,className:i,"data-sonner-toaster":!0,"data-theme":de,"data-y-position":be,"data-lifted":X&&R.length>1&&!o,"data-x-position":Me,style:{"--front-toast-height":`${((We=U[0])==null?void 0:We.height)||0}px`,"--width":`${ext}px`,"--gap":`${N}px`,..._,...ixt(c,u)},onBlur:Ae=>{we.current&&!Ae.currentTarget.contains(Ae.relatedTarget)&&(we.current=!1,he.current&&(he.current.focus({preventScroll:!0}),he.current=null))},onFocus:Ae=>{Ae.target instanceof HTMLElement&&Ae.target.dataset.dismissible==="false"||we.current||(we.current=!0,he.current=Ae.relatedTarget)},onMouseEnter:()=>se(!0),onMouseMove:()=>se(!0),onMouseLeave:()=>{ee||se(!1)},onDragEnd:()=>se(!1),onPointerDown:Ae=>{Ae.target instanceof HTMLElement&&Ae.target.dataset.dismissible==="false"||Q(!0)},onPointerUp:()=>Q(!1)},R.filter(Ae=>!Ae.position&&ke===0||Ae.position===je).map((Ae,Re)=>{var Te,qe;return ht.createElement(axt,{key:Ae.id,icons:T,index:Re,toast:Ae,defaultRichColors:f,duration:(Te=w==null?void 0:w.duration)!=null?Te:y,className:w==null?void 0:w.className,descriptionClassName:w==null?void 0:w.descriptionClassName,invert:r,visibleToasts:b,closeButton:(qe=w==null?void 0:w.closeButton)!=null?qe:l,interacting:ee,position:je,style:w==null?void 0:w.style,unstyled:w==null?void 0:w.unstyled,classNames:w==null?void 0:w.classNames,cancelButtonStyle:w==null?void 0:w.cancelButtonStyle,actionButtonStyle:w==null?void 0:w.actionButtonStyle,removeToast:ye,toasts:R.filter(ct=>ct.position==Ae.position),heights:U.filter(ct=>ct.position==Ae.position),setHeights:V,expandByDefault:o,gap:N,loadingIcon:S,expanded:X,pauseWhenPageIsHidden:L,swipeDirections:t.swipeDirections})})):null}))});const lxt=({...t})=>{const{theme:s="system"}=Lgt();return e.jsx(oxt,{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 cxt=o2e[" useId ".trim().toString()]||(()=>{}),dxt=0;function vu(t){const[s,r]=C.useState(cxt());return fd(()=>{r(n=>n??String(dxt++))},[t]),s?`radix-${s}`:""}const uxt=["top","right","bottom","left"],t2=Math.min,Xp=Math.max,Jie=Math.round,g7=Math.floor,d0=t=>({x:t,y:t}),hxt={left:"right",right:"left",bottom:"top",top:"bottom"},mxt={start:"end",end:"start"};function j0e(t,s,r){return Xp(t,t2(s,r))}function v1(t,s){return typeof t=="function"?t(s):t}function _1(t){return t.split("-")[0]}function bA(t){return t.split("-")[1]}function iwe(t){return t==="x"?"y":"x"}function owe(t){return t==="y"?"height":"width"}const pxt=new Set(["top","bottom"]);function Xy(t){return pxt.has(_1(t))?"y":"x"}function lwe(t){return iwe(Xy(t))}function fxt(t,s,r){r===void 0&&(r=!1);const n=bA(t),a=lwe(t),o=owe(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=eoe(l)),[l,eoe(l)]}function gxt(t){const s=eoe(t);return[k0e(t),s,k0e(s)]}function k0e(t){return t.replace(/start|end/g,s=>mxt[s])}const dAe=["left","right"],uAe=["right","left"],xxt=["top","bottom"],yxt=["bottom","top"];function vxt(t,s,r){switch(t){case"top":case"bottom":return r?s?uAe:dAe:s?dAe:uAe;case"left":case"right":return s?xxt:yxt;default:return[]}}function _xt(t,s,r,n){const a=bA(t);let o=vxt(_1(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(k0e)))),o}function eoe(t){return t.replace(/left|right|bottom|top/g,s=>hxt[s])}function bxt(t){return{top:0,right:0,bottom:0,left:0,...t}}function D$e(t){return typeof t!="number"?bxt(t):{top:t,right:t,bottom:t,left:t}}function toe(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 hAe(t,s,r){let{reference:n,floating:a}=t;const o=Xy(s),l=lwe(s),i=owe(l),c=_1(s),u=o==="y",p=n.x+n.width/2-a.width/2,f=n.y+n.height/2-a.height/2,y=n[i]/2-a[i]/2;let _;switch(c){case"top":_={x:p,y:n.y-a.height};break;case"bottom":_={x:p,y:n.y+n.height};break;case"right":_={x:n.x+n.width,y:f};break;case"left":_={x:n.x-a.width,y:f};break;default:_={x:n.x,y:n.y}}switch(bA(s)){case"start":_[l]-=y*(r&&u?-1:1);break;case"end":_[l]+=y*(r&&u?-1:1);break}return _}const wxt=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}=hAe(u,n,c),y=n,_={},b=0;for(let w=0;w({name:"arrow",options:t,async fn(s){const{x:r,y:n,placement:a,rects:o,platform:l,elements:i,middlewareData:c}=s,{element:u,padding:p=0}=v1(t,s)||{};if(u==null)return{};const f=D$e(p),y={x:r,y:n},_=lwe(a),b=owe(_),w=await l.getDimensions(u),j=_==="y",N=j?"top":"left",S=j?"bottom":"right",T=j?"clientHeight":"clientWidth",I=o.reference[b]+o.reference[_]-y[_]-o.floating[b],L=y[_]-o.reference[_],R=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let $=R?R[T]:0;(!$||!await(l.isElement==null?void 0:l.isElement(R)))&&($=i.floating[T]||o.floating[b]);const q=I/2-L/2,U=$/2-w[b]/2-1,V=t2(f[N],U),X=t2(f[S],U),se=V,ee=$-w[b]-X,Q=$/2-w[b]/2+q,de=j0e(se,Q,ee),re=!c.arrow&&bA(a)!=null&&Q!==de&&o.reference[b]/2-(QQ<=0)){var X,se;const Q=(((X=o.flip)==null?void 0:X.index)||0)+1,de=$[Q];if(de&&(!(f==="alignment"?S!==Xy(de):!1)||V.every(le=>le.overflows[0]>0&&Xy(le.placement)===S)))return{data:{index:Q,overflows:V},reset:{placement:de}};let re=(se=V.filter(ne=>ne.overflows[0]<=0).sort((ne,le)=>ne.overflows[1]-le.overflows[1])[0])==null?void 0:se.placement;if(!re)switch(_){case"bestFit":{var ee;const ne=(ee=V.filter(le=>{if(R){const he=Xy(le.placement);return he===S||he==="y"}return!0}).map(le=>[le.placement,le.overflows.filter(he=>he>0).reduce((he,we)=>he+we,0)]).sort((le,he)=>le[1]-he[1])[0])==null?void 0:ee[0];ne&&(re=ne);break}case"initialPlacement":re=i;break}if(a!==re)return{reset:{placement:re}}}return{}}}};function mAe(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function pAe(t){return uxt.some(s=>t[s]>=0)}const Nxt=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=v1(t,s);switch(n){case"referenceHidden":{const o=await b8(s,{...a,elementContext:"reference"}),l=mAe(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:pAe(l)}}}case"escaped":{const o=await b8(s,{...a,altBoundary:!0}),l=mAe(o,r.floating);return{data:{escapedOffsets:l,escaped:pAe(l)}}}default:return{}}}}},O$e=new Set(["left","top"]);async function Sxt(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=_1(r),i=bA(r),c=Xy(r)==="y",u=O$e.has(l)?-1:1,p=o&&c?-1:1,f=v1(s,t);let{mainAxis:y,crossAxis:_,alignmentAxis:b}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return i&&typeof b=="number"&&(_=i==="end"?b*-1:b),c?{x:_*p,y:y*u}:{x:y*u,y:_*p}}const Cxt=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 Sxt(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}}}}},Mxt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:r,y:n,placement:a}=s,{mainAxis:o=!0,crossAxis:l=!1,limiter:i={fn:j=>{let{x:N,y:S}=j;return{x:N,y:S}}},...c}=v1(t,s),u={x:r,y:n},p=await b8(s,c),f=Xy(_1(a)),y=iwe(f);let _=u[y],b=u[f];if(o){const j=y==="y"?"top":"left",N=y==="y"?"bottom":"right",S=_+p[j],T=_-p[N];_=j0e(S,_,T)}if(l){const j=f==="y"?"top":"left",N=f==="y"?"bottom":"right",S=b+p[j],T=b-p[N];b=j0e(S,b,T)}const w=i.fn({...s,[y]:_,[f]:b});return{...w,data:{x:w.x-r,y:w.y-n,enabled:{[y]:o,[f]:l}}}}}},Txt=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}=v1(t,s),p={x:r,y:n},f=Xy(a),y=iwe(f);let _=p[y],b=p[f];const w=v1(i,s),j=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(c){const T=y==="y"?"height":"width",I=o.reference[y]-o.floating[T]+j.mainAxis,L=o.reference[y]+o.reference[T]-j.mainAxis;_L&&(_=L)}if(u){var N,S;const T=y==="y"?"width":"height",I=O$e.has(_1(a)),L=o.reference[f]-o.floating[T]+(I&&((N=l.offset)==null?void 0:N[f])||0)+(I?0:j.crossAxis),R=o.reference[f]+o.reference[T]+(I?0:((S=l.offset)==null?void 0:S[f])||0)-(I?j.crossAxis:0);bR&&(b=R)}return{[y]:_,[f]:b}}}},Axt=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}=v1(t,s),p=await b8(s,u),f=_1(a),y=bA(a),_=Xy(a)==="y",{width:b,height:w}=o.floating;let j,N;f==="top"||f==="bottom"?(j=f,N=y===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(N=f,j=y==="end"?"top":"bottom");const S=w-p.top-p.bottom,T=b-p.left-p.right,I=t2(w-p[j],S),L=t2(b-p[N],T),R=!s.middlewareData.shift;let $=I,q=L;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&(q=T),(n=s.middlewareData.shift)!=null&&n.enabled.y&&($=S),R&&!y){const V=Xp(p.left,0),X=Xp(p.right,0),se=Xp(p.top,0),ee=Xp(p.bottom,0);_?q=b-2*(V!==0||X!==0?V+X:Xp(p.left,p.right)):$=w-2*(se!==0||ee!==0?se+ee:Xp(p.top,p.bottom))}await c({...s,availableWidth:q,availableHeight:$});const U=await l.getDimensions(i.floating);return b!==U.width||w!==U.height?{reset:{rects:!0}}:{}}}};function pde(){return typeof window<"u"}function wA(t){return R$e(t)?(t.nodeName||"").toLowerCase():"#document"}function df(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function C0(t){var s;return(s=(R$e(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function R$e(t){return pde()?t instanceof Node||t instanceof df(t).Node:!1}function Jx(t){return pde()?t instanceof Element||t instanceof df(t).Element:!1}function x0(t){return pde()?t instanceof HTMLElement||t instanceof df(t).HTMLElement:!1}function fAe(t){return!pde()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof df(t).ShadowRoot}const Ext=new Set(["inline","contents"]);function JD(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=ey(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!Ext.has(a)}const Pxt=new Set(["table","td","th"]);function Ixt(t){return Pxt.has(wA(t))}const Lxt=[":popover-open",":modal"];function fde(t){return Lxt.some(s=>{try{return t.matches(s)}catch{return!1}})}const Dxt=["transform","translate","scale","rotate","perspective"],Oxt=["transform","translate","scale","rotate","perspective","filter"],Rxt=["paint","layout","strict","content"];function cwe(t){const s=dwe(),r=Jx(t)?ey(t):t;return Dxt.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)||Oxt.some(n=>(r.willChange||"").includes(n))||Rxt.some(n=>(r.contain||"").includes(n))}function Fxt(t){let s=s2(t);for(;x0(s)&&!uT(s);){if(cwe(s))return s;if(fde(s))return null;s=s2(s)}return null}function dwe(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const zxt=new Set(["html","body","#document"]);function uT(t){return zxt.has(wA(t))}function ey(t){return df(t).getComputedStyle(t)}function gde(t){return Jx(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function s2(t){if(wA(t)==="html")return t;const s=t.assignedSlot||t.parentNode||fAe(t)&&t.host||C0(t);return fAe(s)?s.host:s}function F$e(t){const s=s2(t);return uT(s)?t.ownerDocument?t.ownerDocument.body:t.body:x0(s)&&JD(s)?s:F$e(s)}function w8(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=F$e(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=df(a);if(o){const i=N0e(l);return s.concat(l,l.visualViewport||[],JD(a)?a:[],i&&r?w8(i):[])}return s.concat(a,w8(a,[],r))}function N0e(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function z$e(t){const s=ey(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=x0(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=Jie(r)!==o||Jie(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function uwe(t){return Jx(t)?t:t.contextElement}function CM(t){const s=uwe(t);if(!x0(s))return d0(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=z$e(s);let l=(o?Jie(r.width):r.width)/n,i=(o?Jie(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const Bxt=d0(0);function B$e(t){const s=df(t);return!dwe()||!s.visualViewport?Bxt:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function $xt(t,s,r){return s===void 0&&(s=!1),!r||s&&r!==df(t)?!1:s}function fS(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=uwe(t);let l=d0(1);s&&(n?Jx(n)&&(l=CM(n)):l=CM(t));const i=$xt(o,r,n)?B$e(o):d0(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 y=df(o),_=n&&Jx(n)?df(n):n;let b=y,w=N0e(b);for(;w&&n&&_!==b;){const j=CM(w),N=w.getBoundingClientRect(),S=ey(w),T=N.left+(w.clientLeft+parseFloat(S.paddingLeft))*j.x,I=N.top+(w.clientTop+parseFloat(S.paddingTop))*j.y;c*=j.x,u*=j.y,p*=j.x,f*=j.y,c+=T,u+=I,b=df(w),w=N0e(b)}}return toe({width:p,height:f,x:c,y:u})}function hwe(t,s){const r=gde(t).scrollLeft;return s?s.left+r:fS(C0(t)).left+r}function $$e(t,s,r){r===void 0&&(r=!1);const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-(r?0:hwe(t,n)),o=n.top+s.scrollTop;return{x:a,y:o}}function qxt(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=C0(n),i=s?fde(s.floating):!1;if(n===l||i&&o)return r;let c={scrollLeft:0,scrollTop:0},u=d0(1);const p=d0(0),f=x0(n);if((f||!f&&!o)&&((wA(n)!=="body"||JD(l))&&(c=gde(n)),x0(n))){const _=fS(n);u=CM(n),p.x=_.x+n.clientLeft,p.y=_.y+n.clientTop}const y=l&&!f&&!o?$$e(l,c,!0):d0(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-c.scrollLeft*u.x+p.x+y.x,y:r.y*u.y-c.scrollTop*u.y+p.y+y.y}}function Uxt(t){return Array.from(t.getClientRects())}function Vxt(t){const s=C0(t),r=gde(t),n=t.ownerDocument.body,a=Xp(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=Xp(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+hwe(t);const i=-r.scrollTop;return ey(n).direction==="rtl"&&(l+=Xp(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function Hxt(t,s){const r=df(t),n=C0(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=dwe();(!u||u&&s==="fixed")&&(i=a.offsetLeft,c=a.offsetTop)}return{width:o,height:l,x:i,y:c}}const Wxt=new Set(["absolute","fixed"]);function Gxt(t,s){const r=fS(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=x0(t)?CM(t):d0(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 gAe(t,s,r){let n;if(s==="viewport")n=Hxt(t,r);else if(s==="document")n=Vxt(C0(t));else if(Jx(s))n=Gxt(s,r);else{const a=B$e(t);n={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return toe(n)}function q$e(t,s){const r=s2(t);return r===s||!Jx(r)||uT(r)?!1:ey(r).position==="fixed"||q$e(r,s)}function Kxt(t,s){const r=s.get(t);if(r)return r;let n=w8(t,[],!1).filter(i=>Jx(i)&&wA(i)!=="body"),a=null;const o=ey(t).position==="fixed";let l=o?s2(t):t;for(;Jx(l)&&!uT(l);){const i=ey(l),c=cwe(l);!c&&i.position==="fixed"&&(a=null),(o?!c&&!a:!c&&i.position==="static"&&!!a&&Wxt.has(a.position)||JD(l)&&!c&&q$e(t,l))?n=n.filter(p=>p!==l):a=i,l=s2(l)}return s.set(t,n),n}function Zxt(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?fde(s)?[]:Kxt(s,this._c):[].concat(r),n],i=l[0],c=l.reduce((u,p)=>{const f=gAe(s,p,a);return u.top=Xp(f.top,u.top),u.right=t2(f.right,u.right),u.bottom=t2(f.bottom,u.bottom),u.left=Xp(f.left,u.left),u},gAe(s,i,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Yxt(t){const{width:s,height:r}=z$e(t);return{width:s,height:r}}function Xxt(t,s,r){const n=x0(s),a=C0(s),o=r==="fixed",l=fS(t,!0,o,s);let i={scrollLeft:0,scrollTop:0};const c=d0(0);function u(){c.x=hwe(a)}if(n||!n&&!o)if((wA(s)!=="body"||JD(a))&&(i=gde(s)),n){const _=fS(s,!0,o,s);c.x=_.x+s.clientLeft,c.y=_.y+s.clientTop}else a&&u();o&&!n&&a&&u();const p=a&&!n&&!o?$$e(a,i):d0(0),f=l.left+i.scrollLeft-c.x-p.x,y=l.top+i.scrollTop-c.y-p.y;return{x:f,y,width:l.width,height:l.height}}function qfe(t){return ey(t).position==="static"}function xAe(t,s){if(!x0(t)||ey(t).position==="fixed")return null;if(s)return s(t);let r=t.offsetParent;return C0(t)===r&&(r=r.ownerDocument.body),r}function U$e(t,s){const r=df(t);if(fde(t))return r;if(!x0(t)){let a=s2(t);for(;a&&!uT(a);){if(Jx(a)&&!qfe(a))return a;a=s2(a)}return r}let n=xAe(t,s);for(;n&&Ixt(n)&&qfe(n);)n=xAe(n,s);return n&&uT(n)&&qfe(n)&&!cwe(n)?r:n||Fxt(t)||r}const Qxt=async function(t){const s=this.getOffsetParent||U$e,r=this.getDimensions,n=await r(t.floating);return{reference:Xxt(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Jxt(t){return ey(t).direction==="rtl"}const eyt={convertOffsetParentRelativeRectToViewportRelativeRect:qxt,getDocumentElement:C0,getClippingRect:Zxt,getOffsetParent:U$e,getElementRects:Qxt,getClientRects:Uxt,getDimensions:Yxt,getScale:CM,isElement:Jx,isRTL:Jxt};function V$e(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function tyt(t,s){let r=null,n;const a=C0(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:y,height:_}=u;if(i||s(),!y||!_)return;const b=g7(f),w=g7(a.clientWidth-(p+y)),j=g7(a.clientHeight-(f+_)),N=g7(p),T={rootMargin:-b+"px "+-w+"px "+-j+"px "+-N+"px",threshold:Xp(0,t2(1,c))||1};let I=!0;function L(R){const $=R[0].intersectionRatio;if($!==c){if(!I)return l();$?l(!1,$):n=setTimeout(()=>{l(!1,1e-7)},1e3)}$===1&&!V$e(u,t.getBoundingClientRect())&&l(),I=!1}try{r=new IntersectionObserver(L,{...T,root:a.ownerDocument})}catch{r=new IntersectionObserver(L,T)}r.observe(t)}return l(!0),o}function syt(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=uwe(t),p=a||o?[...u?w8(u):[],...w8(s)]:[];p.forEach(N=>{a&&N.addEventListener("scroll",r,{passive:!0}),o&&N.addEventListener("resize",r)});const f=u&&i?tyt(u,r):null;let y=-1,_=null;l&&(_=new ResizeObserver(N=>{let[S]=N;S&&S.target===u&&_&&(_.unobserve(s),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var T;(T=_)==null||T.observe(s)})),r()}),u&&!c&&_.observe(u),_.observe(s));let b,w=c?fS(t):null;c&&j();function j(){const N=fS(t);w&&!V$e(w,N)&&r(),w=N,b=requestAnimationFrame(j)}return r(),()=>{var N;p.forEach(S=>{a&&S.removeEventListener("scroll",r),o&&S.removeEventListener("resize",r)}),f==null||f(),(N=_)==null||N.disconnect(),_=null,c&&cancelAnimationFrame(b)}}const ryt=Cxt,nyt=Mxt,ayt=kxt,iyt=Axt,oyt=Nxt,yAe=jxt,lyt=Txt,cyt=(t,s,r)=>{const n=new Map,a={platform:eyt,...r},o={...a.platform,_c:n};return wxt(t,s,{...a,platform:o})};var dyt=typeof document<"u",uyt=function(){},Qae=dyt?C.useLayoutEffect:uyt;function soe(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(!soe(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)&&!soe(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function H$e(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function vAe(t,s){const r=H$e(t);return Math.round(s*r)/r}function Ufe(t){const s=C.useRef(t);return Qae(()=>{s.current=t}),s}function hyt(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]=C.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[y,_]=C.useState(n);soe(y,n)||_(n);const[b,w]=C.useState(null),[j,N]=C.useState(null),S=C.useCallback(le=>{le!==R.current&&(R.current=le,w(le))},[]),T=C.useCallback(le=>{le!==$.current&&($.current=le,N(le))},[]),I=o||b,L=l||j,R=C.useRef(null),$=C.useRef(null),q=C.useRef(p),U=c!=null,V=Ufe(c),X=Ufe(a),se=Ufe(u),ee=C.useCallback(()=>{if(!R.current||!$.current)return;const le={placement:s,strategy:r,middleware:y};X.current&&(le.platform=X.current),cyt(R.current,$.current,le).then(he=>{const we={...he,isPositioned:se.current!==!1};Q.current&&!soe(q.current,we)&&(q.current=we,cp.flushSync(()=>{f(we)}))})},[y,s,r,X,se]);Qae(()=>{u===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,f(le=>({...le,isPositioned:!1})))},[u]);const Q=C.useRef(!1);Qae(()=>(Q.current=!0,()=>{Q.current=!1}),[]),Qae(()=>{if(I&&(R.current=I),L&&($.current=L),I&&L){if(V.current)return V.current(I,L,ee);ee()}},[I,L,ee,V,U]);const de=C.useMemo(()=>({reference:R,floating:$,setReference:S,setFloating:T}),[S,T]),re=C.useMemo(()=>({reference:I,floating:L}),[I,L]),ne=C.useMemo(()=>{const le={position:r,left:0,top:0};if(!re.floating)return le;const he=vAe(re.floating,p.x),we=vAe(re.floating,p.y);return i?{...le,transform:"translate("+he+"px, "+we+"px)",...H$e(re.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:he,top:we}},[r,i,re.floating,p.x,p.y]);return C.useMemo(()=>({...p,update:ee,refs:de,elements:re,floatingStyles:ne}),[p,ee,de,re,ne])}const myt=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?yAe({element:n.current,padding:a}).fn(r):{}:n?yAe({element:n,padding:a}).fn(r):{}}}},pyt=(t,s)=>({...ryt(t),options:[t,s]}),fyt=(t,s)=>({...nyt(t),options:[t,s]}),gyt=(t,s)=>({...lyt(t),options:[t,s]}),xyt=(t,s)=>({...ayt(t),options:[t,s]}),yyt=(t,s)=>({...iyt(t),options:[t,s]}),vyt=(t,s)=>({...oyt(t),options:[t,s]}),_yt=(t,s)=>({...myt(t),options:[t,s]});var byt="Arrow",W$e=C.forwardRef((t,s)=>{const{children:r,width:n=10,height:a=5,...o}=t;return e.jsx(Jr.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"})})});W$e.displayName=byt;var wyt=W$e;function eO(t){const[s,r]=C.useState(void 0);return fd(()=>{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 mwe="Popper",[G$e,M0]=Yc(mwe),[jyt,K$e]=G$e(mwe),Z$e=t=>{const{__scopePopper:s,children:r}=t,[n,a]=C.useState(null);return e.jsx(jyt,{scope:s,anchor:n,onAnchorChange:a,children:r})};Z$e.displayName=mwe;var Y$e="PopperAnchor",X$e=C.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=K$e(Y$e,r),l=C.useRef(null),i=Oa(s,l);return C.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:e.jsx(Jr.div,{...a,ref:i})});X$e.displayName=Y$e;var pwe="PopperContent",[kyt,Nyt]=G$e(pwe),Q$e=C.forwardRef((t,s)=>{var Ae,Re,Te,qe,ct,De;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:y=!1,updatePositionStrategy:_="optimized",onPlaced:b,...w}=t,j=K$e(pwe,r),[N,S]=C.useState(null),T=Oa(s,Rt=>S(Rt)),[I,L]=C.useState(null),R=eO(I),$=(R==null?void 0:R.width)??0,q=(R==null?void 0:R.height)??0,U=n+(o!=="center"?"-"+o:""),V=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},X=Array.isArray(u)?u:[u],se=X.length>0,ee={padding:V,boundary:X.filter(Cyt),altBoundary:se},{refs:Q,floatingStyles:de,placement:re,isPositioned:ne,middlewareData:le}=hyt({strategy:"fixed",placement:U,whileElementsMounted:(...Rt)=>syt(...Rt,{animationFrame:_==="always"}),elements:{reference:j.anchor},middleware:[pyt({mainAxis:a+q,alignmentAxis:l}),c&&fyt({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?gyt():void 0,...ee}),c&&xyt({...ee}),yyt({...ee,apply:({elements:Rt,rects:pe,availableWidth:Je,availableHeight:lt})=>{const{width:rt,height:Se}=pe.reference,it=Rt.floating.style;it.setProperty("--radix-popper-available-width",`${Je}px`),it.setProperty("--radix-popper-available-height",`${lt}px`),it.setProperty("--radix-popper-anchor-width",`${rt}px`),it.setProperty("--radix-popper-anchor-height",`${Se}px`)}}),I&&_yt({element:I,padding:i}),Myt({arrowWidth:$,arrowHeight:q}),y&&vyt({strategy:"referenceHidden",...ee})]}),[he,we]=tqe(re),ye=dd(b);fd(()=>{ne&&(ye==null||ye())},[ne,ye]);const je=(Ae=le.arrow)==null?void 0:Ae.x,ke=(Re=le.arrow)==null?void 0:Re.y,We=((Te=le.arrow)==null?void 0:Te.centerOffset)!==0,[be,Me]=C.useState();return fd(()=>{N&&Me(window.getComputedStyle(N).zIndex)},[N]),e.jsx("div",{ref:Q.setFloating,"data-radix-popper-content-wrapper":"",style:{...de,transform:ne?de.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:be,"--radix-popper-transform-origin":[(qe=le.transformOrigin)==null?void 0:qe.x,(ct=le.transformOrigin)==null?void 0:ct.y].join(" "),...((De=le.hide)==null?void 0:De.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(kyt,{scope:r,placedSide:he,onArrowChange:L,arrowX:je,arrowY:ke,shouldHideArrow:We,children:e.jsx(Jr.div,{"data-side":he,"data-align":we,...w,ref:T,style:{...w.style,animation:ne?void 0:"none"}})})})});Q$e.displayName=pwe;var J$e="PopperArrow",Syt={top:"bottom",right:"left",bottom:"top",left:"right"},eqe=C.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=Nyt(J$e,n),l=Syt[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(wyt,{...a,ref:r,style:{...a.style,display:"block"}})})});eqe.displayName=J$e;function Cyt(t){return t!==null}var Myt=t=>({name:"transformOrigin",options:t,fn(s){var j,N,S;const{placement:r,rects:n,middlewareData:a}=s,l=((j=a.arrow)==null?void 0:j.centerOffset)!==0,i=l?0:t.arrowWidth,c=l?0:t.arrowHeight,[u,p]=tqe(r),f={start:"0%",center:"50%",end:"100%"}[p],y=(((N=a.arrow)==null?void 0:N.x)??0)+i/2,_=(((S=a.arrow)==null?void 0:S.y)??0)+c/2;let b="",w="";return u==="bottom"?(b=l?f:`${y}px`,w=`${-c}px`):u==="top"?(b=l?f:`${y}px`,w=`${n.floating.height+c}px`):u==="right"?(b=`${-c}px`,w=l?f:`${_}px`):u==="left"&&(b=`${n.floating.width+c}px`,w=l?f:`${_}px`),{data:{x:b,y:w}}}});function tqe(t){const[s,r="center"]=t.split("-");return[s,r]}var tO=Z$e,jA=X$e,sO=Q$e,rO=eqe,[xde]=Yc("Tooltip",[M0]),yde=M0(),sqe="TooltipProvider",Tyt=700,S0e="tooltip.open",[Ayt,fwe]=xde(sqe),rqe=t=>{const{__scopeTooltip:s,delayDuration:r=Tyt,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=C.useRef(!0),i=C.useRef(!1),c=C.useRef(0);return C.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),e.jsx(Ayt,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:C.useCallback(()=>{window.clearTimeout(c.current),l.current=!1},[]),onClose:C.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:C.useCallback(u=>{i.current=u},[]),disableHoverableContent:a,children:o})};rqe.displayName=sqe;var j8="Tooltip",[Eyt,vde]=xde(j8),nqe=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,c=fwe(j8,t.__scopeTooltip),u=yde(s),[p,f]=C.useState(null),y=vu(),_=C.useRef(0),b=l??c.disableHoverableContent,w=i??c.delayDuration,j=C.useRef(!1),[N,S]=Yu({prop:n,defaultProp:a??!1,onChange:$=>{$?(c.onOpen(),document.dispatchEvent(new CustomEvent(S0e))):c.onClose(),o==null||o($)},caller:j8}),T=C.useMemo(()=>N?j.current?"delayed-open":"instant-open":"closed",[N]),I=C.useCallback(()=>{window.clearTimeout(_.current),_.current=0,j.current=!1,S(!0)},[S]),L=C.useCallback(()=>{window.clearTimeout(_.current),_.current=0,S(!1)},[S]),R=C.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{j.current=!0,S(!0),_.current=0},w)},[w,S]);return C.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),e.jsx(tO,{...u,children:e.jsx(Eyt,{scope:s,contentId:y,open:N,stateAttribute:T,trigger:p,onTriggerChange:f,onTriggerEnter:C.useCallback(()=>{c.isOpenDelayedRef.current?R():I()},[c.isOpenDelayedRef,R,I]),onTriggerLeave:C.useCallback(()=>{b?L():(window.clearTimeout(_.current),_.current=0)},[L,b]),onOpen:I,onClose:L,disableHoverableContent:b,children:r})})};nqe.displayName=j8;var C0e="TooltipTrigger",aqe=C.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=vde(C0e,r),o=fwe(C0e,r),l=yde(r),i=C.useRef(null),c=Oa(s,i,a.onTriggerChange),u=C.useRef(!1),p=C.useRef(!1),f=C.useCallback(()=>u.current=!1,[]);return C.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),e.jsx(jA,{asChild:!0,...l,children:e.jsx(Jr.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:c,onPointerMove:Mr(t.onPointerMove,y=>{y.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Mr(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Mr(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Mr(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Mr(t.onBlur,a.onClose),onClick:Mr(t.onClick,a.onClose)})})});aqe.displayName=C0e;var Pyt="TooltipPortal",[d3s,Iyt]=xde(Pyt,{forceMount:void 0}),hT="TooltipContent",iqe=C.forwardRef((t,s)=>{const r=Iyt(hT,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=vde(hT,t.__scopeTooltip);return e.jsx(Id,{present:n||l.open,children:l.disableHoverableContent?e.jsx(oqe,{side:a,...o,ref:s}):e.jsx(Lyt,{side:a,...o,ref:s})})}),Lyt=C.forwardRef((t,s)=>{const r=vde(hT,t.__scopeTooltip),n=fwe(hT,t.__scopeTooltip),a=C.useRef(null),o=Oa(s,a),[l,i]=C.useState(null),{trigger:c,onClose:u}=r,p=a.current,{onPointerInTransitChange:f}=n,y=C.useCallback(()=>{i(null),f(!1)},[f]),_=C.useCallback((b,w)=>{const j=b.currentTarget,N={x:b.clientX,y:b.clientY},S=zyt(N,j.getBoundingClientRect()),T=Byt(N,S),I=$yt(w.getBoundingClientRect()),L=Uyt([...T,...I]);i(L),f(!0)},[f]);return C.useEffect(()=>()=>y(),[y]),C.useEffect(()=>{if(c&&p){const b=j=>_(j,p),w=j=>_(j,c);return c.addEventListener("pointerleave",b),p.addEventListener("pointerleave",w),()=>{c.removeEventListener("pointerleave",b),p.removeEventListener("pointerleave",w)}}},[c,p,_,y]),C.useEffect(()=>{if(l){const b=w=>{const j=w.target,N={x:w.clientX,y:w.clientY},S=(c==null?void 0:c.contains(j))||(p==null?void 0:p.contains(j)),T=!qyt(N,l);S?y():T&&(y(),u())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[c,p,l,u,y]),e.jsx(oqe,{...t,ref:o})}),[Dyt,Oyt]=xde(j8,{isInside:!1}),Ryt=QBe("TooltipContent"),oqe=C.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,c=vde(hT,r),u=yde(r),{onClose:p}=c;return C.useEffect(()=>(document.addEventListener(S0e,p),()=>document.removeEventListener(S0e,p)),[p]),C.useEffect(()=>{if(c.trigger){const f=y=>{const _=y.target;_!=null&&_.contains(c.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,p]),e.jsx(g2,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:e.jsxs(sO,{"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(Ryt,{children:n}),e.jsx(Dyt,{scope:r,isInside:!0,children:e.jsx(Cft,{id:c.contentId,role:"tooltip",children:a||n})})]})})});iqe.displayName=hT;var lqe="TooltipArrow",Fyt=C.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=yde(r);return Oyt(lqe,r).isInside?null:e.jsx(rO,{...a,...n,ref:s})});Fyt.displayName=lqe;function zyt(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 Byt(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 $yt(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 qyt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=y>n&&r<(f-u)*(n-p)/(y-p)+u&&(a=!a)}return a}function Uyt(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),Vyt(s)}function Vyt(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 Hyt=rqe,Wyt=nqe,Gyt=aqe,cqe=iqe;const x2=Hyt,hd=Wyt,md=Gyt,Uc=C.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(cqe,{ref:n,sideOffset:s,className:At("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}));Uc.displayName=cqe.displayName;var kA=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(){}},gS=typeof window>"u"||"Deno"in globalThis;function pm(){}function Kyt(t,s){return typeof t=="function"?t(s):t}function M0e(t){return typeof t=="number"&&t>=0&&t!==1/0}function dqe(t,s){return Math.max(t+(s||0)-Date.now(),0)}function $b(t,s){return typeof t=="function"?t(s):t}function Jf(t,s){return typeof t=="function"?t(s):t}function _Ae(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==gwe(l,s.options))return!1}else if(!k8(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 bAe(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if(xS(s.options.mutationKey)!==xS(o))return!1}else if(!k8(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function gwe(t,s){return((s==null?void 0:s.queryKeyHashFn)||xS)(t)}function xS(t){return JSON.stringify(t,(s,r)=>T0e(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function k8(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>k8(t[r],s[r])):!1}function uqe(t,s){if(t===s)return t;const r=wAe(t)&&wAe(s);if(r||T0e(t)&&T0e(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 A0e(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?uqe(t,s):s}function Yyt(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function Xyt(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var xwe=Symbol();function hqe(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===xwe?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function mqe(t,s){return typeof t=="function"?t(...s):!!t}var N4,eb,WM,Cze,Qyt=(Cze=class extends kA{constructor(){super();Za(this,N4);Za(this,eb);Za(this,WM);qn(this,WM,s=>{if(!gS&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){cs(this,eb)||this.setEventListener(cs(this,WM))}onUnsubscribe(){var s;this.hasListeners()||((s=cs(this,eb))==null||s.call(this),qn(this,eb,void 0))}setEventListener(s){var r;qn(this,WM,s),(r=cs(this,eb))==null||r.call(this),qn(this,eb,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){cs(this,N4)!==s&&(qn(this,N4,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof cs(this,N4)=="boolean"?cs(this,N4):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},N4=new WeakMap,eb=new WeakMap,WM=new WeakMap,Cze),ywe=new Qyt,GM,tb,KM,Mze,Jyt=(Mze=class extends kA{constructor(){super();Za(this,GM,!0);Za(this,tb);Za(this,KM);qn(this,KM,s=>{if(!gS&&window.addEventListener){const r=()=>s(!0),n=()=>s(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){cs(this,tb)||this.setEventListener(cs(this,KM))}onUnsubscribe(){var s;this.hasListeners()||((s=cs(this,tb))==null||s.call(this),qn(this,tb,void 0))}setEventListener(s){var r;qn(this,KM,s),(r=cs(this,tb))==null||r.call(this),qn(this,tb,s(this.setOnline.bind(this)))}setOnline(s){cs(this,GM)!==s&&(qn(this,GM,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return cs(this,GM)}},GM=new WeakMap,tb=new WeakMap,KM=new WeakMap,Mze),noe=new Jyt;function E0e(){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 e0t(t){return Math.min(1e3*2**t,3e4)}function pqe(t){return(t??"online")==="online"?noe.isOnline():!0}var fqe=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function Vfe(t){return t instanceof fqe}function gqe(t){let s=!1,r=0,n=!1,a;const o=E0e(),l=w=>{var j;n||(y(new fqe(w)),(j=t.abort)==null||j.call(t))},i=()=>{s=!0},c=()=>{s=!1},u=()=>ywe.isFocused()&&(t.networkMode==="always"||noe.isOnline())&&t.canRun(),p=()=>pqe(t.networkMode)&&t.canRun(),f=w=>{var j;n||(n=!0,(j=t.onSuccess)==null||j.call(t,w),a==null||a(),o.resolve(w))},y=w=>{var j;n||(n=!0,(j=t.onError)==null||j.call(t,w),a==null||a(),o.reject(w))},_=()=>new Promise(w=>{var j;a=N=>{(n||u())&&w(N)},(j=t.onPause)==null||j.call(t)}).then(()=>{var w;a=void 0,n||(w=t.onContinue)==null||w.call(t)}),b=()=>{if(n)return;let w;const j=r===0?t.initialPromise:void 0;try{w=j??t.fn()}catch(N){w=Promise.reject(N)}Promise.resolve(w).then(f).catch(N=>{var R;if(n)return;const S=t.retry??(gS?0:3),T=t.retryDelay??e0t,I=typeof T=="function"?T(r,N):T,L=S===!0||typeof S=="number"&&ru()?void 0:_()).then(()=>{s?y(N):b()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:c,canStart:p,start:()=>(p()?b():_().then(b),o)}}var t0t=t=>setTimeout(t,0);function s0t(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=t0t;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 du=s0t(),S4,Tze,xqe=(Tze=class{constructor(){Za(this,S4)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),M0e(this.gcTime)&&qn(this,S4,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(gS?1/0:5*60*1e3))}clearGcTimeout(){cs(this,S4)&&(clearTimeout(cs(this,S4)),qn(this,S4,void 0))}},S4=new WeakMap,Tze),ZM,C4,Qf,M4,Mh,qD,T4,Sx,_v,Aze,r0t=(Aze=class extends xqe{constructor(s){super();Za(this,Sx);Za(this,ZM);Za(this,C4);Za(this,Qf);Za(this,M4);Za(this,Mh);Za(this,qD);Za(this,T4);qn(this,T4,!1),qn(this,qD,s.defaultOptions),this.setOptions(s.options),this.observers=[],qn(this,M4,s.client),qn(this,Qf,cs(this,M4).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,qn(this,ZM,n0t(this.options)),this.state=s.state??cs(this,ZM),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=cs(this,Mh))==null?void 0:s.promise}setOptions(s){this.options={...cs(this,qD),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&cs(this,Qf).remove(this)}setData(s,r){const n=A0e(this.state.data,s,this.options);return Yi(this,Sx,_v).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(s,r){Yi(this,Sx,_v).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=cs(this,Mh))==null?void 0:n.promise;return(a=cs(this,Mh))==null||a.cancel(s),r?r.then(pm).catch(pm):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(cs(this,ZM))}isActive(){return this.observers.some(s=>Jf(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===xwe||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>$b(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:!dqe(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=cs(this,Mh))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=cs(this,Mh))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),cs(this,Qf).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(cs(this,Mh)&&(cs(this,T4)?cs(this,Mh).cancel({revert:!0}):cs(this,Mh).cancelRetry()),this.scheduleGc()),cs(this,Qf).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Yi(this,Sx,_v).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(cs(this,Mh))return cs(this,Mh).continueRetry(),cs(this,Mh).promise}if(s&&this.setOptions(s),!this.options.queryFn){const y=this.observers.find(_=>_.options.queryFn);y&&this.setOptions(y.options)}const n=new AbortController,a=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(qn(this,T4,!0),n.signal)})},o=()=>{const y=hqe(this.options,r),b=(()=>{const w={client:cs(this,M4),queryKey:this.queryKey,meta:this.meta};return a(w),w})();return qn(this,T4,!1),this.options.persister?this.options.persister(y,b,this):y(b)},i=(()=>{const y={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:cs(this,M4),state:this.state,fetchFn:o};return a(y),y})();(u=this.options.behavior)==null||u.onFetch(i,this),qn(this,C4,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=i.fetchOptions)==null?void 0:p.meta))&&Yi(this,Sx,_v).call(this,{type:"fetch",meta:(f=i.fetchOptions)==null?void 0:f.meta});const c=y=>{var _,b,w,j;Vfe(y)&&y.silent||Yi(this,Sx,_v).call(this,{type:"error",error:y}),Vfe(y)||((b=(_=cs(this,Qf).config).onError)==null||b.call(_,y,this),(j=(w=cs(this,Qf).config).onSettled)==null||j.call(w,this.state.data,y,this)),this.scheduleGc()};return qn(this,Mh,gqe({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:y=>{var _,b,w,j;if(y===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(y)}catch(N){c(N);return}(b=(_=cs(this,Qf).config).onSuccess)==null||b.call(_,y,this),(j=(w=cs(this,Qf).config).onSettled)==null||j.call(w,y,this.state.error,this),this.scheduleGc()},onError:c,onFail:(y,_)=>{Yi(this,Sx,_v).call(this,{type:"failed",failureCount:y,error:_})},onPause:()=>{Yi(this,Sx,_v).call(this,{type:"pause"})},onContinue:()=>{Yi(this,Sx,_v).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),cs(this,Mh).start()}},ZM=new WeakMap,C4=new WeakMap,Qf=new WeakMap,M4=new WeakMap,Mh=new WeakMap,qD=new WeakMap,T4=new WeakMap,Sx=new WeakSet,_v=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,...yqe(n.data,this.options),fetchMeta:s.meta??null};case"success":return qn(this,C4,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 Vfe(a)&&a.revert&&cs(this,C4)?{...cs(this,C4),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),du.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),cs(this,Qf).notify({query:this,type:"updated",action:s})})},Aze);function yqe(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:pqe(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function n0t(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 Uy,Eze,a0t=(Eze=class extends kA{constructor(s={}){super();Za(this,Uy);this.config=s,qn(this,Uy,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??gwe(a,r);let l=this.get(o);return l||(l=new r0t({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){cs(this,Uy).has(s.queryHash)||(cs(this,Uy).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=cs(this,Uy).get(s.queryHash);r&&(s.destroy(),r===s&&cs(this,Uy).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){du.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return cs(this,Uy).get(s)}getAll(){return[...cs(this,Uy).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>_Ae(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>_Ae(s,n)):r}notify(s){du.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){du.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){du.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},Uy=new WeakMap,Eze),Vy,um,A4,Hy,T_,Pze,i0t=(Pze=class extends xqe{constructor(s){super();Za(this,Hy);Za(this,Vy);Za(this,um);Za(this,A4);this.mutationId=s.mutationId,qn(this,um,s.mutationCache),qn(this,Vy,[]),this.state=s.state||vqe(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){cs(this,Vy).includes(s)||(cs(this,Vy).push(s),this.clearGcTimeout(),cs(this,um).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){qn(this,Vy,cs(this,Vy).filter(r=>r!==s)),this.scheduleGc(),cs(this,um).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){cs(this,Vy).length||(this.state.status==="pending"?this.scheduleGc():cs(this,um).remove(this))}continue(){var s;return((s=cs(this,A4))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,i,c,u,p,f,y,_,b,w,j,N,S,T,I,L,R,$,q;const r=()=>{Yi(this,Hy,T_).call(this,{type:"continue"})};qn(this,A4,gqe({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:(U,V)=>{Yi(this,Hy,T_).call(this,{type:"failed",failureCount:U,error:V})},onPause:()=>{Yi(this,Hy,T_).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>cs(this,um).canRun(this)}));const n=this.state.status==="pending",a=!cs(this,A4).canStart();try{if(n)r();else{Yi(this,Hy,T_).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=cs(this,um).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&&Yi(this,Hy,T_).call(this,{type:"pending",context:V,variables:s,isPaused:a})}const U=await cs(this,A4).start();return await((p=(u=cs(this,um).config).onSuccess)==null?void 0:p.call(u,U,s,this.state.context,this)),await((y=(f=this.options).onSuccess)==null?void 0:y.call(f,U,s,this.state.context)),await((b=(_=cs(this,um).config).onSettled)==null?void 0:b.call(_,U,null,this.state.variables,this.state.context,this)),await((j=(w=this.options).onSettled)==null?void 0:j.call(w,U,null,s,this.state.context)),Yi(this,Hy,T_).call(this,{type:"success",data:U}),U}catch(U){try{throw await((S=(N=cs(this,um).config).onError)==null?void 0:S.call(N,U,s,this.state.context,this)),await((I=(T=this.options).onError)==null?void 0:I.call(T,U,s,this.state.context)),await((R=(L=cs(this,um).config).onSettled)==null?void 0:R.call(L,void 0,U,this.state.variables,this.state.context,this)),await((q=($=this.options).onSettled)==null?void 0:q.call($,void 0,U,s,this.state.context)),U}finally{Yi(this,Hy,T_).call(this,{type:"error",error:U})}}finally{cs(this,um).runNext(this)}}},Vy=new WeakMap,um=new WeakMap,A4=new WeakMap,Hy=new WeakSet,T_=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),du.batch(()=>{cs(this,Vy).forEach(n=>{n.onMutationUpdate(s)}),cs(this,um).notify({mutation:this,type:"updated",action:s})})},Pze);function vqe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Lv,Cx,UD,Ize,o0t=(Ize=class extends kA{constructor(s={}){super();Za(this,Lv);Za(this,Cx);Za(this,UD);this.config=s,qn(this,Lv,new Set),qn(this,Cx,new Map),qn(this,UD,0)}build(s,r,n){const a=new i0t({mutationCache:this,mutationId:++ZF(this,UD)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){cs(this,Lv).add(s);const r=x7(s);if(typeof r=="string"){const n=cs(this,Cx).get(r);n?n.push(s):cs(this,Cx).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(cs(this,Lv).delete(s)){const r=x7(s);if(typeof r=="string"){const n=cs(this,Cx).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&cs(this,Cx).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=x7(s);if(typeof r=="string"){const n=cs(this,Cx).get(r),a=n==null?void 0:n.find(o=>o.state.status==="pending");return!a||a===s}else return!0}runNext(s){var n;const r=x7(s);if(typeof r=="string"){const a=(n=cs(this,Cx).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(){du.batch(()=>{cs(this,Lv).forEach(s=>{this.notify({type:"removed",mutation:s})}),cs(this,Lv).clear(),cs(this,Cx).clear()})}getAll(){return Array.from(cs(this,Lv))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>bAe(r,n))}findAll(s={}){return this.getAll().filter(r=>bAe(s,r))}notify(s){du.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>r.state.isPaused);return du.batch(()=>Promise.all(s.map(r=>r.continue().catch(pm))))}},Lv=new WeakMap,Cx=new WeakMap,UD=new WeakMap,Ize);function x7(t){var s;return(s=t.options.scope)==null?void 0:s.id}function aoe(t){return{onFetch:(s,r)=>{var p,f,y,_,b;const n=s.options,a=(y=(f=(p=s.fetchOptions)==null?void 0:p.meta)==null?void 0:f.fetchMore)==null?void 0:y.direction,o=((_=s.state.data)==null?void 0:_.pages)||[],l=((b=s.state.data)==null?void 0:b.pageParams)||[];let i={pages:[],pageParams:[]},c=0;const u=async()=>{let w=!1;const j=T=>{Object.defineProperty(T,"signal",{enumerable:!0,get:()=>(s.signal.aborted?w=!0:s.signal.addEventListener("abort",()=>{w=!0}),s.signal)})},N=hqe(s.options,s.fetchOptions),S=async(T,I,L)=>{if(w)return Promise.reject();if(I==null&&T.pages.length)return Promise.resolve(T);const $=(()=>{const X={client:s.client,queryKey:s.queryKey,pageParam:I,direction:L?"backward":"forward",meta:s.options.meta};return j(X),X})(),q=await N($),{maxPages:U}=s.options,V=L?Xyt:Yyt;return{pages:V(T.pages,q,U),pageParams:V(T.pageParams,I,U)}};if(a&&o.length){const T=a==="backward",I=T?_qe:P0e,L={pages:o,pageParams:l},R=I(n,L);i=await S(L,R,T)}else{const T=t??o.length;do{const I=c===0?l[0]??n.initialPageParam:P0e(n,i);if(c>0&&I==null)break;i=await S(i,I),c++}while(c{var w,j;return(j=(w=s.options).persister)==null?void 0:j.call(w,u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=u}}}function P0e(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 _qe(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 l0t(t,s){return s?P0e(t,s)!=null:!1}function c0t(t,s){return!s||!t.getPreviousPageParam?!1:_qe(t,s)!=null}var sd,sb,rb,YM,XM,nb,QM,JM,Lze,d0t=(Lze=class{constructor(t={}){Za(this,sd);Za(this,sb);Za(this,rb);Za(this,YM);Za(this,XM);Za(this,nb);Za(this,QM);Za(this,JM);qn(this,sd,t.queryCache||new a0t),qn(this,sb,t.mutationCache||new o0t),qn(this,rb,t.defaultOptions||{}),qn(this,YM,new Map),qn(this,XM,new Map),qn(this,nb,0)}mount(){ZF(this,nb)._++,cs(this,nb)===1&&(qn(this,QM,ywe.subscribe(async t=>{t&&(await this.resumePausedMutations(),cs(this,sd).onFocus())})),qn(this,JM,noe.subscribe(async t=>{t&&(await this.resumePausedMutations(),cs(this,sd).onOnline())})))}unmount(){var t,s;ZF(this,nb)._--,cs(this,nb)===0&&((t=cs(this,QM))==null||t.call(this),qn(this,QM,void 0),(s=cs(this,JM))==null||s.call(this),qn(this,JM,void 0))}isFetching(t){return cs(this,sd).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return cs(this,sb).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=cs(this,sd).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=cs(this,sd).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime($b(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return cs(this,sd).findAll(t).map(({queryKey:s,state:r})=>{const n=r.data;return[s,n]})}setQueryData(t,s,r){const n=this.defaultQueryOptions({queryKey:t}),a=cs(this,sd).get(n.queryHash),o=a==null?void 0:a.state.data,l=Kyt(s,o);if(l!==void 0)return cs(this,sd).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return du.batch(()=>cs(this,sd).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=cs(this,sd).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=cs(this,sd);du.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=cs(this,sd);return du.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const r={revert:!0,...s},n=du.batch(()=>cs(this,sd).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(pm).catch(pm)}invalidateQueries(t,s={}){return du.batch(()=>(cs(this,sd).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=du.batch(()=>cs(this,sd).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(pm)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(pm)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=cs(this,sd).build(this,s);return r.isStaleByTime($b(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(pm).catch(pm)}fetchInfiniteQuery(t){return t.behavior=aoe(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(pm).catch(pm)}ensureInfiniteQueryData(t){return t.behavior=aoe(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return noe.isOnline()?cs(this,sb).resumePausedMutations():Promise.resolve()}getQueryCache(){return cs(this,sd)}getMutationCache(){return cs(this,sb)}getDefaultOptions(){return cs(this,rb)}setDefaultOptions(t){qn(this,rb,t)}setQueryDefaults(t,s){cs(this,YM).set(xS(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...cs(this,YM).values()],r={};return s.forEach(n=>{k8(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){cs(this,XM).set(xS(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...cs(this,XM).values()],r={};return s.forEach(n=>{k8(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...cs(this,rb).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=gwe(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===xwe&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...cs(this,rb).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){cs(this,sd).clear(),cs(this,sb).clear()}},sd=new WeakMap,sb=new WeakMap,rb=new WeakMap,YM=new WeakMap,XM=new WeakMap,nb=new WeakMap,QM=new WeakMap,JM=new WeakMap,Lze),Jm,ko,VD,hm,E4,eT,ab,ib,HD,tT,sT,P4,I4,ob,rT,el,J6,I0e,L0e,D0e,O0e,R0e,F0e,z0e,wqe,Dze,bqe=(Dze=class extends kA{constructor(s,r){super();Za(this,el);Za(this,Jm);Za(this,ko);Za(this,VD);Za(this,hm);Za(this,E4);Za(this,eT);Za(this,ab);Za(this,ib);Za(this,HD);Za(this,tT);Za(this,sT);Za(this,P4);Za(this,I4);Za(this,ob);Za(this,rT,new Set);this.options=r,qn(this,Jm,s),qn(this,ib,null),qn(this,ab,E0e()),this.options.experimental_prefetchInRender||cs(this,ab).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(cs(this,ko).addObserver(this),kAe(cs(this,ko),this.options)?Yi(this,el,J6).call(this):this.updateResult(),Yi(this,el,O0e).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return B0e(cs(this,ko),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return B0e(cs(this,ko),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Yi(this,el,R0e).call(this),Yi(this,el,F0e).call(this),cs(this,ko).removeObserver(this)}setOptions(s){const r=this.options,n=cs(this,ko);if(this.options=cs(this,Jm).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Jf(this.options.enabled,cs(this,ko))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Yi(this,el,z0e).call(this),cs(this,ko).setOptions(this.options),r._defaulted&&!roe(this.options,r)&&cs(this,Jm).getQueryCache().notify({type:"observerOptionsUpdated",query:cs(this,ko),observer:this});const a=this.hasListeners();a&&NAe(cs(this,ko),n,this.options,r)&&Yi(this,el,J6).call(this),this.updateResult(),a&&(cs(this,ko)!==n||Jf(this.options.enabled,cs(this,ko))!==Jf(r.enabled,cs(this,ko))||$b(this.options.staleTime,cs(this,ko))!==$b(r.staleTime,cs(this,ko)))&&Yi(this,el,I0e).call(this);const o=Yi(this,el,L0e).call(this);a&&(cs(this,ko)!==n||Jf(this.options.enabled,cs(this,ko))!==Jf(r.enabled,cs(this,ko))||o!==cs(this,ob))&&Yi(this,el,D0e).call(this,o)}getOptimisticResult(s){const r=cs(this,Jm).getQueryCache().build(cs(this,Jm),s),n=this.createResult(r,s);return h0t(this,n)&&(qn(this,hm,n),qn(this,eT,this.options),qn(this,E4,cs(this,ko).state)),n}getCurrentResult(){return cs(this,hm)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){cs(this,rT).add(s)}getCurrentQuery(){return cs(this,ko)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=cs(this,Jm).defaultQueryOptions(s),n=cs(this,Jm).getQueryCache().build(cs(this,Jm),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return Yi(this,el,J6).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),cs(this,hm)))}createResult(s,r){var U;const n=cs(this,ko),a=this.options,o=cs(this,hm),l=cs(this,E4),i=cs(this,eT),u=s!==n?s.state:cs(this,VD),{state:p}=s;let f={...p},y=!1,_;if(r._optimisticResults){const V=this.hasListeners(),X=!V&&kAe(s,r),se=V&&NAe(s,n,r,a);(X||se)&&(f={...f,...yqe(p.data,s.options)}),r._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:b,errorUpdatedAt:w,status:j}=f;_=f.data;let N=!1;if(r.placeholderData!==void 0&&_===void 0&&j==="pending"){let V;o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(V=o.data,N=!0):V=typeof r.placeholderData=="function"?r.placeholderData((U=cs(this,sT))==null?void 0:U.state.data,cs(this,sT)):r.placeholderData,V!==void 0&&(j="success",_=A0e(o==null?void 0:o.data,V,r),y=!0)}if(r.select&&_!==void 0&&!N)if(o&&_===(l==null?void 0:l.data)&&r.select===cs(this,HD))_=cs(this,tT);else try{qn(this,HD,r.select),_=r.select(_),_=A0e(o==null?void 0:o.data,_,r),qn(this,tT,_),qn(this,ib,null)}catch(V){qn(this,ib,V)}cs(this,ib)&&(b=cs(this,ib),_=cs(this,tT),w=Date.now(),j="error");const S=f.fetchStatus==="fetching",T=j==="pending",I=j==="error",L=T&&S,R=_!==void 0,q={status:j,fetchStatus:f.fetchStatus,isPending:T,isSuccess:j==="success",isError:I,isInitialLoading:L,isLoading:L,data:_,dataUpdatedAt:f.dataUpdatedAt,error:b,errorUpdatedAt:w,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:S,isRefetching:S&&!T,isLoadingError:I&&!R,isPaused:f.fetchStatus==="paused",isPlaceholderData:y,isRefetchError:I&&R,isStale:vwe(s,r),refetch:this.refetch,promise:cs(this,ab),isEnabled:Jf(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const V=ee=>{q.status==="error"?ee.reject(q.error):q.data!==void 0&&ee.resolve(q.data)},X=()=>{const ee=qn(this,ab,q.promise=E0e());V(ee)},se=cs(this,ab);switch(se.status){case"pending":s.queryHash===n.queryHash&&V(se);break;case"fulfilled":(q.status==="error"||q.data!==se.value)&&X();break;case"rejected":(q.status!=="error"||q.error!==se.reason)&&X();break}}return q}updateResult(){const s=cs(this,hm),r=this.createResult(cs(this,ko),this.options);if(qn(this,E4,cs(this,ko).state),qn(this,eT,this.options),cs(this,E4).data!==void 0&&qn(this,sT,cs(this,ko)),roe(r,s))return;qn(this,hm,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!cs(this,rT).size)return!0;const l=new Set(o??cs(this,rT));return this.options.throwOnError&&l.add("error"),Object.keys(cs(this,hm)).some(i=>{const c=i;return cs(this,hm)[c]!==s[c]&&l.has(c)})};Yi(this,el,wqe).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Yi(this,el,O0e).call(this)}},Jm=new WeakMap,ko=new WeakMap,VD=new WeakMap,hm=new WeakMap,E4=new WeakMap,eT=new WeakMap,ab=new WeakMap,ib=new WeakMap,HD=new WeakMap,tT=new WeakMap,sT=new WeakMap,P4=new WeakMap,I4=new WeakMap,ob=new WeakMap,rT=new WeakMap,el=new WeakSet,J6=function(s){Yi(this,el,z0e).call(this);let r=cs(this,ko).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(pm)),r},I0e=function(){Yi(this,el,R0e).call(this);const s=$b(this.options.staleTime,cs(this,ko));if(gS||cs(this,hm).isStale||!M0e(s))return;const n=dqe(cs(this,hm).dataUpdatedAt,s)+1;qn(this,P4,setTimeout(()=>{cs(this,hm).isStale||this.updateResult()},n))},L0e=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(cs(this,ko)):this.options.refetchInterval)??!1},D0e=function(s){Yi(this,el,F0e).call(this),qn(this,ob,s),!(gS||Jf(this.options.enabled,cs(this,ko))===!1||!M0e(cs(this,ob))||cs(this,ob)===0)&&qn(this,I4,setInterval(()=>{(this.options.refetchIntervalInBackground||ywe.isFocused())&&Yi(this,el,J6).call(this)},cs(this,ob)))},O0e=function(){Yi(this,el,I0e).call(this),Yi(this,el,D0e).call(this,Yi(this,el,L0e).call(this))},R0e=function(){cs(this,P4)&&(clearTimeout(cs(this,P4)),qn(this,P4,void 0))},F0e=function(){cs(this,I4)&&(clearInterval(cs(this,I4)),qn(this,I4,void 0))},z0e=function(){const s=cs(this,Jm).getQueryCache().build(cs(this,Jm),this.options);if(s===cs(this,ko))return;const r=cs(this,ko);qn(this,ko,s),qn(this,VD,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},wqe=function(s){du.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(cs(this,hm))}),cs(this,Jm).getQueryCache().notify({query:cs(this,ko),type:"observerResultsUpdated"})})},Dze);function u0t(t,s){return Jf(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function kAe(t,s){return u0t(t,s)||t.state.data!==void 0&&B0e(t,s,s.refetchOnMount)}function B0e(t,s,r){if(Jf(s.enabled,t)!==!1&&$b(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&vwe(t,s)}return!1}function NAe(t,s,r,n){return(t!==s||Jf(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&vwe(t,r)}function vwe(t,s){return Jf(s.enabled,t)!==!1&&t.isStaleByTime($b(s.staleTime,t))}function h0t(t,s){return!roe(t.getCurrentResult(),s)}var m0t=class extends bqe{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:aoe()})}getOptimisticResult(t){return t.behavior=aoe(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,s){var b,w;const{state:r}=t,n=super.createResult(t,s),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,c=(w=(b=r.fetchMeta)==null?void 0:b.fetchMore)==null?void 0:w.direction,u=l&&c==="forward",p=a&&c==="forward",f=l&&c==="backward",y=a&&c==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:l0t(s,r.data),hasPreviousPage:c0t(s,r.data),isFetchNextPageError:u,isFetchingNextPage:p,isFetchPreviousPageError:f,isFetchingPreviousPage:y,isRefetchError:i&&!u&&!f,isRefetching:o&&!p&&!y}}},lb,cb,ep,Dv,m1,Jae,$0e,Oze,p0t=(Oze=class extends kA{constructor(r,n){super();Za(this,m1);Za(this,lb);Za(this,cb);Za(this,ep);Za(this,Dv);qn(this,lb,r),this.setOptions(n),this.bindMethods(),Yi(this,m1,Jae).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var a;const n=this.options;this.options=cs(this,lb).defaultMutationOptions(r),roe(this.options,n)||cs(this,lb).getMutationCache().notify({type:"observerOptionsUpdated",mutation:cs(this,ep),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&xS(n.mutationKey)!==xS(this.options.mutationKey)?this.reset():((a=cs(this,ep))==null?void 0:a.state.status)==="pending"&&cs(this,ep).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=cs(this,ep))==null||r.removeObserver(this)}onMutationUpdate(r){Yi(this,m1,Jae).call(this),Yi(this,m1,$0e).call(this,r)}getCurrentResult(){return cs(this,cb)}reset(){var r;(r=cs(this,ep))==null||r.removeObserver(this),qn(this,ep,void 0),Yi(this,m1,Jae).call(this),Yi(this,m1,$0e).call(this)}mutate(r,n){var a;return qn(this,Dv,n),(a=cs(this,ep))==null||a.removeObserver(this),qn(this,ep,cs(this,lb).getMutationCache().build(cs(this,lb),this.options)),cs(this,ep).addObserver(this),cs(this,ep).execute(r)}},lb=new WeakMap,cb=new WeakMap,ep=new WeakMap,Dv=new WeakMap,m1=new WeakSet,Jae=function(){var n;const r=((n=cs(this,ep))==null?void 0:n.state)??vqe();qn(this,cb,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},$0e=function(r){du.batch(()=>{var n,a,o,l,i,c,u,p;if(cs(this,Dv)&&this.hasListeners()){const f=cs(this,cb).variables,y=cs(this,cb).context;(r==null?void 0:r.type)==="success"?((a=(n=cs(this,Dv)).onSuccess)==null||a.call(n,r.data,f,y),(l=(o=cs(this,Dv)).onSettled)==null||l.call(o,r.data,null,f,y)):(r==null?void 0:r.type)==="error"&&((c=(i=cs(this,Dv)).onError)==null||c.call(i,r.error,f,y),(p=(u=cs(this,Dv)).onSettled)==null||p.call(u,void 0,r.error,f,y))}this.listeners.forEach(f=>{f(cs(this,cb))})})},Oze),jqe=C.createContext(void 0),ss=t=>{const s=C.useContext(jqe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},f0t=({client:t,children:s})=>(C.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(jqe.Provider,{value:t,children:s})),kqe=C.createContext(!1),g0t=()=>C.useContext(kqe);kqe.Provider;function x0t(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var y0t=C.createContext(x0t()),v0t=()=>C.useContext(y0t),_0t=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},b0t=t=>{C.useEffect(()=>{t.clearReset()},[t])},w0t=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||mqe(r,[t.error,n])),j0t=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))}},k0t=(t,s)=>t.isLoading&&t.isFetching&&!s,N0t=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,SAe=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function Nqe(t,s,r){var f,y,_,b,w;const n=g0t(),a=v0t(),o=ss(),l=o.defaultQueryOptions(t);(y=(f=o.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||y.call(f,l),l._optimisticResults=n?"isRestoring":"optimistic",j0t(l),_0t(l,a),b0t(a);const i=!o.getQueryCache().get(l.queryHash),[c]=C.useState(()=>new s(o,l)),u=c.getOptimisticResult(l),p=!n&&t.subscribed!==!1;if(C.useSyncExternalStore(C.useCallback(j=>{const N=p?c.subscribe(du.batchCalls(j)):pm;return c.updateResult(),N},[c,p]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),C.useEffect(()=>{c.setOptions(l)},[l,c]),N0t(l,u))throw SAe(l,c,a);if(w0t({result:u,errorResetBoundary:a,throwOnError:l.throwOnError,query:o.getQueryCache().get(l.queryHash),suspense:l.suspense}))throw u.error;if((b=(_=o.getDefaultOptions().queries)==null?void 0:_._experimental_afterQuery)==null||b.call(_,l,u),l.experimental_prefetchInRender&&!gS&&k0t(u,n)){const j=i?SAe(l,c,a):(w=o.getQueryCache().get(l.queryHash))==null?void 0:w.promise;j==null||j.catch(pm).finally(()=>{c.updateResult()})}return l.notifyOnChangeProps?u:c.trackResult(u)}function wt(t,s){return Nqe(t,bqe)}function Dt(t,s){const r=ss(),[n]=C.useState(()=>new p0t(r,t));C.useEffect(()=>{n.setOptions(t)},[n,t]);const a=C.useSyncExternalStore(C.useCallback(l=>n.subscribe(du.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=C.useCallback((l,i)=>{n.mutate(l,i).catch(pm)},[n]);if(a.error&&mqe(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function S0t(t,s){return Nqe(t,m0t)}/** * @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 N8(){return N8=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function Sqe(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function M0t(){return Math.random().toString(36).substr(2,8)}function MAe(t,s){return{usr:t.state,key:t.key,idx:s}}function q0e(t,s,r,n){return r===void 0&&(r=null),N8({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?NA(s):s,{state:r,key:s&&s.key||n||M0t()})}function ioe(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 NA(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 T0t(t,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=mb.Pop,c=null,u=p();u==null&&(u=0,l.replaceState(N8({},l.state,{idx:u}),""));function p(){return(l.state||{idx:null}).idx}function f(){i=mb.Pop;let j=p(),N=j==null?null:j-u;u=j,c&&c({action:i,location:w.location,delta:N})}function y(j,N){i=mb.Push;let S=q0e(w.location,j,N);u=p()+1;let T=MAe(S,u),I=w.createHref(S);try{l.pushState(T,"",I)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;a.location.assign(I)}o&&c&&c({action:i,location:w.location,delta:1})}function _(j,N){i=mb.Replace;let S=q0e(w.location,j,N);u=p();let T=MAe(S,u),I=w.createHref(S);l.replaceState(T,"",I),o&&c&&c({action:i,location:w.location,delta:0})}function b(j){let N=a.location.origin!=="null"?a.location.origin:a.location.href,S=typeof j=="string"?j:ioe(j);return S=S.replace(/ $/,"%20"),Ed(N,"No window.location.(origin|href) available to create URL for href: "+S),new URL(S,N)}let w={get action(){return i},get location(){return t(a,l)},listen(j){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(CAe,f),c=j,()=>{a.removeEventListener(CAe,f),c=null}},createHref(j){return s(a,j)},createURL:b,encodeLocation(j){let N=b(j);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:y,replace:_,go(j){return l.go(j)}};return w}var TAe;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(TAe||(TAe={}));function A0t(t,s,r){return r===void 0&&(r="/"),E0t(t,s,r)}function E0t(t,s,r,n){let a=typeof s=="string"?NA(s):s,o=_we(a.pathname||"/",r);if(o==null)return null;let l=Cqe(t);P0t(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("/")&&(Ed(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=qb([n,c.relativePath]),p=r.concat(c);o.children&&o.children.length>0&&(Ed(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),Cqe(o.children,s,p,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:z0t(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 Mqe(o.path))a(o,l,c)}),s}function Mqe(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=Mqe(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 P0t(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:B0t(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const I0t=/^:[\w-]+$/,L0t=3,D0t=2,O0t=1,R0t=10,F0t=-2,AAe=t=>t==="*";function z0t(t,s){let r=t.split("/"),n=r.length;return r.some(AAe)&&(n+=F0t),s&&(n+=D0t),r.filter(a=>!AAe(a)).reduce((a,o)=>a+(I0t.test(o)?L0t:o===""?O0t:R0t),n)}function B0t(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 $0t(t,s,r){let{routesMeta:n}=t,a={},o="/",l=[];for(let i=0;i{let{paramName:y,isOptional:_}=p;if(y==="*"){let w=i[f]||"";l=o.slice(0,o.length-w.length).replace(/(.)\/+$/,"$1")}const b=i[f];return _&&!b?u[y]=void 0:u[y]=(b||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:l,pattern:t}}function U0t(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),Sqe(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 V0t(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return Sqe(!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 _we(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 H0t(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?NA(t):t;return{pathname:r?r.startsWith("/")?r:W0t(r,s):s,search:Z0t(n),hash:Y0t(a)}}function W0t(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 Hfe(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 G0t(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function bwe(t,s){let r=G0t(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function wwe(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=NA(t):(a=N8({},t),Ed(!a.pathname||!a.pathname.includes("?"),Hfe("?","pathname","search",a)),Ed(!a.pathname||!a.pathname.includes("#"),Hfe("#","pathname","hash",a)),Ed(!a.search||!a.search.includes("#"),Hfe("#","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 y=l.split("/");for(;y[0]==="..";)y.shift(),f-=1;a.pathname=y.join("/")}i=f>=0?s[f]:"/"}let c=H0t(a,i),u=l&&l!=="/"&&l.endsWith("/"),p=(o||l===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(u||p)&&(c.pathname+="/"),c}const qb=t=>t.join("/").replace(/\/\/+/g,"/"),K0t=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Z0t=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Y0t=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function X0t(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Tqe=["post","put","patch","delete"];new Set(Tqe);const Q0t=["get",...Tqe];new Set(Q0t);/** * 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 S8(){return S8=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),C.useCallback(function(u,p){if(p===void 0&&(p={}),!i.current)return;if(typeof u=="number"){n.go(u);return}let f=wwe(u,JSON.parse(l),o,p.relative==="path");t==null&&s!=="/"&&(f.pathname=f.pathname==="/"?s:qb([s,f.pathname])),(p.replace?n.replace:n.push)(f,p.state,p)},[s,n,l,o,t])}const svt=C.createContext(null);function rvt(t){let s=C.useContext(T0).outlet;return s&&C.createElement(svt.Provider,{value:t},s)}function Po(){let{matches:t}=C.useContext(T0),s=t[t.length-1];return s?s.params:{}}function Pqe(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=C.useContext(y2),{matches:a}=C.useContext(T0),{pathname:o}=Qu(),l=JSON.stringify(bwe(a,n.v7_relativeSplatPath));return C.useMemo(()=>wwe(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function nvt(t,s){return avt(t,s)}function avt(t,s,r,n){SA()||Ed(!1);let{navigator:a}=C.useContext(y2),{matches:o}=C.useContext(T0),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=Qu(),p;if(s){var f;let j=typeof s=="string"?NA(s):s;c==="/"||(f=j.pathname)!=null&&f.startsWith(c)||Ed(!1),p=j}else p=u;let y=p.pathname||"/",_=y;if(c!=="/"){let j=c.replace(/^\//,"").split("/");_="/"+y.replace(/^\//,"").split("/").slice(j.length).join("/")}let b=A0t(t,{pathname:_}),w=dvt(b&&b.map(j=>Object.assign({},j,{params:Object.assign({},i,j.params),pathname:qb([c,a.encodeLocation?a.encodeLocation(j.pathname).pathname:j.pathname]),pathnameBase:j.pathnameBase==="/"?c:qb([c,a.encodeLocation?a.encodeLocation(j.pathnameBase).pathname:j.pathnameBase])})),o,r,n);return s&&w?C.createElement(_de.Provider,{value:{location:S8({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:mb.Pop}},w):w}function ivt(){let t=pvt(),s=X0t(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 C.createElement(C.Fragment,null,C.createElement("h2",null,"Unexpected Application Error!"),C.createElement("h3",{style:{fontStyle:"italic"}},s),r?C.createElement("pre",{style:a},r):null,null)}const ovt=C.createElement(ivt,null);class lvt extends C.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?C.createElement(T0.Provider,{value:this.props.routeContext},C.createElement(Aqe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function cvt(t){let{routeContext:s,match:r,children:n}=t,a=C.useContext(jwe);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),C.createElement(T0.Provider,{value:s},n)}function dvt(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||Ed(!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,y)=>{let _,b=!1,w=null,j=null;r&&(_=i&&f.route.id?i[f.route.id]:void 0,w=f.route.errorElement||ovt,c&&(u<0&&y===0?(gvt("route-fallback"),b=!0,j=null):u===y&&(b=!0,j=f.route.hydrateFallbackElement||null)));let N=s.concat(l.slice(0,y+1)),S=()=>{let T;return _?T=w:b?T=j:f.route.Component?T=C.createElement(f.route.Component,null):f.route.element?T=f.route.element:T=p,C.createElement(cvt,{match:f,routeContext:{outlet:p,matches:N,isDataRoute:r!=null},children:T})};return r&&(f.route.ErrorBoundary||f.route.errorElement||y===0)?C.createElement(lvt,{location:r.location,revalidation:r.revalidation,component:w,error:_,children:S(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):S()},null)}var Iqe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(Iqe||{}),Lqe=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}(Lqe||{});function uvt(t){let s=C.useContext(jwe);return s||Ed(!1),s}function hvt(t){let s=C.useContext(J0t);return s||Ed(!1),s}function mvt(t){let s=C.useContext(T0);return s||Ed(!1),s}function Dqe(t){let s=mvt(),r=s.matches[s.matches.length-1];return r.route.id||Ed(!1),r.route.id}function pvt(){var t;let s=C.useContext(Aqe),r=hvt(),n=Dqe();return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function fvt(){let{router:t}=uvt(Iqe.UseNavigateStable),s=Dqe(Lqe.UseNavigateStable),r=C.useRef(!1);return Eqe(()=>{r.current=!0}),C.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,S8({fromRouteId:s},o)))},[t,s])}const EAe={};function gvt(t,s,r){EAe[t]||(EAe[t]=!0)}function xvt(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Wfe(t){let{to:s,replace:r,state:n,relative:a}=t;SA()||Ed(!1);let{future:o,static:l}=C.useContext(y2),{matches:i}=C.useContext(T0),{pathname:c}=Qu(),u=Pr(),p=wwe(s,bwe(i,o.v7_relativeSplatPath),c,a==="path"),f=JSON.stringify(p);return C.useEffect(()=>u(JSON.parse(f),{replace:r,state:n,relative:a}),[u,f,a,r,n]),null}function yvt(t){return rvt(t.context)}function Us(t){Ed(!1)}function vvt(t){let{basename:s="/",children:r=null,location:n,navigationType:a=mb.Pop,navigator:o,static:l=!1,future:i}=t;SA()&&Ed(!1);let c=s.replace(/^\/*/,"/"),u=C.useMemo(()=>({basename:c,navigator:o,static:l,future:S8({v7_relativeSplatPath:!1},i)}),[c,i,o,l]);typeof n=="string"&&(n=NA(n));let{pathname:p="/",search:f="",hash:y="",state:_=null,key:b="default"}=n,w=C.useMemo(()=>{let j=_we(p,c);return j==null?null:{location:{pathname:j,search:f,hash:y,state:_,key:b},navigationType:a}},[c,p,f,y,_,b,a]);return w==null?null:C.createElement(y2.Provider,{value:u},C.createElement(_de.Provider,{children:r,value:w}))}function Oqe(t){let{children:s,location:r}=t;return nvt(U0e(s),r)}new Promise(()=>{});function U0e(t,s){s===void 0&&(s=[]);let r=[];return C.Children.forEach(t,(n,a)=>{if(!C.isValidElement(n))return;let o=[...s,a];if(n.type===C.Fragment){r.push.apply(r,U0e(n.props.children,o));return}n.type!==Us&&Ed(!1),!n.props.index||!n.props.children||Ed(!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=U0e(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 V0e(){return V0e=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function bvt(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function wvt(t,s){return t.button===0&&(!s||s==="_self")&&!bvt(t)}function H0e(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 jvt(t,s){let r=H0e(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const kvt=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Nvt="6";try{window.__reactRouterVersion=Nvt}catch{}const Svt="startTransition",PAe=o2e[Svt];function Cvt(t){let{basename:s,children:r,future:n,window:a}=t,o=C.useRef();o.current==null&&(o.current=C0t({window:a,v5Compat:!0}));let l=o.current,[i,c]=C.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},p=C.useCallback(f=>{u&&PAe?PAe(()=>c(f)):c(f)},[c,u]);return C.useLayoutEffect(()=>l.listen(p),[l,p]),C.useEffect(()=>xvt(n),[n]),C.createElement(vvt,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const Mvt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Tvt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,So=C.forwardRef(function(s,r){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:c,to:u,preventScrollReset:p,viewTransition:f}=s,y=_vt(s,kvt),{basename:_}=C.useContext(y2),b,w=!1;if(typeof u=="string"&&Tvt.test(u)&&(b=u,Mvt))try{let T=new URL(window.location.href),I=u.startsWith("//")?new URL(T.protocol+u):new URL(u),L=_we(I.pathname,_);I.origin===T.origin&&L!=null?u=L+I.search+I.hash:w=!0}catch{}let j=evt(u,{relative:a}),N=Avt(u,{replace:l,state:i,target:c,preventScrollReset:p,relative:a,viewTransition:f});function S(T){n&&n(T),T.defaultPrevented||N(T)}return C.createElement("a",V0e({},y,{href:b||j,onClick:w||o?n:S,ref:r,target:c}))});var IAe;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(IAe||(IAe={}));var LAe;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(LAe||(LAe={}));function Avt(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,c=Pr(),u=Qu(),p=Pqe(t,{relative:l});return C.useCallback(f=>{if(wvt(f,r)){f.preventDefault();let y=n!==void 0?n:ioe(u)===ioe(p);c(t,{replace:y,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[u,c,p,n,a,r,t,o,l,i])}function Xc(t){let s=C.useRef(H0e(t)),r=C.useRef(!1),n=Qu(),a=C.useMemo(()=>jvt(n.search,r.current?null:s.current),[n.search]),o=Pr(),l=C.useCallback((i,c)=>{const u=H0e(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,c)},[o,a]);return[a,l]}var Evt=typeof Element<"u",Pvt=typeof Map=="function",Ivt=typeof Set=="function",Lvt=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function eie(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(!eie(t[n],s[n]))return!1;return!0}var o;if(Pvt&&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(!eie(n.value[1],s.get(n.value[0])))return!1;return!0}if(Ivt&&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(Lvt&&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(Evt&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!eie(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var Dvt=function(s,r){try{return eie(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 Ovt=Co(Dvt);var Rvt=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}},Fvt=Rvt;const DAe=Co(Fvt);var zvt=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))(Rqe||{}),Gfe={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"]}},OAe=Object.values(Rqe),kwe={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$vt=Object.entries(kwe).reduce((t,[s,r])=>(t[r]=s,t),{}),zx="data-rh",MM={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},TM=(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},qvt=t=>{let s=TM(t,"title");const r=TM(t,MM.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=TM(t,MM.DEFAULT_TITLE);return s||n||void 0},Uvt=t=>TM(t,MM.ON_CHANGE_CLIENT_STATE)||(()=>{}),Kfe=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),Vvt=(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),b6=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&Hvt(`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 y=0;ya.push(c));const i=Object.keys(l);for(let c=0;c{if(Array.isArray(t)&&t.length){for(let r=0;r({baseTag:Vvt(["href"],t),bodyAttributes:Kfe("bodyAttributes",t),defer:TM(t,MM.DEFER),encode:TM(t,MM.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:Kfe("htmlAttributes",t),linkTags:b6("link",["rel","href"],t),metaTags:b6("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:b6("noscript",["innerHTML"],t),onChangeClientState:Uvt(t),scriptTags:b6("script",["src","innerHTML"],t),styleTags:b6("style",["cssText"],t),title:qvt(t),titleAttributes:Kfe("titleAttributes",t),prioritizeSeoTags:Wvt(t,MM.PRIORITIZE_SEO_TAGS)}),Fqe=t=>Array.isArray(t)?t.join(""):t,Kvt=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(Kvt(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},RAe=(t,s)=>({...t,[s]:void 0}),Zvt=["noscript","script","style"],W0e=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),zqe=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),Yvt=(t,s,r,n)=>{const a=zqe(r),o=Fqe(s);return a?`<${t} ${zx}="true" ${a}>${W0e(o,n)}`:`<${t} ${zx}="true">${W0e(o,n)}`},Xvt=(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}="${W0e(o[p],r)}"`;return u?`${u} ${f}`:f},""),i=o.innerHTML||o.cssText||"",c=Zvt.indexOf(t)===-1;return`${n}<${t} ${zx}="true" ${l}${c?"/>":`>${i}`}`},""),Bqe=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=kwe[n];return r[a||n]=t[n],r},s),Qvt=(t,s,r)=>{const n={key:s,[zx]:!0},a=Bqe(r,n);return[ht.createElement("title",a,s)]},tie=(t,s)=>s.map((r,n)=>{const a={key:n,[zx]:!0};return Object.keys(r).forEach(o=>{const i=kwe[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)}),Xf=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>Qvt(t,s.title,s.titleAttributes),toString:()=>Yvt(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Bqe(s),toString:()=>zqe(s)};default:return{toComponent:()=>tie(t,s),toString:()=>Xvt(t,s,r)}}},Jvt=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=Zfe(t,Gfe.meta),o=Zfe(s,Gfe.link),l=Zfe(r,Gfe.script);return{priorityMethods:{toComponent:()=>[...tie("meta",a.priority),...tie("link",o.priority),...tie("script",l.priority)],toString:()=>`${Xf("meta",a.priority,n)} ${Xf("link",o.priority,n)} ${Xf("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},e1t=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:y}=t,_={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:_,linkTags:p,metaTags:f,scriptTags:y}=Jvt(t)),{priority:_,base:Xf("base",s,n),bodyAttributes:Xf("bodyAttributes",r,n),htmlAttributes:Xf("htmlAttributes",a,n),link:Xf("link",p,n),meta:Xf("meta",f,n),noscript:Xf("noscript",o,n),script:Xf("script",y,n),style:Xf("style",l,n),title:Xf("title",{title:i,titleAttributes:c},n)}},G0e=e1t,y7=[],$qe=!!(typeof window<"u"&&window.document&&window.document.createElement),K0e=class{constructor(t,s){bn(this,"instances",[]);bn(this,"canUseDOM",$qe);bn(this,"context");bn(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?y7:this.instances,add:t=>{(this.canUseDOM?y7:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?y7:this.instances).indexOf(t);(this.canUseDOM?y7:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=G0e({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},t1t={},qqe=ht.createContext(t1t),L4,Uqe=(L4=class extends C.Component{constructor(r){super(r);bn(this,"helmetData");this.helmetData=new K0e(this.props.context||{},L4.canUseDOM)}render(){return ht.createElement(qqe.Provider,{value:this.helmetData.value},this.props.children)}},bn(L4,"canUseDOM",$qe),L4),q3=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${zx}]`),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(zx,"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}},Z0e=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(zx),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(zx):r.getAttribute(zx)!==l.join(",")&&r.setAttribute(zx,l.join(","))},s1t=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=Fqe(t)),Z0e("title",s)},FAe=(t,s)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:c,scriptTags:u,styleTags:p,title:f,titleAttributes:y}=t;Z0e("body",n),Z0e("html",a),s1t(f,y);const _={baseTag:q3("base",r),linkTags:q3("link",o),metaTags:q3("meta",l),noscriptTags:q3("noscript",i),scriptTags:q3("script",u),styleTags:q3("style",p)},b={},w={};Object.keys(_).forEach(j=>{const{newTags:N,oldTags:S}=_[j];N.length&&(b[j]=N),S.length&&(w[j]=_[j].oldTags)}),s&&s(),c(t,b,w)},w6=null,r1t=t=>{w6&&cancelAnimationFrame(w6),t.defer?w6=requestAnimationFrame(()=>{FAe(t,()=>{w6=null})}):(FAe(t),w6=null)},n1t=r1t,zAe=class extends C.Component{constructor(){super(...arguments);bn(this,"rendered",!1)}shouldComponentUpdate(s){return!Bvt(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=Gvt(s.get().map(o=>{const l={...o.props};return delete l.context,l}));Uqe.canUseDOM?n1t(a):G0e&&(n=G0e(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}},kye,qh=(kye=class extends C.Component{shouldComponentUpdate(t){return!Ovt(RAe(this.props,"helmetData"),RAe(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 DAe(OAe.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 ${OAe.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),DAe(!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[$vt[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 K0e)){const a=n;n=new K0e(a.context,!0),delete r.helmetData}return n?ht.createElement(zAe,{...r,context:n.value}):ht.createElement(qqe.Consumer,null,a=>ht.createElement(zAe,{...r,context:a}))}},bn(kye,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),kye),Y0e=function(t,s){return Y0e=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])},Y0e(t,s)};function Vqe(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");Y0e(t,s);function r(){this.constructor=t}t.prototype=s===null?Object.create(s):(r.prototype=s.prototype,new r)}var og=function(){return og=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 Wqe(t,s){return function(r,n){s(r,n,t)}}function Gqe(t,s,r,n,a,o){function l(N){if(N!==void 0&&typeof N!="function")throw new TypeError("Function expected");return N}for(var i=n.kind,c=i==="getter"?"get":i==="setter"?"set":"value",u=!s&&t?n.static?t:t.prototype:null,p=s||(u?Object.getOwnPropertyDescriptor(u,n.name):{}),f,y=!1,_=r.length-1;_>=0;_--){var b={};for(var w in n)b[w]=w==="access"?{}:n[w];for(var w in n.access)b.access[w]=n.access[w];b.addInitializer=function(N){if(y)throw new TypeError("Cannot add initializers after decoration has completed");o.push(l(N||null))};var j=(0,r[_])(i==="accessor"?{get:p.get,set:p.set}:p[c],b);if(i==="accessor"){if(j===void 0)continue;if(j===null||typeof j!="object")throw new TypeError("Object expected");(f=l(j.get))&&(p.get=f),(f=l(j.set))&&(p.set=f),(f=l(j.init))&&a.unshift(f)}else(f=l(j))&&(i==="field"?a.unshift(f):p[c]=f)}u&&Object.defineProperty(u,n.name,p),y=!0}function Kqe(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 Nwe(t,s){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),a,o=[],l;try{for(;(s===void 0||s-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(i){l={error:i}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(l)throw l.error}}return o}function eUe(){for(var t=[],s=0;s1||c(_,w)})},b&&(a[_]=b(a[_])))}function c(_,b){try{u(n[_](b))}catch(w){y(o[0][3],w)}}function u(_){_.value instanceof mT?Promise.resolve(_.value.v).then(p,f):y(o[0][2],_)}function p(_){c("next",_)}function f(_){c("throw",_)}function y(_,b){_(b),o.shift(),o.length&&c(o[0][0],o[0][1])}}function rUe(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:mT(t[a](l)),done:!1}:o?o(l):l}:o}}function nUe(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 ooe=="function"?ooe(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 aUe(t,s){return Object.defineProperty?Object.defineProperty(t,"raw",{value:s}):t.raw=s,t}var a1t=Object.create?function(t,s){Object.defineProperty(t,"default",{enumerable:!0,value:s})}:function(t,s){t.default=s},X0e=function(t){return X0e=Object.getOwnPropertyNames||function(s){var r=[];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[r.length]=n);return r},X0e(t)};function iUe(t){if(t&&t.__esModule)return t;var s={};if(t!=null)for(var r=X0e(t),n=0;n{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Wh(async()=>{const{default:n}=await Promise.resolve().then(()=>WS);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class Cwe extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class BAe extends Cwe{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class $Ae extends Cwe{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class qAe extends Cwe{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var Q0e;(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"})(Q0e||(Q0e={}));class d1t{constructor(s,{headers:r={},customFetch:n,region:a=Q0e.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=c1t(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s){return ua(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 y;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",y=i):typeof i=="string"?(u["Content-Type"]="text/plain",y=i):typeof FormData<"u"&&i instanceof FormData?y=i:(u["Content-Type"]="application/json",y=JSON.stringify(i)):y=i;const _=yield this.fetch(f.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},u),this.headers),o),body:y,signal:c}).catch(N=>{throw N.name==="AbortError"?N:new BAe(N)}),b=_.headers.get("x-relay-error");if(b&&b==="true")throw new $Ae(_);if(!_.ok)throw new qAe(_);let w=((a=_.headers.get("Content-Type"))!==null&&a!==void 0?a:"text/plain").split(";")[0].trim(),j;return w==="application/json"?j=yield _.json():w==="application/octet-stream"||w==="application/pdf"?j=yield _.blob():w==="text/event-stream"?j=_:w==="multipart/form-data"?j=yield _.formData():j=yield _.text(),{data:j,error:null,response:_}}catch(o){return o instanceof Error&&o.name==="AbortError"?{data:null,error:new BAe(o)}:{data:null,error:o,response:o instanceof qAe||o instanceof $Ae?o.context:void 0}}})}}var ip={};const CA=Rze(l1t);var v7={},_7={},b7={},w7={},j7={},u1t=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},pT=u1t();const h1t=pT.fetch,pUe=pT.fetch.bind(pT),fUe=pT.Headers,m1t=pT.Request,p1t=pT.Response,WS=Object.freeze(Object.defineProperty({__proto__:null,Headers:fUe,Request:m1t,Response:p1t,default:pUe,fetch:h1t},Symbol.toStringTag,{value:"Module"})),f1t=Rze(WS);var k7={},UAe;function gUe(){if(UAe)return k7;UAe=1,Object.defineProperty(k7,"__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 k7.default=t,k7}var VAe;function xUe(){if(VAe)return j7;VAe=1,Object.defineProperty(j7,"__esModule",{value:!0});const t=CA,s=t.__importDefault(f1t),r=t.__importDefault(gUe());class n{constructor(o){var l,i;this.shouldThrowOnError=!1,this.method=o.method,this.url=o.url,this.headers=new Headers(o.headers),this.schema=o.schema,this.body=o.body,this.shouldThrowOnError=(l=o.shouldThrowOnError)!==null&&l!==void 0?l:!1,this.signal=o.signal,this.isMaybeSingle=(i=o.isMaybeSingle)!==null&&i!==void 0?i:!1,o.fetch?this.fetch=o.fetch:typeof fetch>"u"?this.fetch=s.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(o,l){return this.headers=new Headers(this.headers),this.headers.set(o,l),this}then(o,l){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const i=this.fetch;let c=i(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var p,f,y,_;let b=null,w=null,j=null,N=u.status,S=u.statusText;if(u.ok){if(this.method!=="HEAD"){const R=await u.text();R===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((p=this.headers.get("Accept"))===null||p===void 0)&&p.includes("application/vnd.pgrst.plan+text"))?w=R:w=JSON.parse(R))}const I=(f=this.headers.get("Prefer"))===null||f===void 0?void 0:f.match(/count=(exact|planned|estimated)/),L=(y=u.headers.get("content-range"))===null||y===void 0?void 0:y.split("/");I&&L&&L.length>1&&(j=parseInt(L[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(w)&&(w.length>1?(b={code:"PGRST116",details:`Results contain ${w.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},w=null,j=null,N=406,S="Not Acceptable"):w.length===1?w=w[0]:w=null)}else{const I=await u.text();try{b=JSON.parse(I),Array.isArray(b)&&u.status===404&&(w=[],b=null,N=200,S="OK")}catch{u.status===404&&I===""?(N=204,S="No Content"):b={message:I}}if(b&&this.isMaybeSingle&&(!((_=b==null?void 0:b.details)===null||_===void 0)&&_.includes("0 rows"))&&(b=null,N=200,S="OK"),b&&this.shouldThrowOnError)throw new r.default(b)}return{error:b,data:w,count:j,status:N,statusText:S}});return this.shouldThrowOnError||(c=c.catch(u=>{var p,f,y;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:`${(y=u==null?void 0:u.code)!==null&&y!==void 0?y:""}`},data:null,count:null,status:0,statusText:""}})),c.then(o,l)}returns(){return this}overrideTypes(){return this}}return j7.default=n,j7}var HAe;function yUe(){if(HAe)return w7;HAe=1,Object.defineProperty(w7,"__esModule",{value:!0});const s=CA.__importDefault(xUe());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("|"),y=(p=this.headers.get("Accept"))!==null&&p!==void 0?p:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${u}; for="${y}"; 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 w7.default=r,w7}var WAe;function Mwe(){if(WAe)return b7;WAe=1,Object.defineProperty(b7,"__esModule",{value:!0});const s=CA.__importDefault(yUe()),r=new RegExp("[,()]");class n extends s.default{eq(o,l){return this.url.searchParams.append(o,`eq.${l}`),this}neq(o,l){return this.url.searchParams.append(o,`neq.${l}`),this}gt(o,l){return this.url.searchParams.append(o,`gt.${l}`),this}gte(o,l){return this.url.searchParams.append(o,`gte.${l}`),this}lt(o,l){return this.url.searchParams.append(o,`lt.${l}`),this}lte(o,l){return this.url.searchParams.append(o,`lte.${l}`),this}like(o,l){return this.url.searchParams.append(o,`like.${l}`),this}likeAllOf(o,l){return this.url.searchParams.append(o,`like(all).{${l.join(",")}}`),this}likeAnyOf(o,l){return this.url.searchParams.append(o,`like(any).{${l.join(",")}}`),this}ilike(o,l){return this.url.searchParams.append(o,`ilike.${l}`),this}ilikeAllOf(o,l){return this.url.searchParams.append(o,`ilike(all).{${l.join(",")}}`),this}ilikeAnyOf(o,l){return this.url.searchParams.append(o,`ilike(any).{${l.join(",")}}`),this}is(o,l){return this.url.searchParams.append(o,`is.${l}`),this}in(o,l){const i=Array.from(new Set(l)).map(c=>typeof c=="string"&&r.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(o,`in.(${i})`),this}contains(o,l){return typeof l=="string"?this.url.searchParams.append(o,`cs.${l}`):Array.isArray(l)?this.url.searchParams.append(o,`cs.{${l.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(l)}`),this}containedBy(o,l){return typeof l=="string"?this.url.searchParams.append(o,`cd.${l}`):Array.isArray(l)?this.url.searchParams.append(o,`cd.{${l.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(l)}`),this}rangeGt(o,l){return this.url.searchParams.append(o,`sr.${l}`),this}rangeGte(o,l){return this.url.searchParams.append(o,`nxl.${l}`),this}rangeLt(o,l){return this.url.searchParams.append(o,`sl.${l}`),this}rangeLte(o,l){return this.url.searchParams.append(o,`nxr.${l}`),this}rangeAdjacent(o,l){return this.url.searchParams.append(o,`adj.${l}`),this}overlaps(o,l){return typeof l=="string"?this.url.searchParams.append(o,`ov.${l}`):this.url.searchParams.append(o,`ov.{${l.join(",")}}`),this}textSearch(o,l,{config:i,type:c}={}){let u="";c==="plain"?u="pl":c==="phrase"?u="ph":c==="websearch"&&(u="w");const p=i===void 0?"":`(${i})`;return this.url.searchParams.append(o,`${u}fts${p}.${l}`),this}match(o){return Object.entries(o).forEach(([l,i])=>{this.url.searchParams.append(l,`eq.${i}`)}),this}not(o,l,i){return this.url.searchParams.append(o,`not.${l}.${i}`),this}or(o,{foreignTable:l,referencedTable:i=l}={}){const c=i?`${i}.or`:"or";return this.url.searchParams.append(c,`(${o})`),this}filter(o,l,i){return this.url.searchParams.append(o,`${l}.${i}`),this}}return b7.default=n,b7}var GAe;function vUe(){if(GAe)return _7;GAe=1,Object.defineProperty(_7,"__esModule",{value:!0});const s=CA.__importDefault(Mwe());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((y,_)=>y.concat(Object.keys(_)),[]);if(f.length>0){const y=[...new Set(f)].map(_=>`"${_}"`);this.url.searchParams.set("columns",y.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 KAe;function g1t(){if(KAe)return v7;KAe=1,Object.defineProperty(v7,"__esModule",{value:!0});const t=CA,s=t.__importDefault(vUe()),r=t.__importDefault(Mwe());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 y=new URL(`${this.url}/rpc/${o}`);let _;i||c?(f=i?"HEAD":"GET",Object.entries(l).filter(([w,j])=>j!==void 0).map(([w,j])=>[w,Array.isArray(j)?`{${j.join(",")}}`:`${j}`]).forEach(([w,j])=>{y.searchParams.append(w,j)})):(f="POST",_=l);const b=new Headers(this.headers);return u&&b.set("Prefer",`count=${u}`),new r.default({method:f,url:y,headers:b,schema:this.schemaName,body:_,fetch:(p=this.fetch)!==null&&p!==void 0?p:fetch})}}return v7.default=n,v7}Object.defineProperty(ip,"__esModule",{value:!0});var _Ue=ip.PostgrestError=AUe=ip.PostgrestBuilder=MUe=ip.PostgrestTransformBuilder=SUe=ip.PostgrestFilterBuilder=kUe=ip.PostgrestQueryBuilder=wUe=ip.PostgrestClient=void 0;const MA=CA,bUe=MA.__importDefault(g1t());var wUe=ip.PostgrestClient=bUe.default;const jUe=MA.__importDefault(vUe());var kUe=ip.PostgrestQueryBuilder=jUe.default;const NUe=MA.__importDefault(Mwe());var SUe=ip.PostgrestFilterBuilder=NUe.default;const CUe=MA.__importDefault(yUe());var MUe=ip.PostgrestTransformBuilder=CUe.default;const TUe=MA.__importDefault(xUe());var AUe=ip.PostgrestBuilder=TUe.default;const EUe=MA.__importDefault(gUe());_Ue=ip.PostgrestError=EUe.default;var PUe=ip.default={PostgrestClient:bUe.default,PostgrestQueryBuilder:jUe.default,PostgrestFilterBuilder:NUe.default,PostgrestTransformBuilder:CUe.default,PostgrestBuilder:TUe.default,PostgrestError:EUe.default};const x1t=Object.freeze(Object.defineProperty({__proto__:null,get PostgrestBuilder(){return AUe},get PostgrestClient(){return wUe},get PostgrestError(){return _Ue},get PostgrestFilterBuilder(){return SUe},get PostgrestQueryBuilder(){return kUe},get PostgrestTransformBuilder(){return MUe},default:PUe},Symbol.toStringTag,{value:"Module"})),{PostgrestClient:y1t,PostgrestQueryBuilder:h3s,PostgrestFilterBuilder:m3s,PostgrestTransformBuilder:p3s,PostgrestBuilder:f3s,PostgrestError:g3s}=PUe||x1t;class v1t{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 _1t="2.78.0",b1t=`realtime-js/${_1t}`,w1t="1.0.0",J0e=1e4,j1t=1e3,k1t=100;var _L;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(_L||(_L={}));var au;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(au||(au={}));var Tx;(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"})(Tx||(Tx={}));var eve;(function(t){t.websocket="websocket"})(eve||(eve={}));var e4;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(e4||(e4={}));class N1t{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 IUe{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 Fl;(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"})(Fl||(Fl={}));const ZAe=(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]=S1t(l,t,s,a),o),{}):{}},S1t=(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)?LUe(o,l):tve(l)},LUe=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return A1t(s,r)}switch(t){case Fl.bool:return C1t(s);case Fl.float4:case Fl.float8:case Fl.int2:case Fl.int4:case Fl.int8:case Fl.numeric:case Fl.oid:return M1t(s);case Fl.json:case Fl.jsonb:return T1t(s);case Fl.timestamp:return E1t(s);case Fl.abstime:case Fl.date:case Fl.daterange:case Fl.int4range:case Fl.int8range:case Fl.money:case Fl.reltime:case Fl.text:case Fl.time:case Fl.timestamptz:case Fl.timetz:case Fl.tsrange:case Fl.tstzrange:return tve(s);default:return tve(s)}},tve=t=>t,C1t=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},M1t=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},T1t=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},A1t=(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=>LUe(s,i))}return t},E1t=t=>typeof t=="string"?t.replace(" ","T"):t,DUe=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 Yfe{constructor(s,r,n={},a=J0e){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 YAe;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(YAe||(YAe={}));class bL{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=bL.syncState(this.state,a,o,l),this.pendingDiffs.forEach(c=>{this.state=bL.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=bL.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 y=p.map(j=>j.presence_ref),_=f.map(j=>j.presence_ref),b=p.filter(j=>_.indexOf(j.presence_ref)<0),w=f.filter(j=>y.indexOf(j.presence_ref)<0);b.length>0&&(i[u]=b),w.length>0&&(c[u]=w)}else i[u]=p}),this.syncDiff(o,{joins:i,leaves:c},n,a)}static syncDiff(s,r,n,a){const{joins:o,leaves:l}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return n||(n=()=>{}),a||(a=()=>{}),this.map(o,(i,c)=>{var u;const p=(u=s[i])!==null&&u!==void 0?u:[];if(s[i]=this.cloneDeep(c),p.length>0){const f=s[i].map(_=>_.presence_ref),y=p.filter(_=>f.indexOf(_.presence_ref)<0);s[i].unshift(...y)}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 XAe;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(XAe||(XAe={}));var wL;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(wL||(wL={}));var kv;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(kv||(kv={}));class Twe{constructor(s,r={config:{}},n){var a,o;if(this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=au.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 Yfe(this,Tx.join,this.params,this.timeout),this.rejoinTimer=new IUe(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=au.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=au.closed,this.socket._remove(this)}),this._onError(l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=au.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=au.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=au.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Tx.reply,{},(l,i)=>{this._trigger(this._replyEventName(i),l)}),this.presence=new bL(this),this.broadcastEndpointURL=DUe(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==au.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(_=>_.filter))!==null&&a!==void 0?a:[],p=!!this.bindings[wL.PRESENCE]&&this.bindings[wL.PRESENCE].length>0||((o=this.params.config.presence)===null||o===void 0?void 0:o.enabled)===!0,f={},y={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(_=>s==null?void 0:s(kv.CHANNEL_ERROR,_)),this._onClose(()=>s==null?void 0:s(kv.CLOSED)),this.updateJoinPayload(Object.assign({config:y},f)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:_})=>{var b;if(this.socket.setAuth(),_===void 0){s==null||s(kv.SUBSCRIBED);return}else{const w=this.bindings.postgres_changes,j=(b=w==null?void 0:w.length)!==null&&b!==void 0?b:0,N=[];for(let S=0;S{this.state=au.errored,s==null||s(kv.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(_).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(kv.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===au.joined&&s===wL.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=au.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Tx.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(a=>{n=new Yfe(this,Tx.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=au.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 Yfe(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>k1t){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}=Tx;if(n&&[i,c,u,p].indexOf(l)>=0&&n!==this._joinRef())return;let y=this._onMessage(l,r,n);if(r&&!y)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(l)?(a=this.bindings.postgres_changes)===null||a===void 0||a.filter(_=>{var b,w,j;return((b=_.filter)===null||b===void 0?void 0:b.event)==="*"||((j=(w=_.filter)===null||w===void 0?void 0:w.event)===null||j===void 0?void 0:j.toLocaleLowerCase())===l}).map(_=>_.callback(y,n)):(o=this.bindings[l])===null||o===void 0||o.filter(_=>{var b,w,j,N,S,T;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in _){const I=_.id,L=(b=_.filter)===null||b===void 0?void 0:b.event;return I&&((w=r.ids)===null||w===void 0?void 0:w.includes(I))&&(L==="*"||(L==null?void 0:L.toLocaleLowerCase())===((j=r.data)===null||j===void 0?void 0:j.type.toLocaleLowerCase()))}else{const I=(S=(N=_==null?void 0:_.filter)===null||N===void 0?void 0:N.event)===null||S===void 0?void 0:S.toLocaleLowerCase();return I==="*"||I===((T=r==null?void 0:r.event)===null||T===void 0?void 0:T.toLocaleLowerCase())}else return _.type.toLocaleLowerCase()===l}).map(_=>{if(typeof y=="object"&&"ids"in y){const b=y.data,{schema:w,table:j,commit_timestamp:N,type:S,errors:T}=b;y=Object.assign(Object.assign({},{schema:w,table:j,commit_timestamp:N,eventType:S,new:{},old:{},errors:T}),this._getPayloadRecords(b))}_.callback(y,n)})}_isClosed(){return this.state===au.closed}_isJoined(){return this.state===au.joined}_isJoining(){return this.state===au.joining}_isLeaving(){return this.state===au.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&&Twe.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(Tx.close,{},s)}_onError(s){this._on(Tx.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=au.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=ZAe(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=ZAe(s.columns,s.old_record)),r}}const Xfe=()=>{},N7={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},P1t=[1e3,2e3,5e3,1e4],I1t=1e4,L1t=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class D1t{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=J0e,this.transport=null,this.heartbeatIntervalMs=N7.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=Xfe,this.ref=0,this.reconnectTimer=null,this.logger=Xfe,this.conn=null,this.sendBuffer=[],this.serializer=new N1t,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)=>Wh(async()=>{const{default:i}=await Promise.resolve().then(()=>WS);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}/${eve.websocket}`,this.httpEndpoint=DUe(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=v1t.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:w1t}))}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 _L.connecting:return e4.Connecting;case _L.open:return e4.Open;case _L.closing:return e4.Closing;default:return e4.Closed}}isConnected(){return this.connectionState()===e4.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 Twe(`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(j1t,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},N7.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(Tx.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([L1t],{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:b1t};r&&n.updateJoinPayload(a),n.joinedOnce&&n._isJoined()&&n._push(Tx.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 IUe(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},N7.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:J0e,this.heartbeatIntervalMs=(a=s==null?void 0:s.heartbeatIntervalMs)!==null&&a!==void 0?a:N7.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:Xfe,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=>P1t[f-1]||I1t,this.encode=(u=s==null?void 0:s.encode)!==null&&u!==void 0?u:(f,y)=>y(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 Awe extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function Fc(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class O1t extends Awe{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 sve extends Awe{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}const Ewe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Wh(async()=>{const{default:n}=await Promise.resolve().then(()=>WS);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},R1t=()=>ua(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Wh(()=>Promise.resolve().then(()=>WS),void 0)).Response:Response}),rve=t=>{if(Array.isArray(t))return t.map(r=>rve(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]=rve(n)}),s},F1t=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)},Qfe=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)},z1t=(t,s,r)=>ua(void 0,void 0,void 0,function*(){const n=yield R1t();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 O1t(Qfe(a),o,l))}).catch(a=>{s(new sve(Qfe(a),a))}):s(new sve(Qfe(t),t))}),B1t=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"||!n?a:(F1t(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 nO(t,s,r,n,a,o){return ua(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,B1t(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=>z1t(c,i,n))})})}function C8(t,s,r,n){return ua(this,void 0,void 0,function*(){return nO(t,"GET",s,r,n)})}function Nx(t,s,r,n,a){return ua(this,void 0,void 0,function*(){return nO(t,"POST",s,n,a,r)})}function nve(t,s,r,n,a){return ua(this,void 0,void 0,function*(){return nO(t,"PUT",s,n,a,r)})}function $1t(t,s,r,n){return ua(this,void 0,void 0,function*(){return nO(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function Pwe(t,s,r,n,a){return ua(this,void 0,void 0,function*(){return nO(t,"DELETE",s,n,a,r)})}class q1t{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r}then(s,r){return this.execute().then(s,r)}execute(){return ua(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Fc(s))return{data:null,error:s};throw s}})}}var OUe;class U1t{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r,this[OUe]="BlobDownloadBuilder",this.promise=null}asStream(){return new q1t(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 ua(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Fc(s))return{data:null,error:s};throw s}})}}OUe=Symbol.toStringTag;const V1t={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},QAe={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class H1t{constructor(s,r={},n,a){this.shouldThrowOnError=!1,this.url=s,this.headers=r,this.bucketId=n,this.fetch=Ewe(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(s,r,n,a){return ua(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},QAe),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"?nve:Nx)(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(Fc(o))return{data:null,error:o};throw o}})}upload(s,r,n){return ua(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return ua(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:QAe.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 nve(this.fetch,i.toString(),c,{headers:p});return{data:{path:o,fullPath:f.Key},error:null}}catch(c){if(this.shouldThrowOnError)throw c;if(Fc(c))return{data:null,error:c};throw c}})}createSignedUploadUrl(s,r){return ua(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 Nx(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 Awe("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Fc(n))return{data:null,error:n};throw n}})}update(s,r,n){return ua(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return ua(this,void 0,void 0,function*(){try{return{data:yield Nx(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(Fc(a))return{data:null,error:a};throw a}})}copy(s,r,n){return ua(this,void 0,void 0,function*(){try{return{data:{path:(yield Nx(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(Fc(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return ua(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield Nx(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(Fc(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return ua(this,void 0,void 0,function*(){try{const a=yield Nx(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(Fc(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=()=>C8(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0});return new U1t(c,this.shouldThrowOnError)}info(s){return ua(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield C8(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:rve(n),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Fc(n))return{data:null,error:n};throw n}})}exists(s){return ua(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield $1t(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Fc(n)&&n instanceof sve){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 ua(this,void 0,void 0,function*(){try{return{data:yield Pwe(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fc(r))return{data:null,error:r};throw r}})}list(s,r,n){return ua(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},V1t),r),{prefix:s||""});return{data:yield Nx(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Fc(a))return{data:null,error:a};throw a}})}listV2(s,r){return ua(this,void 0,void 0,function*(){try{const n=Object.assign({},s);return{data:yield Nx(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Fc(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 RUe="2.78.0",FUe={"X-Client-Info":`storage-js/${RUe}`};class W1t{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({},FUe),r),this.fetch=Ewe(n)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(s){return ua(this,void 0,void 0,function*(){try{const r=this.listBucketOptionsToQueryString(s);return{data:yield C8(this.fetch,`${this.url}/bucket${r}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fc(r))return{data:null,error:r};throw r}})}getBucket(s){return ua(this,void 0,void 0,function*(){try{return{data:yield C8(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fc(r))return{data:null,error:r};throw r}})}createBucket(s){return ua(this,arguments,void 0,function*(r,n={public:!1}){try{return{data:yield Nx(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(Fc(a))return{data:null,error:a};throw a}})}updateBucket(s,r){return ua(this,void 0,void 0,function*(){try{return{data:yield nve(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(Fc(n))return{data:null,error:n};throw n}})}emptyBucket(s){return ua(this,void 0,void 0,function*(){try{return{data:yield Nx(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ua(this,void 0,void 0,function*(){try{return{data:yield Pwe(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fc(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 G1t{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},FUe),r),this.fetch=Ewe(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return ua(this,void 0,void 0,function*(){try{return{data:yield Nx(this.fetch,`${this.url}/bucket`,{name:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fc(r))return{data:null,error:r};throw r}})}listBuckets(s){return ua(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 C8(this.fetch,a,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ua(this,void 0,void 0,function*(){try{return{data:yield Pwe(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Fc(r))return{data:null,error:r};throw r}})}}const Iwe={"X-Client-Info":`storage-js/${RUe}`,"Content-Type":"application/json"};class zUe extends Error{constructor(s){super(s),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function Jp(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}class Jfe extends zUe{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 K1t extends zUe{constructor(s,r){super(s),this.name="StorageVectorsUnknownError",this.originalError=r}}var JAe;(function(t){t.InternalError="InternalError",t.S3VectorConflictException="S3VectorConflictException",t.S3VectorNotFoundException="S3VectorNotFoundException",t.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",t.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",t.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(JAe||(JAe={}));const Lwe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Wh(async()=>{const{default:n}=await Promise.resolve().then(()=>WS);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Z1t=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)},eEe=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Y1t=(t,s,r)=>ua(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 Jfe(eEe(l),a,i))}).catch(()=>{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new Jfe(i,a,l))});else{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new Jfe(i,a,l))}}else s(new K1t(eEe(t),t))}),X1t=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return n?(Z1t(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 Q1t(t,s,r,n,a,o){return ua(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,X1t(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=>Y1t(c,i,n))})})}function ef(t,s,r,n,a){return ua(this,void 0,void 0,function*(){return Q1t(t,"POST",s,n,a,r)})}class J1t{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Iwe),r),this.fetch=Lwe(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(s){return ua(this,void 0,void 0,function*(){try{return{data:(yield ef(this.fetch,`${this.url}/CreateIndex`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Jp(r))return{data:null,error:r};throw r}})}getIndex(s,r){return ua(this,void 0,void 0,function*(){try{return{data:yield ef(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Jp(n))return{data:null,error:n};throw n}})}listIndexes(s){return ua(this,void 0,void 0,function*(){try{return{data:yield ef(this.fetch,`${this.url}/ListIndexes`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Jp(r))return{data:null,error:r};throw r}})}deleteIndex(s,r){return ua(this,void 0,void 0,function*(){try{return{data:(yield ef(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Jp(n))return{data:null,error:n};throw n}})}}class e_t{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Iwe),r),this.fetch=Lwe(n)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(s){return ua(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 ef(this.fetch,`${this.url}/PutVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Jp(r))return{data:null,error:r};throw r}})}getVectors(s){return ua(this,void 0,void 0,function*(){try{return{data:yield ef(this.fetch,`${this.url}/GetVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Jp(r))return{data:null,error:r};throw r}})}listVectors(s){return ua(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 ef(this.fetch,`${this.url}/ListVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Jp(r))return{data:null,error:r};throw r}})}queryVectors(s){return ua(this,void 0,void 0,function*(){try{return{data:yield ef(this.fetch,`${this.url}/QueryVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Jp(r))return{data:null,error:r};throw r}})}deleteVectors(s){return ua(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 ef(this.fetch,`${this.url}/DeleteVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Jp(r))return{data:null,error:r};throw r}})}}class t_t{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},Iwe),r),this.fetch=Lwe(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return ua(this,void 0,void 0,function*(){try{return{data:(yield ef(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Jp(r))return{data:null,error:r};throw r}})}getBucket(s){return ua(this,void 0,void 0,function*(){try{return{data:yield ef(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Jp(r))return{data:null,error:r};throw r}})}listBuckets(){return ua(this,arguments,void 0,function*(s={}){try{return{data:yield ef(this.fetch,`${this.url}/ListVectorBuckets`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Jp(r))return{data:null,error:r};throw r}})}deleteBucket(s){return ua(this,void 0,void 0,function*(){try{return{data:(yield ef(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Jp(r))return{data:null,error:r};throw r}})}}class s_t extends t_t{constructor(s,r={}){super(s,r.headers||{},r.fetch)}from(s){return new r_t(this.url,this.headers,s,this.fetch)}}class r_t extends J1t{constructor(s,r,n,a){super(s,r,a),this.vectorBucketName=n}createIndex(s){const r=Object.create(null,{createIndex:{get:()=>super.createIndex}});return ua(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 ua(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 ua(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 ua(this,void 0,void 0,function*(){return r.deleteIndex.call(this,this.vectorBucketName,s)})}index(s){return new n_t(this.url,this.headers,this.vectorBucketName,s,this.fetch)}}class n_t extends e_t{constructor(s,r,n,a,o){super(s,r,o),this.vectorBucketName=n,this.indexName=a}putVectors(s){const r=Object.create(null,{putVectors:{get:()=>super.putVectors}});return ua(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 ua(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 ua(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 ua(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 ua(this,void 0,void 0,function*(){return r.deleteVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class a_t extends W1t{constructor(s,r={},n,a){super(s,r,n,a)}from(s){return new H1t(this.url,this.headers,s,this.fetch)}get vectors(){return new s_t(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new G1t(this.url+"/iceberg",this.headers,this.fetch)}}const i_t="2.78.0";let eI="";typeof Deno<"u"?eI="deno":typeof document<"u"?eI="web":typeof navigator<"u"&&navigator.product==="ReactNative"?eI="react-native":eI="node";const o_t={"X-Client-Info":`supabase-js-${eI}/${i_t}`},l_t={headers:o_t},c_t={schema:"public"},d_t={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},u_t={},h_t=t=>{let s;return t?s=t:typeof fetch>"u"?s=pUe:s=fetch,(...r)=>s(...r)},m_t=()=>typeof Headers>"u"?fUe:Headers,p_t=(t,s,r)=>{const n=h_t(r),a=m_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 f_t(t){return t.endsWith("/")?t:t+"/"}function g_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,y={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?y.accessToken=t.accessToken:delete y.accessToken,y}function x_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(f_t(s))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const BUe="2.78.0",p5=30*1e3,ave=3,ege=ave*p5,y_t="http://localhost:9999",v_t="supabase.auth.token",__t={"X-Client-Info":`gotrue-js/${BUe}`},ive="X-Supabase-Api-Version",$Ue={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},b_t=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,w_t=10*60*1e3;class M8 extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Ia(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class j_t extends M8{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function k_t(t){return Ia(t)&&t.name==="AuthApiError"}class t4 extends M8{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class _2 extends M8{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class vx extends _2{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function N_t(t){return Ia(t)&&t.name==="AuthSessionMissingError"}class U3 extends _2{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class S7 extends _2{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class C7 extends _2{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 S_t(t){return Ia(t)&&t.name==="AuthImplicitGrantRedirectError"}class tEe extends _2{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 ove extends _2{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function tge(t){return Ia(t)&&t.name==="AuthRetryableFetchError"}class sEe extends _2{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class lve extends _2{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const loe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),rEe=` \r=`.split(""),C_t=(()=>{const t=new Array(128);for(let s=0;s=6;){const n=s.queue>>s.queuedBits-6&63;r(loe[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(loe[n]),s.queuedBits-=6}}function qUe(t,s,r){const n=C_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 aEe(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{A_t(l,n,r)};for(let l=0;l>6),s(128|t&63);return}else if(t<=65535){s(224|t>>12),s(128|t>>6&63),s(128|t&63);return}else if(t<=1114111){s(240|t>>18),s(128|t>>12&63),s(128|t>>6&63),s(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function T_t(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}M_t(n,s)}}function A_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 AM(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function l4(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};return t.forEach(a=>nEe(a,r,n)),nEe(null,r,n),s.join("")}function P_t(t){return Math.round(Date.now()/1e3)+t}function I_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 dm=()=>typeof window<"u"&&typeof document<"u",Cw={tested:!1,writable:!1},UUe=()=>{if(!dm())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Cw.tested)return Cw.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Cw.tested=!0,Cw.writable=!0}catch{Cw.tested=!0,Cw.writable=!1}return Cw.writable};function L_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 VUe=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>Wh(async()=>{const{default:n}=await Promise.resolve().then(()=>WS);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},D_t=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",f5=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},Mw=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},w_=async(t,s)=>{await t.removeItem(s)};class wde{constructor(){this.promise=new wde.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}wde.promiseConstructor=Promise;function sge(t){const s=t.split(".");if(s.length!==3)throw new lve("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function R_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 F_t(t){return("0"+t.toString(16)).substr(-2)}function z_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,F_t).join("")}async function B_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 $_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 B_t(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function V3(t,s,r=!1){const n=z_t();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await f5(t,`${s}-code-verifier`,a);const o=await $_t(n);return[o,n===o?"plain":"s256"]}const q_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 U_t(t){const s=t.headers.get(ive);if(!s||!s.match(q_t))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function V_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 H_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 W_t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function H3(t){if(!W_t.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function rge(){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 G_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 KN=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),K_t=[502,503,504];async function oEe(t){var s;if(!D_t(t))throw new ove(KN(t),0);if(K_t.includes(t.status))throw new ove(KN(t),t.status);let r;try{r=await t.json()}catch(o){throw new t4(KN(o),o)}let n;const a=U_t(t);if(a&&a.getTime()>=$Ue["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new sEe(KN(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new vx}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((o,l)=>o&&typeof l=="string",!0))throw new sEe(KN(r),t.status,r.weak_password.reasons);throw new j_t(KN(r),t.status||500,n)}const Z_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 xi(t,s,r,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[ive]||(o[ive]=$Ue["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 Y_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 Y_t(t,s,r,n,a,o){const l=Z_t(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(c){throw console.error(c),new ove(KN(c),0)}if(i.ok||await oEe(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(c){await oEe(c)}}function _x(t){var s;let r=null;J_t(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=P_t(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function lEe(t){const s=_x(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 K_(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function X_t(t){return{data:t,error:null}}function Q_t(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=v2(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 cEe(t){return t}function J_t(t){return t.access_token&&t.refresh_token&&t.expires_in}const nge=["global","local","others"];class ebt{constructor({url:s="",headers:r={},fetch:n}){this.url=s,this.headers=r,this.fetch=VUe(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=nge[0]){if(nge.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${nge.join(", ")}`);try{return await xi(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:s,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Ia(n))return{data:null,error:n};throw n}}async inviteUserByEmail(s,r={}){try{return await xi(this.fetch,"POST",`${this.url}/invite`,{body:{email:s,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:K_})}catch(n){if(Ia(n))return{data:{user:null},error:n};throw n}}async generateLink(s){try{const{options:r}=s,n=v2(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 xi(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:Q_t,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(Ia(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(s){try{return await xi(this.fetch,"POST",`${this.url}/admin/users`,{body:s,headers:this.headers,xform:K_})}catch(r){if(Ia(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 xi(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:cEe});if(p.error)throw p.error;const f=await p.json(),y=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,_=(c=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&c!==void 0?c:[];return _.length>0&&(_.forEach(b=>{const w=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(b.split(";")[1].split("=")[1]);u[`${j}Page`]=w}),u.total=parseInt(y)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ia(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){H3(s);try{return await xi(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:K_})}catch(r){if(Ia(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){H3(s);try{return await xi(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:K_})}catch(n){if(Ia(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){H3(s);try{return await xi(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:K_})}catch(n){if(Ia(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){H3(s.userId);try{const{data:r,error:n}=await xi(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(Ia(r))return{data:null,error:r};throw r}}async _deleteFactor(s){H3(s.userId),H3(s.id);try{return{data:await xi(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(Ia(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 xi(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:cEe});if(p.error)throw p.error;const f=await p.json(),y=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,_=(c=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&c!==void 0?c:[];return _.length>0&&(_.forEach(b=>{const w=parseInt(b.split(";")[0].split("=")[1].substring(0,1)),j=JSON.parse(b.split(";")[1].split("=")[1]);u[`${j}Page`]=w}),u.total=parseInt(y)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Ia(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(s){try{return await xi(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ia(r))return{data:null,error:r};throw r}}async _getOAuthClient(s){try{return await xi(this.fetch,"GET",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ia(r))return{data:null,error:r};throw r}}async _updateOAuthClient(s,r){try{return await xi(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Ia(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(s){try{return await xi(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(Ia(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(s){try{return await xi(this.fetch,"POST",`${this.url}/admin/oauth/clients/${s}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Ia(r))return{data:null,error:r};throw r}}}function dEe(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}const W3={debug:!!(globalThis&&UUe()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class HUe extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class tbt extends HUe{}async function sbt(t,s,r){W3.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),W3.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){W3.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{W3.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw W3.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new tbt(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(W3.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 rbt(){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 WUe(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function nbt(t){return parseInt(t,16)}function abt(t){const s=new TextEncoder().encode(t);return"0x"+Array.from(s,n=>n.toString(16).padStart(2,"0")).join("")}function ibt(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:y}=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(y!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${y}`);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 _=WUe(t.address),b=p?`${p}://${n}`:n,w=t.statement?`${t.statement} `:"",j=`${b} wants you to sign in with your Ethereum account: ${_} ${w}`;let N=`URI: ${f} Version: ${y} Chain ID: ${r}${l?` Nonce: ${l}`:""} Issued At: ${o.toISOString()}`;if(a&&(N+=` Expiration Time: ${a.toISOString()}`),i&&(N+=` Not Before: ${i.toISOString()}`),c&&(N+=` Request ID: ${c}`),u){let S=` Resources:`;for(const T of u){if(!T||typeof T!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${T}`);S+=` - ${T}`}N+=S}return`${j} ${N}`}class qd 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 coe extends qd{constructor(s,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:s}),this.name="WebAuthnUnknownError",this.originalError=r}}function obt({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 qd({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 qd({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 qd({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 qd({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 qd({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new qd({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 qd({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new qd({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(GUe(l)){if(o.rp.id!==l)return new qd({message:`The RP ID "${o.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new qd({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 qd({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 qd({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 qd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function lbt({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 qd({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new qd({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(GUe(n)){if(r.rpId!==n)return new qd({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new qd({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new qd({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 qd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class cbt{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 dbt=new cbt;function ubt(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=v2(t,["challenge","user","excludeCredentials"]),o=AM(s).buffer,l=Object.assign(Object.assign({},r),{id:AM(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]=doe(i,l):n[o]=doe(l)}else n[o]=l}return n}function vbt(t,s){return doe(xbt,t,s||{})}function _bt(t,s){return doe(ybt,t,s||{})}class bbt{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??dbt.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=vbt(l.webauthn.credential_options.publicKey,o==null?void 0:o.create),{data:p,error:f}=await fbt({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=_bt(l.webauthn.credential_options.publicKey,o==null?void 0:o.request),{data:p,error:f}=await gbt(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 Ia(l)?{data:null,error:l}:{data:null,error:new t4("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 M8("rpId is required for WebAuthn authentication")};try{if(!uEe())return{data:null,error:new t4("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 Ia(l)?{data:null,error:l}:{data:null,error:new t4("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 M8("rpId is required for WebAuthn registration")};try{if(!uEe())return{data:null,error:new t4("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(y=>y.factor_type==="webauthn"&&y.friendly_name===s&&y.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 Ia(l)?{data:null,error:l}:{data:null,error:new t4("Unexpected error in register",l)}}}}rbt();const wbt={url:y_t,storageKey:v_t,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:__t,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function hEe(t,s,r){return await r()}const G3={};class T8{get jwks(){var s,r;return(r=(s=G3[this.storageKey])===null||s===void 0?void 0:s.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(s){G3[this.storageKey]=Object.assign(Object.assign({},G3[this.storageKey]),{jwks:s})}get jwks_cached_at(){var s,r;return(r=(s=G3[this.storageKey])===null||s===void 0?void 0:s.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(s){G3[this.storageKey]=Object.assign(Object.assign({},G3[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=T8.nextInstanceID,T8.nextInstanceID+=1,this.instanceID>0&&dm()&&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({},wbt),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 ebt({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=VUe(a.fetch),this.lock=a.lock||hEe,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:dm()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=sbt:this.lock=hEe,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 bbt(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:UUe()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=dEe(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=dEe(this.memoryStorage)),dm()&&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} (${BUe}) ${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=L_t(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),dm()&&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),S_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 Ia(r)?{error:r}:{error:new t4("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const o=await xi(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:_x}),{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(Ia(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:y}=s;let _=null,b=null;this.flowType==="pkce"&&([_,b]=await V3(this.storage,this.storageKey)),o=await xi(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:y==null?void 0:y.emailRedirectTo,body:{email:p,password:f,data:(r=y==null?void 0:y.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:y==null?void 0:y.captchaToken},code_challenge:_,code_challenge_method:b},xform:_x})}else if("phone"in s){const{phone:p,password:f,options:y}=s;o=await xi(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:p,password:f,data:(n=y==null?void 0:y.data)!==null&&n!==void 0?n:{},channel:(a=y==null?void 0:y.channel)!==null&&a!==void 0?a:"sms",gotrue_meta_security:{captcha_token:y==null?void 0:y.captchaToken}},xform:_x})}else throw new S7("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(Ia(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 xi(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:lEe})}else if("phone"in s){const{phone:o,password:l,options:i}=s;r=await xi(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:lEe})}else throw new S7("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 U3}:(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(Ia(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,y;let _,b;if("message"in s)_=s.message,b=s.signature;else{const{chain:w,wallet:j,statement:N,options:S}=s;let T;if(dm())if(typeof j=="object")T=j;else{const U=window;if("ethereum"in U&&typeof U.ethereum=="object"&&"request"in U.ethereum&&typeof U.ethereum.request=="function")T=U.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof j!="object"||!(S!=null&&S.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");T=j}const I=new URL((r=S==null?void 0:S.url)!==null&&r!==void 0?r:window.location.href),L=await T.request({method:"eth_requestAccounts"}).then(U=>U).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!L||L.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const R=WUe(L[0]);let $=(n=S==null?void 0:S.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!$){const U=await T.request({method:"eth_chainId"});$=nbt(U)}const q={domain:I.host,address:R,statement:N,uri:I.href,version:"1",chainId:$,nonce:(a=S==null?void 0:S.signInWithEthereum)===null||a===void 0?void 0:a.nonce,issuedAt:(l=(o=S==null?void 0:S.signInWithEthereum)===null||o===void 0?void 0:o.issuedAt)!==null&&l!==void 0?l:new Date,expirationTime:(i=S==null?void 0:S.signInWithEthereum)===null||i===void 0?void 0:i.expirationTime,notBefore:(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};_=ibt(q),b=await T.request({method:"personal_sign",params:[abt(_),R]})}try{const{data:w,error:j}=await xi(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:_,signature:b},!((f=s.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(y=s.options)===null||y===void 0?void 0:y.captchaToken}}:null),xform:_x});if(j)throw j;return!w||!w.session||!w.user?{data:{user:null,session:null},error:new U3}:(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),{data:Object.assign({},w),error:j})}catch(w){if(Ia(w))return{data:{user:null,session:null},error:w};throw w}}async signInWithSolana(s){var r,n,a,o,l,i,c,u,p,f,y,_;let b,w;if("message"in s)b=s.message,w=s.signature;else{const{chain:j,wallet:N,statement:S,options:T}=s;let I;if(dm())if(typeof N=="object")I=N;else{const R=window;if("solana"in R&&typeof R.solana=="object"&&("signIn"in R.solana&&typeof R.solana.signIn=="function"||"signMessage"in R.solana&&typeof R.solana.signMessage=="function"))I=R.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof N!="object"||!(T!=null&&T.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");I=N}const L=new URL((r=T==null?void 0:T.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in I&&I.signIn){const R=await I.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},T==null?void 0:T.signInWithSolana),{version:"1",domain:L.host,uri:L.href}),S?{statement:S}:null));let $;if(Array.isArray(R)&&R[0]&&typeof R[0]=="object")$=R[0];else if(R&&typeof R=="object"&&"signedMessage"in R&&"signature"in R)$=R;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in $&&"signature"in $&&(typeof $.signedMessage=="string"||$.signedMessage instanceof Uint8Array)&&$.signature instanceof Uint8Array)b=typeof $.signedMessage=="string"?$.signedMessage:new TextDecoder().decode($.signedMessage),w=$.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in I)||typeof I.signMessage!="function"||!("publicKey"in I)||typeof I!="object"||!I.publicKey||!("toBase58"in I.publicKey)||typeof I.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");b=[`${L.host} wants you to sign in with your Solana account:`,I.publicKey.toBase58(),...S?["",S,""]:[""],"Version: 1",`URI: ${L.href}`,`Issued At: ${(a=(n=T==null?void 0:T.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&a!==void 0?a:new Date().toISOString()}`,...!((o=T==null?void 0:T.signInWithSolana)===null||o===void 0)&&o.notBefore?[`Not Before: ${T.signInWithSolana.notBefore}`]:[],...!((l=T==null?void 0:T.signInWithSolana)===null||l===void 0)&&l.expirationTime?[`Expiration Time: ${T.signInWithSolana.expirationTime}`]:[],...!((i=T==null?void 0:T.signInWithSolana)===null||i===void 0)&&i.chainId?[`Chain ID: ${T.signInWithSolana.chainId}`]:[],...!((c=T==null?void 0:T.signInWithSolana)===null||c===void 0)&&c.nonce?[`Nonce: ${T.signInWithSolana.nonce}`]:[],...!((u=T==null?void 0:T.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${T.signInWithSolana.requestId}`]:[],...!((f=(p=T==null?void 0:T.signInWithSolana)===null||p===void 0?void 0:p.resources)===null||f===void 0)&&f.length?["Resources",...T.signInWithSolana.resources.map($=>`- ${$}`)]:[]].join(` `);const R=await I.signMessage(new TextEncoder().encode(b),"utf8");if(!R||!(R instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");w=R}}try{const{data:j,error:N}=await xi(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:b,signature:l4(w)},!((y=s.options)===null||y===void 0)&&y.captchaToken?{gotrue_meta_security:{captcha_token:(_=s.options)===null||_===void 0?void 0:_.captchaToken}}:null),xform:_x});if(N)throw N;return!j||!j.session||!j.user?{data:{user:null,session:null},error:new U3}:(j.session&&(await this._saveSession(j.session),await this._notifyAllSubscribers("SIGNED_IN",j.session)),{data:Object.assign({},j),error:N})}catch(j){if(Ia(j))return{data:{user:null,session:null},error:j};throw j}}async _exchangeCodeForSession(s){const r=await Mw(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:o,error:l}=await xi(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:_x});if(await w_(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new U3}:(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(Ia(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 xi(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:_x}),{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 U3}:(c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",c.session)),{data:c,error:u})}catch(r){if(Ia(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 V3(this.storage,this.storageKey));const{error:f}=await xi(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 xi(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 S7("You must provide either an email or phone number.")}catch(i){if(Ia(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 xi(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:_x});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(Ia(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 V3(this.storage,this.storageKey)),await xi(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:X_t})}catch(o){if(Ia(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 vx;const{error:a}=await xi(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(Ia(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 xi(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 xi(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 S7("You must provide either an email or phone number and a type")}catch(r){if(Ia(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 Mw(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 xi(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:K_}):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 vx}:await xi(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:K_})})}catch(r){if(Ia(r))return N_t(r)&&(await this._removeSession(),await w_(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 vx;const l=a.session;let i=null,c=null;this.flowType==="pkce"&&s.email!=null&&([i,c]=await V3(this.storage,this.storageKey));const{data:u,error:p}=await xi(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:K_});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(Ia(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 vx;const r=Date.now()/1e3;let n=r,a=!0,o=null;const{payload:l}=sge(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(Ia(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 vx;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(Ia(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!dm())throw new C7("No browser detected.");if(s.error||s.error_description||s.error_code)throw new C7(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 tEe("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new C7("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 tEe("No code detected.");const{data:S,error:T}=await this._exchangeCodeForSession(s.code);if(T)throw T;const I=new URL(window.location.href);return I.searchParams.delete("code"),window.history.replaceState(window.history.state,"",I.toString()),{data:{session:S.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:o,refresh_token:l,expires_in:i,expires_at:c,token_type:u}=s;if(!o||!i||!l||!u)throw new C7("No session defined in URL");const p=Math.round(Date.now()/1e3),f=parseInt(i);let y=p+f;c&&(y=parseInt(c));const _=y-p;_*1e3<=p5&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${_}s, should have been closer to ${f}s`);const b=y-f;p-b>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",b,y,p):p-b<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",b,y,p);const{data:w,error:j}=await this._getUser(o);if(j)throw j;const N={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:f,expires_at:y,refresh_token:l,token_type:u,user:w.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:N,redirectType:s.type},error:null}}catch(n){if(Ia(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 Mw(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&&!(k_t(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await w_(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=I_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 V3(this.storage,this.storageKey,!0));try{return await xi(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(Ia(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(Ia(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:y}=o;if(y)throw y;const _=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,s.provider,{redirectTo:(l=s.options)===null||l===void 0?void 0:l.redirectTo,scopes:(i=s.options)===null||i===void 0?void 0:i.scopes,queryParams:(c=s.options)===null||c===void 0?void 0:c.queryParams,skipBrowserRedirect:!0});return await xi(this.fetch,"GET",_,{headers:this.headers,jwt:(p=(u=f.session)===null||u===void 0?void 0:u.access_token)!==null&&p!==void 0?p:void 0})});if(a)throw a;return dm()&&!(!((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(Ia(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 xi(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:_x}),{data:y,error:_}=f;return _?{data:{user:null,session:null},error:_}:!y||!y.session||!y.user?{data:{user:null,session:null},error:new U3}:(y.session&&(await this._saveSession(y.session),await this._notifyAllSubscribers("USER_UPDATED",y.session)),{data:y,error:_})}catch(a){if(Ia(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 xi(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(Ia(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 R_t(async a=>(a>0&&await O_t(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await xi(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:_x})),(a,o)=>{const l=200*Math.pow(2,a);return o&&tge(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(),p5);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)/p5);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${p5}ms, refresh threshold is ${ave} ticks`),a<=ave&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(s){if(s.isAcquireTimeout||s instanceof HUe)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!dm()||!(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 V3(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 xi(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(Ia(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 xi(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(Ia(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"?mbt(s.webauthn.credential_response):pbt(s.webauthn.credential_response)})}:{code:s.code}),{data:i,error:c}=await xi(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(Ia(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 xi(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:ubt(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:hbt(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(Ia(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}=sge(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 xi(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 vx}})}catch(r){if(Ia(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 vx};const l=await xi(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&&dm()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Ia(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 vx};const l=await xi(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&&dm()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Ia(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+w_t>a)return n;const{data:o,error:l}=await xi(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(l)throw l;return!o.keys||o.keys.length===0||(this.jwks=o,this.jwks_cached_at=a,n=o.keys.find(i=>i.kid===s),!n)?null:n}async getClaims(s,r={}){try{let n=s;if(!n){const{data:_,error:b}=await this.getSession();if(b||!_.session)return{data:null,error:b};n=_.session.access_token}const{header:a,payload:o,signature:l,raw:{header:i,payload:c}}=sge(n);r!=null&&r.allowExpired||V_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:_}=await this.getUser(n);if(_)throw _;return{data:{claims:o,header:a,signature:l},error:null}}const p=H_t(a.alg),f=await crypto.subtle.importKey("jwk",u,p,!0,["verify"]);if(!await crypto.subtle.verify(p,f,l,E_t(`${i}.${c}`)))throw new lve("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(Ia(n))return{data:null,error:n};throw n}}}T8.nextInstanceID=0;const jbt=T8;class kbt extends jbt{constructor(s){super(s)}}class Nbt{constructor(s,r,n){var a,o,l;this.supabaseUrl=s,this.supabaseKey=r;const i=x_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:c_t,realtime:u_t,auth:Object.assign(Object.assign({},d_t),{storageKey:c}),global:l_t},p=g_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,y)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(y)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((l=p.auth)!==null&&l!==void 0?l:{},this.headers,p.global.fetch),this.fetch=p_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 y1t(new URL("rest/v1",i).href,{headers:this.headers,schema:p.db.schema,fetch:this.fetch}),this.storage=new a_t(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),p.accessToken||this._listenForAuthEvents()}get functions(){return new d1t(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 y={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new kbt({url:this.authUrl.href,headers:Object.assign(Object.assign({},y),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(_=>_.toLowerCase()==="authorization")})}_initRealtimeClient(s){return new D1t(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 Sbt=(t,s,r)=>new Nbt(t,s,r);function Cbt(){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}Cbt()&&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 Mbt="https://relzejiswnotikjgvjhz.supabase.co",Tbt="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",G=Sbt(Mbt,Tbt,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),KUe=C.createContext(void 0),Abt=({children:t})=>{const[s,r]=C.useState(null),[n,a]=C.useState(null),[o,l]=C.useState(!0),[i,c]=C.useState(!1),[u,p]=C.useState(!1),[f,y]=C.useState(null),[_,b]=C.useState([]),[w,j]=C.useState(null),N=Pr(),S=()=>{c(!1),p(!1),y(null),b([]),j(null)},T=async $=>{try{console.log("Checking roles via RPC for user:",$);const[{data:q,error:U},{data:V,error:X}]=await Promise.all([G.rpc("has_role",{_user_id:$,_role:"admin"}),G.rpc("has_role",{_user_id:$,_role:"brokerage_manager"})]);if(U||X)console.error("Role RPC errors:",{isAdminError:U,isBrokerError:X}),c(!1),p(!1);else{const Q=!!q,de=!!V;console.log("RPC roles result:",{adminValue:Q,brokerValue:de}),c(Q),p(de)}const{data:se,error:ee}=await G.from("profiles").select("brokerage_id").eq("id",$).single();if(y(!ee&&se?se.brokerage_id:null),V){console.log("Fetching managed brokerages for user:",$);const{data:Q,error:de}=await G.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",$);if(console.log("Managed brokerage assignments result:",{assignments:Q,assignmentsError:de}),de||!Q){console.error("Error fetching managed brokerage assignments:",de),b([]);return}const re=Array.from(new Set(Q.map(we=>we.brokerage_id).filter(Boolean)));if(re.length===0){b([]);return}const{data:ne,error:le}=await G.from("brokerages").select("id, name").in("id",re);if(console.log("Managed brokerages details result:",{brokeragesData:ne,brokeragesError:le}),le||!ne){console.error("Error fetching managed brokerages details:",le),b([]);return}const he=ne.map(we=>({id:we.id,name:we.name})).sort((we,ye)=>re.indexOf(we.id)-re.indexOf(ye.id));console.log("Parsed managed brokerages:",he),b(he),he.length>0&&j(we=>we??he[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),b([])}catch(q){console.error("Unexpected error in checkRoles:",q),S()}};C.useEffect(()=>{let $=!0,q=!1;const U=()=>{!$||q||(q=!0,l(!1))},{data:{subscription:V}}=G.auth.onAuthStateChange((ee,Q)=>{console.log("Auth event:",ee),$&&(a(Q),r((Q==null?void 0:Q.user)??null),U(),ee==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{N("/profile?reset=true")},100)),Q!=null&&Q.user?setTimeout(()=>{T(Q.user.id)},0):S())}),X=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),U()},4e3);return(async()=>{try{const{data:{session:ee}}=await G.auth.getSession();if(!$)return;a(ee),r((ee==null?void 0:ee.user)??null),ee!=null&&ee.user?await T(ee.user.id):S()}catch(ee){console.error("Error restoring auth session:",ee),$&&(a(null),r(null),S())}finally{U()}})(),()=>{$=!1,window.clearTimeout(X),V.unsubscribe()}},[]);const I=async($,q)=>{const{error:U}=await G.auth.signInWithPassword({email:$,password:q});if(U)throw me.error(U.message),U;me.success("Welcome back!"),N("/dashboard")},L=async($,q,U)=>{const V=`${window.location.origin}/dashboard`,{error:X}=await G.auth.signUp({email:$,password:q,options:{emailRedirectTo:V,data:{name:U}}});if(X)throw me.error(X.message),X;me.success("Account created! Welcome to LevelUp."),N("/dashboard")},R=async()=>{try{const{data:{session:$}}=await G.auth.getSession();if($){const{error:q}=await G.auth.signOut();q?q.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",q.message):(console.error("Sign out error:",q),me.error(q.message)):me.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),a(null),c(!1),p(!1),y(null),b([]),j(null),N("/auth")}catch($){console.error("Unexpected sign out error:",$),N("/auth")}};return e.jsx(KUe.Provider,{value:{user:s,session:n,loading:o,signIn:I,signUp:L,signOut:R,isAdmin:i,isBrokerageManager:u,brokerageId:f,managedBrokerages:_,selectedBrokerageId:w,setSelectedBrokerageId:j},children:t})},Ws=()=>{const t=C.useContext(KUe);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},ZUe=C.createContext(void 0),Tw="levelup_admin_session",j_="levelup_impersonation",Ebt=({children:t})=>{const[s,r]=C.useState(!1),[n,a]=C.useState(null),[o,l]=C.useState(!1);C.useEffect(()=>{const u=sessionStorage.getItem(j_);if(u)try{const p=JSON.parse(u);r(!0),a(p)}catch{sessionStorage.removeItem(j_)}},[]);const i=async u=>{l(!0);try{const{data:{session:p}}=await G.auth.getSession();if(!p)return me.error("No active session found"),!1;const f={access_token:p.access_token,refresh_token:p.refresh_token};sessionStorage.setItem(Tw,JSON.stringify(f));const y=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${p.access_token}`},body:JSON.stringify({targetUserId:u})}),_=await y.json();if(!y.ok)throw new Error(_.error||"Failed to impersonate user");const b={id:_.targetUser.id,name:_.targetUser.name,email:_.targetUser.email};if(sessionStorage.setItem(j_,JSON.stringify(b)),_.method==="session"){const{error:w}=await G.auth.setSession({access_token:_.access_token,refresh_token:_.refresh_token});if(w)throw console.error("Set session error:",w),sessionStorage.removeItem(Tw),sessionStorage.removeItem(j_),new Error("Failed to establish impersonation session")}else{const w=_.type||"recovery",{error:j}=await G.auth.verifyOtp({token_hash:_.token_hash,type:w});if(j)throw console.error("Verify OTP error:",j),sessionStorage.removeItem(Tw),sessionStorage.removeItem(j_),new Error("Failed to establish impersonation session")}return r(!0),a(b),me.success(`Now viewing as ${b.name}`),window.location.href="/dashboard",!0}catch(p){return console.error("Impersonation error:",p),me.error(p.message||"Failed to impersonate user"),sessionStorage.removeItem(Tw),sessionStorage.removeItem(j_),!1}finally{l(!1)}},c=async()=>{l(!0);try{const u=sessionStorage.getItem(Tw);if(!u){await G.auth.signOut(),window.location.href="/auth";return}const p=JSON.parse(u);await G.auth.signOut();const{error:f}=await G.auth.setSession({access_token:p.access_token,refresh_token:p.refresh_token});if(sessionStorage.removeItem(Tw),sessionStorage.removeItem(j_),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 admin account"),window.location.href="/admin/members"}catch(u){console.error("Stop impersonation error:",u),me.error("Failed to restore admin session"),sessionStorage.removeItem(Tw),sessionStorage.removeItem(j_),window.location.href="/auth"}finally{l(!1)}};return e.jsx(ZUe.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:c,isLoading:o},children:t})},Dwe=()=>{const t=C.useContext(ZUe);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},A8=HS("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=C.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?J2e:"button";return e.jsx(l,{className:At(A8({variant:s,size:r,className:t})),ref:o,...a})});K.displayName="Button";const Pbt=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=Dwe();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(uh,{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(Ss,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Ur,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Exit Impersonation"}),e.jsx("span",{className:"sm:hidden",children:"Exit"})]})})]})})},YUe=C.createContext(void 0),K3="levelup_acting_as",M7="levelup_acting_as_self",Ibt=({children:t})=>{const{user:s}=Ws(),[r,n]=C.useState(!1),[a,o]=C.useState([]),[l,i]=C.useState(null),[c,u]=C.useState({}),[p,f]=C.useState(!0),[y,_]=C.useState(()=>sessionStorage.getItem(M7)==="true");C.useEffect(()=>{if(!(s!=null&&s.id)){n(!1),o([]),i(null),u({}),f(!1);return}(async()=>{f(!0);try{const{data:T}=await G.rpc("has_role",{_user_id:s.id,_role:"assistant"});if(!T){n(!1),o([]),i(null),u({}),f(!1);return}n(!0);const{data:I,error:L}=await G.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",s.id);if(L||!I||I.length===0){o([]),f(!1);return}const R=I.map(U=>U.agent_id),{data:$}=await G.from("profiles").select("id, name, email, avatar_url").in("id",R),q=($||[]).map(U=>({id:U.id,name:U.name||U.email||"Unknown",email:U.email||"",avatar_url:U.avatar_url}));if(o(q),sessionStorage.getItem(M7)==="true")_(!0),i(null),u({});else{const U=sessionStorage.getItem(K3);if(U){const V=q.find(X=>X.id===U);if(V){i(V);const X=I.find(se=>se.agent_id===U);u((X==null?void 0:X.permissions)||{})}else if(q.length>0){i(q[0]);const X=I.find(se=>se.agent_id===q[0].id);u((X==null?void 0:X.permissions)||{}),sessionStorage.setItem(K3,q[0].id)}}else if(q.length>0){i(q[0]);const V=I.find(X=>X.agent_id===q[0].id);u((V==null?void 0:V.permissions)||{}),sessionStorage.setItem(K3,q[0].id)}}}catch(T){console.error("Error loading assistant data:",T)}finally{f(!1)}})()},[s==null?void 0:s.id]);const b=S=>{i(S),_(!1),sessionStorage.removeItem(M7),S?(sessionStorage.setItem(K3,S.id),G.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(s==null?void 0:s.id)||"").eq("agent_id",S.id).single().then(({data:T})=>{u((T==null?void 0:T.permissions)||{})})):(sessionStorage.removeItem(K3),u({}))},w=()=>{_(!0),i(null),u({}),sessionStorage.setItem(M7,"true"),sessionStorage.removeItem(K3)},j=S=>!r||y?!0:c[S]===!0,N=r&&l&&!y?l.id:(s==null?void 0:s.id)||null;return e.jsx(YUe.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:b,effectiveUserId:N,permissions:c,hasPermission:j,isLoading:p,isActingAsSelf:y,setActingAsSelf:w},children:t})},Owe=()=>{const t=C.useContext(YUe);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},ai=()=>{const{effectiveUserId:t}=Owe();return t};var XUe={exports:{}},QUe={};/** * @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 fT=C;function Lbt(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Dbt=typeof Object.is=="function"?Object.is:Lbt,Obt=fT.useState,Rbt=fT.useEffect,Fbt=fT.useLayoutEffect,zbt=fT.useDebugValue;function Bbt(t,s){var r=s(),n=Obt({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return Fbt(function(){a.value=r,a.getSnapshot=s,age(a)&&o({inst:a})},[t,r,s]),Rbt(function(){return age(a)&&o({inst:a}),t(function(){age(a)&&o({inst:a})})},[t]),zbt(r),r}function age(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!Dbt(t,r)}catch{return!0}}function $bt(t,s){return s()}var qbt=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?$bt:Bbt;QUe.useSyncExternalStore=fT.useSyncExternalStore!==void 0?fT.useSyncExternalStore:qbt;XUe.exports=QUe;var Ubt=XUe.exports;function Vbt(){return Ubt.useSyncExternalStore(Hbt,()=>!0,()=>!1)}function Hbt(){return()=>{}}var Rwe="Avatar",[Wbt]=Yc(Rwe),[Gbt,JUe]=Wbt(Rwe),eVe=C.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=C.useState("idle");return e.jsx(Gbt,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(Jr.span,{...n,ref:s})})});eVe.displayName=Rwe;var tVe="AvatarImage",sVe=C.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=JUe(tVe,r),i=Kbt(n,o),c=dd(u=>{a(u),l.onImageLoadingStatusChange(u)});return fd(()=>{i!=="idle"&&c(i)},[i,c]),i==="loaded"?e.jsx(Jr.img,{...o,ref:s,src:n}):null});sVe.displayName=tVe;var rVe="AvatarFallback",nVe=C.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=JUe(rVe,r),[l,i]=C.useState(n===void 0);return C.useEffect(()=>{if(n!==void 0){const c=window.setTimeout(()=>i(!0),n);return()=>window.clearTimeout(c)}},[n]),l&&o.imageLoadingStatus!=="loaded"?e.jsx(Jr.span,{...a,ref:s}):null});nVe.displayName=rVe;function mEe(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Kbt(t,{referrerPolicy:s,crossOrigin:r}){const n=Vbt(),a=C.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=C.useState(()=>mEe(o,t));return fd(()=>{i(mEe(o,t))},[o,t]),fd(()=>{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 aVe=eVe,iVe=sVe,oVe=nVe;const yn=C.forwardRef(({className:t,...s},r)=>e.jsx(aVe,{ref:r,className:At("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));yn.displayName=aVe.displayName;const Da=C.forwardRef(({className:t,...s},r)=>e.jsx(iVe,{ref:r,className:At("aspect-square h-full w-full",t),...s}));Da.displayName=iVe.displayName;const vn=C.forwardRef(({className:t,...s},r)=>e.jsx(oVe,{ref:r,className:At("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));vn.displayName=oVe.displayName;const Zbt=HS("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function nt({className:t,variant:s,...r}){return e.jsx("div",{className:At(Zbt({variant:s}),t),...r})}var Ybt=C.createContext(void 0);function b2(t){const s=C.useContext(Ybt);return t||s||"ltr"}var ige=0;function jde(){C.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??pEe()),document.body.insertAdjacentElement("beforeend",t[1]??pEe()),ige++,()=>{ige===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),ige--}},[])}function pEe(){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 oge="focusScope.autoFocusOnMount",lge="focusScope.autoFocusOnUnmount",fEe={bubbles:!1,cancelable:!0},Xbt="FocusScope",aO=C.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,c]=C.useState(null),u=dd(a),p=dd(o),f=C.useRef(null),y=Oa(s,w=>c(w)),_=C.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;C.useEffect(()=>{if(n){let w=function(T){if(_.paused||!i)return;const I=T.target;i.contains(I)?f.current=I:A_(f.current,{select:!0})},j=function(T){if(_.paused||!i)return;const I=T.relatedTarget;I!==null&&(i.contains(I)||A_(f.current,{select:!0}))},N=function(T){if(document.activeElement===document.body)for(const L of T)L.removedNodes.length>0&&A_(i)};document.addEventListener("focusin",w),document.addEventListener("focusout",j);const S=new MutationObserver(N);return i&&S.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",j),S.disconnect()}}},[n,i,_.paused]),C.useEffect(()=>{if(i){xEe.add(_);const w=document.activeElement;if(!i.contains(w)){const N=new CustomEvent(oge,fEe);i.addEventListener(oge,u),i.dispatchEvent(N),N.defaultPrevented||(Qbt(r2t(lVe(i)),{select:!0}),document.activeElement===w&&A_(i))}return()=>{i.removeEventListener(oge,u),setTimeout(()=>{const N=new CustomEvent(lge,fEe);i.addEventListener(lge,p),i.dispatchEvent(N),N.defaultPrevented||A_(w??document.body,{select:!0}),i.removeEventListener(lge,p),xEe.remove(_)},0)}}},[i,u,p,_]);const b=C.useCallback(w=>{if(!r&&!n||_.paused)return;const j=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,N=document.activeElement;if(j&&N){const S=w.currentTarget,[T,I]=Jbt(S);T&&I?!w.shiftKey&&N===I?(w.preventDefault(),r&&A_(T,{select:!0})):w.shiftKey&&N===T&&(w.preventDefault(),r&&A_(I,{select:!0})):N===S&&w.preventDefault()}},[r,n,_.paused]);return e.jsx(Jr.div,{tabIndex:-1,...l,ref:y,onKeyDown:b})});aO.displayName=Xbt;function Qbt(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(A_(n,{select:s}),document.activeElement!==r)return}function Jbt(t){const s=lVe(t),r=gEe(s,t),n=gEe(s.reverse(),t);return[r,n]}function lVe(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 gEe(t,s){for(const r of t)if(!e2t(r,{upTo:s}))return r}function e2t(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 t2t(t){return t instanceof HTMLInputElement&&"select"in t}function A_(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&t2t(t)&&s&&t.select()}}var xEe=s2t();function s2t(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=yEe(t,s),t.unshift(s)},remove(s){var r;t=yEe(t,s),(r=t[0])==null||r.resume()}}}function yEe(t,s){const r=[...t],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function r2t(t){return t.filter(s=>s.tagName!=="A")}var cge="rovingFocusGroup.onEntryFocus",n2t={bubbles:!1,cancelable:!0},iO="RovingFocusGroup",[cve,cVe,a2t]=XD(iO),[i2t,w2]=Yc(iO,[a2t]),[o2t,l2t]=i2t(iO),dVe=C.forwardRef((t,s)=>e.jsx(cve.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(cve.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(c2t,{...t,ref:s})})}));dVe.displayName=iO;var c2t=C.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,y=C.useRef(null),_=Oa(s,y),b=b2(o),[w,j]=Yu({prop:l,defaultProp:i??null,onChange:c,caller:iO}),[N,S]=C.useState(!1),T=dd(u),I=cVe(r),L=C.useRef(!1),[R,$]=C.useState(0);return C.useEffect(()=>{const q=y.current;if(q)return q.addEventListener(cge,T),()=>q.removeEventListener(cge,T)},[T]),e.jsx(o2t,{scope:r,orientation:n,dir:b,loop:a,currentTabStopId:w,onItemFocus:C.useCallback(q=>j(q),[j]),onItemShiftTab:C.useCallback(()=>S(!0),[]),onFocusableItemAdd:C.useCallback(()=>$(q=>q+1),[]),onFocusableItemRemove:C.useCallback(()=>$(q=>q-1),[]),children:e.jsx(Jr.div,{tabIndex:N||R===0?-1:0,"data-orientation":n,...f,ref:_,style:{outline:"none",...t.style},onMouseDown:Mr(t.onMouseDown,()=>{L.current=!0}),onFocus:Mr(t.onFocus,q=>{const U=!L.current;if(q.target===q.currentTarget&&U&&!N){const V=new CustomEvent(cge,n2t);if(q.currentTarget.dispatchEvent(V),!V.defaultPrevented){const X=I().filter(re=>re.focusable),se=X.find(re=>re.active),ee=X.find(re=>re.id===w),de=[se,ee,...X].filter(Boolean).map(re=>re.ref.current);mVe(de,p)}}L.current=!1}),onBlur:Mr(t.onBlur,()=>S(!1))})})}),uVe="RovingFocusGroupItem",hVe=C.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,c=vu(),u=o||c,p=l2t(uVe,r),f=p.currentTabStopId===u,y=cVe(r),{onFocusableItemAdd:_,onFocusableItemRemove:b,currentTabStopId:w}=p;return C.useEffect(()=>{if(n)return _(),()=>b()},[n,_,b]),e.jsx(cve.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:e.jsx(Jr.span,{tabIndex:f?0:-1,"data-orientation":p.orientation,...i,ref:s,onMouseDown:Mr(t.onMouseDown,j=>{n?p.onItemFocus(u):j.preventDefault()}),onFocus:Mr(t.onFocus,()=>p.onItemFocus(u)),onKeyDown:Mr(t.onKeyDown,j=>{if(j.key==="Tab"&&j.shiftKey){p.onItemShiftTab();return}if(j.target!==j.currentTarget)return;const N=h2t(j,p.orientation,p.dir);if(N!==void 0){if(j.metaKey||j.ctrlKey||j.altKey||j.shiftKey)return;j.preventDefault();let T=y().filter(I=>I.focusable).map(I=>I.ref.current);if(N==="last")T.reverse();else if(N==="prev"||N==="next"){N==="prev"&&T.reverse();const I=T.indexOf(j.currentTarget);T=p.loop?m2t(T,I+1):T.slice(I+1)}setTimeout(()=>mVe(T))}}),children:typeof l=="function"?l({isCurrentTabStop:f,hasTabStop:w!=null}):l})})});hVe.displayName=uVe;var d2t={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function u2t(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function h2t(t,s,r){const n=u2t(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return d2t[n]}function mVe(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function m2t(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var kde=dVe,Nde=hVe,p2t=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},Z3=new WeakMap,T7=new WeakMap,A7={},dge=0,pVe=function(t){return t&&(t.host||pVe(t.parentNode))},f2t=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=pVe(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})},g2t=function(t,s,r,n){var a=f2t(s,Array.isArray(t)?t:[t]);A7[r]||(A7[r]=new WeakMap);var o=A7[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(y){if(i.has(y))p(y);else try{var _=y.getAttribute(n),b=_!==null&&_!=="false",w=(Z3.get(y)||0)+1,j=(o.get(y)||0)+1;Z3.set(y,w),o.set(y,j),l.push(y),w===1&&b&&T7.set(y,!0),j===1&&y.setAttribute(r,"true"),b||y.setAttribute(n,"true")}catch(N){console.error("aria-hidden: cannot operate on ",y,N)}})};return p(s),i.clear(),dge++,function(){l.forEach(function(f){var y=Z3.get(f)-1,_=o.get(f)-1;Z3.set(f,y),o.set(f,_),y||(T7.has(f)||f.removeAttribute(n),T7.delete(f)),_||f.removeAttribute(r)}),dge--,dge||(Z3=new WeakMap,Z3=new WeakMap,T7=new WeakMap,A7={})}},Sde=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=p2t(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),g2t(n,a,r,"aria-hidden")):function(){return null}},sie="right-scroll-bar-position",rie="width-before-scroll-bar",x2t="with-scroll-bars-hidden",y2t="--removed-body-scroll-bar-size";function uge(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function v2t(t,s){var r=C.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 _2t=typeof window<"u"?C.useLayoutEffect:C.useEffect,vEe=new WeakMap;function b2t(t,s){var r=v2t(null,function(n){return t.forEach(function(a){return uge(a,n)})});return _2t(function(){var n=vEe.get(r);if(n){var a=new Set(n),o=new Set(t),l=r.current;a.forEach(function(i){o.has(i)||uge(i,null)}),o.forEach(function(i){a.has(i)||uge(i,l)})}vEe.set(r,t)},[t]),r}function w2t(t){return t}function j2t(t,s){s===void 0&&(s=w2t);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 k2t(t){t===void 0&&(t={});var s=j2t(null);return s.options=og({async:!0,ssr:!1},t),s}var fVe=function(t){var s=t.sideCar,r=v2(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 C.createElement(n,og({},r))};fVe.isSideCarExport=!0;function N2t(t,s){return t.useMedium(s),fVe}var gVe=k2t(),hge=function(){},Cde=C.forwardRef(function(t,s){var r=C.useRef(null),n=C.useState({onScrollCapture:hge,onWheelCapture:hge,onTouchMoveCapture:hge}),a=n[0],o=n[1],l=t.forwardProps,i=t.children,c=t.className,u=t.removeScrollBar,p=t.enabled,f=t.shards,y=t.sideCar,_=t.noRelative,b=t.noIsolation,w=t.inert,j=t.allowPinchZoom,N=t.as,S=N===void 0?"div":N,T=t.gapMode,I=v2(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),L=y,R=b2t([r,s]),$=og(og({},I),a);return C.createElement(C.Fragment,null,p&&C.createElement(L,{sideCar:gVe,removeScrollBar:u,shards:f,noRelative:_,noIsolation:b,inert:w,setCallbacks:o,allowPinchZoom:!!j,lockRef:r,gapMode:T}),l?C.cloneElement(C.Children.only(i),og(og({},$),{ref:R})):C.createElement(S,og({},$,{className:c,ref:R}),i))});Cde.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Cde.classNames={fullWidth:rie,zeroRight:sie};var S2t=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function C2t(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=S2t();return s&&t.setAttribute("nonce",s),t}function M2t(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function T2t(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var A2t=function(){var t=0,s=null;return{add:function(r){t==0&&(s=C2t())&&(M2t(s,r),T2t(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},E2t=function(){var t=A2t();return function(s,r){C.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&r])}},xVe=function(){var t=E2t(),s=function(r){var n=r.styles,a=r.dynamic;return t(n,a),null};return s},P2t={left:0,top:0,right:0,gap:0},mge=function(t){return parseInt(t||"",10)||0},I2t=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[mge(r),mge(n),mge(a)]},L2t=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return P2t;var s=I2t(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])}},D2t=xVe(),EM="data-scroll-locked",O2t=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(x2t,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(EM,`] { 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(sie,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(rie,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(sie," .").concat(sie,` { right: 0 `).concat(n,`; } .`).concat(rie," .").concat(rie,` { margin-right: 0 `).concat(n,`; } body[`).concat(EM,`] { `).concat(y2t,": ").concat(i,`px; } `)},_Ee=function(){var t=parseInt(document.body.getAttribute(EM)||"0",10);return isFinite(t)?t:0},R2t=function(){C.useEffect(function(){return document.body.setAttribute(EM,(_Ee()+1).toString()),function(){var t=_Ee()-1;t<=0?document.body.removeAttribute(EM):document.body.setAttribute(EM,t.toString())}},[])},F2t=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;R2t();var o=C.useMemo(function(){return L2t(a)},[a]);return C.createElement(D2t,{styles:O2t(o,!s,a,r?"":"!important")})},dve=!1;if(typeof window<"u")try{var E7=Object.defineProperty({},"passive",{get:function(){return dve=!0,!0}});window.addEventListener("test",E7,E7),window.removeEventListener("test",E7,E7)}catch{dve=!1}var Y3=dve?{passive:!1}:!1,z2t=function(t){return t.tagName==="TEXTAREA"},yVe=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!z2t(t)&&r[s]==="visible")},B2t=function(t){return yVe(t,"overflowY")},$2t=function(t){return yVe(t,"overflowX")},bEe=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=vVe(t,n);if(a){var o=_Ve(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},q2t=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},U2t=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},vVe=function(t,s){return t==="v"?B2t(s):$2t(s)},_Ve=function(t,s){return t==="v"?q2t(s):U2t(s)},V2t=function(t,s){return t==="h"&&s==="rtl"?-1:1},H2t=function(t,s,r,n,a){var o=V2t(t,window.getComputedStyle(s).direction),l=o*n,i=r.target,c=s.contains(i),u=!1,p=l>0,f=0,y=0;do{if(!i)break;var _=_Ve(t,i),b=_[0],w=_[1],j=_[2],N=w-j-o*b;(b||N)&&vVe(t,i)&&(f+=N,y+=b);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(y)<1)&&(u=!0),u},P7=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},wEe=function(t){return[t.deltaX,t.deltaY]},jEe=function(t){return t&&"current"in t?t.current:t},W2t=function(t,s){return t[0]===s[0]&&t[1]===s[1]},G2t=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},K2t=0,X3=[];function Z2t(t){var s=C.useRef([]),r=C.useRef([0,0]),n=C.useRef(),a=C.useState(K2t++)[0],o=C.useState(xVe)[0],l=C.useRef(t);C.useEffect(function(){l.current=t},[t]),C.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var w=Swe([t.lockRef.current],(t.shards||[]).map(jEe),!0).filter(Boolean);return w.forEach(function(j){return j.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(j){return j.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var i=C.useCallback(function(w,j){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!l.current.allowPinchZoom;var N=P7(w),S=r.current,T="deltaX"in w?w.deltaX:S[0]-N[0],I="deltaY"in w?w.deltaY:S[1]-N[1],L,R=w.target,$=Math.abs(T)>Math.abs(I)?"h":"v";if("touches"in w&&$==="h"&&R.type==="range")return!1;var q=bEe($,R);if(!q)return!0;if(q?L=$:(L=$==="v"?"h":"v",q=bEe($,R)),!q)return!1;if(!n.current&&"changedTouches"in w&&(T||I)&&(n.current=L),!L)return!0;var U=n.current||L;return H2t(U,j,w,U==="h"?T:I)},[]),c=C.useCallback(function(w){var j=w;if(!(!X3.length||X3[X3.length-1]!==o)){var N="deltaY"in j?wEe(j):P7(j),S=s.current.filter(function(L){return L.name===j.type&&(L.target===j.target||j.target===L.shadowParent)&&W2t(L.delta,N)})[0];if(S&&S.should){j.cancelable&&j.preventDefault();return}if(!S){var T=(l.current.shards||[]).map(jEe).filter(Boolean).filter(function(L){return L.contains(j.target)}),I=T.length>0?i(j,T[0]):!l.current.noIsolation;I&&j.cancelable&&j.preventDefault()}}},[]),u=C.useCallback(function(w,j,N,S){var T={name:w,delta:j,target:N,should:S,shadowParent:Y2t(N)};s.current.push(T),setTimeout(function(){s.current=s.current.filter(function(I){return I!==T})},1)},[]),p=C.useCallback(function(w){r.current=P7(w),n.current=void 0},[]),f=C.useCallback(function(w){u(w.type,wEe(w),w.target,i(w,t.lockRef.current))},[]),y=C.useCallback(function(w){u(w.type,P7(w),w.target,i(w,t.lockRef.current))},[]);C.useEffect(function(){return X3.push(o),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:y}),document.addEventListener("wheel",c,Y3),document.addEventListener("touchmove",c,Y3),document.addEventListener("touchstart",p,Y3),function(){X3=X3.filter(function(w){return w!==o}),document.removeEventListener("wheel",c,Y3),document.removeEventListener("touchmove",c,Y3),document.removeEventListener("touchstart",p,Y3)}},[]);var _=t.removeScrollBar,b=t.inert;return C.createElement(C.Fragment,null,b?C.createElement(o,{styles:G2t(a)}):null,_?C.createElement(F2t,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function Y2t(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const X2t=N2t(gVe,Z2t);var oO=C.forwardRef(function(t,s){return C.createElement(Cde,og({},t,{ref:s,sideCar:X2t}))});oO.classNames=Cde.classNames;var uve=["Enter"," "],Q2t=["ArrowDown","PageUp","Home"],bVe=["ArrowUp","PageDown","End"],J2t=[...Q2t,...bVe],ewt={ltr:[...uve,"ArrowRight"],rtl:[...uve,"ArrowLeft"]},twt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},lO="Menu",[E8,swt,rwt]=XD(lO),[GS,wVe]=Yc(lO,[rwt,M0,w2]),Mde=M0(),jVe=w2(),[nwt,KS]=GS(lO),[awt,cO]=GS(lO),kVe=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=Mde(s),[c,u]=C.useState(null),p=C.useRef(!1),f=dd(o),y=b2(a);return C.useEffect(()=>{const _=()=>{p.current=!0,document.addEventListener("pointerdown",b,{capture:!0,once:!0}),document.addEventListener("pointermove",b,{capture:!0,once:!0})},b=()=>p.current=!1;return document.addEventListener("keydown",_,{capture:!0}),()=>{document.removeEventListener("keydown",_,{capture:!0}),document.removeEventListener("pointerdown",b,{capture:!0}),document.removeEventListener("pointermove",b,{capture:!0})}},[]),e.jsx(tO,{...i,children:e.jsx(nwt,{scope:s,open:r,onOpenChange:f,content:c,onContentChange:u,children:e.jsx(awt,{scope:s,onClose:C.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:p,dir:y,modal:l,children:n})})})};kVe.displayName=lO;var iwt="MenuAnchor",Fwe=C.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Mde(r);return e.jsx(jA,{...a,...n,ref:s})});Fwe.displayName=iwt;var zwe="MenuPortal",[owt,NVe]=GS(zwe,{forceMount:void 0}),SVe=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=KS(zwe,s);return e.jsx(owt,{scope:s,forceMount:r,children:e.jsx(Id,{present:r||o.open,children:e.jsx(vA,{asChild:!0,container:a,children:n})})})};SVe.displayName=zwe;var vg="MenuContent",[lwt,Bwe]=GS(vg),CVe=C.forwardRef((t,s)=>{const r=NVe(vg,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=KS(vg,t.__scopeMenu),l=cO(vg,t.__scopeMenu);return e.jsx(E8.Provider,{scope:t.__scopeMenu,children:e.jsx(Id,{present:n||o.open,children:e.jsx(E8.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(cwt,{...a,ref:s}):e.jsx(dwt,{...a,ref:s})})})})}),cwt=C.forwardRef((t,s)=>{const r=KS(vg,t.__scopeMenu),n=C.useRef(null),a=Oa(s,n);return C.useEffect(()=>{const o=n.current;if(o)return Sde(o)},[]),e.jsx($we,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Mr(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),dwt=C.forwardRef((t,s)=>{const r=KS(vg,t.__scopeMenu);return e.jsx($we,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),uwt=e2("MenuContent.ScrollLock"),$we=C.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:y,onDismiss:_,disableOutsideScroll:b,...w}=t,j=KS(vg,r),N=cO(vg,r),S=Mde(r),T=jVe(r),I=swt(r),[L,R]=C.useState(null),$=C.useRef(null),q=Oa(s,$,j.onContentChange),U=C.useRef(0),V=C.useRef(""),X=C.useRef(0),se=C.useRef(null),ee=C.useRef("right"),Q=C.useRef(0),de=b?oO:C.Fragment,re=b?{as:uwt,allowPinchZoom:!0}:void 0,ne=he=>{var Ae,Re;const we=V.current+he,ye=I().filter(Te=>!Te.disabled),je=document.activeElement,ke=(Ae=ye.find(Te=>Te.ref.current===je))==null?void 0:Ae.textValue,We=ye.map(Te=>Te.textValue),be=jwt(We,we,ke),Me=(Re=ye.find(Te=>Te.textValue===be))==null?void 0:Re.ref.current;(function Te(qe){V.current=qe,window.clearTimeout(U.current),qe!==""&&(U.current=window.setTimeout(()=>Te(""),1e3))})(we),Me&&setTimeout(()=>Me.focus())};C.useEffect(()=>()=>window.clearTimeout(U.current),[]),jde();const le=C.useCallback(he=>{var ye,je;return ee.current===((ye=se.current)==null?void 0:ye.side)&&Nwt(he,(je=se.current)==null?void 0:je.area)},[]);return e.jsx(lwt,{scope:r,searchRef:V,onItemEnter:C.useCallback(he=>{le(he)&&he.preventDefault()},[le]),onItemLeave:C.useCallback(he=>{var we;le(he)||((we=$.current)==null||we.focus(),R(null))},[le]),onTriggerLeave:C.useCallback(he=>{le(he)&&he.preventDefault()},[le]),pointerGraceTimerRef:X,onPointerGraceIntentChange:C.useCallback(he=>{se.current=he},[]),children:e.jsx(de,{...re,children:e.jsx(aO,{asChild:!0,trapped:a,onMountAutoFocus:Mr(o,he=>{var we;he.preventDefault(),(we=$.current)==null||we.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(g2,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:y,onDismiss:_,children:e.jsx(kde,{asChild:!0,...T,dir:N.dir,orientation:"vertical",loop:n,currentTabStopId:L,onCurrentTabStopIdChange:R,onEntryFocus:Mr(c,he=>{N.isUsingKeyboardRef.current||he.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(sO,{role:"menu","aria-orientation":"vertical","data-state":UVe(j.open),"data-radix-menu-content":"",dir:N.dir,...S,...w,ref:q,style:{outline:"none",...w.style},onKeyDown:Mr(w.onKeyDown,he=>{const ye=he.target.closest("[data-radix-menu-content]")===he.currentTarget,je=he.ctrlKey||he.altKey||he.metaKey,ke=he.key.length===1;ye&&(he.key==="Tab"&&he.preventDefault(),!je&&ke&&ne(he.key));const We=$.current;if(he.target!==We||!J2t.includes(he.key))return;he.preventDefault();const Me=I().filter(Ae=>!Ae.disabled).map(Ae=>Ae.ref.current);bVe.includes(he.key)&&Me.reverse(),bwt(Me)}),onBlur:Mr(t.onBlur,he=>{he.currentTarget.contains(he.target)||(window.clearTimeout(U.current),V.current="")}),onPointerMove:Mr(t.onPointerMove,P8(he=>{const we=he.target,ye=Q.current!==he.clientX;if(he.currentTarget.contains(we)&&ye){const je=he.clientX>Q.current?"right":"left";ee.current=je,Q.current=he.clientX}}))})})})})})})});CVe.displayName=vg;var hwt="MenuGroup",qwe=C.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Jr.div,{role:"group",...n,ref:s})});qwe.displayName=hwt;var mwt="MenuLabel",MVe=C.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Jr.div,{...n,ref:s})});MVe.displayName=mwt;var uoe="MenuItem",kEe="menu.itemSelect",Tde=C.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=C.useRef(null),l=cO(uoe,t.__scopeMenu),i=Bwe(uoe,t.__scopeMenu),c=Oa(s,o),u=C.useRef(!1),p=()=>{const f=o.current;if(!r&&f){const y=new CustomEvent(kEe,{bubbles:!0,cancelable:!0});f.addEventListener(kEe,_=>n==null?void 0:n(_),{once:!0}),ewe(f,y),y.defaultPrevented?u.current=!1:l.onClose()}};return e.jsx(TVe,{...a,ref:c,disabled:r,onClick:Mr(t.onClick,p),onPointerDown:f=>{var y;(y=t.onPointerDown)==null||y.call(t,f),u.current=!0},onPointerUp:Mr(t.onPointerUp,f=>{var y;u.current||(y=f.currentTarget)==null||y.click()}),onKeyDown:Mr(t.onKeyDown,f=>{const y=i.searchRef.current!=="";r||y&&f.key===" "||uve.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Tde.displayName=uoe;var TVe=C.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=Bwe(uoe,r),i=jVe(r),c=C.useRef(null),u=Oa(s,c),[p,f]=C.useState(!1),[y,_]=C.useState("");return C.useEffect(()=>{const b=c.current;b&&_((b.textContent??"").trim())},[o.children]),e.jsx(E8.ItemSlot,{scope:r,disabled:n,textValue:a??y,children:e.jsx(Nde,{asChild:!0,...i,focusable:!n,children:e.jsx(Jr.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:u,onPointerMove:Mr(t.onPointerMove,P8(b=>{n?l.onItemLeave(b):(l.onItemEnter(b),b.defaultPrevented||b.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Mr(t.onPointerLeave,P8(b=>l.onItemLeave(b))),onFocus:Mr(t.onFocus,()=>f(!0)),onBlur:Mr(t.onBlur,()=>f(!1))})})})}),pwt="MenuCheckboxItem",AVe=C.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(DVe,{scope:t.__scopeMenu,checked:r,children:e.jsx(Tde,{role:"menuitemcheckbox","aria-checked":hoe(r)?"mixed":r,...a,ref:s,"data-state":Vwe(r),onSelect:Mr(a.onSelect,()=>n==null?void 0:n(hoe(r)?!0:!r),{checkForDefaultPrevented:!1})})})});AVe.displayName=pwt;var EVe="MenuRadioGroup",[fwt,gwt]=GS(EVe,{value:void 0,onValueChange:()=>{}}),PVe=C.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=dd(n);return e.jsx(fwt,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(qwe,{...a,ref:s})})});PVe.displayName=EVe;var IVe="MenuRadioItem",LVe=C.forwardRef((t,s)=>{const{value:r,...n}=t,a=gwt(IVe,t.__scopeMenu),o=r===a.value;return e.jsx(DVe,{scope:t.__scopeMenu,checked:o,children:e.jsx(Tde,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":Vwe(o),onSelect:Mr(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});LVe.displayName=IVe;var Uwe="MenuItemIndicator",[DVe,xwt]=GS(Uwe,{checked:!1}),OVe=C.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=xwt(Uwe,r);return e.jsx(Id,{present:n||hoe(o.checked)||o.checked===!0,children:e.jsx(Jr.span,{...a,ref:s,"data-state":Vwe(o.checked)})})});OVe.displayName=Uwe;var ywt="MenuSeparator",RVe=C.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(Jr.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});RVe.displayName=ywt;var vwt="MenuArrow",FVe=C.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Mde(r);return e.jsx(rO,{...a,...n,ref:s})});FVe.displayName=vwt;var _wt="MenuSub",[x3s,zVe]=GS(_wt),tI="MenuSubTrigger",BVe=C.forwardRef((t,s)=>{const r=KS(tI,t.__scopeMenu),n=cO(tI,t.__scopeMenu),a=zVe(tI,t.__scopeMenu),o=Bwe(tI,t.__scopeMenu),l=C.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:c}=o,u={__scopeMenu:t.__scopeMenu},p=C.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return C.useEffect(()=>p,[p]),C.useEffect(()=>{const f=i.current;return()=>{window.clearTimeout(f),c(null)}},[i,c]),e.jsx(Fwe,{asChild:!0,...u,children:e.jsx(TVe,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":UVe(r.open),...t,ref:y1(s,a.onTriggerChange),onClick:f=>{var y;(y=t.onClick)==null||y.call(t,f),!(t.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Mr(t.onPointerMove,P8(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:Mr(t.onPointerLeave,P8(f=>{var _,b;p();const y=(_=r.content)==null?void 0:_.getBoundingClientRect();if(y){const w=(b=r.content)==null?void 0:b.dataset.side,j=w==="right",N=j?-5:5,S=y[j?"left":"right"],T=y[j?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+N,y:f.clientY},{x:S,y:y.top},{x:T,y:y.top},{x:T,y:y.bottom},{x:S,y:y.bottom}],side:w}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Mr(t.onKeyDown,f=>{var _;const y=o.searchRef.current!=="";t.disabled||y&&f.key===" "||ewt[n.dir].includes(f.key)&&(r.onOpenChange(!0),(_=r.content)==null||_.focus(),f.preventDefault())})})})});BVe.displayName=tI;var $Ve="MenuSubContent",qVe=C.forwardRef((t,s)=>{const r=NVe(vg,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=KS(vg,t.__scopeMenu),l=cO(vg,t.__scopeMenu),i=zVe($Ve,t.__scopeMenu),c=C.useRef(null),u=Oa(s,c);return e.jsx(E8.Provider,{scope:t.__scopeMenu,children:e.jsx(Id,{present:n||o.open,children:e.jsx(E8.Slot,{scope:t.__scopeMenu,children:e.jsx($we,{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:Mr(t.onFocusOutside,p=>{p.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Mr(t.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:Mr(t.onKeyDown,p=>{var _;const f=p.currentTarget.contains(p.target),y=twt[l.dir].includes(p.key);f&&y&&(o.onOpenChange(!1),(_=i.trigger)==null||_.focus(),p.preventDefault())})})})})})});qVe.displayName=$Ve;function UVe(t){return t?"open":"closed"}function hoe(t){return t==="indeterminate"}function Vwe(t){return hoe(t)?"indeterminate":t?"checked":"unchecked"}function bwt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function wwt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function jwt(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=wwt(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 kwt(t,s){const{x:r,y:n}=t;let a=!1;for(let o=0,l=s.length-1;on!=y>n&&r<(f-u)*(n-p)/(y-p)+u&&(a=!a)}return a}function Nwt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return kwt(r,s)}function P8(t){return s=>s.pointerType==="mouse"?t(s):void 0}var Swt=kVe,Cwt=Fwe,Mwt=SVe,Twt=CVe,Awt=qwe,Ewt=MVe,Pwt=Tde,Iwt=AVe,Lwt=PVe,Dwt=LVe,Owt=OVe,Rwt=RVe,Fwt=FVe,zwt=BVe,Bwt=qVe,Ade="DropdownMenu",[$wt]=Yc(Ade,[wVe]),Rm=wVe(),[qwt,VVe]=$wt(Ade),HVe=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,c=Rm(s),u=C.useRef(null),[p,f]=Yu({prop:a,defaultProp:o??!1,onChange:l,caller:Ade});return e.jsx(qwt,{scope:s,triggerId:vu(),triggerRef:u,contentId:vu(),open:p,onOpenChange:f,onOpenToggle:C.useCallback(()=>f(y=>!y),[f]),modal:i,children:e.jsx(Swt,{...c,open:p,onOpenChange:f,dir:n,modal:i,children:r})})};HVe.displayName=Ade;var WVe="DropdownMenuTrigger",GVe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=VVe(WVe,r),l=Rm(r);return e.jsx(Cwt,{asChild:!0,...l,children:e.jsx(Jr.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:y1(s,o.triggerRef),onPointerDown:Mr(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:Mr(t.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});GVe.displayName=WVe;var Uwt="DropdownMenuPortal",KVe=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Rm(s);return e.jsx(Mwt,{...n,...r})};KVe.displayName=Uwt;var ZVe="DropdownMenuContent",YVe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=VVe(ZVe,r),o=Rm(r),l=C.useRef(!1);return e.jsx(Twt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:Mr(t.onCloseAutoFocus,i=>{var c;l.current||(c=a.triggerRef.current)==null||c.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:Mr(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)"}})});YVe.displayName=ZVe;var Vwt="DropdownMenuGroup",Hwt=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Awt,{...a,...n,ref:s})});Hwt.displayName=Vwt;var Wwt="DropdownMenuLabel",XVe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Ewt,{...a,...n,ref:s})});XVe.displayName=Wwt;var Gwt="DropdownMenuItem",QVe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Pwt,{...a,...n,ref:s})});QVe.displayName=Gwt;var Kwt="DropdownMenuCheckboxItem",JVe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Iwt,{...a,...n,ref:s})});JVe.displayName=Kwt;var Zwt="DropdownMenuRadioGroup",Ywt=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Lwt,{...a,...n,ref:s})});Ywt.displayName=Zwt;var Xwt="DropdownMenuRadioItem",eHe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Dwt,{...a,...n,ref:s})});eHe.displayName=Xwt;var Qwt="DropdownMenuItemIndicator",tHe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Owt,{...a,...n,ref:s})});tHe.displayName=Qwt;var Jwt="DropdownMenuSeparator",sHe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Rwt,{...a,...n,ref:s})});sHe.displayName=Jwt;var ejt="DropdownMenuArrow",tjt=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Fwt,{...a,...n,ref:s})});tjt.displayName=ejt;var sjt="DropdownMenuSubTrigger",rHe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(zwt,{...a,...n,ref:s})});rHe.displayName=sjt;var rjt="DropdownMenuSubContent",nHe=C.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Rm(r);return e.jsx(Bwt,{...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)"}})});nHe.displayName=rjt;var njt=HVe,ajt=GVe,ijt=KVe,aHe=YVe,iHe=XVe,oHe=QVe,lHe=JVe,cHe=eHe,dHe=tHe,uHe=sHe,hHe=rHe,mHe=nHe;const ju=njt,ku=ajt,ojt=C.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(hHe,{ref:a,className:At("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",s&&"pl-8",t),...n,children:[r,e.jsx(Xa,{className:"ml-auto h-4 w-4"})]}));ojt.displayName=hHe.displayName;const ljt=C.forwardRef(({className:t,...s},r)=>e.jsx(mHe,{ref:r,className:At("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}));ljt.displayName=mHe.displayName;const Jd=C.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(ijt,{children:e.jsx(aHe,{ref:n,sideOffset:s,className:At("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})}));Jd.displayName=aHe.displayName;const Ta=C.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(oHe,{ref:n,className:At("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",s&&"pl-8",t),...r}));Ta.displayName=oHe.displayName;const cjt=C.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(lHe,{ref:a,className:At("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(dHe,{children:e.jsx(ma,{className:"h-4 w-4"})})}),s]}));cjt.displayName=lHe.displayName;const djt=C.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(cHe,{ref:n,className:At("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(dHe,{children:e.jsx(pd,{className:"h-2 w-2 fill-current"})})}),s]}));djt.displayName=cHe.displayName;const hve=C.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(iHe,{ref:n,className:At("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));hve.displayName=iHe.displayName;const r2=C.forwardRef(({className:t,...s},r)=>e.jsx(uHe,{ref:r,className:At("-mx-1 my-1 h-px bg-muted",t),...s}));r2.displayName=uHe.displayName;const ujt=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:a,setActingAsSelf:o}=Owe();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(ro,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"My Account"})]}):e.jsxs(e.Fragment,{children:[e.jsx(mr,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"Acting as"})]}),e.jsxs(ju,{children:[e.jsx(ku,{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(ro,{className:"h-4 w-4"}),e.jsx("strong",{children:"My Account"})]}):s?e.jsxs(e.Fragment,{children:[e.jsxs(yn,{className:"h-5 w-5",children:[e.jsx(Da,{src:s.avatar_url||void 0}),e.jsx(vn,{className:"text-[10px] bg-primary-foreground/30",children:l(s.name)})]}),e.jsx("strong",{children:s.name})]}):e.jsx("strong",{children:"Select..."}),e.jsx(tl,{className:"h-3 w-3"})]})}),e.jsxs(Jd,{align:"start",className:"z-[2147483647]",children:[e.jsxs(Ta,{onClick:o,className:"gap-2",children:[e.jsx(ro,{className:"h-4 w-4"}),e.jsx("span",{children:"My Account"}),a&&e.jsx(nt,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),e.jsx(r2,{}),r.map(i=>e.jsxs(Ta,{onClick:()=>n(i),className:"gap-2",children:[e.jsxs(yn,{className:"h-6 w-6",children:[e.jsx(Da,{src:i.avatar_url||void 0}),e.jsx(vn,{className:"text-[10px]",children:l(i.name)})]}),e.jsx("span",{children:i.name}),!a&&i.id===(s==null?void 0:s.id)&&e.jsx(nt,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},i.id))]})]})]}),e.jsx(nt,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:a?"Personal Mode":"Assistant Mode"})]})})},cr=({children:t,requireAdmin:s=!1,requireBrokerageManager:r=!1})=>{const{user:n,loading:a,isAdmin:o,isBrokerageManager:l}=Ws();return a?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})}):n?s&&!o?e.jsx(Wfe,{to:"/dashboard",replace:!0}):r&&!l&&!o?e.jsx(Wfe,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t}):e.jsx(Wfe,{to:"/auth",replace:!0})};var Hwe={};(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 we=new OffscreenCanvas(1,1),ye=we.getContext("2d");ye.fillRect(0,0,1,1);var je=we.transferToImageBitmap();ye.createPattern(je,"no-repeat")}catch{return!1}return!0}();function c(){}function u(we){var ye=r.exports.Promise,je=ye!==void 0?ye:s.Promise;return typeof je=="function"?new je(we):(we(c,c),null)}var p=function(we,ye){return{transform:function(je){if(we)return je;if(ye.has(je))return ye.get(je);var ke=new OffscreenCanvas(je.width,je.height),We=ke.getContext("2d");return We.drawImage(je,0,0),ye.set(je,ke),ke},clear:function(){ye.clear()}}}(i,new Map),f=function(){var we=Math.floor(16.666666666666668),ye,je,ke={},We=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(ye=function(be){var Me=Math.random();return ke[Me]=requestAnimationFrame(function Ae(Re){We===Re||We+we-1{const{data:s,error:r}=await G.from("celebration_queue").select("*").eq("user_id",t.id).is("seen_at",null).order("created_at",{ascending:!0});if(r)throw r;return s},enabled:!!(t!=null&&t.id),refetchOnWindowFocus:!0,staleTime:0})}function mjt(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("celebration_queue").update({seen_at:new Date().toISOString()}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}function pjt(){const t=ss(),{user:s}=Ws();return Dt({mutationFn:async r=>{const{error:n}=await G.from("celebration_queue").insert({user_id:r.user_id,celebration_type:r.celebration_type,title:r.title,message:r.message||null,points_amount:r.points_amount||null,created_by:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["celebrations"]})}})}var Ede="Dialog",[pHe,fHe]=Yc(Ede),[fjt,ny]=pHe(Ede),gHe=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=C.useRef(null),c=C.useRef(null),[u,p]=Yu({prop:n,defaultProp:a??!1,onChange:o,caller:Ede});return e.jsx(fjt,{scope:s,triggerRef:i,contentRef:c,contentId:vu(),titleId:vu(),descriptionId:vu(),open:u,onOpenChange:p,onOpenToggle:C.useCallback(()=>p(f=>!f),[p]),modal:l,children:r})};gHe.displayName=Ede;var xHe="DialogTrigger",yHe=C.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=ny(xHe,r),o=Oa(s,a.triggerRef);return e.jsx(Jr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Kwe(a.open),...n,ref:o,onClick:Mr(t.onClick,a.onOpenToggle)})});yHe.displayName=xHe;var Wwe="DialogPortal",[gjt,vHe]=pHe(Wwe,{forceMount:void 0}),_He=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=ny(Wwe,s);return e.jsx(gjt,{scope:s,forceMount:r,children:C.Children.map(n,l=>e.jsx(Id,{present:r||o.open,children:e.jsx(vA,{asChild:!0,container:a,children:l})}))})};_He.displayName=Wwe;var moe="DialogOverlay",bHe=C.forwardRef((t,s)=>{const r=vHe(moe,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=ny(moe,t.__scopeDialog);return o.modal?e.jsx(Id,{present:n||o.open,children:e.jsx(yjt,{...a,ref:s})}):null});bHe.displayName=moe;var xjt=e2("DialogOverlay.RemoveScroll"),yjt=C.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=ny(moe,r);return e.jsx(oO,{as:xjt,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(Jr.div,{"data-state":Kwe(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),yS="DialogContent",wHe=C.forwardRef((t,s)=>{const r=vHe(yS,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=ny(yS,t.__scopeDialog);return e.jsx(Id,{present:n||o.open,children:o.modal?e.jsx(vjt,{...a,ref:s}):e.jsx(_jt,{...a,ref:s})})});wHe.displayName=yS;var vjt=C.forwardRef((t,s)=>{const r=ny(yS,t.__scopeDialog),n=C.useRef(null),a=Oa(s,r.contentRef,n);return C.useEffect(()=>{const o=n.current;if(o)return Sde(o)},[]),e.jsx(jHe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Mr(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Mr(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:Mr(t.onFocusOutside,o=>o.preventDefault())})}),_jt=C.forwardRef((t,s)=>{const r=ny(yS,t.__scopeDialog),n=C.useRef(!1),a=C.useRef(!1);return e.jsx(jHe,{...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()}})}),jHe=C.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=ny(yS,r),c=C.useRef(null),u=Oa(s,c);return jde(),e.jsxs(e.Fragment,{children:[e.jsx(aO,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(g2,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":Kwe(i.open),...l,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(wjt,{titleId:i.titleId}),e.jsx(kjt,{contentRef:c,descriptionId:i.descriptionId})]})]})}),Gwe="DialogTitle",kHe=C.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=ny(Gwe,r);return e.jsx(Jr.h2,{id:a.titleId,...n,ref:s})});kHe.displayName=Gwe;var NHe="DialogDescription",SHe=C.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=ny(NHe,r);return e.jsx(Jr.p,{id:a.descriptionId,...n,ref:s})});SHe.displayName=NHe;var CHe="DialogClose",MHe=C.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=ny(CHe,r);return e.jsx(Jr.button,{type:"button",...n,ref:s,onClick:Mr(t.onClick,()=>a.onOpenChange(!1))})});MHe.displayName=CHe;function Kwe(t){return t?"open":"closed"}var THe="DialogTitleWarning",[bjt,AHe]=rft(THe,{contentName:yS,titleName:Gwe,docsSlug:"dialog"}),wjt=({titleId:t})=>{const s=AHe(THe),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 C.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},jjt="DialogDescriptionWarning",kjt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${AHe(jjt).contentName}}.`;return C.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},Pde=gHe,Zwe=yHe,Ide=_He,TA=bHe,AA=wHe,dO=kHe,uO=SHe,hO=MHe;const _s=Pde,Fi=Zwe,Njt=Ide,y3s=hO,EHe=C.forwardRef(({className:t,...s},r)=>e.jsx(TA,{ref:r,className:At("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}));EHe.displayName=TA.displayName;const vs=C.forwardRef(({className:t,children:s,overlayClassName:r,...n},a)=>e.jsxs(Njt,{children:[e.jsx(EHe,{className:r}),e.jsxs(AA,{ref:a,className:At("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(hO,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(Ur,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));vs.displayName=AA.displayName;const Cs=({className:t,...s})=>e.jsx("div",{className:At("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});Cs.displayName="DialogHeader";const Vn=({className:t,...s})=>e.jsx("div",{className:At("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Vn.displayName="DialogFooter";const Ns=C.forwardRef(({className:t,...s},r)=>e.jsx(dO,{ref:r,className:At("text-lg font-semibold leading-none tracking-tight",t),...s}));Ns.displayName=dO.displayName;const Zr=C.forwardRef(({className:t,...s},r)=>e.jsx(uO,{ref:r,className:At("text-sm text-muted-foreground",t),...s}));Zr.displayName=uO.displayName;const Sjt={points_earned:mo,listing_created:Rn,deal_closed:Td,custom:Kn},SEe={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"},CEe=()=>{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 Cjt(){const{user:t}=Ws(),s=ss(),{data:r}=hjt(),n=mjt(),[a,o]=C.useState(null),[l,i]=C.useState(!1),c=C.useCallback(()=>{const _=Date.now()+3e3,b={startVelocity:30,spread:360,ticks:60,zIndex:9999},w=(N,S)=>Math.random()*(S-N)+N,j=setInterval(()=>{const N=_-Date.now();if(N<=0){clearInterval(j);return}const S=50*(N/3e3);NEe({...b,particleCount:S,origin:{x:w(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),NEe({...b,particleCount:S,origin:{x:w(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);C.useEffect(()=>{CEe()||r&&r.length>0&&!a&&(o(r[0]),i(!0),setTimeout(c,100))},[r,a,c]);const u=async()=>{if(a){const y=a.id;i(!1),o(null),s.setQueryData(["celebrations","pending",t==null?void 0:t.id],_=>(_==null?void 0:_.filter(b=>b.id!==y))??[]),await n.mutateAsync(y)}};if(CEe()||!a)return null;const p=Sjt[a.celebration_type]||Kn,f=SEe[a.celebration_type]||SEe.custom;return e.jsx(_s,{open:l,onOpenChange:y=>!y&&u(),children:e.jsxs(vs,{className:"sm:max-w-md text-center border-0 overflow-hidden",children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${f} opacity-10`}),e.jsxs("div",{className:"relative z-10 py-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:`w-20 h-20 rounded-full bg-gradient-to-br ${f} flex items-center justify-center animate-bounce`,children:e.jsx(p,{className:"w-10 h-10 text-white"})})}),e.jsxs("div",{className:"flex justify-center gap-1 mb-4",children:[e.jsx(hn,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx(hn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx(hn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-150"})]}),e.jsxs("h2",{className:"text-2xl font-bold mb-2 bg-gradient-to-r from-primary to-secondary bg-clip-text text-transparent",children:["🎉 ",a.title]}),a.points_amount&&a.points_amount>0&&e.jsxs("div",{className:"text-4xl font-bold text-primary mb-2",children:["+",a.points_amount," points!"]}),a.message&&e.jsx("p",{className:"text-muted-foreground mb-6",children:a.message}),e.jsx(K,{onClick:u,className:"w-full",size:"lg",children:"Awesome! 🙌"}),r&&r.length>1&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-3",children:["+",r.length-1," more celebration",r.length>2?"s":""," waiting"]})]})]})})}const PHe="/assets/levelup-logo-horizontal-DEFNc0ms.png",Ywe="/assets/levelup-logo-white-C2RAgAoG.png",Mjt="/assets/listings-hero-BI9Ki9Dq.jpg",Fe=C.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:At("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}));Fe.displayName="Input";var IHe={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(Fv,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(g,d){var m=d[0],v=d[1],k=d[2],E=d[3],P=m*E-k*v;return P?(g[0]=E*(P=1/P),g[1]=-v*P,g[2]=-k*P,g[3]=m*P,g):null}function f(){var g=new u(9);return u!=Float32Array&&(g[1]=0,g[2]=0,g[3]=0,g[5]=0,g[6]=0,g[7]=0),g[0]=1,g[4]=1,g[8]=1,g}function y(g,d){var m=d[0],v=d[1],k=d[2],E=d[3],P=d[4],O=d[5],B=d[6],W=d[7],J=d[8];return g[0]=P*J-O*W,g[1]=k*W-v*J,g[2]=v*O-k*P,g[3]=O*B-E*J,g[4]=m*J-k*B,g[5]=k*E-m*O,g[6]=E*W-P*B,g[7]=v*B-m*W,g[8]=m*P-v*E,g}function _(g,d,m){var v=d[0],k=d[1],E=d[2],P=d[3],O=d[4],B=d[5],W=d[6],J=d[7],te=d[8],ie=m[0],ce=m[1],ue=m[2],Ne=m[3],Le=m[4],Ie=m[5],Ge=m[6],Ze=m[7],at=m[8];return g[0]=ie*v+ce*P+ue*W,g[1]=ie*k+ce*O+ue*J,g[2]=ie*E+ce*B+ue*te,g[3]=Ne*v+Le*P+Ie*W,g[4]=Ne*k+Le*O+Ie*J,g[5]=Ne*E+Le*B+Ie*te,g[6]=Ge*v+Ze*P+at*W,g[7]=Ge*k+Ze*O+at*J,g[8]=Ge*E+Ze*B+at*te,g}function b(){var g=new u(16);return u!=Float32Array&&(g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[11]=0,g[12]=0,g[13]=0,g[14]=0),g[0]=1,g[5]=1,g[10]=1,g[15]=1,g}function w(g){var d=new u(16);return d[0]=g[0],d[1]=g[1],d[2]=g[2],d[3]=g[3],d[4]=g[4],d[5]=g[5],d[6]=g[6],d[7]=g[7],d[8]=g[8],d[9]=g[9],d[10]=g[10],d[11]=g[11],d[12]=g[12],d[13]=g[13],d[14]=g[14],d[15]=g[15],d}function j(g){return g[0]=1,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=1,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=1,g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,g}function N(g,d){var m=d[0],v=d[1],k=d[2],E=d[3],P=d[4],O=d[5],B=d[6],W=d[7],J=d[8],te=d[9],ie=d[10],ce=d[11],ue=d[12],Ne=d[13],Le=d[14],Ie=d[15],Ge=m*O-v*P,Ze=m*B-k*P,at=m*W-E*P,vt=v*B-k*O,pt=v*W-E*O,St=k*W-E*B,Lt=J*Ne-te*ue,Bt=J*Le-ie*ue,as=J*Ie-ce*ue,Wt=te*Le-ie*Ne,us=te*Ie-ce*Ne,bs=ie*Ie-ce*Le,ws=Ge*bs-Ze*us+at*Wt+vt*as-pt*Bt+St*Lt;return ws?(g[0]=(O*bs-B*us+W*Wt)*(ws=1/ws),g[1]=(k*us-v*bs-E*Wt)*ws,g[2]=(Ne*St-Le*pt+Ie*vt)*ws,g[3]=(ie*pt-te*St-ce*vt)*ws,g[4]=(B*as-P*bs-W*Bt)*ws,g[5]=(m*bs-k*as+E*Bt)*ws,g[6]=(Le*at-ue*St-Ie*Ze)*ws,g[7]=(J*St-ie*at+ce*Ze)*ws,g[8]=(P*us-O*as+W*Lt)*ws,g[9]=(v*as-m*us-E*Lt)*ws,g[10]=(ue*pt-Ne*at+Ie*Ge)*ws,g[11]=(te*at-J*pt-ce*Ge)*ws,g[12]=(O*Bt-P*Wt-B*Lt)*ws,g[13]=(m*Wt-v*Bt+k*Lt)*ws,g[14]=(Ne*Ze-ue*vt-Le*Ge)*ws,g[15]=(J*vt-te*Ze+ie*Ge)*ws,g):null}function S(g,d,m){var v=d[0],k=d[1],E=d[2],P=d[3],O=d[4],B=d[5],W=d[6],J=d[7],te=d[8],ie=d[9],ce=d[10],ue=d[11],Ne=d[12],Le=d[13],Ie=d[14],Ge=d[15],Ze=m[0],at=m[1],vt=m[2],pt=m[3];return g[0]=Ze*v+at*O+vt*te+pt*Ne,g[1]=Ze*k+at*B+vt*ie+pt*Le,g[2]=Ze*E+at*W+vt*ce+pt*Ie,g[3]=Ze*P+at*J+vt*ue+pt*Ge,g[4]=(Ze=m[4])*v+(at=m[5])*O+(vt=m[6])*te+(pt=m[7])*Ne,g[5]=Ze*k+at*B+vt*ie+pt*Le,g[6]=Ze*E+at*W+vt*ce+pt*Ie,g[7]=Ze*P+at*J+vt*ue+pt*Ge,g[8]=(Ze=m[8])*v+(at=m[9])*O+(vt=m[10])*te+(pt=m[11])*Ne,g[9]=Ze*k+at*B+vt*ie+pt*Le,g[10]=Ze*E+at*W+vt*ce+pt*Ie,g[11]=Ze*P+at*J+vt*ue+pt*Ge,g[12]=(Ze=m[12])*v+(at=m[13])*O+(vt=m[14])*te+(pt=m[15])*Ne,g[13]=Ze*k+at*B+vt*ie+pt*Le,g[14]=Ze*E+at*W+vt*ce+pt*Ie,g[15]=Ze*P+at*J+vt*ue+pt*Ge,g}function T(g,d,m){var v,k,E,P,O,B,W,J,te,ie,ce,ue,Ne=m[0],Le=m[1],Ie=m[2];return d===g?(g[12]=d[0]*Ne+d[4]*Le+d[8]*Ie+d[12],g[13]=d[1]*Ne+d[5]*Le+d[9]*Ie+d[13],g[14]=d[2]*Ne+d[6]*Le+d[10]*Ie+d[14],g[15]=d[3]*Ne+d[7]*Le+d[11]*Ie+d[15]):(k=d[1],E=d[2],P=d[3],O=d[4],B=d[5],W=d[6],J=d[7],te=d[8],ie=d[9],ce=d[10],ue=d[11],g[0]=v=d[0],g[1]=k,g[2]=E,g[3]=P,g[4]=O,g[5]=B,g[6]=W,g[7]=J,g[8]=te,g[9]=ie,g[10]=ce,g[11]=ue,g[12]=v*Ne+O*Le+te*Ie+d[12],g[13]=k*Ne+B*Le+ie*Ie+d[13],g[14]=E*Ne+W*Le+ce*Ie+d[14],g[15]=P*Ne+J*Le+ue*Ie+d[15]),g}function I(g,d,m){var v=m[0],k=m[1],E=m[2];return g[0]=d[0]*v,g[1]=d[1]*v,g[2]=d[2]*v,g[3]=d[3]*v,g[4]=d[4]*k,g[5]=d[5]*k,g[6]=d[6]*k,g[7]=d[7]*k,g[8]=d[8]*E,g[9]=d[9]*E,g[10]=d[10]*E,g[11]=d[11]*E,g[12]=d[12],g[13]=d[13],g[14]=d[14],g[15]=d[15],g}function L(g,d,m){var v=Math.sin(m),k=Math.cos(m),E=d[4],P=d[5],O=d[6],B=d[7],W=d[8],J=d[9],te=d[10],ie=d[11];return d!==g&&(g[0]=d[0],g[1]=d[1],g[2]=d[2],g[3]=d[3],g[12]=d[12],g[13]=d[13],g[14]=d[14],g[15]=d[15]),g[4]=E*k+W*v,g[5]=P*k+J*v,g[6]=O*k+te*v,g[7]=B*k+ie*v,g[8]=W*k-E*v,g[9]=J*k-P*v,g[10]=te*k-O*v,g[11]=ie*k-B*v,g}function R(g,d,m){var v=Math.sin(m),k=Math.cos(m),E=d[0],P=d[1],O=d[2],B=d[3],W=d[8],J=d[9],te=d[10],ie=d[11];return d!==g&&(g[4]=d[4],g[5]=d[5],g[6]=d[6],g[7]=d[7],g[12]=d[12],g[13]=d[13],g[14]=d[14],g[15]=d[15]),g[0]=E*k-W*v,g[1]=P*k-J*v,g[2]=O*k-te*v,g[3]=B*k-ie*v,g[8]=E*v+W*k,g[9]=P*v+J*k,g[10]=O*v+te*k,g[11]=B*v+ie*k,g}function $(g,d,m){var v=Math.sin(m),k=Math.cos(m),E=d[0],P=d[1],O=d[2],B=d[3],W=d[4],J=d[5],te=d[6],ie=d[7];return d!==g&&(g[8]=d[8],g[9]=d[9],g[10]=d[10],g[11]=d[11],g[12]=d[12],g[13]=d[13],g[14]=d[14],g[15]=d[15]),g[0]=E*k+W*v,g[1]=P*k+J*v,g[2]=O*k+te*v,g[3]=B*k+ie*v,g[4]=W*k-E*v,g[5]=J*k-P*v,g[6]=te*k-O*v,g[7]=ie*k-B*v,g}function q(g,d){return g[0]=d[0],g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=d[1],g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=d[2],g[11]=0,g[12]=0,g[13]=0,g[14]=0,g[15]=1,g}function U(g,d,m){var v,k,E,P=m[0],O=m[1],B=m[2],W=Math.sqrt(P*P+O*O+B*B);return W0&&(E=1/Math.sqrt(E)),g[0]=d[0]*E,g[1]=d[1]*E,g[2]=d[2]*E,g}function qe(g,d){return g[0]*d[0]+g[1]*d[1]+g[2]*d[2]}function ct(g,d,m){var v=d[0],k=d[1],E=d[2],P=m[0],O=m[1],B=m[2];return g[0]=k*B-E*O,g[1]=E*P-v*B,g[2]=v*O-k*P,g}function De(g,d,m,v){var k=d[0],E=d[1],P=d[2];return g[0]=k+v*(m[0]-k),g[1]=E+v*(m[1]-E),g[2]=P+v*(m[2]-P),g}function Rt(g,d,m){var v=d[0],k=d[1],E=d[2],P=m[3]*v+m[7]*k+m[11]*E+m[15];return g[0]=(m[0]*v+m[4]*k+m[8]*E+m[12])/(P=P||1),g[1]=(m[1]*v+m[5]*k+m[9]*E+m[13])/P,g[2]=(m[2]*v+m[6]*k+m[10]*E+m[14])/P,g}function pe(g,d,m){var v=d[0],k=d[1],E=d[2];return g[0]=v*m[0]+k*m[3]+E*m[6],g[1]=v*m[1]+k*m[4]+E*m[7],g[2]=v*m[2]+k*m[5]+E*m[8],g}function Je(g,d,m){var v=m[0],k=m[1],E=m[2],P=m[3],O=d[0],B=d[1],W=d[2],J=k*W-E*B,te=E*O-v*W,ie=v*B-k*O;return g[0]=O+P*(J+=J)+k*(ie+=ie)-E*(te+=te),g[1]=B+P*te+E*J-v*ie,g[2]=W+P*ie+v*te-k*J,g}function lt(g){return g[0]=0,g[1]=0,g[2]=0,g}function rt(g,d){return g[0]===d[0]&&g[1]===d[1]&&g[2]===d[2]}var Se=he,it=we,$e=de;function ot(){var g=new u(4);return u!=Float32Array&&(g[0]=0,g[1]=0,g[2]=0,g[3]=0),g}function Ue(g,d,m){return g[0]=d[0]*m,g[1]=d[1]*m,g[2]=d[2]*m,g[3]=d[3]*m,g}function Ke(g,d){var m=d[0],v=d[1],k=d[2],E=d[3],P=m*m+v*v+k*k+E*E;return P>0&&(P=1/Math.sqrt(P)),g[0]=m*P,g[1]=v*P,g[2]=k*P,g[3]=E*P,g}function Xe(g,d,m){var v=d[0],k=d[1],E=d[2],P=d[3];return g[0]=m[0]*v+m[4]*k+m[8]*E+m[12]*P,g[1]=m[1]*v+m[5]*k+m[9]*E+m[13]*P,g[2]=m[2]*v+m[6]*k+m[10]*E+m[14]*P,g[3]=m[3]*v+m[7]*k+m[11]*E+m[15]*P,g}function He(){var g=new u(4);return u!=Float32Array&&(g[0]=0,g[1]=0,g[2]=0),g[3]=1,g}function Ye(g){return g[0]=0,g[1]=0,g[2]=0,g[3]=1,g}function tt(g,d,m){m*=.5;var v=d[0],k=d[1],E=d[2],P=d[3],O=Math.sin(m),B=Math.cos(m);return g[0]=v*B+P*O,g[1]=k*B+E*O,g[2]=E*B-k*O,g[3]=P*B-v*O,g}function Et(g,d,m){m*=.5;var v=d[0],k=d[1],E=d[2],P=d[3],O=Math.sin(m),B=Math.cos(m);return g[0]=v*B-E*O,g[1]=k*B+P*O,g[2]=E*B+v*O,g[3]=P*B-k*O,g}ee(),ot();var qt,ms,Xt,rs=Ke,ps=(qt=ee(),ms=re(1,0,0),Xt=re(0,1,0),function(g,d,m){var v=qe(d,m);return v<-.999999?(ct(qt,ms,d),$e(qt)<1e-6&&ct(qt,Xt,d),Te(qt,qt),function(k,E,P){P*=.5;var O=Math.sin(P);k[0]=O*E[0],k[1]=O*E[1],k[2]=O*E[2],k[3]=Math.cos(P)}(g,qt,Math.PI),g):v>.999999?(g[0]=0,g[1]=0,g[2]=0,g[3]=1,g):(ct(qt,d,m),g[0]=qt[0],g[1]=qt[1],g[2]=qt[2],g[3]=1+v,rs(g,g))});function Ms(){var g=new u(2);return u!=Float32Array&&(g[0]=0,g[1]=0),g}function jt(g,d){var m=new u(2);return m[0]=g,m[1]=d,m}function As(g,d,m){return g[0]=d,g[1]=m,g}function Ps(g,d,m){return g[0]=d[0]+m[0],g[1]=d[1]+m[1],g}function ar(g,d,m){return g[0]=d[0]-m[0],g[1]=d[1]-m[1],g}function Dn(g,d,m){return g[0]=d[0]*m,g[1]=d[1]*m,g}function Va(g){var d=g[0],m=g[1];return Math.sqrt(d*d+m*m)}function pa(g,d){var m=d[0],v=d[1],k=m*m+v*v;return k>0&&(k=1/Math.sqrt(k)),g[0]=d[0]*k,g[1]=d[1]*k,g}function qa(g,d){return g[0]*d[0]+g[1]*d[1]}He(),He(),f();var Kr,Yn,mn=ar;function Gn(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}Ms();var Zt=function(){if(Yn)return Kr;function g(d,m,v,k){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*(k-m)-this.cy,this.ay=1-this.cy-this.by,this.p1x=d,this.p1y=m,this.p2x=v,this.p2y=k}return Yn=1,Kr=g,g.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,k=0;k<8;k++){var E=this.sampleCurveX(v)-d;if(Math.abs(E)E?O=v:B=v,v=.5*(B-O)+O;return v},solve:function(d,m){return this.sampleCurveY(this.solveCurveX(d,m))}},Kr}(),$r=Gn(Zt);function es(g,d){this.x=g,this.y=d}function an(g,d){if(Array.isArray(g)){if(!Array.isArray(d)||g.length!==d.length)return!1;for(let m=0;m=1)return 1;const d=g*g,m=d*g;return 4*(g<.5?m:3*(g-d)+m-.75)}function sc(g,d,m,v){const k=new $r(g,d,m,v);return function(E){return k.solve(E)}}const Vt=sc(.25,.1,.25,1);function ve(g,d,m){return Math.min(m,Math.max(d,g))}function ze(g,d,m){return(m=ve((m-g)/(d-g),0,1))*m*(3-2*m)}function Qe(g,d,m){const v=m-d,k=((g-d)%v+v)%v+d;return k===d?m:k}function Ct(g,d,m){if(!g.length)return m(null,[]);let v=g.length;const k=new Array(g.length);let E=null;g.forEach((P,O)=>{d(P,(B,W)=>{B&&(E=B),k[O]=W,--v==0&&m(E,k)})})}let Nt=1;function zt(){return Nt++}function Kt(g){return g<=1?1:Math.pow(2,Math.ceil(Math.log2(g)))}function $t(g,d){g.forEach(m=>{d[m]&&(d[m]=d[m].bind(d))})}function Qt(g,d,m){const v={};for(const k in g)v[k]=d.call(this,g[k],k,g);return v}function Is(g,d,m){const v={};for(const k in g)d.call(this,g[k],k,g)&&(v[k]=g[k]);return v}function gs(g){return Array.isArray(g)?g.map(gs):typeof g=="object"&&g?Qt(g,gs):g}function gr(g,d){for(let m=0;m=0)return!0;return!1}const qr={};function hr(g){qr[g]||(typeof console<"u"&&console.warn(g),qr[g]=!0)}function Cn(g,d,m){return(m.y-g.y)*(d.x-g.x)>(d.y-g.y)*(m.x-g.x)}function Mn(g){let d=0;for(let m,v,k=0,E=g.length,P=E-1;k@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(m,v,k,E)=>{const P=k||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 Qo=null;function Qa(g,d){return[g[4*d],g[4*d+1],g[4*d+2],g[4*d+3]]}function nl(g,d,m,v){for(;d>1;g[k]>1;g[k]<=v?d=k+1:m=k}return d}function Na(g){return g>0?1/(1.001-g):1+g}function ao(g){return g>0?1-1/(1.001-g):-g}function Si(g,d,m){return(g-d.min)*(m.max-m.min)/(d.max-d.min)+m.min}const aa={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(!aa.API_URL)return null;try{const g=new URL(aa.API_URL);return g.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":g.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"https://api.mapbox.com/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function io(g){return aa.API_URL_REGEX.test(g)}function yc(g){return aa.API_SPRITE_REGEX.test(g)}let Lc,eu,Cf,El,th,yd;function zm(){return Lc==null&&(Lc=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Lc}const Pl={now:()=>El!==void 0?El:performance.now(),setNow(g){El=g},restoreNow(){El=void 0},frame(g){const d=requestAnimationFrame(g);return{cancel:()=>cancelAnimationFrame(d)}},getImageData(g,d=0){const{width:m,height:v}=g;th||(th=document.createElement("canvas"));const k=th.getContext("2d",{willReadFrequently:!0});if(!k)throw new Error("failed to create canvas 2d context");return(m>th.width||v>th.height)&&(th.width=m,th.height=v),k.clearRect(-d,-d,m+2*d,v+2*d),k.drawImage(g,0,0,m,v),k.getImageData(-d,-d,m+2*d,v+2*d)},resolveURL:g=>(eu||(eu=document.createElement("a")),eu.href=g,eu.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(Cf==null&&(Cf=window.matchMedia("(prefers-reduced-motion: reduce)")),Cf.matches)},hasCanvasFingerprintNoise(){if(yd!==void 0)return yd;if(!zm())return yd=!1,!1;const g=new OffscreenCanvas(85,1),d=g.getContext("2d",{willReadFrequently:!0});let m=0;for(let k=0;k0?`?${E}`:""}`}const D1="mapbox-tiles";let O1=500,R1=50;const Tp=["language","worldview","jobid"];let Qh,tu;function Jh(){try{return caches}catch{}}function Ld(){const g=Jh();g&&Qh==null&&(Qh=g.open(D1))}let vd=1/0;const su={supported:!1,testSupport:function(g){!Bm&&Tf&&($m?$0(g):Mf=g)}};let Mf,Tf,Bm=!1,$m=!1;const _d=typeof self<"u"?self:{};function $0(g){const d=g.createTexture();g.bindTexture(g.TEXTURE_2D,d);try{if(g.texImage2D(g.TEXTURE_2D,0,g.RGBA,g.RGBA,g.UNSIGNED_BYTE,Tf),g.isContextLost())return;su.supported=!0}catch{}g.deleteTexture(d),Bm=!0}_d.document&&(Tf=_d.document.createElement("img"),Tf.onload=function(){Mf&&$0(Mf),Mf=null,$m=!0},Tf.onerror=function(){Bm=!0,Mf=null},Tf.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Ug={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(Ug);class jl extends Error{constructor(d,m,v){m===401&&io(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 F1=fa()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Vg=function(g,d){if(!(/^file:/.test(m=g.url)||/^file:/.test(F1())&&!/^\w+:/.test(m))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(v,k){const E=new AbortController,P=new Request(v.url,{method:v.method||"GET",body:v.body,credentials:v.credentials,headers:v.headers,referrer:F1(),referrerPolicy:v.referrerPolicy,signal:E.signal});let O=!1,B=!1;const W=(J=P.url).indexOf("sku=")>0&&io(J);var J;v.type==="json"&&P.headers.set("Accept","application/json");const te=(ce,ue,Ne)=>{if(B)return;if(ce&&ce.message!=="SecurityError"&&hr(ce.toString()),ue&&Ne)return ie(ue);const Le=Date.now();fetch(P).then(Ie=>{if(Ie.ok){const Ge=W?Ie.clone():null;return ie(Ie,Ge,Le)}return k(new jl(Ie.statusText,Ie.status,v.url))}).catch(Ie=>{Ie.name!=="AbortError"&&k(new Error(`${Ie.message} ${v.url}`))})},ie=(ce,ue,Ne)=>{(v.type==="arrayBuffer"?ce.arrayBuffer():v.type==="json"?ce.json():ce.text()).then(Le=>{B||(ue&&Ne&&function(Ie,Ge,Ze){if(Ld(),Qh==null)return;const at=go(Ge.headers.get("Cache-Control")||"");if(at["no-store"])return;const vt={status:Ge.status,statusText:Ge.statusText,headers:new Headers};Ge.headers.forEach((Lt,Bt)=>vt.headers.set(Bt,Lt)),at["max-age"]&&vt.headers.set("Expires",new Date(Ze+1e3*at["max-age"]).toUTCString());const pt=vt.headers.get("Expires");if(!pt||new Date(pt).getTime()-Ze<42e4)return;let St=uy(Ie.url,{persistentParams:Tp});if(Ge.status===206){const Lt=Ie.headers.get("Range");if(!Lt)return;vt.status=200,St=qg(St,{range:Lt})}(function(Lt,Bt){if(tu===void 0)try{new Response(new ReadableStream),tu=!0}catch{tu=!1}tu?Bt(Lt.body):Lt.blob().then(Bt).catch(as=>hr(as.message))})(Ge,Lt=>{const Bt=new Response((as=Ge.status)!==200&&as!==404&&[101,103,204,205,304].includes(as)?null:Lt,vt);var as;Ld(),Qh!=null&&Qh.then(Wt=>Wt.put(St,Bt)).catch(Wt=>hr(Wt.message))})}(P,ue,Ne),O=!0,k(null,Le,ce.headers))}).catch(Le=>{B||k(new Error(Le.message))})};return W?function(ce,ue){if(Ld(),Qh==null)return ue(null);Qh.then(Ne=>{let Le=uy(ce.url,{persistentParams:Tp});const Ie=ce.headers.get("Range");Ie&&(Le=qg(Le,{range:Ie})),Ne.match(Le).then(Ge=>{const Ze=function(at){if(!at)return!1;const vt=new Date(at.headers.get("Expires")||0),pt=go(at.headers.get("Cache-Control")||"");return Number(vt)>Date.now()&&!pt["no-cache"]}(Ge);Ne.delete(Le).catch(ue),Ze&&Ne.put(Le,Ge.clone()).catch(ue),ue(null,Ge,Ze)}).catch(ue)}).catch(ue)}(P,te):te(null,null),{cancel:()=>{B=!0,O||E.abort()}}}(g,d);if(fa(self)&&self.worker.actor)return self.worker.actor.send("getResource",g,d,void 0,!0)}var m;return function(v,k){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=()=>{k(new Error(E.statusText))},E.onload=()=>{if((E.status>=200&&E.status<300||E.status===0)&&E.response!==null){let P=E.response;if(v.type==="json")try{P=JSON.parse(E.response)}catch(B){return k(B)}const O=new Headers;E.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(B=>{const W=B.split(": "),J=W.shift(),te=W.join(": ");O.append(J,te)}),k(null,P,O)}else k(new jl(E.statusText,E.status,v.url))},E.send(v.body),{cancel:()=>E.abort()}}(g,d)},jh=function(g,d){return Vg(Object.assign(g,{type:"arrayBuffer"}),d)};function R2(g){const d=document.createElement("a");return d.href=g,d.protocol===location.protocol&&d.host===location.host}const lC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let q0,Sa;q0=[],Sa=0;const hy=function(g,d){if(su.supported&&(g.headers||(g.headers={}),g.headers.accept="image/webp,*/*"),Sa>=aa.MAX_PARALLEL_IMAGE_REQUESTS){const E={requestParameters:g,callback:d,cancelled:!1,cancel(){this.cancelled=!0}};return q0.push(E),E}Sa++;let m=!1;const v=()=>{if(!m)for(m=!0,Sa--;q0.length&&Sa{v(),E?d(E):P&&(self.createImageBitmap?function(B,W){const J=new Blob([new Uint8Array(B)],{type:"image/png"});createImageBitmap(J).then(te=>{W(null,te)}).catch(te=>{W(new Error(`Could not load image because of ${te.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(P,(B,W)=>d(B,W,O)):function(B,W){const J=new Image;J.onload=()=>{W(null,J),URL.revokeObjectURL(J.src),J.onload=null,requestAnimationFrame(()=>{J.src=lC})},J.onerror=()=>W(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const te=new Blob([new Uint8Array(B)],{type:"image/png"});J.src=B.byteLength?URL.createObjectURL(te):lC}(P,(B,W)=>d(B,W,O)))});return{cancel:()=>{k.cancel(),v()}}};var F2,cC,dC,em={exports:{}},U0={exports:{}},V0={exports:{}},z2=function(){if(dC)return em.exports;dC=1;var g=(F2||(F2=1,U0.exports=function(m,v){var k,E,P,O,B,W,J,te;for(E=m.length-(k=3&m.length),P=v,B=3432918353,W=461845907,te=0;te>>16)*B&65535)<<16)&4294967295)<<15|J>>>17))*W+(((J>>>16)*W&65535)<<16)&4294967295)<<13|P>>>19))+((5*(P>>>16)&65535)<<16)&4294967295))+((58964+(O>>>16)&65535)<<16);switch(J=0,k){case 3:J^=(255&m.charCodeAt(te+2))<<16;case 2:J^=(255&m.charCodeAt(te+1))<<8;case 1:P^=J=(65535&(J=(J=(65535&(J^=255&m.charCodeAt(te)))*B+(((J>>>16)*B&65535)<<16)&4294967295)<<15|J>>>17))*W+(((J>>>16)*W&65535)<<16)&4294967295}return P^=m.length,P=2246822507*(65535&(P^=P>>>16))+((2246822507*(P>>>16)&65535)<<16)&4294967295,P=3266489909*(65535&(P^=P>>>13))+((3266489909*(P>>>16)&65535)<<16)&4294967295,(P^=P>>>16)>>>0}),U0.exports),d=(cC||(cC=1,V0.exports=function(m,v){for(var k,E=m.length,P=v^E,O=0;E>=4;)k=1540483477*(65535&(k=255&m.charCodeAt(O)|(255&m.charCodeAt(++O))<<8|(255&m.charCodeAt(++O))<<16|(255&m.charCodeAt(++O))<<24))+((1540483477*(k>>>16)&65535)<<16),P=1540483477*(65535&P)+((1540483477*(P>>>16)&65535)<<16)^(k=1540483477*(65535&(k^=k>>>24))+((1540483477*(k>>>16)&65535)<<16)),E-=4,++O;switch(E){case 3:P^=(255&m.charCodeAt(O+2))<<16;case 2:P^=(255&m.charCodeAt(O+1))<<8;case 1:P=1540483477*(65535&(P^=255&m.charCodeAt(O)))+((1540483477*(P>>>16)&65535)<<16)}return P=1540483477*(65535&(P^=P>>>13))+((1540483477*(P>>>16)&65535)<<16),(P^=P>>>15)>>>0}),V0.exports);return em.exports=g,em.exports.murmur3=g,em.exports.murmur2=d,em.exports}(),z1=Gn(z2);class qm{constructor(d,...m){Object.assign(this,m[0]||{}),this.type=d}}class my extends qm{constructor(d,m={}){super("error",Object.assign({error:d},m))}}function B2(g,d,m){m[g]&&m[g].indexOf(d)!==-1||(m[g]=m[g]||[],m[g].push(d))}function xt(g,d,m){if(m&&m[g]){const v=m[g].indexOf(d);v!==-1&&m[g].splice(v,1)}}class Ts{on(d,m){return this._listeners=this._listeners||{},B2(d,m,this._listeners),this}off(d,m){return xt(d,m,this._listeners),xt(d,m,this._oneTimeListeners),this}once(d,m){return m?(this._oneTimeListeners=this._oneTimeListeners||{},B2(d,m,this._oneTimeListeners),this):new Promise(v=>{this.once(d,v)})}fire(d,m){const v=typeof d=="string"?new qm(d,m):d,k=v.type;if(this.listens(k)){v.target=this;const E=this._listeners&&this._listeners[k]?this._listeners[k].slice():[];for(const B of E)B.call(this,v);const P=this._oneTimeListeners&&this._oneTimeListeners[k]?this._oneTimeListeners[k].slice():[];for(const B of P)xt(k,B,this._oneTimeListeners),B.call(this,v);const O=this._eventedParent;if(O){const B=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(v,B),O.fire(v)}}else v instanceof my&&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 Ys{constructor(d){typeof d=="string"?this.name=d:(this.name=d.name,this.iconsetId=d.iconsetId)}static from(d){return new Ys(d)}static toString(d){return d.iconsetId?`${d.name}${d.iconsetId}`:d.name}static parse(d){const[m,v]=d.split("");return new Ys({name:m,iconsetId:v})}static isEqual(d,m){return d.name===m.name&&d.iconsetId===m.iconsetId}toString(){return Ys.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var ln,cn={},na=function(){if(ln)return cn;ln=1;var g={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function 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 k(E,P,O){return O<0?O+=1:O>1&&(O-=1),6*O<1?E+(P-E)*O*6:2*O<1?P:3*O<2?E+(P-E)*(2/3-O)*6:E}try{cn.parseCSSColor=function(E){var P,O=E.replace(/ /g,"").toLowerCase();if(O in g)return g[O].slice();if(O[0]==="#")return O.length===4?(P=parseInt(O.substr(1),16))>=0&&P<=4095?[(3840&P)>>4|(3840&P)>>8,240&P|(240&P)>>4,15&P|(15&P)<<4,1]:null:O.length===7&&(P=parseInt(O.substr(1),16))>=0&&P<=16777215?[(16711680&P)>>16,(65280&P)>>8,255&P,1]:null;var B=O.indexOf("("),W=O.indexOf(")");if(B!==-1&&W+1===O.length){var J=O.substr(0,B),te=O.substr(B+1,W-(B+1)).split(","),ie=1;switch(J){case"rgba":if(te.length!==4)return null;ie=v(te.pop());case"rgb":return te.length!==3?null:[m(te[0]),m(te[1]),m(te[2]),ie];case"hsla":if(te.length!==4)return null;ie=v(te.pop());case"hsl":if(te.length!==3)return null;var ce=(parseFloat(te[0])%360+360)%360/360,ue=v(te[1]),Ne=v(te[2]),Le=Ne<=.5?Ne*(ue+1):Ne+ue-Ne*ue,Ie=2*Ne-Le;return[d(255*k(Ie,Le,ce+1/3)),d(255*k(Ie,Le,ce)),d(255*k(Ie,Le,ce-1/3)),ie];default:return null}}return null}}catch{}return cn}();class Fr{constructor(d,m,v,k=1){this.r=d,this.g=m,this.b=v,this.a=k}static parse(d){if(!d)return;if(d instanceof Fr)return d;if(typeof d!="string")return;const m=na.parseCSSColor(d);return m?new Fr(m[0]/255,m[1]/255,m[2]/255,m[3]):void 0}toString(){const[d,m,v,k]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*d)},${Math.round(255*m)},${Math.round(255*v)},${k})`}toNonPremultipliedRenderColor(d){const{r:m,g:v,b:k,a:E}=this;return new Hg(d,m,v,k,E)}toPremultipliedRenderColor(d){const{r:m,g:v,b:k,a:E}=this;return new Ap(d,m*E,v*E,k*E,E)}clone(){return new Fr(this.r,this.g,this.b,this.a)}}class oo{constructor(d,m,v,k,E,P=!1){if(this.premultiplied=!1,this.premultiplied=P,d){const O=d.image.height,B=O*O;this.premultiplied?(m=E===0?0:m/E*(O-1),v=E===0?0:v/E*(O-1),k=E===0?0:k/E*(O-1)):(m*=O-1,v*=O-1,k*=O-1);const W=Math.floor(m),J=Math.floor(v),te=Math.floor(k),ie=Math.ceil(m),ce=Math.ceil(v),ue=Math.ceil(k),Ne=m-W,Le=v-J,Ie=k-te,Ge=d.image.data,Ze=4*(W+J*B+te*O),at=4*(W+J*B+ue*O),vt=4*(W+ce*B+te*O),pt=4*(W+ce*B+ue*O),St=4*(ie+J*B+te*O),Lt=4*(ie+J*B+ue*O),Bt=4*(ie+ce*B+te*O),as=4*(ie+ce*B+ue*O);if(Ze<0||as>=Ge.length)throw new Error("out of range");this.r=Hr(Hr(Hr(Ge[Ze],Ge[at],Ie),Hr(Ge[vt],Ge[pt],Ie),Le),Hr(Hr(Ge[St],Ge[Lt],Ie),Hr(Ge[Bt],Ge[as],Ie),Le),Ne)/255*(this.premultiplied?E:1),this.g=Hr(Hr(Hr(Ge[Ze+1],Ge[at+1],Ie),Hr(Ge[vt+1],Ge[pt+1],Ie),Le),Hr(Hr(Ge[St+1],Ge[Lt+1],Ie),Hr(Ge[Bt+1],Ge[as+1],Ie),Le),Ne)/255*(this.premultiplied?E:1),this.b=Hr(Hr(Hr(Ge[Ze+2],Ge[at+2],Ie),Hr(Ge[vt+2],Ge[pt+2],Ie),Le),Hr(Hr(Ge[St+2],Ge[Lt+2],Ie),Hr(Ge[Bt+2],Ge[as+2],Ie),Le),Ne)/255*(this.premultiplied?E:1),this.a=E}else this.r=m,this.g=v,this.b=k,this.a=E}toArray(){const{r:d,g:m,b:v,a:k}=this;return[255*d,255*m,255*v,k]}toHslaArray(){let{r:d,g:m,b:v,a:k}=this;if(this.premultiplied){if(k===0)return[0,0,0,0];const ue=1/k;d*=ue,m*=ue,v*=ue}const E=Math.min(Math.max(d,0),1),P=Math.min(Math.max(m,0),1),O=Math.min(Math.max(v,0),1),B=Math.min(E,P,O),W=Math.max(E,P,O),J=W-B,te=.5*(B+W);if(J===0)return[0,0,100*te,k];const ie=te>.5?J/(2-W-B):J/(W+B);let ce;switch(W){case E:ce=60*((P-O)/J+(PHr(v,d[k],m))}Fr.black=new Fr(0,0,0,1),Fr.white=new Fr(1,1,1,1),Fr.transparent=new Fr(0,0,0,0),Fr.red=new Fr(1,0,0,1),Fr.blue=new Fr(0,0,1,1);var W0=Object.freeze({__proto__:null,array:H0,color:function(g,d,m){return new Fr(Hr(g.r,d.r,m),Hr(g.g,d.g,m),Hr(g.b,d.b,m),Hr(g.a,d.a,m))},number:Hr});class Um extends Error{constructor(d,m){super(m),this.message=m,this.key=d}}class B1{constructor(d,m=[]){this.parent=d,this.bindings={};for(const[v,k]of m)this.bindings[v]=k}concat(d){return new B1(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 Ep={kind:"null"},Rr={kind:"number"},Ca={kind:"string"},bi={kind:"boolean"},sh={kind:"color"},Af={kind:"object"},ui={kind:"value"},uC={kind:"collator"},$2={kind:"formatted"},q2={kind:"resolvedImage"};function Dd(g,d){return{kind:"array",itemType:g,N:d}}function ml(g){if(g.kind==="array"){const d=ml(g.itemType);return typeof g.N=="number"?`array<${d}, ${g.N}>`:g.itemType.kind==="value"?"array":`array<${d}>`}return g.kind}const mme=[Ep,Rr,Ca,bi,sh,$2,Af,Dd(ui),q2];function py(g,d){if(d.kind==="error")return null;if(g.kind==="array"){if(d.kind==="array"&&(d.N===0&&d.itemType.kind==="value"||!py(g.itemType,d.itemType))&&(typeof g.N!="number"||g.N===d.N))return null}else{if(g.kind===d.kind)return null;if(g.kind==="value"){for(const m of mme)if(!py(m,d))return null}}return`Expected ${ml(g)} but found ${ml(d)} instead.`}function bE(g,d){return d.some(m=>m.kind===g.kind)}function U2(g,d){return d.some(m=>m==="null"?g===null:m==="array"?Array.isArray(g):m==="object"?g&&!Array.isArray(g)&&typeof g=="object":m===typeof g)}function hC(g,d){return g.kind==="array"&&d.kind==="array"?g.N===d.N&&hC(g.itemType,d.itemType):g.kind===d.kind}class wE{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 mC{constructor(d,m,v,k,E){this.text=d.normalize?d.normalize():d,this.image=m,this.scale=v,this.fontStack=k,this.textColor=E}}class Cu{constructor(d){this.sections=d}static fromString(d){return new Cu([new mC(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 Cu?d:Cu.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 k=m.image.getPrimary().id.toString();d.push(["image",k]);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 Wg{constructor(d,m={}){this.id=Ys.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,k,E;try{({id:m,params:v,sx:k,sy:E}=JSON.parse(d)||{})}catch{return null}return m?new Wg(m,{params:v,sx:k,sy:E}):null}scaleSelf(d,m=d){return this.sx*=d,this.sy*=m,this}}class Mu{constructor(d,m,v,k,E=!1){this.primaryId=Ys.from(d),this.primaryOptions=m,v&&(this.secondaryId=Ys.from(v)),this.secondaryOptions=k,this.available=E}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new Wg(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Wg(this.secondaryId,this.secondaryOptions):null}static from(d){return typeof d=="string"?Mu.build({name:d}):d}static build(d,m,v,k){return!d||typeof d=="object"&&!("name"in d)?null:new Mu(d,v,m,k)}}function G0(g,d,m,v){return typeof g=="number"&&g>=0&&g<=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 [${[g,d,m,v].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof v=="number"?[g,d,m,v]:[g,d,m]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function $1(g){if(g===null||typeof g=="string"||typeof g=="boolean"||typeof g=="number"||g instanceof Fr||g instanceof wE||g instanceof Cu||g instanceof Mu)return!0;if(Array.isArray(g)){for(const d of g)if(!$1(d))return!1;return!0}if(typeof g=="object"){for(const d in g)if(!$1(g[d]))return!1;return!0}return!1}function vc(g){if(g===null)return Ep;if(typeof g=="string")return Ca;if(typeof g=="boolean")return bi;if(typeof g=="number")return Rr;if(g instanceof Fr)return sh;if(g instanceof wE)return uC;if(g instanceof Cu)return $2;if(g instanceof Mu)return q2;if(Array.isArray(g)){const d=g.length;let m;for(const v of g){const k=vc(v);if(m){if(m===k)continue;m=ui;break}m=k}return Dd(m||ui,d)}return Af}function Vm(g){const d=typeof g;return g===null?"":d==="string"||d==="number"||d==="boolean"?String(g):g instanceof Cu||g instanceof Mu||g instanceof Fr?g.toString():JSON.stringify(g)}class Gg{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(!$1(d[1]))return m.error("invalid value");const v=d[1];let k=vc(v);const E=m.expectedType;return k.kind!=="array"||k.N!==0||!E||E.kind!=="array"||typeof E.N=="number"&&E.N!==0||(k=E),new Gg(k,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 Fr?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Cu?this.value.serialize():this.value}}class rc{constructor(d){this.name="ExpressionEvaluationError",this.message=d}toJSON(){return this.message}}const jE={string:Ca,number:Rr,boolean:bi,object:Af};class Pp{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,k=1;const E=d[0];if(E==="array"){let O,B;if(d.length>2){const W=d[1];if(typeof W!="string"||!(W in jE)||W==="object")return m.error('The item type argument of "array" must be one of string, number, boolean',1);O=jE[W],k++}else O=ui;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);B=d[2],k++}v=Dd(O,B)}else v=jE[E];const P=[];for(;kd.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 k=d.N;(typeof k=="number"||this.args.length>1)&&m.push(k)}}return m.concat(this.args.map(v=>v.serialize()))}}class Ef{constructor(d){this.type=$2,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 k=[];let E=!1;for(let P=1;P<=d.length-1;++P){const O=d[P];if(E&&typeof O=="object"&&!Array.isArray(O)){E=!1;let B=null;if(O["font-scale"]&&(B=m.parseObjectValue(O["font-scale"],P,"font-scale",Rr),!B))return null;let W=null;if(O["text-font"]&&(W=m.parseObjectValue(O["text-font"],P,"text-font",Dd(Ca)),!W))return null;let J=null;if(O["text-color"]&&(J=m.parseObjectValue(O["text-color"],P,"text-color",sh),!J))return null;const te=k[k.length-1];te.scale=B,te.font=W,te.textColor=J}else{const B=m.parse(d[P],P,ui);if(!B)return null;const W=B.type.kind;if(W!=="string"&&W!=="value"&&W!=="null"&&W!=="resolvedImage")return m.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");E=!0,k.push({content:B,scale:null,font:null,textColor:null})}}return new Ef(k)}evaluate(d){return new Cu(this.sections.map(m=>{const v=m.content.evaluate(d);return hC(vc(v),q2)?new mC("",v,null,null,null):new mC(Vm(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 On{constructor(d,m,v,k){this._imageWarnHistory={},this.type=q2,this.namePrimary=d,this.nameSecondary=m,v&&(this.paramsPrimary=v.params,this.iconsetIdPrimary=v.iconset?v.iconset.id:void 0),k&&(this.paramsSecondary=k.params,this.iconsetIdSecondary=k.iconset?k.iconset.id:void 0)}static parse(d,m){if(d.length<2)return m.error("Expected two or more arguments.");let v=1;const k=[];function E(){if(vYs.isEqual(P,E)),k.available){const P=k.getSecondary()?k.getSecondary().id:null;P&&(k.available=d.availableImages.some(O=>Ys.isEqual(O,P)))}}return k}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 k in d)d[k]&&(v.params[k]=d[k].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 Lr(g){return dn(g)?"string":q1(g)?"number":fC(g)?"boolean":Array.isArray(g)?"array":g===null?"null":pC(g)?"object":typeof g}function pC(g){return g!=null&&!Array.isArray(g)&&typeof g!="function"&&!(g instanceof String||g instanceof Number||g instanceof Boolean)&&typeof g=="object"}function dn(g){return typeof g=="string"||g instanceof String}function q1(g){return typeof g=="number"||g instanceof Number}function fC(g){return typeof g=="boolean"||g instanceof Boolean}const nn={"to-boolean":bi,"to-color":sh,"to-number":Rr,"to-string":Ca};class Pf{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],k=[];let E=Ep;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=Dd(m.expectedType.itemType,P)}else{if(!(P>0&&$1(d[1][0])))return null;E=Dd(vc(d[1][0]),P)}for(let O=0;O4?`Invalid rbga value ${JSON.stringify(m)}: expected an array containing either three or four numeric values.`:G0(m[0],m[1],m[2],m[3]),!v))return new Fr(m[0]/255,m[1]/255,m[2]/255,m[3])}throw new rc(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 k=Number(m);if(!isNaN(k))return k}throw new rc(`Could not convert ${JSON.stringify(m)} to number.`)}return this.type.kind==="formatted"?Cu.fromString(Vm(this.args[0].evaluate(d))):this.type.kind==="resolvedImage"?Mu.build(Vm(this.args[0].evaluate(d))):this.type.kind==="array"?this.args.map(m=>m.evaluate(d)):Vm(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 Ef([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new On(this.args[0]).serialize();const d=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(m=>{d.push(m.serialize())}),d}}const kE=["Unknown","Point","LineString","Polygon"];class gC{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"?kE[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:k}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(v*m-d[0])+this.featureDistanceData.bearing[1]*(k*m-d[1])}return 0}parseColor(d){let m=this._parseColorCache[d];return m||(m=this._parseColorCache[d]=Fr.parse(d)),m}getConfig(d){return this.options?this.options.get(d):null}}class Tu{constructor(d,m,v,k,E){this.name=d,this.type=m,this._evaluate=v,this.args=k,this._overloadIndex=E}evaluate(d){if(!this._evaluate){const m=Tu.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],k=Tu.definitions[v];if(!k)return m.error(`Unknown expression "${v}". If you wanted a literal array, use ["literal", [...]].`,0);const E=Array.isArray(k)?k[0]:k.type,P=Array.isArray(k)?[[k[1],k[2]]]:k.overloads,O=[];let B=null,W=-1;for(const[J,te]of P){if(Array.isArray(J)&&J.length!==d.length-1)continue;O.push(J),W++,B=new MC(m.registry,m.path,null,m.scope,void 0,m._scope,m.options,m.iconImageUseTheme);const ie=[];let ce=!1;for(let ue=1;ueie)).map(xC).join(" | "),te=[];for(let ie=1;iem;){if(v-m>600){const B=v-m+1,W=d-m+1,J=Math.log(B),te=.5*Math.exp(2*J/3),ie=.5*Math.sqrt(J*te*(B-te)/B)*(W-B/2<0?-1:1);yC(g,d,Math.max(m,Math.floor(d-W*te/B+ie)),Math.min(v,Math.floor(d+(B-W)*te/B+ie)),k)}const E=g[d];let P=m,O=v;for(Ip(g,m,d),k(g[v],E)>0&&Ip(g,m,v);P0;)O--}k(g[m],E)===0?Ip(g,m,O):(O++,Ip(g,O,v)),O<=d&&(m=O+1),d<=O&&(v=O-1)}}function Ip(g,d,m){const v=g[d];g[d]=g[m],g[m]=v}function NE(g,d){return gd?1:0}function fy(g){let d=0;for(let m,v,k=0,E=g.length,P=E-1;k=d[2]||g[1]<=d[1]||g[3]>=d[3])}function pme(g,d,m){const v=g[0]-d[0],k=g[1]-d[1],E=g[0]-m[0],P=g[1]-m[1];return v*P-E*k==0&&v*E<=0&&k*P<=0}function U1(g,d,m=!1){let v=!1;for(let O=0,B=d.length;O(k=g)[1]!=(P=ue)[1]>k[1]&&k[0]<(P[0]-E[0])*(k[1]-E[1])/(P[1]-E[1])+E[0]&&(v=!v)}}var k,E,P;return v}function H2(g,d,m,v){const k=v[0]-m[0],E=v[1]-m[1],P=(g[0]-m[0])*E-k*(g[1]-m[1]),O=(d[0]-m[0])*E-k*(d[1]-m[1]);return P>0&&O<0||P<0&&O>0}function W2(g,d,m,v){return(k=[v[0]-m[0],v[1]-m[1]])[0]*(E=[d[0]-g[0],d[1]-g[1]])[1]-k[1]*E[0]!=0&&!(!H2(g,d,m,v)||!H2(m,v,g,d));var k,E}function Kg(g){const d=new es(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),m=new es(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const v of g[0])d.x>v.x&&(d.x=v.x),d.y>v.y&&(d.y=v.y),m.xm[2]){const k=.5*v;let E=g[0]-m[0]>k?-v:m[0]-g[0]>k?v:0;E===0&&(E=g[0]-m[2]>k?-v:m[2]-g[0]>k?v:0),g[0]+=E}Hm(d,g)}function lR(g,d,m,v){const k=Math.pow(2,v.z)*gy,E=[v.x*gy,v.y*gy],P=[];if(!g)return P;for(const O of g)for(const B of O){const W=[B.x+E[0],B.y+E[1]];oR(W,d,m,k),P.push(W)}return P}function vC(g,d,m,v){const k=Math.pow(2,v.z)*gy,E=[v.x*gy,v.y*gy],P=[];if(!g)return P;for(const B of g){const W=[];for(const J of B){const te=[J.x+E[0],J.y+E[1]];Hm(d,te),W.push(te)}P.push(W)}if(d[2]-d[0]<=k/2){(O=d)[0]=O[1]=1/0,O[2]=O[3]=-1/0;for(const B of P)for(const W of B)oR(W,d,m,k)}var O;return P}class yy{constructor(d,m){this.type=bi,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($1(d[1])){const v=d[1];if(v.type==="FeatureCollection")for(let k=0;km)return _C(E,P,(m-(v-O))/O)}return d[d.length-1]}pointToSegmentDistance(d,m,v){let[k,E]=m,P=tm(v[0]-k)*this.kx,O=(v[1]-E)*this.ky;if(P!==0||O!==0){const B=(tm(d[0]-k)*this.kx*P+(d[1]-E)*this.ky*O)/(P*P+O*O);B>1?(k=v[0],E=v[1]):B>0&&(k+=P/this.kx*B,E+=O/this.ky*B)}return P=tm(d[0]-k)*this.kx,O=(d[1]-E)*this.ky,Math.sqrt(P*P+O*O)}pointOnLine(d,m){let v=1/0,k=d[0][0],E=d[0][1],P=0,O=0;for(let B=0;B1?(W=d[B+1][0],J=d[B+1][1]):ce>0&&(W+=te/this.kx*ce,J+=ie/this.ky*ce)),te=tm(m[0]-W)*this.kx,ie=(m[1]-J)*this.ky;const ue=te*te+ie*ie;ueE.index||k.index===E.index&&k.t>E.t){const W=k;k=E,E=W}const P=[k.point],O=k.index+1,B=E.index;!ME(v[O],P[0])&&O<=B&&P.push(v[O]);for(let W=O+1;W<=B;W++)P.push(v[W]);return ME(v[B],E.point)||P.push(E.point),P}lineSliceAlong(d,m,v){let k=0;const E=[];for(let P=0;Pd&&E.length===0&&E.push(_C(O,B,(d-(k-W))/W)),k>=m)return E.push(_C(O,B,(m-(k-W))/W)),E;k>d&&E.push(B)}return E}bufferPoint(d,m){const v=m/this.ky,k=m/this.kx;return[d[0]-k,d[1]-v,d[0]+k,d[1]+v]}bufferBBox(d,m){const v=m/this.ky,k=m/this.kx;return[d[0]-k,d[1]-v,d[2]+k,d[3]+v]}insideBBox(d,m){return tm(d[0]-m[0])>=0&&tm(d[0]-m[2])<=0&&d[1]>=m[1]&&d[1]<=m[3]}}function ME(g,d){return g[0]===d[0]&&g[1]===d[1]}function _C(g,d,m){const v=tm(d[0]-g[0]);return[g[0]+v*m,g[1]+(d[1]-g[1])*m]}function tm(g){for(;g<-180;)g+=360;for(;g>180;)g-=360;return g}class bC{constructor(d=[],m=(v,k)=>vk?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,k=m[d];for(;d>0;){const E=d-1>>1,P=m[E];if(v(k,P)>=0)break;m[d]=P,d=E}m[d]=k}_down(d){const{data:m,compare:v}=this,k=this.length>>1,E=m[d];for(;d=0)break;m[d]=m[P],d=P}m[d]=E}}var Qs=8192;function TE(g,d){return d.dist-g.dist}const wC=100,jC=50;function AE(g){const d=[1/0,1/0,-1/0,-1/0];if(d.length!==g.length)return!1;for(let m=0;m=g[0]&&g[1]g[1])return[null,null];const m=K2(g);if(d){if(m===2)return[g,null];const v=Math.floor(m/2);return[[g[0],g[0]+v],[g[0]+v,g[1]]]}{if(m===1)return[g,null];const v=Math.floor(m/2)-1;return[[g[0],g[0]+v],[g[0]+v+1,g[1]]]}}function K0(g,d){const m=[1/0,1/0,-1/0,-1/0];if(!If(d,g.length))return m;for(let v=d[0];v<=d[1];++v)Hm(m,g[v]);return m}function Z0(g){const d=[1/0,1/0,-1/0,-1/0];for(let m=0;md[2]&&(v=g[0]-d[2]),g[1]>d[3]&&(k=g[1]-d[3]),g[3]=v)return v;if(V2(k,E)){if(IE(g,d))return 0}else if(IE(d,g))return 0;let P=v;for(const O of g)for(let B=0,W=O.length,J=W-1;B=E)continue;const J=W.range1;if(K2(J)<=O){if(!If(J,g.length))return NaN;if(d){const te=_me(g,J,m,v);if((E=Math.min(E,te))===0)return E}else for(let te=J[0];te<=J[1];++te){const ie=vme(g[te],m,v);if((E=Math.min(E,ie))===0)return E}}else{const te=EE(J,d);if(te[0]!==null){const ie=vy(K0(g,te[0]),B,v);ie=P)continue;const te=J.range1,ie=J.range2;if(K2(te)<=B&&K2(ie)<=W){if(!If(te,g.length)||!If(ie,m.length))return NaN;if(d&&v?P=Math.min(P,Ea(g,te,m,ie,k)):d||v?d&&!v?P=Math.min(P,PE(m,ie,g,te,k)):!d&&v&&(P=Math.min(P,PE(g,te,m,ie,k))):P=Math.min(P,yme(g,te,m,ie,k)),P===0)return P}else{const ce=EE(te,d),ue=EE(ie,v);lo(O,P,k,g,m,ce[0],ue[0]),lo(O,P,k,g,m,ce[0],ue[1]),lo(O,P,k,g,m,ce[1],ue[0]),lo(O,P,k,g,m,ce[1],ue[1])}}return P}function LE(g,d,m,v,k=1/0){let E=k;const P=K0(g,[0,g.length-1]);for(const O of m)if(!(E!==1/0&&vy(P,K0(O,[0,O.length-1]),v)>=E)&&(E=Math.min(E,hR(g,d,O,!0,v,E)),E===0))return E;return E}function SC(g,d,m,v,k=1/0){let E=k;const P=K0(g,[0,g.length-1]);for(const O of m){if(E!==1/0&&vy(P,Z0(O),v)>=E)continue;const B=wme(g,d,O,v,E);if(isNaN(B))return B;if((E=Math.min(E,B))===0)return E}return E}function DE(g){return g==="Point"||g==="MultiPoint"||g==="LineString"||g==="MultiLineString"||g==="Polygon"||g==="MultiPolygon"}class Y0{constructor(d,m){this.type=Rr,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($1(d[1])){const v=d[1];if(v.type==="FeatureCollection"){for(let k=0;k{d&&!W1(m)&&(d=!1)}),d}function Z2(g){if(g instanceof Tu&&g.name==="feature-state")return!1;let d=!0;return g.eachChild(m=>{d&&!Z2(m)&&(d=!1)}),d}function G1(g,d){if(g instanceof Tu&&d.indexOf(g.name)>=0)return!1;let m=!0;return g.eachChild(v=>{m&&!G1(v,d)&&(m=!1)}),m}function mR(g,d,m){return[g,d,m].filter(Boolean).join("")}function OE(g,d){switch(g){case"string":return Vm(d);case"number":return+d;case"boolean":return!!d;case"color":return Fr.parse(d);case"formatted":return Cu.fromString(Vm(d));case"resolvedImage":return Mu.build(Vm(d))}return d}function pR(g,d,m,v){return v!==void 0&&(g=v*Math.round(g/v)),d!==void 0&&gm&&(g=m),g}class K1{constructor(d,m,v,k=!1){this.type=d,this.key=m,this.scope=v,this.featureConstant=k}static parse(d,m){let v=m.expectedType;if(v==null&&(v=ui),d.length<2||d.length>3)return m.error("Invalid number of arguments for 'config' expression.");const k=m.parse(d[1],1);if(!(k instanceof Gg))return m.error("Key name of 'config' expression must be a string literal.");let E,P=!0;const O=Vm(k.value);if(d.length>=3){const B=m.parse(d[2],2);if(!(B instanceof Gg))return m.error("Scope of 'config' expression must be a string literal.");E=Vm(B.value)}if(m.options){const B=mR(O,E,m._scope),W=m.options.get(B);W&&(P=W1(W.value||W.default))}return new K1(v,O,E,P)}evaluate(d){const m=mR(this.key,this.scope,d.scope),v=d.getConfig(m);if(!v)return null;const{type:k,value:E,values:P,minValue:O,maxValue:B,stepValue:W}=v,J=v.default.evaluate(d);let te=J;if(E){const ie=d.scope;d.scope=(ie||"").split("").slice(1).join(""),te=E.evaluate(d),d.scope=ie}return k&&(te=OE(k,te)),te===void 0||O===void 0&&B===void 0&&W===void 0||(typeof te=="number"?te=pR(te,O,B,W):Array.isArray(te)&&(te=te.map(ie=>typeof ie=="number"?pR(ie,O,B,W):ie))),E!==void 0&&te!==void 0&&P&&!P.includes(te)&&(te=J,k&&(te=OE(k,te))),(k&&k!==this.type||te!==void 0&&!hC(vc(te),this.type))&&(te=OE(this.type.kind,te)),te}eachChild(){}outputDefined(){return!1}serialize(){const d=["config",this.key];return this.scope&&d.concat(this.scope),d}}class CC{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 CC(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 MC{constructor(d,m=[],v,k=new B1,E=[],P,O,B){this.registry=d,this.path=m,this.key=m.map(W=>typeof W=="string"?`['${W}']`:`[${W}]`).join(""),this.scope=k,this.errors=E,this.expectedType=v,this._scope=P,this.options=O,this.iconImageUseTheme=B}parse(d,m,v,k,E={}){return m||v?this.concat(m,null,v,k)._parse(d,E):this._parse(d,E)}parseObjectValue(d,m,v,k,E,P={}){return this.concat(m,v,k,E)._parse(d,P)}_parse(d,m){function v(k,E,P){return P==="assert"?new Pp(E,[k]):P==="coerce"?new Pf(E,[k]):k}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 k=typeof d[0]=="string"?this.registry[d[0]]:void 0;if(k){let E=k.parse(d,this);if(!E)return null;if(this.expectedType){const P=this.expectedType,O=E.type;if(P.kind!=="string"&&P.kind!=="number"&&P.kind!=="boolean"&&P.kind!=="object"&&P.kind!=="array"||O.kind!=="value")if(P.kind!=="color"&&P.kind!=="formatted"&&P.kind!=="resolvedImage"||O.kind!=="value"&&O.kind!=="string"){if(this.checkSubtype(P,O))return null}else E=v(E,P,m.typeAnnotation||"coerce");else E=v(E,P,m.typeAnnotation||"assert")}if(!(E instanceof Gg)&&E.type.kind!=="resolvedImage"&&RE(E)){const P=new gC(this._scope,this.options,this.iconImageUseTheme);try{E=new Gg(E.type,E.evaluate(P))}catch(O){return this.error(O.message),null}}return E}return Pf.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,k){let E=typeof d=="number"?this.path.concat(d):this.path;E=typeof m=="string"?E.concat(m):E;const P=k?this.scope.concat(k):this.scope;return new MC(this.registry,E,v||null,P,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(d,...m){const v=`${this.key}${m.map(k=>`[${k}]`).join("")}`;this.errors.push(new Um(v,d))}checkSubtype(d,m){const v=py(d,m);return v&&this.error(v),v}}function RE(g){if(g instanceof CC)return RE(g.boundExpression);if(g instanceof Tu&&g.name==="error"||g instanceof Dc||g instanceof yy||g instanceof Y0||g instanceof K1)return!1;const d=g instanceof Pf||g instanceof Pp;let m=!0;return g.eachChild(v=>{m=d?m&&RE(v):m&&v instanceof Gg}),!!m&&W1(g)&&G1(g,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function TC(g,d){const m=g.length-1;let v,k,E=0,P=m,O=0;for(;E<=P;)if(O=Math.floor((E+P)/2),v=g[O],k=g[O+1],v<=d){if(O===m||dd))throw new rc("Input is not a number.");P=O-1}return 0}class Y2{constructor(d,m,v){this.type=d,this.input=m,this.labels=[],this.outputs=[];for(const[k,E]of v)this.labels.push(k),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,Rr);if(!v)return null;const k=[];let E=null;m.expectedType&&m.expectedType.kind!=="value"&&(E=m.expectedType);for(let P=1;P=O)return m.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',W);const te=m.parse(B,J,E);if(!te)return null;E=E||te.type,k.push([O,te])}return new Y2(E,v,k)}evaluate(d){const m=this.labels,v=this.outputs;if(m.length===1)return v[0].evaluate(d);const k=this.input.evaluate(d);if(k<=m[0])return v[0].evaluate(d);const E=m.length;return k>=m[E-1]?v[E-1].evaluate(d):v[TC(m,k)].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 fR=.95047,gR=1.08883,xR=4/29,Z1=6/29,yR=3*Z1*Z1,jme=Z1*Z1*Z1,kme=Math.PI/180,Nme=180/Math.PI;function FE(g){return g>jme?Math.pow(g,1/3):g/yR+xR}function zE(g){return g>Z1?g*g*g:yR*(g-xR)}function BE(g){return 255*(g<=.0031308?12.92*g:1.055*Math.pow(g,1/2.4)-.055)}function $E(g){return(g/=255)<=.04045?g/12.92:Math.pow((g+.055)/1.055,2.4)}function vR(g){const d=$E(g.r),m=$E(g.g),v=$E(g.b),k=FE((.4124564*d+.3575761*m+.1804375*v)/fR),E=FE((.2126729*d+.7151522*m+.072175*v)/1);return{l:116*E-16,a:500*(k-E),b:200*(E-FE((.0193339*d+.119192*m+.9503041*v)/gR)),alpha:g.a}}function AC(g){let d=(g.l+16)/116,m=isNaN(g.a)?d:d+g.a/500,v=isNaN(g.b)?d:d-g.b/200;return d=1*zE(d),m=fR*zE(m),v=gR*zE(v),new Fr(BE(3.2404542*m-1.5371385*d-.4985314*v),BE(-.969266*m+1.8760108*d+.041556*v),BE(.0556434*m-.2040259*d+1.0572252*v),g.alpha)}function EC(g,d,m){const v=d-g;return g+m*(v>180||v<-180?v-360*Math.round(v/360):v)}const Y1={forward:vR,reverse:AC,interpolate:function(g,d,m){return{l:Hr(g.l,d.l,m),a:Hr(g.a,d.a,m),b:Hr(g.b,d.b,m),alpha:Hr(g.alpha,d.alpha,m)}}},X2={forward:function(g){const{l:d,a:m,b:v}=vR(g),k=Math.atan2(v,m)*Nme;return{h:k<0?k+360:k,c:Math.sqrt(m*m+v*v),l:d,alpha:g.a}},reverse:function(g){const d=g.h*kme,m=g.c;return AC({l:g.l,a:Math.cos(d)*m,b:Math.sin(d)*m,alpha:g.alpha})},interpolate:function(g,d,m){return{h:EC(g.h,d.h,m),c:Hr(g.c,d.c,m),l:Hr(g.l,d.l,m),alpha:Hr(g.alpha,d.alpha,m)}}};var _R=Object.freeze({__proto__:null,hcl:X2,lab:Y1});class sm{constructor(d,m,v,k,E){this.type=d,this.operator=m,this.interpolation=v,this.input=k,this.labels=[],this.outputs=[];for(const[P,O]of E)this.labels.push(P),this.outputs.push(O)}static interpolationFactor(d,m,v,k){let E=0;if(d.name==="exponential")E=PC(m,d.base,v,k);else if(d.name==="linear")E=PC(m,1,v,k);else if(d.name==="cubic-bezier"){const P=d.controlPoints;E=new $r(P[0],P[1],P[2],P[3]).solve(PC(m,1,v,k))}return E}static parse(d,m){let[v,k,E,...P]=d;if(!Array.isArray(k)||k.length===0)return m.error("Expected an interpolation type expression.",1);if(k[0]==="linear")k={name:"linear"};else if(k[0]==="exponential"){const W=k[1];if(typeof W!="number")return m.error("Exponential interpolation requires a numeric base.",1,1);k={name:"exponential",base:W}}else{if(k[0]!=="cubic-bezier")return m.error(`Unknown interpolation type ${String(k[0])}`,1,0);{const W=k.slice(1);if(W.length!==4||W.some(J=>typeof J!="number"||J<0||J>1))return m.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);k={name:"cubic-bezier",controlPoints:W}}}if(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,Rr),!E)return null;const O=[];let B=null;v==="interpolate-hcl"||v==="interpolate-lab"?B=sh:m.expectedType&&m.expectedType.kind!=="value"&&(B=m.expectedType);for(let W=0;W=J)return m.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',ie);const ue=m.parse(te,ce,B);if(!ue)return null;B=B||ue.type,O.push([J,ue])}return B.kind==="number"||B.kind==="color"||B.kind==="array"&&B.itemType.kind==="number"&&typeof B.N=="number"?new sm(B,v,k,E,O):m.error(`Type ${ml(B)} is not interpolatable.`)}evaluate(d){const m=this.labels,v=this.outputs;if(m.length===1)return v[0].evaluate(d);const k=this.input.evaluate(d);if(k<=m[0])return v[0].evaluate(d);const E=m.length;if(k>=m[E-1])return v[E-1].evaluate(d);const P=TC(m,k),O=sm.interpolationFactor(this.interpolation,k,m[P],m[P+1]),B=v[P].evaluate(d),W=v[P+1].evaluate(d);return this.operator==="interpolate"?W0[this.type.kind.toLowerCase()](B,W,O):this.operator==="interpolate-hcl"?X2.reverse(X2.interpolate(X2.forward(B),X2.forward(W),O)):Y1.reverse(Y1.interpolate(Y1.forward(B),Y1.forward(W),O))}eachChild(d){d(this.input);for(const m of this.outputs)d(m)}outputDefined(){return this.outputs.every(d=>d.outputDefined())}serialize(){let d;d=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const m=[this.operator,d,this.input.serialize()];for(let v=0;vpy(k,O.type));return new Q2(P?ui:v,E)}evaluate(d){let m,v=null,k=0;for(const E of this.args){if(k++,v=E.evaluate(d),v&&v instanceof Mu&&!v.available&&(m||(m=v),v=null,k===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 Zg{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 rc("Array index out of bounds: index exceeds array size");if(m!==Math.floor(m))throw new rc("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 LC{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,Rr),k=m.parse(d[2],2,Dd(m.expectedType||ui));return v&&k?new LC(k.type.itemType,v,k):null}evaluate(d){const m=this.index.evaluate(d),v=this.input.evaluate(d);if(m<0)throw new rc(`Array index out of bounds: ${m} < 0.`);if(m>v.length-1)throw new rc(`Array index out of bounds: ${m} > ${v.length-1}.`);if(m===Math.floor(m))return v[m];const k=Math.floor(m),E=Math.ceil(m),P=v[k],O=v[E];if(typeof P!="number"||typeof O!="number")throw new rc(`Cannot interpolate between non-number values at index ${m}.`);const B=m-k;return P*(1-B)+O*B}eachChild(d){d(this.index),d(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class qE{constructor(d,m){this.type=bi,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,ui),k=m.parse(d[2],2,ui);return v&&k?bE(v.type,[bi,Ca,Rr,Ep,ui])?new qE(v,k):m.error(`Expected first argument to be of type boolean, string, number or null, but found ${ml(v.type)} instead`):null}evaluate(d){const m=this.needle.evaluate(d),v=this.haystack.evaluate(d);if(v==null)return!1;if(!U2(m,["boolean","string","number","null"]))throw new rc(`Expected first argument to be of type boolean, string, number or null, but found ${ml(vc(m))} instead.`);if(!U2(v,["string","array"]))throw new rc(`Expected second argument to be of type array or string, but found ${ml(vc(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 X1{constructor(d,m,v){this.type=Rr,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,ui),k=m.parse(d[2],2,ui);if(!v||!k)return null;if(!bE(v.type,[bi,Ca,Rr,Ep,ui]))return m.error(`Expected first argument to be of type boolean, string, number or null, but found ${ml(v.type)} instead`);if(d.length===4){const E=m.parse(d[3],3,Rr);return E?new X1(v,k,E):null}return new X1(v,k)}evaluate(d){const m=this.needle.evaluate(d),v=this.haystack.evaluate(d);if(!U2(m,["boolean","string","number","null"]))throw new rc(`Expected first argument to be of type boolean, string, number or null, but found ${ml(vc(m))} instead.`);if(!U2(v,["string","array"]))throw new rc(`Expected second argument to be of type array or string, but found ${ml(vc(v))} instead.`);if(this.fromIndex){const k=this.fromIndex.evaluate(d);return v.indexOf(m,k)}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 J2{constructor(d,m,v,k,E,P){this.inputType=d,this.type=m,this.input=v,this.cases=k,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,k;m.expectedType&&m.expectedType.kind!=="value"&&(k=m.expectedType);const E={},P=[];for(let W=2;WNumber.MAX_SAFE_INTEGER)return ie.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof ue=="number"&&Math.floor(ue)!==ue)return ie.error("Numeric branch labels must be integer values.");if(v){if(ie.checkSubtype(v,vc(ue)))return null}else v=vc(ue);if(E[String(ue)]!==void 0)return ie.error("Branch labels must be unique.");E[String(ue)]=P.length}const ce=m.parse(te,W,k);if(!ce)return null;k=k||ce.type,P.push(ce)}const O=m.parse(d[1],1,ui);if(!O)return null;const B=m.parse(d[d.length-1],d.length-1,k);return B?O.type.kind!=="value"&&m.concat(1).checkSubtype(v,O.type)?null:new J2(v,k,O,E,P,B):null}evaluate(d){const m=this.input.evaluate(d);return(hC(vc(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=[],k={};for(const P of m){const O=k[this.cases[P]];O===void 0?(k[this.cases[P]]=v.length,v.push([this.cases[P],[P]])):v[O][1].push(P)}const E=P=>this.inputType.kind==="number"?Number(P):P;for(const[P,O]of v)d.push(O.length===1?E(O[0]):O.map(E)),d.push(this.outputs[P].serialize());return d.push(this.otherwise.serialize()),d}}class ew{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 k=[];for(let P=1;Pm.outputDefined())&&this.otherwise.outputDefined()}serialize(){const d=["case"];return this.eachChild(m=>{d.push(m.serialize())}),d}}class DC{constructor(d,m,v,k){this.type=d,this.input=m,this.beginIndex=v,this.endIndex=k}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,ui),k=m.parse(d[2],2,Rr);if(!v||!k)return null;if(!bE(v.type,[Dd(ui),Ca,ui]))return m.error(`Expected first argument to be of type array or string, but found ${ml(v.type)} instead`);if(d.length===4){const E=m.parse(d[3],3,Rr);return E?new DC(v.type,v,k,E):null}return new DC(v.type,v,k)}evaluate(d){const m=this.input.evaluate(d),v=this.beginIndex.evaluate(d);if(!U2(m,["string","array"]))throw new rc(`Expected first argument to be of type array or string, but found ${ml(vc(m))} instead.`);if(this.endIndex){const k=this.endIndex.evaluate(d);return m.slice(v,k)}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 UE{constructor(d,m){this.type=Dd(Ca),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,Ca),k=m.parse(d[2],2,Ca);return v&&k?new UE(v,k):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 VE(g,d){return g==="=="||g==="!="?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 HE(g,d,m,v){return v.compare(d,m)===0}function Q1(g,d,m){const v=g!=="=="&&g!=="!=";return class LHe{constructor(E,P,O){this.type=bi,this.lhs=E,this.rhs=P,this.collator=O,this.hasUntypedArgument=E.type.kind==="value"||P.type.kind==="value"}static parse(E,P){if(E.length!==3&&E.length!==4)return P.error("Expected two or three arguments.");const O=E[0];let B=P.parse(E[1],1,ui);if(!B)return null;if(!VE(O,B.type))return P.concat(1).error(`"${O}" comparisons are not supported for type '${ml(B.type)}'.`);let W=P.parse(E[2],2,ui);if(!W)return null;if(!VE(O,W.type))return P.concat(2).error(`"${O}" comparisons are not supported for type '${ml(W.type)}'.`);if(B.type.kind!==W.type.kind&&B.type.kind!=="value"&&W.type.kind!=="value")return P.error(`Cannot compare types '${ml(B.type)}' and '${ml(W.type)}'.`);v&&(B.type.kind==="value"&&W.type.kind!=="value"?B=new Pp(W.type,[B]):B.type.kind!=="value"&&W.type.kind==="value"&&(W=new Pp(B.type,[W])));let J=null;if(E.length===4){if(B.type.kind!=="string"&&W.type.kind!=="string"&&B.type.kind!=="value"&&W.type.kind!=="value")return P.error("Cannot use collator to compare non-string types.");if(J=P.parse(E[3],3,uC),!J)return null}return new LHe(B,W,J)}evaluate(E){const P=this.lhs.evaluate(E),O=this.rhs.evaluate(E);if(v&&this.hasUntypedArgument){const B=vc(P),W=vc(O);if(B.kind!==W.kind||B.kind!=="string"&&B.kind!=="number")throw new rc(`Expected arguments for "${g}" to be (string, string) or (number, number), but found (${B.kind}, ${W.kind}) instead.`)}if(this.collator&&!v&&this.hasUntypedArgument){const B=vc(P),W=vc(O);if(B.kind!=="string"||W.kind!=="string")return d(E,P,O)}return this.collator?m(E,P,O,this.collator.evaluate(E)):d(E,P,O)}eachChild(E){E(this.lhs),E(this.rhs),this.collator&&E(this.collator)}outputDefined(){return!0}serialize(){const E=[g];return this.eachChild(P=>{E.push(P.serialize())}),E}}}const Sme=Q1("==",function(g,d,m){return d===m},HE),Cme=Q1("!=",function(g,d,m){return d!==m},function(g,d,m,v){return!HE(0,d,m,v)}),bR=Q1("<",function(g,d,m){return d",function(g,d,m){return d>m},function(g,d,m,v){return v.compare(d,m)>0}),OC=Q1("<=",function(g,d,m){return d<=m},function(g,d,m,v){return v.compare(d,m)<=0}),Mme=Q1(">=",function(g,d,m){return d>=m},function(g,d,m,v){return v.compare(d,m)>=0});class RC{constructor(d,m,v,k,E,P){this.type=Ca,this.number=d,this.locale=m,this.currency=v,this.unit=k,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,Rr);if(!v)return null;const k=d[2];if(typeof k!="object"||Array.isArray(k))return m.error("NumberFormat options argument must be an object.");let E=null;if(k.locale&&(E=m.parseObjectValue(k.locale,2,"locale",Ca),!E))return null;let P=null;if(k.currency&&(P=m.parseObjectValue(k.currency,2,"currency",Ca),!P))return null;let O=null;if(k.unit&&(O=m.parseObjectValue(k.unit,2,"unit",Ca),!O))return null;let B=null;if(k["min-fraction-digits"]&&(B=m.parseObjectValue(k["min-fraction-digits"],2,"min-fraction-digits",Rr),!B))return null;let W=null;return k["max-fraction-digits"]&&(W=m.parseObjectValue(k["max-fraction-digits"],2,"max-fraction-digits",Rr),!W)?null:new RC(v,E,P,O,B,W)}evaluate(d){return new Intl.NumberFormat(this.locale?this.locale.evaluate(d):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(d):void 0,unit:this.unit?this.unit.evaluate(d):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(d):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(d):void 0}).format(this.number.evaluate(d))}eachChild(d){d(this.number),this.locale&&d(this.locale),this.currency&&d(this.currency),this.unit&&d(this.unit),this.minFractionDigits&&d(this.minFractionDigits),this.maxFractionDigits&&d(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const d={};return this.locale&&(d.locale=this.locale.serialize()),this.currency&&(d.currency=this.currency.serialize()),this.unit&&(d.unit=this.unit.serialize()),this.minFractionDigits&&(d["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(d["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),d]}}class WE{constructor(d){this.type=Rr,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 ${ml(v.type)} instead.`):new WE(v):null}evaluate(d){const m=this.input.evaluate(d);if(typeof m=="string"||Array.isArray(m))return m.length;throw new rc(`Expected value to be of type string or array, but found ${ml(vc(m))} instead.`)}eachChild(d){d(this.input)}outputDefined(){return!1}serialize(){const d=["length"];return this.eachChild(m=>{d.push(m.serialize())}),d}}function jR(g){return function(){g=1831565813+(g|=0)|0;let d=Math.imul(g^g>>>15,1|g);return d=d+Math.imul(d^d>>>7,61|d)^d,((d^d>>>14)>>>0)/4294967296}}const J1={"==":Sme,"!=":Cme,">":wR,"<":bR,">=":Mme,"<=":OC,array:Pp,at:IC,"at-interpolated":LC,boolean:Pp,case:ew,coalesce:Q2,collator:Dc,format:Ef,image:On,in:qE,"index-of":X1,interpolate:sm,"interpolate-hcl":sm,"interpolate-lab":sm,length:WE,let:Zg,literal:Gg,match:J2,number:Pp,"number-format":RC,object:Pp,slice:DC,step:Y2,string:Pp,"to-boolean":Pf,"to-color":Pf,"to-number":Pf,"to-string":Pf,var:CC,within:yy,distance:Y0,config:K1,split:UE};function GE(g,[d,m,v,k]){d=d.evaluate(g),m=m.evaluate(g),v=v.evaluate(g);const E=k?k.evaluate(g):1,P=G0(d,m,v,E);if(P)throw new rc(P);return new Fr(d/255,m/255,v/255,E)}function KE(g,[d,m,v,k]){d=d.evaluate(g),m=m.evaluate(g),v=v.evaluate(g);const E=k?k.evaluate(g):1,P=function(W,J,te,ie){return typeof W=="number"&&W>=0&&W<=360?typeof J=="number"&&J>=0&&J<=100&&typeof te=="number"&&te>=0&&te<=100?ie===void 0||typeof ie=="number"&&ie>=0&&ie<=1?null:`Invalid hsla value [${[W,J,te,ie].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof ie=="number"?[W,J,te,ie]:[W,J,te]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof ie=="number"?[W,J,te,ie]:[W,J,te]).join(", ")}]: 'h' must be between 0 and 360.`}(d,m,v,E);if(P)throw new rc(P);const O=`hsla(${d}, ${m}%, ${v}%, ${E})`,B=Fr.parse(O);if(!B)throw new rc(`Failed to parse HSLA color: ${O}`);return B}function kR(g,d){return g in d}function ZE(g,d){const m=d[g];return m===void 0?null:m}function by(g){return{type:g}}function X0(g){if(g instanceof K1)return new Set([g.key]);let d=new Set;return g.eachChild(m=>{d=new Set([...d,...X0(m)])}),d}function FC(g){if(g instanceof Tu&&g.name==="is-active-floor")return!0;let d=!1;return g.eachChild(m=>{!d&&FC(m)&&(d=!0)}),d}function NR(g){return{result:"success",value:g}}function wy(g){return{result:"error",value:g}}function YE(g,d){return!!g&&!!g.parameters&&g.parameters.indexOf(d)>-1}function tw(g){return g["property-type"]==="data-driven"}function SR(g){return YE(g.expression,"measure-light")}function CR(g){return YE(g.expression,"zoom")}function zC(g){return!!g.expression&&g.expression.interpolated}function BC(g){return typeof g=="object"&&g!==null&&!Array.isArray(g)}function MR(g){return g}function TR(g,d){const m=d.type==="color",v=g.stops&&typeof g.stops[0][0]=="object",k=v||!(v||g.property!==void 0),E=g.type||(zC(d)?"exponential":"interval");if(m&&((g=Object.assign({},g)).stops&&(g.stops=g.stops.map(W=>[W[0],Fr.parse(W[1])])),g.default=Fr.parse(g.default?g.default:d.default)),g.colorSpace&&g.colorSpace!=="rgb"&&!_R[g.colorSpace])throw new Error(`Unknown color space: ${g.colorSpace}`);let P,O,B;if(E==="exponential")P=AR;else if(E==="interval")P=Ame;else if(E==="categorical"){P=Tme,O=Object.create(null);for(const W of g.stops)O[W[0]]=W[1];B=typeof g.stops[0][0]}else{if(E!=="identity")throw new Error(`Unknown function type "${E}"`);P=ER}if(v){const W={},J=[];for(let ce=0;cece[0]),evaluate:({zoom:ce},ue)=>AR({stops:te,base:g.base},d,ce).evaluate(ce,ue)}}if(k){const W=E==="exponential"?{name:"exponential",base:g.base!==void 0?g.base:1}:null;return{kind:"camera",interpolationType:W,interpolationFactor:sm.interpolationFactor.bind(void 0,W),zoomStops:g.stops.map(J=>J[0]),evaluate:({zoom:J})=>P(g,d,J,O,B)}}return{kind:"source",evaluate(W,J){const te=J&&J.properties?J.properties[g.property]:void 0;return te===void 0?Lf(g.default,d.default):P(g,d,te,O,B)}}}function Lf(g,d,m){return g!==void 0?g:d!==void 0?d:m!==void 0?m:void 0}function Tme(g,d,m,v,k){return Lf(typeof m===k?v[m]:void 0,g.default,d.default)}function Ame(g,d,m){if(!q1(m))return Lf(g.default,d.default);const v=g.stops.length;if(v===1||m<=g.stops[0][0])return g.stops[0][1];if(m>=g.stops[v-1][0])return g.stops[v-1][1];const k=TC(g.stops.map(E=>E[0]),m);return g.stops[k][1]}function AR(g,d,m){const v=g.base!==void 0?g.base:1;if(!q1(m))return Lf(g.default,d.default);const k=g.stops.length;if(k===1||m<=g.stops[0][0])return g.stops[0][1];if(m>=g.stops[k-1][0])return g.stops[k-1][1];const E=TC(g.stops.map(J=>J[0]),m),P=function(J,te,ie,ce){const ue=ce-ie,Ne=J-ie;return ue===0?0:te===1?Ne/ue:(Math.pow(te,Ne)-1)/(Math.pow(te,ue)-1)}(m,v,g.stops[E][0],g.stops[E+1][0]),O=g.stops[E][1],B=g.stops[E+1][1];let W=W0[d.type]||MR;if(g.colorSpace&&g.colorSpace!=="rgb"){const J=_R[g.colorSpace];W=(te,ie)=>J.reverse(J.interpolate(J.forward(te),J.forward(ie),P))}return typeof O.evaluate=="function"?{evaluate(...J){const te=O.evaluate.apply(void 0,J),ie=B.evaluate.apply(void 0,J);if(te!==void 0&&ie!==void 0)return W(te,ie,P)}}:W(O,B,P)}function ER(g,d,m){return d.type==="color"?m=Fr.parse(m):d.type==="formatted"?m=Cu.fromString(m.toString()):d.type==="resolvedImage"?m=Mu.build(m.toString()):Lr(m)===d.type||d.type==="enum"&&d.values[m]||(m=void 0),Lf(m,g.default,d.default)}Tu.register(J1,{error:[{kind:"error"},[Ca],(g,[d])=>{throw new rc(d.evaluate(g))}],typeof:[Ca,[ui],(g,[d])=>ml(vc(d.evaluate(g)))],"to-rgba":[Dd(Rr,4),[sh],(g,[d])=>d.evaluate(g).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Dd(Rr,4),[sh],(g,[d])=>d.evaluate(g).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[sh,[Rr,Rr,Rr],GE],rgba:[sh,[Rr,Rr,Rr,Rr],GE],hsl:[sh,[Rr,Rr,Rr],KE],hsla:[sh,[Rr,Rr,Rr,Rr],KE],has:{type:bi,overloads:[[[Ca],(g,[d])=>kR(d.evaluate(g),g.properties())],[[Ca,Af],(g,[d,m])=>kR(d.evaluate(g),m.evaluate(g))]]},get:{type:ui,overloads:[[[Ca],(g,[d])=>ZE(d.evaluate(g),g.properties())],[[Ca,Af],(g,[d,m])=>ZE(d.evaluate(g),m.evaluate(g))]]},"feature-state":[ui,[Ca],(g,[d])=>ZE(d.evaluate(g),g.featureState||{})],properties:[Af,[],g=>g.properties()],"geometry-type":[Ca,[],g=>g.geometryType()],worldview:[Ca,[],g=>g.globals.worldview||""],"is-active-floor":[bi,by(Ca),(g,d)=>{if(!(g.globals.activeFloors&&g.globals.activeFloors.size>0))return!1;const m=g.globals.activeFloors;return d.some(v=>{const k=v.evaluate(g);return m.has(k)})}],id:[ui,[],g=>g.id()],zoom:[Rr,[],g=>g.globals.zoom],pitch:[Rr,[],g=>g.globals.pitch||0],"distance-from-center":[Rr,[],g=>g.distanceFromCenter()],"measure-light":[Rr,[Ca],(g,[d])=>g.measureLight(d.evaluate(g))],"heatmap-density":[Rr,[],g=>g.globals.heatmapDensity||0],"line-progress":[Rr,[],g=>g.globals.lineProgress||0],"raster-value":[Rr,[],g=>g.globals.rasterValue||0],"raster-particle-speed":[Rr,[],g=>g.globals.rasterParticleSpeed||0],"sky-radial-progress":[Rr,[],g=>g.globals.skyRadialProgress||0],accumulated:[ui,[],g=>g.globals.accumulated===void 0?null:g.globals.accumulated],"+":[Rr,by(Rr),(g,d)=>{let m=0;for(const v of d)m+=v.evaluate(g);return m}],"*":[Rr,by(Rr),(g,d)=>{let m=1;for(const v of d)m*=v.evaluate(g);return m}],"-":{type:Rr,overloads:[[[Rr,Rr],(g,[d,m])=>d.evaluate(g)-m.evaluate(g)],[[Rr],(g,[d])=>-d.evaluate(g)]]},"/":[Rr,[Rr,Rr],(g,[d,m])=>d.evaluate(g)/m.evaluate(g)],"%":[Rr,[Rr,Rr],(g,[d,m])=>d.evaluate(g)%m.evaluate(g)],ln2:[Rr,[],()=>Math.LN2],pi:[Rr,[],()=>Math.PI],e:[Rr,[],()=>Math.E],"^":[Rr,[Rr,Rr],(g,[d,m])=>Math.pow(d.evaluate(g),m.evaluate(g))],sqrt:[Rr,[Rr],(g,[d])=>Math.sqrt(d.evaluate(g))],log10:[Rr,[Rr],(g,[d])=>Math.log(d.evaluate(g))/Math.LN10],ln:[Rr,[Rr],(g,[d])=>Math.log(d.evaluate(g))],log2:[Rr,[Rr],(g,[d])=>Math.log2(d.evaluate(g))],sin:[Rr,[Rr],(g,[d])=>Math.sin(d.evaluate(g))],cos:[Rr,[Rr],(g,[d])=>Math.cos(d.evaluate(g))],tan:[Rr,[Rr],(g,[d])=>Math.tan(d.evaluate(g))],asin:[Rr,[Rr],(g,[d])=>Math.asin(d.evaluate(g))],acos:[Rr,[Rr],(g,[d])=>Math.acos(d.evaluate(g))],atan:[Rr,[Rr],(g,[d])=>Math.atan(d.evaluate(g))],min:[Rr,by(Rr),(g,d)=>Math.min(...d.map(m=>m.evaluate(g)))],max:[Rr,by(Rr),(g,d)=>Math.max(...d.map(m=>m.evaluate(g)))],abs:[Rr,[Rr],(g,[d])=>Math.abs(d.evaluate(g))],round:[Rr,[Rr],(g,[d])=>{const m=d.evaluate(g);return m<0?-Math.round(-m):Math.round(m)}],floor:[Rr,[Rr],(g,[d])=>Math.floor(d.evaluate(g))],ceil:[Rr,[Rr],(g,[d])=>Math.ceil(d.evaluate(g))],"filter-==":[bi,[Ca,ui],(g,[d,m])=>g.properties()[d.value]===m.value],"filter-id-==":[bi,[ui],(g,[d])=>g.id()===d.value],"filter-type-==":[bi,[Ca],(g,[d])=>g.geometryType()===d.value],"filter-<":[bi,[Ca,ui],(g,[d,m])=>{const v=g.properties()[d.value],k=m.value;return typeof v==typeof k&&v{const m=g.id(),v=d.value;return typeof m==typeof v&&m":[bi,[Ca,ui],(g,[d,m])=>{const v=g.properties()[d.value],k=m.value;return typeof v==typeof k&&v>k}],"filter-id->":[bi,[ui],(g,[d])=>{const m=g.id(),v=d.value;return typeof m==typeof v&&m>v}],"filter-<=":[bi,[Ca,ui],(g,[d,m])=>{const v=g.properties()[d.value],k=m.value;return typeof v==typeof k&&v<=k}],"filter-id-<=":[bi,[ui],(g,[d])=>{const m=g.id(),v=d.value;return typeof m==typeof v&&m<=v}],"filter->=":[bi,[Ca,ui],(g,[d,m])=>{const v=g.properties()[d.value],k=m.value;return typeof v==typeof k&&v>=k}],"filter-id->=":[bi,[ui],(g,[d])=>{const m=g.id(),v=d.value;return typeof m==typeof v&&m>=v}],"filter-has":[bi,[ui],(g,[d])=>d.value in g.properties()],"filter-has-id":[bi,[],g=>g.id()!==null&&g.id()!==void 0],"filter-type-in":[bi,[Dd(Ca)],(g,[d])=>d.value.indexOf(g.geometryType())>=0],"filter-id-in":[bi,[Dd(ui)],(g,[d])=>d.value.indexOf(g.id())>=0],"filter-in-small":[bi,[Ca,Dd(ui)],(g,[d,m])=>m.value.indexOf(g.properties()[d.value])>=0],"filter-in-large":[bi,[Ca,Dd(ui)],(g,[d,m])=>function(v,k,E,P){for(;E<=P;){const O=E+P>>1;if(k[O]===v)return!0;k[O]>v?P=O-1:E=O+1}return!1}(g.properties()[d.value],m.value,0,m.value.length-1)],all:{type:bi,overloads:[[[bi,bi],(g,[d,m])=>d.evaluate(g)&&m.evaluate(g)],[by(bi),(g,d)=>{for(const m of d)if(!m.evaluate(g))return!1;return!0}]]},any:{type:bi,overloads:[[[bi,bi],(g,[d,m])=>d.evaluate(g)||m.evaluate(g)],[by(bi),(g,d)=>{for(const m of d)if(m.evaluate(g))return!0;return!1}]]},"!":[bi,[bi],(g,[d])=>!d.evaluate(g)],"is-supported-script":[bi,[Ca],(g,[d])=>{const m=g.globals&&g.globals.isSupportedScript;return!m||m(d.evaluate(g))}],upcase:[Ca,[Ca],(g,[d])=>d.evaluate(g).toUpperCase()],downcase:[Ca,[Ca],(g,[d])=>d.evaluate(g).toLowerCase()],concat:[Ca,by(ui),(g,d)=>d.map(m=>Vm(m.evaluate(g))).join("")],"resolved-locale":[Ca,[uC],(g,[d])=>d.evaluate(g).resolvedLocale()],random:[Rr,[Rr,Rr,ui],(g,d)=>{const[m,v,k]=d.map(P=>P.evaluate(g));if(m>v||m===v)return m;let E;if(typeof k=="string")E=function(P){let O=0;if(P.length===0)return O;for(let B=0;BJSON.stringify(te)).join(", ")}, but found ${JSON.stringify(J)} instead.`);return J}catch(J){const te=J;return this._warningHistory[te.message]||(this._warningHistory[te.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${te.message}`)),this._defaultValue}}}function sw(g){return Array.isArray(g)&&g.length>0&&typeof g[0]=="string"&&g[0]in J1}function jy(g,d,m,v,k){const E=new MC(J1,[],d?function(O){const B={color:sh,string:Ca,number:Rr,enum:Ca,boolean:bi,formatted:$2,resolvedImage:q2};return O.type==="array"?Dd(B[O.value]||ui,O.length):B[O.type]}(d):void 0,void 0,void 0,m,v,k),P=E.parse(g,void 0,void 0,void 0,d&&d.type==="string"?{typeAnnotation:"coerce"}:void 0);return P?NR(new $C(P,d,m,v,k)):wy(E.errors)}class e_{constructor(d,m,v,k){this.kind=d,this._styleExpression=m,this.isLightConstant=v,this.isLineProgressConstant=k,this.isStateDependent=d!=="constant"&&!Z2(m.expression),this.configDependencies=X0(m.expression),this.isIndoorDependent=FC(m.expression)}evaluateWithoutErrorHandling(d,m,v,k,E,P){return this._styleExpression.evaluateWithoutErrorHandling(d,m,v,k,E,P)}evaluate(d,m,v,k,E,P,O){return this._styleExpression.evaluate(d,m,v,k,E,P,void 0,void 0,O)}}class Q0{constructor(d,m,v,k,E,P){this.kind=d,this.zoomStops=v,this._styleExpression=m,this.isStateDependent=d!=="camera"&&!Z2(m.expression),this.isIndoorDependent=FC(m.expression),this.isLightConstant=E,this.isLineProgressConstant=P,this.configDependencies=X0(m.expression),this.interpolationType=k}evaluateWithoutErrorHandling(d,m,v,k,E,P){return this._styleExpression.evaluateWithoutErrorHandling(d,m,v,k,E,P)}evaluate(d,m,v,k,E,P){return this._styleExpression.evaluate(d,m,v,k,E,P)}interpolationFactor(d,m,v){return this.interpolationType?sm.interpolationFactor(this.interpolationType,d,m,v):0}}function XE(g,d,m,v,k){if((g=jy(g,d,m,v,k)).result==="error")return g;const E=g.value.expression,P=W1(E);if(!P&&!tw(d))return wy([new Um("","data expressions not supported")]);const O=G1(E,["zoom","pitch","distance-from-center"]);if(!O&&!CR(d))return wy([new Um("","zoom expressions not supported")]);const B=G1(E,["measure-light"]);if(!B&&!SR(d))return wy([new Um("","measure-light expression not supported")]);const W=G1(E,["line-progress"]);if(!W&&!function(ie){return YE(ie.expression,"line-progress")}(d))return wy([new Um("","line-progress expression not supported")]);const J=d.expression&&d.expression.relaxZoomRestriction,te=Lp(E);return te||O||J?te instanceof Um?wy([te]):te instanceof sm&&!zC(d)?wy([new Um("",'"interpolate" expressions cannot be used with this property')]):NR(te?new Q0(P&&W?"camera":"composite",g.value,te.labels,te instanceof sm?te.interpolation:void 0,B,W):new e_(P&&W?"constant":"source",g.value,B,W)):wy([new Um("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class qC{constructor(d,m){this._parameters=d,this._specification=m,Object.assign(this,TR(this._parameters,this._specification))}static deserialize(d){return new qC(d._parameters,d._specification)}static serialize(d){return{_parameters:d._parameters,_specification:d._specification}}}function Lp(g){let d=null;if(g instanceof Zg)d=Lp(g.result);else if(g instanceof Q2){for(const m of g.args)if(d=Lp(m),d)break}else(g instanceof Y2||g instanceof sm)&&g.input instanceof Tu&&g.input.name==="zoom"&&(d=g);return d instanceof Um||g.eachChild(m=>{const v=Lp(m);v instanceof Um?d=v:d&&v&&d!==v&&(d=new Um("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),d}var QE,PR,IR=function(){if(PR)return QE;PR=1,QE=d;var g=3;function d(m,v,k){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*(k=P[2]);for(var O=0;O=ie[Ne+0]&&E>=ie[Ne+1])?(B[ue]=!0,O.push(te[ue])):B[ue]=!1}}},d.prototype._forEachCell=function(m,v,k,E,P,O,B,W){for(var J=this._convertToCellCoord(m),te=this._convertToCellCoord(v),ie=this._convertToCellCoord(k),ce=this._convertToCellCoord(E),ue=J;ue<=ie;ue++)for(var Ne=te;Ne<=ce;Ne++){var Le=this.d*Ne+ue;if((!W||W(this._convertFromCellCoord(ue),this._convertFromCellCoord(Ne),this._convertFromCellCoord(ue+1),this._convertFromCellCoord(Ne+1)))&&P.call(this,m,v,k,E,Le,O,B,W))return}},d.prototype._convertFromCellCoord=function(m){return(m-this.padding)/this.scale},d.prototype._convertToCellCoord=function(m){return Math.max(0,Math.min(this.d-1,Math.floor(m*this.scale)+this.padding))},d.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var m=this.cells,v=g+this.cells.length+1+1,k=0,E=0;E=0||(k[E]=Yg(g[E],d)));g instanceof Error&&(k.message=g.message)}if(k.$name)throw new Error("$name property is reserved for worker serialization logic.");return v!=="Object"&&(k.$name=v),k}throw new Error("can't serialize object of type "+typeof g)}function ky(g){if(g==null||typeof g=="boolean"||typeof g=="number"||typeof g=="string"||g instanceof Boolean||g instanceof Number||g instanceof String||g instanceof Date||g instanceof RegExp||rw(g)||g instanceof ImageBitmap||ArrayBuffer.isView(g)||g instanceof ImageData)return g;if(Array.isArray(g))return g.map(ky);if(typeof g=="object"){const d=g.$name||"Object";if(d==="Map"){const k=g.entries||[],E=new Map;for(let P=0;Pg>=128&&g<=255,Arabic:g=>g>=1536&&g<=1791,"Arabic Supplement":g=>g>=1872&&g<=1919,"Arabic Extended-A":g=>g>=2208&&g<=2303,"Hangul Jamo":g=>g>=4352&&g<=4607,"Unified Canadian Aboriginal Syllabics":g=>g>=5120&&g<=5759,Khmer:g=>g>=6016&&g<=6143,"Unified Canadian Aboriginal Syllabics Extended":g=>g>=6320&&g<=6399,"General Punctuation":g=>g>=8192&&g<=8303,"Letterlike Symbols":g=>g>=8448&&g<=8527,"Number Forms":g=>g>=8528&&g<=8591,"Miscellaneous Technical":g=>g>=8960&&g<=9215,"Control Pictures":g=>g>=9216&&g<=9279,"Optical Character Recognition":g=>g>=9280&&g<=9311,"Enclosed Alphanumerics":g=>g>=9312&&g<=9471,"Geometric Shapes":g=>g>=9632&&g<=9727,"Miscellaneous Symbols":g=>g>=9728&&g<=9983,"Miscellaneous Symbols and Arrows":g=>g>=11008&&g<=11263,"CJK Radicals Supplement":g=>g>=11904&&g<=12031,"Kangxi Radicals":g=>g>=12032&&g<=12255,"Ideographic Description Characters":g=>g>=12272&&g<=12287,"CJK Symbols and Punctuation":g=>g>=12288&&g<=12351,Hiragana:g=>g>=12352&&g<=12447,Katakana:g=>g>=12448&&g<=12543,Bopomofo:g=>g>=12544&&g<=12591,"Hangul Compatibility Jamo":g=>g>=12592&&g<=12687,Kanbun:g=>g>=12688&&g<=12703,"Bopomofo Extended":g=>g>=12704&&g<=12735,"CJK Strokes":g=>g>=12736&&g<=12783,"Katakana Phonetic Extensions":g=>g>=12784&&g<=12799,"Enclosed CJK Letters and Months":g=>g>=12800&&g<=13055,"CJK Compatibility":g=>g>=13056&&g<=13311,"CJK Unified Ideographs Extension A":g=>g>=13312&&g<=19903,"Yijing Hexagram Symbols":g=>g>=19904&&g<=19967,"CJK Unified Ideographs":g=>g>=19968&&g<=40959,"Yi Syllables":g=>g>=40960&&g<=42127,"Yi Radicals":g=>g>=42128&&g<=42191,"Hangul Jamo Extended-A":g=>g>=43360&&g<=43391,"Hangul Syllables":g=>g>=44032&&g<=55215,"Hangul Jamo Extended-B":g=>g>=55216&&g<=55295,"Private Use Area":g=>g>=57344&&g<=63743,"CJK Compatibility Ideographs":g=>g>=63744&&g<=64255,"Arabic Presentation Forms-A":g=>g>=64336&&g<=65023,"Vertical Forms":g=>g>=65040&&g<=65055,"CJK Compatibility Forms":g=>g>=65072&&g<=65103,"Small Form Variants":g=>g>=65104&&g<=65135,"Arabic Presentation Forms-B":g=>g>=65136&&g<=65279,"Halfwidth and Fullwidth Forms":g=>g>=65280&&g<=65519,Osage:g=>g>=66736&&g<=66815,"CJK Unified Ideographs Extension B":g=>g>=131072&&g<=173791};function nw(g){for(const d of g)if(UC(d.charCodeAt(0)))return!0;return!1}function JE(g){for(const d of g)if(!LR(d.charCodeAt(0)))return!1;return!0}function LR(g){return!(Yr.Arabic(g)||Yr["Arabic Supplement"](g)||Yr["Arabic Extended-A"](g)||Yr["Arabic Presentation Forms-A"](g)||Yr["Arabic Presentation Forms-B"](g))}function UC(g){return!(g!==746&&g!==747&&(g<4352||!(Yr["Bopomofo Extended"](g)||Yr.Bopomofo(g)||Yr["CJK Compatibility Forms"](g)&&!(g>=65097&&g<=65103)||Yr["CJK Compatibility Ideographs"](g)||Yr["CJK Compatibility"](g)||Yr["CJK Radicals Supplement"](g)||Yr["CJK Strokes"](g)||!(!Yr["CJK Symbols and Punctuation"](g)||g>=12296&&g<=12305||g>=12308&&g<=12319||g===12336)||Yr["CJK Unified Ideographs Extension A"](g)||Yr["CJK Unified Ideographs"](g)||Yr["Enclosed CJK Letters and Months"](g)||Yr["Hangul Compatibility Jamo"](g)||Yr["Hangul Jamo Extended-A"](g)||Yr["Hangul Jamo Extended-B"](g)||Yr["Hangul Jamo"](g)||Yr["Hangul Syllables"](g)||Yr.Hiragana(g)||Yr["Ideographic Description Characters"](g)||Yr.Kanbun(g)||Yr["Kangxi Radicals"](g)||Yr["Katakana Phonetic Extensions"](g)||Yr.Katakana(g)&&g!==12540||!(!Yr["Halfwidth and Fullwidth Forms"](g)||g===65288||g===65289||g===65293||g>=65306&&g<=65310||g===65339||g===65341||g===65343||g>=65371&&g<=65503||g===65507||g>=65512&&g<=65519)||!(!Yr["Small Form Variants"](g)||g>=65112&&g<=65118||g>=65123&&g<=65126)||Yr["Unified Canadian Aboriginal Syllabics"](g)||Yr["Unified Canadian Aboriginal Syllabics Extended"](g)||Yr["Vertical Forms"](g)||Yr["Yijing Hexagram Symbols"](g)||Yr["Yi Syllables"](g)||Yr["Yi Radicals"](g))))}function VC(g){return!(UC(g)||function(d){return!!(Yr["Latin-1 Supplement"](d)&&(d===167||d===169||d===174||d===177||d===188||d===189||d===190||d===215||d===247)||Yr["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)||Yr["Letterlike Symbols"](d)||Yr["Number Forms"](d)||Yr["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)||Yr["Control Pictures"](d)&&d!==9251||Yr["Optical Character Recognition"](d)||Yr["Enclosed Alphanumerics"](d)||Yr["Geometric Shapes"](d)||Yr["Miscellaneous Symbols"](d)&&!(d>=9754&&d<=9759)||Yr["Miscellaneous Symbols and Arrows"](d)&&(d>=11026&&d<=11055||d>=11088&&d<=11097||d>=11192&&d<=11243)||Yr["CJK Symbols and Punctuation"](d)||Yr.Katakana(d)||Yr["Private Use Area"](d)||Yr["CJK Compatibility Forms"](d)||Yr["Small Form Variants"](d)||Yr["Halfwidth and Fullwidth Forms"](d)||d===8734||d===8756||d===8757||d>=9984&&d<=10087||d>=10102&&d<=10131||d===65532||d===65533)}(g))}function HC(g){return Yr.Arabic(g)||Yr["Arabic Supplement"](g)||Yr["Arabic Extended-A"](g)||Yr["Arabic Presentation Forms-A"](g)||Yr["Arabic Presentation Forms-B"](g)}function eP(g){return g>=1424&&g<=2303||Yr["Arabic Presentation Forms-A"](g)||Yr["Arabic Presentation Forms-B"](g)}function Xg(g,d){return!(!d&&eP(g)||g>=2304&&g<=3583||g>=3840&&g<=4255||Yr.Khmer(g))}function Eme(g){for(const d of g)if(eP(d.charCodeAt(0)))return!0;return!1}const kh={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let tP=null,Au=kh.unavailable,Qg=null;const aw=function(g){g&&typeof g=="string"&&g.indexOf("NetworkError")>-1&&(Au=kh.error),tP&&tP(g)};function WC(){GC.fire(new qm("pluginStateChange",{pluginStatus:Au,pluginURL:Qg}))}const GC=new Ts,iw=function(){return Au},DR=function(){if(Au!==kh.deferred||!Qg)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Au=kh.loading,WC(),Qg&&jh({url:Qg},g=>{g?aw(g):(Au=kh.loaded,WC())})},Jg={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Au===kh.loaded||Jg.applyArabicShaping!=null,isLoading:()=>Au===kh.loading,setState(g){Au=g.pluginStatus,Qg=g.pluginURL},isParsing:()=>Au===kh.parsing,isParsed:()=>Au===kh.parsed,getPluginURL:()=>Qg};class Hi{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 k of m)if(!Xg(k.charCodeAt(0),v))return!1;return!0}(d,Jg.isLoaded())}}class KC{constructor(d,m,v,k,E){this.property=d,this.value=m,this.expression=function(P,O,B,W,J){if(BC(P))return new qC(P,O);if(sw(P)||Array.isArray(P)&&P.length>0){const te=XE(P,O,B,W,J);if(te.result==="error")throw new Error(te.value.map(ie=>`${ie.key}: ${ie.message}`).join(", "));return te.value}{let te=P;return typeof P=="string"&&O.type==="color"&&(te=Fr.parse(P)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>te}}}(m===void 0?d.specification.default:m,d.specification,v,k,E)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(d,m,v,k){return this.property.possiblyEvaluate(this,d,m,v,k)}}class sP{constructor(d,m,v,k){this.property=d,this.value=new KC(d,void 0,m,v,k)}transitioned(d,m){return new RR(this.property,this.value,m,Object.assign({},d.transition,this.transition),d.now)}untransitioned(){return new RR(this.property,this.value,null,{},0)}}class OR{constructor(d,m,v,k){this._properties=d,this._values=Object.create(d.defaultTransitionablePropertyValues),this._scope=m,this._options=v,this._iconImageUseTheme=k,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 sP(this._values[d].property,this._scope,this._options,this._iconImageUseTheme)),this._values[d].value=new KC(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 k in d){const E=d[k];if(k.endsWith("-transition")){const P=k.slice(0,-11);v[P]&&this.setTransition(P,E)}else v.hasOwnProperty(k)&&this.setValue(k,E)}}getTransition(d){return gs(this._values[d].transition)}setTransition(d,m){this._values.hasOwnProperty(d)||(this._values[d]=new sP(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 k=this.getTransition(m);k!==void 0&&(d[`${m}-transition`]=k)}return d}transitioned(d,m){const v=new FR(this._properties);for(const k of Object.keys(this._values))v._values[k]=this._values[k].transitioned(d,m._values[k]);return v}untransitioned(){const d=new FR(this._properties);for(const m of Object.keys(this._values))d._values[m]=this._values[m].untransitioned();return d}isIndoorDependent(){return this._isIndoorDependent}}class RR{constructor(d,m,v,k,E){const P=k.delay||0,O=k.duration||0;E=E||0,this.property=d,this.value=m,this.begin=E+P,this.end=this.begin+O,d.specification.transition&&(k.delay||k.duration)&&(this.prior=v)}possiblyEvaluate(d,m,v){const k=d.now||0,E=this.value.possiblyEvaluate(d,m,v),P=this.prior;if(P){if(k>this.end)return this.prior=null,E;if(this.value.isDataDriven())return this.prior=null,E;if(k":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*"}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-gradient":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["line-progress"]}},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1]},"line-trim-fade-range":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-trim-color":{"type":"color","default":"transparent","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"use-theme":true,"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d"},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function BR(g){return g instanceof Number||g instanceof String||g instanceof Boolean?g.valueOf():g}function ZC(g){if(Array.isArray(g))return g.map(ZC);if(g instanceof Object&&!(g instanceof Number||g instanceof String||g instanceof Boolean)){const d={};for(const m in g)d[m]=ZC(g[m]);return d}return BR(g)}function Df(g){if(g===!0||g===!1)return!0;if(!Array.isArray(g)||g.length===0)return!1;switch(g[0]){case"has":return g.length>=2&&g[1]!=="$id"&&g[1]!=="$type";case"in":return g.length>=3&&(typeof g[1]!="string"||Array.isArray(g[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return g.length!==3||Array.isArray(g[1])||Array.isArray(g[2]);case"any":case"all":for(const d of g.slice(1))if(!Df(d)&&typeof d!="boolean")return!1;return!0;default:return!0}}function YC(g,d="",m=null,v="fill"){if(g==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Df(g)||(g=XC(g));const k=g;let E=!0;try{E=function(J){if(!s_(J))return J;let te=ZC(J);return $R(te),te=rv(te),te}(k)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md and paste the contents of this message in the report. Thank you! Filter Expression: ${JSON.stringify(k,null,2)} `)}let P=null,O=null;if(v!=="background"&&v!=="sky"&&v!=="slot"){O=Gt[`filter_${v}`];const J=jy(E,O,d,m);if(J.result==="error")throw new Error(J.value.map(te=>`${te.key}: ${te.message}`).join(", "));P=(te,ie,ce)=>J.value.evaluate(te,ie,{},ce)}let B=null,W=null;if(E!==k){const J=jy(k,O,d,m);if(J.result==="error")throw new Error(J.value.map(te=>`${te.key}: ${te.message}`).join(", "));B=(te,ie,ce,ue,Ne)=>J.value.evaluate(te,ie,{},ce,void 0,void 0,ue,Ne),W=!W1(J.value.expression)}return{filter:P,dynamicFilter:B||void 0,needGeometry:qR(E),needFeature:!!W}}function rv(g){if(!Array.isArray(g))return g;const d=function(m){if(Pme.has(m[0])){for(let v=1;vrv(m))}function $R(g){let d=!1;const m=[];if(g[0]==="case"){for(let v=1;v",">=","<","<=","to-boolean"]);function Ime(g,d){return gd?1:0}function qR(g){if(!Array.isArray(g))return!1;if(g[0]==="within"||g[0]==="distance")return!0;for(let d=1;d"||d==="<="||d===">="?QC(g[1],g[2],d):d==="any"?(m=g.slice(1),["any"].concat(m.map(XC))):d==="all"?["all"].concat(g.slice(1).map(XC)):d==="none"?["all"].concat(g.slice(1).map(XC).map(ow)):d==="in"?JC(g[1],g.slice(2)):d==="!in"?ow(JC(g[1],g.slice(2))):d==="has"?e3(g[1]):d!=="!has"||ow(e3(g[1]));var m}function QC(g,d,m){switch(g){case"$type":return[`filter-type-${m}`,d];case"$id":return[`filter-id-${m}`,d];default:return[`filter-${m}`,g,d]}}function JC(g,d){if(d.length===0)return!1;switch(g){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",g,["literal",d.sort(Ime)]]:["filter-in-small",g,["literal",d]]}}function e3(g){switch(g){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",g]}}function ow(g){return["!",g]}const nv="";function Dp(g,d){return d?`${g}${nv}${d}`:g}let UR;const VR=()=>UR||(UR=new Mo({"icon-size":new ir(Gt.layout_symbol["icon-size"]),"icon-image":new ir(Gt.layout_symbol["icon-image"]),"icon-rotate":new ir(Gt.layout_symbol["icon-rotate"]),"icon-offset":new ir(Gt.layout_symbol["icon-offset"]),"text-size":new ir(Gt.layout_symbol["text-size"]),"text-rotate":new ir(Gt.layout_symbol["text-rotate"]),"text-offset":new ir(Gt.layout_symbol["text-offset"])}));class HR{constructor(d,m,v,k,E,P){const O=jy(d,Gt.appearance.condition);if(O.result==="success"&&(this.condition=O.value),this.name=m,v){this.properties=new tv(VR()),this.unevaluatedLayout=new zR(VR(),k,E,P);for(const B in v)this.unevaluatedLayout.setValue(B,v[B])}}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"),k=this.hasProperty("icon-rotate");return d||m||v||k}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 WR="-transition",Of=new Set(["fill","line","background","hillshade","raster"]);class Eu extends Ts{constructor(d,m,v,k,E,P){if(super(),this.id=d.id,this.fqid=Dp(this.id,v),this.type=d.type,this.scope=v,this.lut=k,this.options=E,this.iconImageUseTheme=P,this.appearances=new Array,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},d.type!=="custom"){if(this.metadata=d.metadata,this.minzoom=d.minzoom,this.maxzoom=d.maxzoom,d.type&&d.type!=="background"&&d.type!=="sky"&&d.type!=="slot"){this.source=d.source,this.sourceLayer=d["source-layer"],this.filter=d.filter;const O=jy(this.filter,Gt[`filter_${d.type}`]);O.result!=="error"&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...O.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||O.value.isIndoorDependent)}if(d.slot&&(this.slot=d.slot),d.appearances&&this.setAppearances(d.appearances),m.layout&&(this._unevaluatedLayout=new zR(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 OR(m.paint,this.scope,E);for(const O in d.paint)this.setPaintProperty(O,d.paint[O]);for(const O in d.layout)this.setLayoutProperty(O,d.layout[O]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new tv(m.paint)}}}onAdd(d){}onRemove(d){}isDraped(d){return!this.is3D(!0)&&Of.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 HR(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(WR)?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,k=v._properties.properties;if(d.endsWith(WR)){const te=d.slice(0,-11);return k[te]&&v.setTransition(te,m||void 0),!1}if(!k[d])return!1;const E=v._values[d],P=E.value.isDataDriven(),O=E.value;v.setValue(d,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...v.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||v.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(d);const B=v._values[d].value,W=B.isDataDriven(),J=d.endsWith("pattern")||d==="line-dasharray";return W||P||J||this._handleOverridablePaintPropertyUpdate(d,O,B)}_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())),Is(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 ev&&tw(m.property.specification)&&(m.value.kind==="source"||m.value.kind==="composite")&&m.value.isStateDependent)return!0}for(const d of this.appearances)if(!Z2(d.condition.expression))return!0;return!1}compileFilter(d){this._filterCompiled||(this._featureFilter=YC(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,k,E,P,O,B,W){}}const GR={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class lw{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 Lme=new ArrayBuffer(0);class Ji{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=Lme),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 la(g,d=1){let m=0,v=0;return{members:g.map(k=>{const E=GR[k.type].BYTES_PER_ELEMENT,P=m=KR(m,Math.max(d,E)),O=k.components||1;return v=Math.max(v,E),m+=E*O,{name:k.name,type:k.type,components:O,offset:P}}),size:KR(m,Math.max(v,d)),alignment:d}}function KR(g,d){return Math.ceil(g/d)*d}class Ny extends Ji{_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 k=2*d;return this.int16[k+0]=m,this.int16[k+1]=v,d}}Ny.prototype.bytesPerElement=4,_r(Ny,"StructArrayLayout2i4");class r_ extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v){const k=this.length;return this.resize(k+1),this.emplace(k,d,m,v)}emplace(d,m,v,k){const E=3*d;return this.int16[E+0]=m,this.int16[E+1]=v,this.int16[E+2]=k,d}}r_.prototype.bytesPerElement=6,_r(r_,"StructArrayLayout3i6");class n_ extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,k){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,k)}emplace(d,m,v,k,E){const P=4*d;return this.int16[P+0]=m,this.int16[P+1]=v,this.int16[P+2]=k,this.int16[P+3]=E,d}}n_.prototype.bytesPerElement=8,_r(n_,"StructArrayLayout4i8");class ex extends Ji{_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}}ex.prototype.bytesPerElement=4,_r(ex,"StructArrayLayout1f4");class rP extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v){const k=this.length;return this.resize(k+1),this.emplace(k,d,m,v)}emplace(d,m,v,k){const E=4*d,P=2*d;return this.int16[E+0]=m,this.int16[E+1]=v,this.float32[P+1]=k,d}}rP.prototype.bytesPerElement=8,_r(rP,"StructArrayLayout2i1f8");class nP extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v){const k=this.length;return this.resize(k+1),this.emplace(k,d,m,v)}emplace(d,m,v,k){const E=4*d;return this.int16[E+0]=m,this.int16[E+1]=v,this.int16[E+2]=k,d}}nP.prototype.bytesPerElement=8,_r(nP,"StructArrayLayout3i8");class aP extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,k,E)}emplace(d,m,v,k,E,P){const O=5*d;return this.int16[O+0]=m,this.int16[O+1]=v,this.int16[O+2]=k,this.int16[O+3]=E,this.int16[O+4]=P,d}}aP.prototype.bytesPerElement=10,_r(aP,"StructArrayLayout5i10");class t3 extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,d,m,v,k,E,P,O)}emplace(d,m,v,k,E,P,O,B){const W=6*d,J=12*d,te=3*d;return this.int16[W+0]=m,this.int16[W+1]=v,this.uint8[J+4]=k,this.uint8[J+5]=E,this.uint8[J+6]=P,this.uint8[J+7]=O,this.float32[te+2]=B,d}}t3.prototype.bytesPerElement=12,_r(t3,"StructArrayLayout2i4ub1f12");class rm extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v){const k=this.length;return this.resize(k+1),this.emplace(k,d,m,v)}emplace(d,m,v,k){const E=3*d;return this.float32[E+0]=m,this.float32[E+1]=v,this.float32[E+2]=k,d}}rm.prototype.bytesPerElement=12,_r(rm,"StructArrayLayout3f12");class rh extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,k,E)}emplace(d,m,v,k,E,P){const O=6*d,B=3*d;return this.uint16[O+0]=m,this.uint16[O+1]=v,this.uint16[O+2]=k,this.uint16[O+3]=E,this.float32[B+2]=P,d}}rh.prototype.bytesPerElement=12,_r(rh,"StructArrayLayout4ui1f12");class av extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v,k){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,k)}emplace(d,m,v,k,E){const P=4*d;return this.uint16[P+0]=m,this.uint16[P+1]=v,this.uint16[P+2]=k,this.uint16[P+3]=E,d}}av.prototype.bytesPerElement=8,_r(av,"StructArrayLayout4ui8");class s3 extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,d,m,v,k,E,P)}emplace(d,m,v,k,E,P,O){const B=6*d;return this.int16[B+0]=m,this.int16[B+1]=v,this.int16[B+2]=k,this.int16[B+3]=E,this.int16[B+4]=P,this.int16[B+5]=O,d}}s3.prototype.bytesPerElement=12,_r(s3,"StructArrayLayout6i12");class iP extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E,P,O,B,W,J,te,ie){const ce=this.length;return this.resize(ce+1),this.emplace(ce,d,m,v,k,E,P,O,B,W,J,te,ie)}emplace(d,m,v,k,E,P,O,B,W,J,te,ie,ce){const ue=12*d;return this.int16[ue+0]=m,this.int16[ue+1]=v,this.int16[ue+2]=k,this.int16[ue+3]=E,this.uint16[ue+4]=P,this.uint16[ue+5]=O,this.uint16[ue+6]=B,this.uint16[ue+7]=W,this.int16[ue+8]=J,this.int16[ue+9]=te,this.int16[ue+10]=ie,this.int16[ue+11]=ce,d}}iP.prototype.bytesPerElement=24,_r(iP,"StructArrayLayout4i4ui4i24");class oP extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,d,m,v,k,E,P)}emplace(d,m,v,k,E,P,O){const B=10*d,W=5*d;return this.int16[B+0]=m,this.int16[B+1]=v,this.int16[B+2]=k,this.float32[W+2]=E,this.float32[W+3]=P,this.float32[W+4]=O,d}}oP.prototype.bytesPerElement=20,_r(oP,"StructArrayLayout3i3f20");class Sy extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,k){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,k)}emplace(d,m,v,k,E){const P=4*d;return this.float32[P+0]=m,this.float32[P+1]=v,this.float32[P+2]=k,this.float32[P+3]=E,d}}Sy.prototype.bytesPerElement=16,_r(Sy,"StructArrayLayout4f16");class r3 extends Ji{_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}}r3.prototype.bytesPerElement=4,_r(r3,"StructArrayLayout1ul4");class nm extends Ji{_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 k=2*d;return this.uint16[k+0]=m,this.uint16[k+1]=v,d}}nm.prototype.bytesPerElement=4,_r(nm,"StructArrayLayout2ui4");class n3 extends Ji{_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,k,E,P,O,B,W,J,te,ie,ce){const ue=this.length;return this.resize(ue+1),this.emplace(ue,d,m,v,k,E,P,O,B,W,J,te,ie,ce)}emplace(d,m,v,k,E,P,O,B,W,J,te,ie,ce,ue){const Ne=20*d,Le=10*d;return this.int16[Ne+0]=m,this.int16[Ne+1]=v,this.int16[Ne+2]=k,this.int16[Ne+3]=E,this.int16[Ne+4]=P,this.float32[Le+3]=O,this.float32[Le+4]=B,this.float32[Le+5]=W,this.float32[Le+6]=J,this.int16[Ne+14]=te,this.uint32[Le+8]=ie,this.uint16[Ne+18]=ce,this.uint16[Ne+19]=ue,d}}n3.prototype.bytesPerElement=40,_r(n3,"StructArrayLayout5i4f1i1ul2ui40");class a3 extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,d,m,v,k,E,P,O)}emplace(d,m,v,k,E,P,O,B){const W=8*d;return this.int16[W+0]=m,this.int16[W+1]=v,this.int16[W+2]=k,this.int16[W+4]=E,this.int16[W+5]=P,this.int16[W+6]=O,this.int16[W+7]=B,d}}a3.prototype.bytesPerElement=16,_r(a3,"StructArrayLayout3i2i2i16");class i3 extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,k,E)}emplace(d,m,v,k,E,P){const O=4*d,B=8*d;return this.float32[O+0]=m,this.float32[O+1]=v,this.float32[O+2]=k,this.int16[B+6]=E,this.int16[B+7]=P,d}}i3.prototype.bytesPerElement=16,_r(i3,"StructArrayLayout2f1f2i16");class lP extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,d,m,v,k,E,P)}emplace(d,m,v,k,E,P,O){const B=20*d,W=5*d;return this.uint8[B+0]=m,this.uint8[B+1]=v,this.float32[W+1]=k,this.float32[W+2]=E,this.float32[W+3]=P,this.float32[W+4]=O,d}}lP.prototype.bytesPerElement=20,_r(lP,"StructArrayLayout2ub4f20");class Il extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v){const k=this.length;return this.resize(k+1),this.emplace(k,d,m,v)}emplace(d,m,v,k){const E=3*d;return this.uint16[E+0]=m,this.uint16[E+1]=v,this.uint16[E+2]=k,d}}Il.prototype.bytesPerElement=6,_r(Il,"StructArrayLayout3ui6");class a_ extends Ji{_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,k,E,P,O,B,W,J,te,ie,ce,ue,Ne,Le,Ie,Ge,Ze,at,vt){const pt=this.length;return this.resize(pt+1),this.emplace(pt,d,m,v,k,E,P,O,B,W,J,te,ie,ce,ue,Ne,Le,Ie,Ge,Ze,at,vt)}emplace(d,m,v,k,E,P,O,B,W,J,te,ie,ce,ue,Ne,Le,Ie,Ge,Ze,at,vt,pt){const St=30*d,Lt=15*d,Bt=60*d;return this.int16[St+0]=m,this.int16[St+1]=v,this.int16[St+2]=k,this.float32[Lt+2]=E,this.float32[Lt+3]=P,this.uint16[St+8]=O,this.uint16[St+9]=B,this.uint32[Lt+5]=W,this.uint32[Lt+6]=J,this.uint32[Lt+7]=te,this.uint16[St+16]=ie,this.uint16[St+17]=ce,this.uint16[St+18]=ue,this.float32[Lt+10]=Ne,this.float32[Lt+11]=Le,this.uint8[Bt+48]=Ie,this.uint8[Bt+49]=Ge,this.uint8[Bt+50]=Ze,this.uint32[Lt+13]=at,this.int16[St+28]=vt,this.uint8[Bt+58]=pt,d}}a_.prototype.bytesPerElement=60,_r(a_,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class cP extends Ji{_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,k,E,P,O,B,W,J,te,ie,ce,ue,Ne,Le,Ie,Ge,Ze,at,vt,pt,St,Lt,Bt,as,Wt,us,bs,ws,Fs,Bs,Ds){const Os=this.length;return this.resize(Os+1),this.emplace(Os,d,m,v,k,E,P,O,B,W,J,te,ie,ce,ue,Ne,Le,Ie,Ge,Ze,at,vt,pt,St,Lt,Bt,as,Wt,us,bs,ws,Fs,Bs,Ds)}emplace(d,m,v,k,E,P,O,B,W,J,te,ie,ce,ue,Ne,Le,Ie,Ge,Ze,at,vt,pt,St,Lt,Bt,as,Wt,us,bs,ws,Fs,Bs,Ds,Os){const ds=20*d,is=40*d,Rs=80*d;return this.float32[ds+0]=m,this.float32[ds+1]=v,this.int16[is+4]=k,this.int16[is+5]=E,this.int16[is+6]=P,this.int16[is+7]=O,this.int16[is+8]=B,this.int16[is+9]=W,this.int16[is+10]=J,this.int16[is+11]=te,this.int16[is+12]=ie,this.uint16[is+13]=ce,this.uint16[is+14]=ue,this.uint16[is+15]=Ne,this.uint16[is+16]=Le,this.uint16[is+17]=Ie,this.uint16[is+18]=Ge,this.uint16[is+19]=Ze,this.uint16[is+20]=at,this.uint16[is+21]=vt,this.uint16[is+22]=pt,this.uint16[is+23]=St,this.uint16[is+24]=Lt,this.uint16[is+25]=Bt,this.uint16[is+26]=as,this.uint16[is+27]=Wt,this.uint32[ds+14]=us,this.float32[ds+15]=bs,this.float32[ds+16]=ws,this.float32[ds+17]=Fs,this.float32[ds+18]=Bs,this.uint8[Rs+76]=Ds,this.uint16[is+39]=Os,d}}cP.prototype.bytesPerElement=80,_r(cP,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class dP extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,d,m,v,k,E,P)}emplace(d,m,v,k,E,P,O){const B=6*d;return this.float32[B+0]=m,this.float32[B+1]=v,this.float32[B+2]=k,this.float32[B+3]=E,this.float32[B+4]=P,this.float32[B+5]=O,d}}dP.prototype.bytesPerElement=24,_r(dP,"StructArrayLayout6f24");class iv extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,k,E)}emplace(d,m,v,k,E,P){const O=5*d;return this.float32[O+0]=m,this.float32[O+1]=v,this.float32[O+2]=k,this.float32[O+3]=E,this.float32[O+4]=P,d}}iv.prototype.bytesPerElement=20,_r(iv,"StructArrayLayout5f20");class uP extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,d,m,v,k,E,P,O)}emplace(d,m,v,k,E,P,O,B){const W=7*d;return this.float32[W+0]=m,this.float32[W+1]=v,this.float32[W+2]=k,this.float32[W+3]=E,this.float32[W+4]=P,this.float32[W+5]=O,this.float32[W+6]=B,d}}uP.prototype.bytesPerElement=28,_r(uP,"StructArrayLayout7f28");class hP extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E,P,O,B,W,J,te){const ie=this.length;return this.resize(ie+1),this.emplace(ie,d,m,v,k,E,P,O,B,W,J,te)}emplace(d,m,v,k,E,P,O,B,W,J,te,ie){const ce=11*d;return this.float32[ce+0]=m,this.float32[ce+1]=v,this.float32[ce+2]=k,this.float32[ce+3]=E,this.float32[ce+4]=P,this.float32[ce+5]=O,this.float32[ce+6]=B,this.float32[ce+7]=W,this.float32[ce+8]=J,this.float32[ce+9]=te,this.float32[ce+10]=ie,d}}hP.prototype.bytesPerElement=44,_r(hP,"StructArrayLayout11f44");class i_ extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E,P,O,B,W){const J=this.length;return this.resize(J+1),this.emplace(J,d,m,v,k,E,P,O,B,W)}emplace(d,m,v,k,E,P,O,B,W,J){const te=9*d;return this.float32[te+0]=m,this.float32[te+1]=v,this.float32[te+2]=k,this.float32[te+3]=E,this.float32[te+4]=P,this.float32[te+5]=O,this.float32[te+6]=B,this.float32[te+7]=W,this.float32[te+8]=J,d}}i_.prototype.bytesPerElement=36,_r(i_,"StructArrayLayout9f36");class Rf extends Ji{_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 k=2*d;return this.float32[k+0]=m,this.float32[k+1]=v,d}}Rf.prototype.bytesPerElement=8,_r(Rf,"StructArrayLayout2f8");class nh extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v,k){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,k)}emplace(d,m,v,k,E){const P=6*d;return this.uint32[3*d+0]=m,this.uint16[P+2]=v,this.uint16[P+3]=k,this.uint16[P+4]=E,d}}nh.prototype.bytesPerElement=12,_r(nh,"StructArrayLayout1ul3ui12");class Cy extends Ji{_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}}Cy.prototype.bytesPerElement=2,_r(Cy,"StructArrayLayout1ui2");class mP extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E,P,O,B,W,J,te,ie,ce,ue,Ne,Le){const Ie=this.length;return this.resize(Ie+1),this.emplace(Ie,d,m,v,k,E,P,O,B,W,J,te,ie,ce,ue,Ne,Le)}emplace(d,m,v,k,E,P,O,B,W,J,te,ie,ce,ue,Ne,Le,Ie){const Ge=16*d;return this.float32[Ge+0]=m,this.float32[Ge+1]=v,this.float32[Ge+2]=k,this.float32[Ge+3]=E,this.float32[Ge+4]=P,this.float32[Ge+5]=O,this.float32[Ge+6]=B,this.float32[Ge+7]=W,this.float32[Ge+8]=J,this.float32[Ge+9]=te,this.float32[Ge+10]=ie,this.float32[Ge+11]=ce,this.float32[Ge+12]=ue,this.float32[Ge+13]=Ne,this.float32[Ge+14]=Le,this.float32[Ge+15]=Ie,d}}mP.prototype.bytesPerElement=64,_r(mP,"StructArrayLayout16f64");class o3 extends Ji{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,k,E,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,d,m,v,k,E,P,O)}emplace(d,m,v,k,E,P,O,B){const W=10*d,J=5*d;return this.uint16[W+0]=m,this.uint16[W+1]=v,this.uint16[W+2]=k,this.uint16[W+3]=E,this.float32[J+2]=P,this.float32[J+3]=O,this.float32[J+4]=B,d}}o3.prototype.bytesPerElement=20,_r(o3,"StructArrayLayout4ui3f20");class pP extends Ji{_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}}pP.prototype.bytesPerElement=2,_r(pP,"StructArrayLayout1i2");class l3 extends Ji{_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}}l3.prototype.bytesPerElement=1,_r(l3,"StructArrayLayout1ub1");class c3 extends lw{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]}}c3.prototype.size=40;class ZR extends n3{get(d){return new c3(this,d)}}_r(ZR,"CollisionBoxArray");class d3 extends lw{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}}d3.prototype.size=60;class YR extends a_{get(d){return new d3(this,d)}}_r(YR,"PlacedSymbolArray");class XR extends lw{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]}}XR.prototype.size=80;class fP extends cP{get(d){return new XR(this,d)}}_r(fP,"SymbolInstanceArray");class u3 extends ex{getoffsetX(d){return this.float32[1*d+0]}}_r(u3,"GlyphOffsetArray");class QR extends Ny{getx(d){return this.int16[2*d+0]}gety(d){return this.int16[2*d+1]}}_r(QR,"SymbolLineVertexArray");class gP extends lw{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]}}gP.prototype.size=12;class xP extends nh{get(d){return new gP(this,d)}}_r(xP,"FeatureIndexArray");class JR extends nm{geta_centroid_pos0(d){return this.uint16[2*d+0]}geta_centroid_pos1(d){return this.uint16[2*d+1]}}_r(JR,"FillExtrusionCentroidArray");class h3 extends lw{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]}}h3.prototype.size=6;class cw extends r_{get(d){return new h3(this,d)}}_r(cw,"FillExtrusionWallArray");const eF=la([{name:"a_pos",components:2,type:"Int16"}],4),Dme=la([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),tF=la([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class xo{constructor(d=[]){this.segments=d}_prepareSegment(d,m,v,k){let E=this.segments[this.segments.length-1];return d>xo.MAX_VERTEX_ARRAY_LENGTH&&hr(`Max vertices per segment is ${xo.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${d}`),(!E||E.vertexLength+d>xo.MAX_VERTEX_ARRAY_LENGTH||E.sortKey!==k)&&(E={vertexOffset:m,primitiveOffset:v,vertexLength:0,primitiveLength:0},k!==void 0&&(E.sortKey=k),this.segments.push(E)),E}prepareSegment(d,m,v,k){return this._prepareSegment(d,m.length,v.length,k)}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,k){return new xo([{vertexOffset:d,primitiveOffset:m,vertexLength:v,primitiveLength:k,vaos:{},sortKey:0}])}}function m3(g,d){return 256*(g=ve(Math.floor(g),0,255))+ve(Math.floor(d),0,255)}xo.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,_r(xo,"SegmentVector");const Ome=la([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Rme=la([{name:"a_pattern_b",components:4,type:"Uint16"}]),Fme=la([{name:"a_dash",components:4,type:"Uint16"}]);class dw{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(d,m,v,k){this.ids.push(yP(d)),this.positions.push(m,v,k)}eachPosition(d,m){const v=yP(d);let k=0,E=this.ids.length-1;for(;k>1;this.ids[P]>=v?E=P:k=P+1}for(;this.ids[k]===v;)m(this.positions[3*k],this.positions[3*k+1],this.positions[3*k+2]),k++}static serialize(d,m){const v=new Float64Array(d.ids),k=new Uint32Array(d.positions);return vP(v,k,0,v.length-1),m&&(m.add(v.buffer),m.add(k.buffer)),{ids:v,positions:k}}static deserialize(d){const m=new dw;let v;m.ids=d.ids,m.positions=d.positions;for(const k of m.ids)k!==v&&m.uniqueIds.push(k),v=k;return m.indexed=!0,m}}function yP(g){const d=+g;return Number.isSafeInteger(d)?d:z1(String(g))}function vP(g,d,m,v){for(;m>1];let E=m-1,P=v+1;for(;;){do E++;while(g[E]k);if(E>=P)break;p3(g,E,P),p3(d,3*E,3*P),p3(d,3*E+1,3*P+1),p3(d,3*E+2,3*P+2)}P-m`u_${E}`),this.type=v,this.context=k}setUniform(d,m,v,k,E){const P=k.constantOr(this.value);m.set(d,E,P instanceof Fr?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 hw(d):new Ll(d)}}class o_{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,k,E){let P=null;E!=="u_pattern"&&E!=="u_dash"||(P=this.pattern),E==="u_pattern_b"&&(P=this.patternTransition),E==="u_pixel_ratio"&&(P=this.pixelRatio),P&&m.set(d,E,P)}getBinding(d,m){return m==="u_pattern"||m==="u_pattern_b"||m==="u_dash"?new g3(d):new Ll(d)}}class sx{constructor(d,m,v,k){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 k}populatePaintArray(d,m,v,k,E,P,O,B){const W=this.paintVertexArray.length,J=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Hi(0,{brightness:P,worldview:B}),m,{},E,k,O):this.expression.kind==="constant"&&this.expression.value,te=pw(this.lutExpression,m,{},k,E,P,O,B);this.paintVertexArray.resize(d),this._setPaintValue(W,d,J,te?null:this.context.lut)}updatePaintArray(d,m,v,k,E,P,O,B){const W=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:O,worldview:B},v,k,void 0,E):this.expression.kind==="constant"&&this.expression.value,J=pw(this.lutExpression,v,k,E,void 0,O,void 0,B);this._setPaintValue(d,m,W,J?null:this.context.lut)}_setPaintValue(d,m,v,k){if(this.type==="color"){const E=_P(v.toPremultipliedRenderColor(k));for(let P=d;P`u_${O}_t`),this.type=v,this.useIntegerZoom=k,this.context=E,this.maxValue=0,this.paintVertexAttributes=m.map(O=>({name:`a_${O}`,type:"Float32",components:v==="color"?4:2,offset:0})),this.paintVertexArray=new P}populatePaintArray(d,m,v,k,E,P,O,B){const W=this.expression.evaluate(new Hi(this.context.zoom,{brightness:P,worldview:B}),m,{},E,k,O),J=this.expression.evaluate(new Hi(this.context.zoom+1,{brightness:P,worldview:B}),m,{},E,k,O),te=pw(this.lutExpression,m,{},k,E,P,O,B),ie=this.paintVertexArray.length;this.paintVertexArray.resize(d),this._setPaintValue(ie,d,W,J,te?null:this.context.lut)}updatePaintArray(d,m,v,k,E,P,O,B){const W=this.expression.evaluate({zoom:this.context.zoom,brightness:O,worldview:B},v,k,void 0,E),J=this.expression.evaluate({zoom:this.context.zoom+1,brightness:O,worldview:B},v,k,void 0,E),te=pw(this.lutExpression,v,k,E,void 0,O,void 0,B);this._setPaintValue(d,m,W,J,te?null:this.context.lut)}_setPaintValue(d,m,v,k,E){if(this.type==="color"){const P=_P(v.toPremultipliedRenderColor(E)),O=_P(v.toPremultipliedRenderColor(E));for(let B=d;B!0){this.binders={},this._buffers=[],this.context=m;const k=[];for(const E in d.paint._values){const P=d.paint.get(E);if(E.endsWith("-use-theme")||!v(E)||!(P instanceof ev&&tw(P.property.specification)))continue;const O=qme(E,d.type),B=P.value,W=P.property.specification.type,J=!!P.property.useIntegerZoom,te=E==="line-dasharray"||E.endsWith("pattern"),ie=d.paint.get(`${E}-use-theme`),ce=E==="line-dasharray"&&d.layout.get("line-cap").value.kind!=="constant"||ie&&ie.value.kind!=="constant";if(B.kind!=="constant"||ce)if(B.kind==="source"||ce||te){const ue=bP(E,W,"source");this.binders[E]=te?new nx(B,O,W,ue,d.id):new sx(B,O,W,ue),k.push(`/a_${E}`)}else{const ue=bP(E,W,"composite");this.binders[E]=new rx(B,O,W,J,m,ue),k.push(`/z_${E}`)}else this.binders[E]=te?new o_(B.value,O):new fw(B.value,O,W,m),k.push(`/u_${E}`);ie&&(this.binders[E].lutExpression=ie.value)}this.cacheKey=k.sort().join("")}getMaxValue(d){const m=this.binders[d];return m instanceof sx||m instanceof rx?m.maxValue:0}populatePaintArrays(d,m,v,k,E,P,O,B){for(const W in this.binders){const J=this.binders[W];J.context=this.context,(J instanceof sx||J instanceof rx||J instanceof nx)&&J.populatePaintArray(d,m,v,k,E,P,O,B)}}setConstantPatternPositions(d,m){for(const v in this.binders){const k=this.binders[v];k instanceof o_&&k.setConstantPatternPositions(d,m)}}getPatternTransitionVertexBuffer(d){const m=this.binders[d];return m instanceof nx?m.paintTransitionVertexBuffer:null}updatePaintArrays(d,m,v,k,E,P,O,B,W,J){let te=!1;const ie=Object.keys(d),ce=ie.length!==0&&!B,ue=ce?ie:m.uniqueIds;this.context.lut=E.lut;for(const Ne in this.binders){const Le=this.binders[Ne];if(Le.context=this.context,(Le instanceof sx||Le instanceof rx||Le instanceof nx)&&Le.expression&&Le.expression.kind&&Le.expression.kind!=="constant"&&(Le.expression.isStateDependent===!0||Le.expression.isLightConstant===!1)){const Ie=E.paint.get(Ne);Le.expression=Ie.value;for(const Ge of ue){const Ze=d[Ge.toString()];m.eachPosition(Ge,(at,vt,pt)=>{const St=k.feature(at);Le.updatePaintArray(vt,pt,St,Ze,P,O,W,J)})}if(!ce)for(const Ge of v.uniqueIds){const Ze=d[Ge.toString()];v.eachPosition(Ge,(at,vt,pt)=>{const St=k.feature(at);Le.updatePaintArray(vt,pt,St,Ze,P,O,W,J)})}te=!0}}return te}defines(){const d=[];for(const m in this.binders){const v=this.binders[m];(v instanceof fw||v instanceof o_)&&d.push(...v.uniformNames.map(k=>`#define HAS_UNIFORM_${k}`))}return d}getPaintVertexBuffers(){return this._buffers}getUniforms(d){const m=[];for(const v in this.binders){const k=this.binders[v];if(k instanceof fw||k instanceof o_||k instanceof rx)for(const E of k.uniformNames)m.push({name:E,property:v,binding:k.getBinding(d,E)})}return m}setUniforms(d,m,v,k,E){for(const{name:P,property:O,binding:B}of v)this.binders[O].setUniform(d,B,E,k.get(O),P)}updatePaintBuffers(){this._buffers=[];for(const d in this.binders){const m=this.binders[d];(m instanceof sx||m instanceof rx||m instanceof nx)&&m.paintVertexBuffer&&this._buffers.push(m.paintVertexBuffer),m instanceof nx&&m.paintTransitionVertexBuffer&&this._buffers.push(m.paintTransitionVertexBuffer)}}upload(d){for(const m in this.binders){const v=this.binders[m];(v instanceof sx||v instanceof rx||v instanceof nx)&&v.upload(d)}this.updatePaintBuffers()}destroy(){for(const d in this.binders){const m=this.binders[d];(m instanceof sx||m instanceof rx||m instanceof nx)&&m.destroy()}}}class Op{constructor(d,m,v=()=>!0){this.programConfigurations={};for(const k of d)this.programConfigurations[k.id]=new My(k,m,v);this.needsUpload=!1,this._featureMap=new dw,this._featureMapWithoutIds=new dw,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(d,m,v,k,E,P,O,B,W){for(const J in this.programConfigurations)this.programConfigurations[J].populatePaintArrays(d,m,k,E,P,O,B,W);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,k,E,P,O,B){for(const W of v)this.needsUpload=this.programConfigurations[W.id].updatePaintArrays(d,this._featureMap,this._featureMapWithoutIds,m,W,k,E,P,O||0,B)||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 $me={"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(g,d){return $me[g]||[g.replace(`${d}-`,"").replace(/-/g,"_")]}const Ume={"line-pattern":{source:rh,composite:rh},"fill-pattern":{source:rh,composite:rh},"fill-extrusion-pattern":{source:rh,composite:rh},"line-dasharray":{source:av,composite:av}},Vme={color:{source:Rf,composite:Sy},number:{source:ex,composite:Rf}};function bP(g,d,m){const v=Ume[g];return v&&v[m]||Vme[d][m]}_r(fw,"ConstantBinder"),_r(o_,"PatternConstantBinder"),_r(sx,"SourceExpressionBinder"),_r(nx,"PatternCompositeBinder"),_r(rx,"CompositeExpressionBinder"),_r(My,"ProgramConfiguration",{omit:["_buffers"]}),_r(Op,"ProgramConfigurationSet");const Od=Qs/Math.PI/2,Gm=5,v3=6,Hme=16383,l_=64,wP=[l_,32,16],Km=-Od,Zm=Od;function ov(g,d,m,v=Od){return m=Ir(m),[g*Math.sin(m)*v,-d*v,g*Math.cos(m)*v]}function c_(g,d,m){return ov(Math.cos(Ir(g)),Math.sin(Ir(g)),d,m)}const M=63710088e-1,h=2*Math.PI*M;class x{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 x(Qe(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,k=d.lat*m,E=Math.sin(v)*Math.sin(k)+Math.cos(v)*Math.cos(k)*Math.cos((d.lng-this.lng)*m);return M*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 c_(this.lat,this.lng,Od+d*Od/M)}static convert(d){if(d instanceof x)return d;if(Array.isArray(d)&&(d.length===2||d.length===3))return new x(Number(d[0]),Number(d[1]));if(!Array.isArray(d)&&typeof d=="object"&&d!==null)return new x(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 x?new x(d.lng,d.lat):x.convert(d),this}setSouthWest(d){return this._sw=d instanceof x?new x(d.lng,d.lat):x.convert(d),this}extend(d){const m=this._sw,v=this._ne;let k,E;if(d instanceof x)k=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(x.convert(d)):typeof d=="object"&&d!==null&&d.hasOwnProperty("lat")&&(d.hasOwnProperty("lon")||d.hasOwnProperty("lng"))?this.extend(x.convert(d)):this;if(k=d._sw,E=d._ne,!k||!E)return this}return m||v?(m.lng=Math.min(k.lng,m.lng),m.lat=Math.min(k.lat,m.lat),v.lng=Math.max(E.lng,v.lng),v.lat=Math.max(E.lat,v.lat)):(this._sw=new x(k.lng,k.lat),this._ne=new x(E.lng,E.lat)),this}getCenter(){return new x((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new x(this.getWest(),this.getNorth())}getSouthEast(){return new x(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(d){const{lng:m,lat:v}=x.convert(d);let k=this._sw.lng<=m&&m<=this._ne.lng;return this._sw.lng>this._ne.lng&&(k=this._sw.lng>=m&&m>=this._ne.lng),this._sw.lat<=v&&v<=this._ne.lat&&k}static convert(d){if(d)return d instanceof A?d:new A(d)}}const D=0,F=25.5;function z(g){return h*Math.cos(g*Math.PI/180)}function H(g){return(180+g)/360}function Y(g){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+g*Math.PI/360)))/360}function ae(g,d){return g/z(d)}function oe(g){return 360*g-180}function ge(g){return 360/Math.PI*Math.atan(Math.exp((180-360*g)*Math.PI/180))-90}function fe(g,d){return g*z(ge(d))}const xe=85.051129;function Pe(g){return Math.cos(Ir(ve(g,-xe,xe)))}function Ce(g,d){const m=ve(d,D,F),v=Math.pow(2,m);return Pe(g)*h/(512*v)}function Ve(g){return 1/Math.cos(g*Math.PI/180)}function Be(g,d=0){const m=Math.exp(Math.PI*(1-(g.y+d/Qs)/(1<=B?(ut(g,d,m,W,J,E,te,O,B),ut(g,W,J,v,k,te,P,O,B)):g.push(P)}function st(g,d,m){let v=g[0],k=v.x,E=v.y;d(v);const P=[v];for(let O=1;Og.x+1||vg.y+1)&&hr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),g}function Pt(g,d,m){const v=g.loadGeometry(),k=g.extent,E=Qs/k;if(d&&m&&m.projection.isReprojectedInTileSpace){const P=1<{const ce=oe((d.x+ie.x/k)/P),ue=ge((d.y+ie.y/k)/P),Ne=J.project(ce,ue);ie.x=(Ne.x*O-B)*k,ie.y=(Ne.y*O-W)*k};for(let ie=0;ie=k||ue.y<0||ue.y>=k||(te(ue),ce.push(ue));v[ie]=ce}}for(const P of v)for(const O of P)mt(O,E);return v}function Ht(g,d){return{type:g.type,id:g.id,properties:g.properties,geometry:d?Pt(g):[]}}class Ut{constructor(d,m,v,k,E){this.properties={},this.extent=v,this.type=0,this.id=void 0,this._pbf=d,this._geometry=-1,this._keys=k,this._values=E,d.readFields(ts,this,m)}loadGeometry(){const d=this._pbf;d.pos=this._geometry;const m=d.readVarint()+d.pos,v=[];let k,E=1,P=0,O=0,B=0;for(;d.pos>3}if(P--,E===1||E===2)O+=d.readSVarint(),B+=d.readSVarint(),E===1&&(k&&v.push(k),k=[]),k&&k.push(new es(O,B));else{if(E!==7)throw new Error(`unknown command ${E}`);k&&k.push(k[0].clone())}}return k&&v.push(k),v}bbox(){const d=this._pbf;d.pos=this._geometry;const m=d.readVarint()+d.pos;let v=1,k=0,E=0,P=0,O=1/0,B=-1/0,W=1/0,J=-1/0;for(;d.pos>3}if(k--,v===1||v===2)E+=d.readSVarint(),P+=d.readSVarint(),EB&&(B=E),PJ&&(J=P);else if(v!==7)throw new Error(`unknown command ${v}`)}return[O,W,B,J]}toGeoJSON(d,m,v){const k=this.extent*Math.pow(2,v),E=this.extent*d,P=this.extent*m,O=this.loadGeometry();function B(ie){return[360*(ie.x+E)/k-180,360/Math.PI*Math.atan(Math.exp((1-2*(ie.y+P)/k)*Math.PI))-90]}function W(ie){return ie.map(B)}let J;if(this.type===1){const ie=[];for(const ue of O)ie.push(ue[0]);const ce=W(ie);J=ie.length===1?{type:"Point",coordinates:ce[0]}:{type:"MultiPoint",coordinates:ce}}else if(this.type===2){const ie=O.map(W);J=ie.length===1?{type:"LineString",coordinates:ie[0]}:{type:"MultiLineString",coordinates:ie}}else{if(this.type!==3)throw new Error("unknown feature type");{const ie=function(ue){const Ne=ue.length;if(Ne<=1)return[ue];const Le=[];let Ie,Ge;for(let Ze=0;Ze=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 Ut(this._pbf,m,this.extent,this._keys,this._values)}}function qs(g,d,m){g===15?d.version=m.readVarint():g===1?d.name=m.readString():g===5?d.extent=m.readVarint():g===2?d._features.push(m.pos):g===3?d._keys.push(m.readString()):g===4&&d._values.push(function(v){let k=null;const E=v.readVarint()+v.pos;for(;v.pos>3;k=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(k==null)throw new Error("unknown feature value");return k}(m))}class Yt{constructor(d,m){this.layers=d.readFields(Ft,{},m)}}function Ft(g,d,m){if(g===3){const v=new fs(m,m.readVarint()+m.pos);v.length&&(d[v.name]=v)}}const ls="3d_elevation_id",Jt="level";class Ls{constructor(){this._valid=!1}reset(d){return this.feature=d,this._valid=!0,this._geometry=d.loadGeometry(),this._geometry.length!==0&&this._geometry[0].length!==0||(this._valid=!1),this}geometry(d,m){return this._valid&&d(m(this._geometry)),this}require(d,m,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,k){const E=this.feature.properties.hasOwnProperty(d)?+this.feature.properties[d]:void 0;return this._valid&&E!==void 0&&!Number.isNaN(E)?v(k?k(E):E):m&&(this._valid=!1),this}}class er{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 pr=new er((g,d,m)=>g.reset(d).require(ls,v=>{m.id=v}).optional("fixed_height_relative",v=>{m.constantHeight=v},Vs.decodeRelativeHeight).geometry(v=>{m.bounds=v},Kg).success(),(g,d,m)=>g.reset(d).require(ls,v=>{m.id=v}).require("elevation_idx",v=>{m.idx=v}).require("extent",v=>{m.extent=v}).require("height_relative",v=>{m.height=v},Vs.decodeRelativeHeight).geometry(v=>{m.position=v},Vs.getPoint).success()),Xs=new er((g,d,m)=>g.reset(d).require(ls,v=>{m.id=v}).optional("fixed_height",v=>{m.constantHeight=v},Vs.decodeMetricHeight).geometry(v=>{m.bounds=v},Kg).success(),(g,d,m)=>g.reset(d).require(ls,v=>{m.id=v}).require("elevation_idx",v=>{m.idx=v}).require("extent",v=>{m.extent=v}).require("height",v=>{m.height=v},Vs.decodeMetricHeight).geometry(v=>{m.position=v},Vs.getPoint).success());class Vs{static getPoint(d){return jt(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"?Xs:void 0:pr}static parse(d){const m=[],v=[],k=d.length,E=new Ls;for(let P=0;P=0);if(E===0)return 0;E!==d.length&&(m=!1)}return m?2:1}function kn(g,d){for(const m of g.projections){const v=xr(d,g.points[0],m.axis);if(m.projection[1]v[1])return 0}return 1}function ga(g,d){let m=0;const v=[0,0,0,0];for(let P=0;P=0&&m++;var k,E;return m}class Ja{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=Er.fromPoints(this.points),this.projections=[],this.frustumEdges=[Se([],this.points[2],this.points[3]),Se([],this.points[0],this.points[3]),Se([],this.points[4],this.points[0]),Se([],this.points[5],this.points[1]),Se([],this.points[6],this.points[2]),Se([],this.points[7],this.points[3])];for(const v of this.frustumEdges){const k=[0,-v[2],v[1]],E=[v[2],0,-v[0]];this.projections.push({axis:k,projection:xr(this.points,this.points[0],k)}),this.projections.push({axis:E,projection:xr(this.points,this.points[0],E)})}}static fromInvProjectionMatrix(d,m,v,k){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(W=>{const J=Xe([],W,d),te=1/J[3]/m*E;return(ie=J)[0]=(ce=J)[0]*(ue=[te,te,k?1/J[3]:te,te])[0],ie[1]=ce[1]*ue[1],ie[2]=ce[2]*ue[2],ie[3]=ce[3]*ue[3],ie;var ie,ce,ue}),O=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(W=>{const J=Te([],ct([],Se([],P[W[0]],P[W[1]]),Se([],P[W[2]],P[W[1]]))),te=-qe(J,P[W[1]]);return J.concat(te)}),B=[];for(let W=0;WW[1]||W[0]>B[1])return 0}return 1}containsPoint(d){for(const m of this.planes){const v=m[3];if(qe([m[0],m[1],m[2]],d)+v<0)return!1}return!0}}class Er{static fromPoints(d){const m=[1/0,1/0,1/0],v=[-1/0,-1/0,-1/0];for(const k of d)ye(m,m,k),je(v,v,k);return new Er(m,v)}static fromTileIdAndHeight(d,m,v){const k=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])]}}_r(Er,"Aabb");class Wa{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],k=-m[0],E=(d.extent+1)*this.metersToTile;return[new es(Math.trunc(d.position[0]+v*E),Math.trunc(d.position[1]+k*E)),new es(Math.trunc(d.position[0]-v*E),Math.trunc(d.position[1]-k*E))]}next(){this.index++}valid(){return this.index{return O.a0?ke(B,B,1/W):ne(B,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,k=0;const[E,P,O,B,W,J,te]=this._tmpVec2;As(te,d.x,d.y);const ie=new Cr(te,null);for(let ce=0;ce0?qa(B,O)/at:0,pt=ve(vt,0,1),St=Math.abs((vt-pt)*this.edgeProps[ce].len);ar(W,te,Le),As(J,Ne[1],-Ne[0]);const Lt=St+Math.abs(qa(W,J));Lt=0;--P){const O=this.edges[P].a,B=this.edges[P].b,{position:W,height:J,extent:te}=this.vertices[O],{position:ie,height:ce,extent:ue}=this.vertices[B],Ne=this.vertexProps[O].dir,Le=this.vertexProps[B].dir;if(ne(m,W[0]/d,W[1]/d,J),ne(v,ie[0]/d,ie[1]/d,ce),ne(k,Ne[1],-Ne[0],0),ke(k,k,te),ne(E,Le[1],-Le[0],0),ke(E,E,ue),this.distSqLines(re(m[0]+.5*k[0],m[1]+.5*k[1],m[2]+.5*k[2]),re(v[0]-.5*E[0],v[1]-.5*E[1],v[2]-.5*E[2]),re(m[0]-.5*k[0],m[1]-.5*k[1],m[2]-.5*k[2]),re(v[0]+.5*E[0],v[1]+.5*E[1],v[2]+.5*E[2]))<=.0025000000000000005)continue;const Ie=this.vertices.length,Ge=Ps(Ms(),W,ie);this.vertices.push({position:Dn(Ge,Ge,.5),height:.5*(J+ce),extent:.5*(te+ue)});const Ze=Ps(Ms(),Ne,Le);this.vertexProps.push({dir:pa(Ze,Ze)}),this.edges.splice(P,1),this.edgeProps.splice(P,1),this.edges.push({a:O,b:Ie}),this.edges.push({a:Ie,b:B});const at=ar(Ms(),this.vertices[Ie].position,W),vt=Va(at),pt={vec:at,dir:Dn(Ms(),at,1/vt),len:vt};this.edgeProps.push(pt),this.edgeProps.push(pt)}}distSqLines(d,m,v,k){const E=he(ee(),m,d),P=he(ee(),k,v),O=he(ee(),d,v),B=qe(E,E),W=qe(E,P),J=qe(E,O),te=qe(P,P),ie=qe(P,O),ce=B*te-W*W;if(ce===0)return Me(De(E,v,k,qe(O,P)/qe(P,P)),d);const ue=(B*ie-W*J)/ce;return Me(De(E,d,m,(W*ie-J*te)/ce),De(P,v,k,ue))}}class ii{static parseFrom(d,m){const v=Vs.parse(d);if(!v)return[];let{vertices:k,features:E}=v;const P=1/Be(m);E.sort((J,te)=>J.id-te.id),k.sort((J,te)=>J.id-te.id||J.idx-te.idx),k=k.filter((J,te,ie)=>te===ie.findIndex(ce=>ce.id===J.id&&ce.idx===J.idx));const O=new Array;let B=0;const W=k.length;for(const J of E){if(J.constantHeight){O.push(new _n(J.id,J.bounds,J.constantHeight));continue}for(;B!==W&&k[B].idk.id===v)}}class wi{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)*Qs,this.yOffset=(d.y*this.zScale-m.y)*Qs)}constantElevation(d,m){if(d.constantHeight!=null)return this.computeBiasedHeight(d.constantHeight,m)}pointElevation(d,m,v){const k=this.constantElevation(m,v);return k??(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*ze(0,m,d>=0?d:Math.abs(.5*d))}}_r(_n,"ElevationFeature");class pi{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 Ny,this.indexArray=new Il,this.segments=new xo,this.programConfigurations=new Op(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 ex),this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,k){}populate(d,m,v,k){const E=this.layers[0],P=[];let O=null;E.type==="circle"&&(O=E.layout.get("circle-sort-key"));for(const{feature:W,id:J,index:te,sourceLayerIndex:ie}of d){const ce=this.layers[0]._featureFilter.needGeometry,ue=Ht(W,ce);if(!this.layers[0]._featureFilter.filter(new Hi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ue,v))continue;const Ne=O?O.evaluate(ue,{},v):void 0,Le={id:J,properties:W.properties,type:W.type,sourceLayerIndex:ie,index:te,geometry:ce?ue.geometry:Pt(W,v,k),patterns:{},sortKey:Ne};P.push(Le)}O&&P.sort((W,J)=>W.sortKey-J.sortKey);let B=null;k.projection.name==="globe"&&(this.globeExtVertexArray=new s3,B=k.projection);for(const W of P){const{geometry:J,index:te,sourceLayerIndex:ie}=W,ce=d[te].feature;this.addFeature(W,J,te,m.availableImages,v,B,m.brightness,m.elevationFeatures),m.featureIndex.insert(ce,J,te,ie,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(d,m,v,k,E,P,O){this.programConfigurations.updatePaintArrays(d,m,E,v,k,P,O,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,eF.members),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=d.createVertexBuffer(this.globeExtVertexArray,tF.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=d.createVertexBuffer(this.elevatedLayoutVertexArray,Dme.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,k,E,P,O,B){let W;this.elevationMode!=="none"&&(W=ii.getElevationFeature(d,B));for(const J of m)for(const te of J){const ie=te.x,ce=te.y;if(ie<0||ie>=Qs||ce<0||ce>=Qs)continue;if(P){const Le=P.projectTilePoint(ie,ce,E),Ie=P.upVector(E,ie,ce);this.addGlobeExtVertex(Le,Ie),this.addGlobeExtVertex(Le,Ie),this.addGlobeExtVertex(Le,Ie),this.addGlobeExtVertex(Le,Ie)}const ue=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,d.sortKey),Ne=ue.vertexLength;if(this.addCircleVertex(ie,ce,-1,-1),this.addCircleVertex(ie,ce,1,-1),this.addCircleVertex(ie,ce,1,1),this.addCircleVertex(ie,ce,-1,1),this.elevationMode!=="none"){const Le=W?W.pointElevation(new es(ie,ce)):0;this.hasElevation=this.hasElevation||Le!==0;for(let Ie=0;Ie<4;Ie++)this.elevatedLayoutVertexArray.emplaceBack(Le)}this.indexArray.emplaceBack(Ne,Ne+1,Ne+2),this.indexArray.emplaceBack(Ne,Ne+2,Ne+3),ue.vertexLength+=4,ue.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,v,{},k,E,O,void 0,this.worldview)}addCircleVertex(d,m,v,k){this.layoutVertexArray.emplaceBack(2*d+(v+1)/2,2*m+(k+1)/2)}addGlobeExtVertex(d,m){this.globeExtVertexArray.emplaceBack(d.x,d.y,d.z,m[0]*16384,m[1]*16384,m[2]*16384)}}function Ua(g,d){for(let m=0;m1){if(eo(g,d))return!0;for(let v=0;v1?m:m.sub(d)._mult(k)._add(d))}function yo(g,d){let m,v,k,E=!1;for(let P=0;Pd.y!=k.y>d.y&&d.x<(k.x-v.x)*(d.y-v.y)/(k.y-v.y)+v.x&&(E=!E)}return E}function Ai(g,d){let m=!1;for(let v=0,k=g.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 Pu(g,d,m,v,k){for(const P of g)if(d<=P.x&&m<=P.y&&v>=P.x&&k>=P.y)return!0;const E=[new es(d,m),new es(d,k),new es(v,k),new es(v,m)];if(g.length>2){for(const P of E)if(Ai(g,P))return!0}for(let P=0;Pk.x&&d.x>k.x||g.yk.y&&d.y>k.y)return!1;const E=Cn(g,d,m[0]);return E!==Cn(g,d,m[1])||E!==Cn(g,d,m[2])||E!==Cn(g,d,m[3])}function Dl(g,d,m,v,k,E){let P=d.y-g.y,O=g.x-d.x;if(E=E||0){const B=P*P+O*O;if(B===0)return!0;const W=Math.sqrt(B);P/=W,O/=W}return!((m.x-g.x)*P+(m.y-g.y)*O-E<0||(v.x-g.x)*P+(v.y-g.y)*O-E<0||(k.x-g.x)*P+(k.y-g.y)*O-E<0)}function Rd(g,d,m,v,k,E,P){return!(Dl(g,d,v,k,E,P)||Dl(d,m,v,k,E,P)||Dl(m,g,v,k,E,P)||Dl(v,k,g,d,m,P)||Dl(k,E,g,d,m,P)||Dl(E,v,g,d,m,P))}function Fd(g,d,m){const v=d.paint.get(g).value;return v.kind==="constant"?v.value:m.programConfigurations.get(d.id).getMaxValue(g)}function Qc(g){return Math.sqrt(g[0]*g[0]+g[1]*g[1])}function am(g,d,m,v,k){if(!d[0]&&!d[1])return g;const E=es.convert(d)._mult(k);m==="viewport"&&E._rotate(-v);const P=[];for(let O=0;O>m&&d.y===this.y>>m}url(d,m){const v=function(E,P,O){var B=Wo(256*E,256*(P=Math.pow(2,O)-P-1),O),W=Wo(256*(E+1),256*(P+1),O);return B[0]+","+B[1]+","+W[0]+","+W[1]}(this.x,this.y,this.z),k=function(E,P,O){let B,W="";for(let J=E;J>0;J--)B=1<this.canonical.z?new jo(d,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new jo(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 vo(this.wrap*+m,d,this.canonical.z,this.canonical.x,this.canonical.y);{const v=this.canonical.z-d;return vo(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 jo(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,k=2*this.canonical.y;return[new jo(m,this.wrap,m,v,k),new jo(m,this.wrap,m,v+1,k),new jo(m,this.wrap,m,v,k+1),new jo(m,this.wrap,m,v+1,k+1)]}isLessThan(d){return this.wrapd.wrap)&&(this.overscaledZd.overscaledZ)&&(this.canonical.xd.canonical.x)&&this.canonical.y{let d=g.canonical.x-1,m=g.wrap;return d<0&&(d=(1<{let d=g.canonical.x+1,m=g.wrap;return d===1<new jo(g.overscaledZ,g.wrap,g.canonical.z,g.canonical.x,(g.canonical.y===0?1<new jo(g.overscaledZ,g.wrap,g.canonical.z,g.canonical.x,g.canonical.y===(1<1?null:function(v,k,E,P){const O=Math.sin(E);return v*(Math.sin((1-P)*E)/O)+k*(Math.sin(P*E)/O)}(g.a[d],g.b[d],g.angle,ve(m,0,1))+g.center[d]}function Fp(g){if(g.z<=1)return ax[g.z+2*g.y+g.x];const d=Wme(sF(g));return Er.fromPoints(d)}function ox(g,d,m){return ke(g,g,1-m),We(g,g,d,m)}function VSe(g,d,m){for(const v of g)Rt(v,v,d),ke(v,v,m)}function HSe(g,d,m,v){const k=d/g.worldSize,E=g.globeMatrix;if(m.z<=1){const Bt=Fp(m).getCorners();return VSe(Bt,E,k),Er.fromPoints(Bt)}const P=sF(m,v),O=Wme(P,Od+zf(g._tileCoverLift));VSe(O,E,k);const B=Number.MAX_VALUE,W=[-B,-B,-B],J=[B,B,B];if(P.contains(g.center)){for(const Wt of O)ye(J,J,Wt),je(W,W,Wt);W[2]=0;const Bt=g.point,as=[Bt.x*k,Bt.y*k,0];return ye(J,J,as),je(W,W,as),new Er(J,W)}if(g._tileCoverLift>0){for(const Bt of O)ye(J,J,Bt),je(W,W,Bt);return new Er(J,W)}const te=[E[12]*k,E[13]*k,E[14]*k],ie=P.getCenter(),ce=ve(g.center.lat,-xe,xe),ue=ve(ie.lat,-xe,xe),Ne=H(g.center.lng),Le=Y(ce);let Ie=Ne-H(ie.lng);const Ge=Le-Y(ue);Ie>.5?Ie-=1:Ie<-.5&&(Ie+=1);let Ze=0;Math.abs(Ie)>Math.abs(Ge)?Ze=Ie>=0?1:3:(Ze=Ge>=0?0:2,We(te,te,[E[4]*k,E[5]*k,E[6]*k],-Math.sin(Ir(Ge>=0?P.getSouth():P.getNorth()))*Od));const at=O[Ze],vt=O[(Ze+1)%4],pt=new Ty(at,vt,te),St=[ix(pt,0)||at[0],ix(pt,1)||at[1],ix(pt,2)||at[2]],Lt=h_(g.zoom);if(Lt>0){const Bt=function({x:Wt,y:us,z:bs},ws,Fs,Bs,Ds){const Os=1/(1<.5?Hs=-1:Dr<-.5&&(Hs=1),ds=((ds+Hs)*ws-(Bs*=ws))*Fs+Bs,is=((is+Hs)*ws-Bs)*Fs+Bs,Rs=(Rs*ws-(Ds*=ws))*Fs+Ds,Js=(Js*ws-Ds)*Fs+Ds,[[ds,Js,0],[is,Js,0],[is,Rs,0],[ds,Rs,0]]}(m,d,g._pixelsPerMercatorPixel,Ne,Le);for(let Wt=0;WtMath.PI/2*1.01}const YSe=Ir(85),zlt=Math.cos(YSe),Blt=Math.sin(YSe),$lt=b(),XSe=g=>{const d=[];return g.paint.get("circle-pitch-alignment")==="map"&&d.push("PITCH_WITH_MAP"),g.paint.get("circle-pitch-scale")==="map"&&d.push("SCALE_WITH_MAP"),d};function QSe(g,d,m,v,k,E,P,O,B){if(E&&g.queryGeometry.isAboveHorizon)return!1;E&&(B*=g.pixelToTileUnitsFactor);const W=g.tileID.canonical,J=m.projection.upVectorScale(W,m.center.lat,m.worldSize).metersToTile;for(const te of d)for(const ie of te){const ce=ie.add(O),ue=k&&m.elevation?m.elevation.exaggeration()*k.getElevationAt(ce.x,ce.y,!0):0,Ne=m.projection.projectTilePoint(ce.x,ce.y,W);if(ue>0){const Ze=m.projection.upVector(W,ce.x,ce.y);Ne.x+=Ze[0]*J*ue,Ne.y+=Ze[1]*J*ue,Ne.z+=Ze[2]*J*ue}const Le=E?ce:qlt(Ne.x,Ne.y,Ne.z,v),Ie=E?g.tilespaceRays.map(Ze=>Vlt(Ze,ue)):g.queryGeometry.screenGeometry,Ge=Xe([],[Ne.x,Ne.y,Ne.z,1],v);if(!P&&E?B*=Ge[3]/m.cameraToCenterDistance:P&&!E&&(B*=m.cameraToCenterDistance/Ge[3]),E){const Ze=ge((ie.y/Qs+W.y)/(1<g.width||k.height>g.height||m.x>g.width-k.width||m.y>g.height-k.height)throw new RangeError("out of range source coordinates for image copy");if(k.width>d.width||k.height>d.height||v.x>d.width-k.width||v.y>d.height-k.height)throw new RangeError("out of range destination coordinates for image copy");const B=g.data,W=d.data,J=E===4&&O;for(let te=0;te{d[g.evaluationKey]=B;const W=g.expression.evaluate(d),J=W?W.toNonPremultipliedRenderColor(null):null;J&&(k.data[P+O+0]=Math.floor(255*J.r),k.data[P+O+1]=Math.floor(255*J.g),k.data[P+O+2]=Math.floor(255*J.b),k.data[P+O+3]=Math.floor(255*J.a))};if(g.clips)for(let P=0,O=0;P80*m){O=g[0],B=g[1];let J=O,te=B;for(let ie=m;ieJ&&(J=ce),ue>te&&(te=ue)}W=Math.max(J-O,te-B),W=W!==0?32767/W:0}return NP(E,P,m,O,B,W,0),P}function lCe(g,d,m,v,k){let E;if(k===function(P,O,B,W){let J=0;for(let te=O,ie=B-W;te0)for(let P=d;P=d;P-=v)E=hCe(P/v|0,g[P],g[P+1],E);return E&&b3(E,E.next)&&(MP(E),E=E.next),E}function yw(g,d){if(!g)return g;d||(d=g);let m,v=g;do if(m=!1,v.steiner||!b3(v,v.next)&&Oc(v.prev,v,v.next)!==0)v=v.next;else{if(MP(v),v=d=v.prev,v===v.next)break;m=!0}while(m||v!==d);return d}function NP(g,d,m,v,k,E,P){if(!g)return;!P&&E&&function(B,W,J,te){let ie=B;do ie.z===0&&(ie.z=Xme(ie.x,ie.y,W,J,te)),ie.prevZ=ie.prev,ie.nextZ=ie.next,ie=ie.next;while(ie!==B);ie.prevZ.nextZ=null,ie.prevZ=null,function(ce){let ue,Ne=1;do{let Le,Ie=ce;ce=null;let Ge=null;for(ue=0;Ie;){ue++;let Ze=Ie,at=0;for(let pt=0;pt0||vt>0&&Ze;)at!==0&&(vt===0||!Ze||Ie.z<=Ze.z)?(Le=Ie,Ie=Ie.nextZ,at--):(Le=Ze,Ze=Ze.nextZ,vt--),Ge?Ge.nextZ=Le:ce=Le,Le.prevZ=Ge,Ge=Le;Ie=Ze}Ge.nextZ=null,Ne*=2}while(ue>1)}(ie)}(g,v,k,E);let O=g;for(;g.prev!==g.next;){const B=g.prev,W=g.next;if(E?Ylt(g,v,k,E):Zlt(g))d.push(B.i,g.i,W.i),MP(g),g=W.next,O=W.next;else if((g=W)===O){P?P===1?NP(g=Xlt(yw(g),d),d,m,v,k,E,2):P===2&&Qlt(g,d,m,v,k,E):NP(yw(g),d,m,v,k,E,1);break}}}function Zlt(g){const d=g.prev,m=g,v=g.next;if(Oc(d,m,v)>=0)return!1;const k=d.x,E=m.x,P=v.x,O=d.y,B=m.y,W=v.y,J=Math.min(k,E,P),te=Math.min(O,B,W),ie=Math.max(k,E,P),ce=Math.max(O,B,W);let ue=v.next;for(;ue!==d;){if(ue.x>=J&&ue.x<=ie&&ue.y>=te&&ue.y<=ce&&SP(k,O,E,B,P,W,ue.x,ue.y)&&Oc(ue.prev,ue,ue.next)>=0)return!1;ue=ue.next}return!0}function Ylt(g,d,m,v){const k=g.prev,E=g,P=g.next;if(Oc(k,E,P)>=0)return!1;const O=k.x,B=E.x,W=P.x,J=k.y,te=E.y,ie=P.y,ce=Math.min(O,B,W),ue=Math.min(J,te,ie),Ne=Math.max(O,B,W),Le=Math.max(J,te,ie),Ie=Xme(ce,ue,d,m,v),Ge=Xme(Ne,Le,d,m,v);let Ze=g.prevZ,at=g.nextZ;for(;Ze&&Ze.z>=Ie&&at&&at.z<=Ge;){if(Ze.x>=ce&&Ze.x<=Ne&&Ze.y>=ue&&Ze.y<=Le&&Ze!==k&&Ze!==P&&SP(O,J,B,te,W,ie,Ze.x,Ze.y)&&Oc(Ze.prev,Ze,Ze.next)>=0||(Ze=Ze.prevZ,at.x>=ce&&at.x<=Ne&&at.y>=ue&&at.y<=Le&&at!==k&&at!==P&&SP(O,J,B,te,W,ie,at.x,at.y)&&Oc(at.prev,at,at.next)>=0))return!1;at=at.nextZ}for(;Ze&&Ze.z>=Ie;){if(Ze.x>=ce&&Ze.x<=Ne&&Ze.y>=ue&&Ze.y<=Le&&Ze!==k&&Ze!==P&&SP(O,J,B,te,W,ie,Ze.x,Ze.y)&&Oc(Ze.prev,Ze,Ze.next)>=0)return!1;Ze=Ze.prevZ}for(;at&&at.z<=Ge;){if(at.x>=ce&&at.x<=Ne&&at.y>=ue&&at.y<=Le&&at!==k&&at!==P&&SP(O,J,B,te,W,ie,at.x,at.y)&&Oc(at.prev,at,at.next)>=0)return!1;at=at.nextZ}return!0}function Xlt(g,d){let m=g;do{const v=m.prev,k=m.next.next;!b3(v,k)&&dCe(v,m,m.next,k)&&CP(v,k)&&CP(k,v)&&(d.push(v.i,m.i,k.i),MP(m),MP(m.next),m=g=k),m=m.next}while(m!==g);return yw(m)}function Qlt(g,d,m,v,k,E){let P=g;do{let O=P.next.next;for(;O!==P.prev;){if(P.i!==O.i&&rct(P,O)){let B=uCe(P,O);return P=yw(P,P.next),B=yw(B,B.next),NP(P,d,m,v,k,E,0),void NP(B,d,m,v,k,E,0)}O=O.next}P=P.next}while(P!==g)}function Jlt(g,d){let m=g.x-d.x;return m===0&&(m=g.y-d.y,m===0)&&(m=(g.next.y-g.y)/(g.next.x-g.x)-(d.next.y-d.y)/(d.next.x-d.x)),m}function ect(g,d){const m=function(k,E){let P=E;const O=k.x,B=k.y;let W,J=-1/0;if(b3(k,P))return P;do{if(b3(k,P.next))return P.next;if(B<=P.y&&B>=P.next.y&&P.next.y!==P.y){const Ne=P.x+(B-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(Ne<=O&&Ne>J&&(J=Ne,W=P.x=P.x&&P.x>=ie&&O!==P.x&&cCe(BW.x||P.x===W.x&&tct(W,P)))&&(W=P,ue=Ne)}P=P.next}while(P!==te);return W}(g,d);if(!m)return d;const v=uCe(m,g);return yw(v,v.next),yw(m,m.next)}function tct(g,d){return Oc(g.prev,g,d.prev)<0&&Oc(d.next,g,g.next)<0}function Xme(g,d,m,v,k){return(g=1431655765&((g=858993459&((g=252645135&((g=16711935&((g=(g-m)*k|0)|g<<8))|g<<4))|g<<2))|g<<1))|(d=1431655765&((d=858993459&((d=252645135&((d=16711935&((d=(d-v)*k|0)|d<<8))|d<<4))|d<<2))|d<<1))<<1}function sct(g){let d=g,m=g;do(d.x=(g-P)*(E-O)&&(g-P)*(v-O)>=(m-P)*(d-O)&&(m-P)*(E-O)>=(k-P)*(v-O)}function SP(g,d,m,v,k,E,P,O){return!(g===P&&d===O)&&cCe(g,d,m,v,k,E,P,O)}function rct(g,d){return g.next.i!==d.i&&g.prev.i!==d.i&&!function(m,v){let k=m;do{if(k.i!==m.i&&k.next.i!==m.i&&k.i!==v.i&&k.next.i!==v.i&&dCe(k,k.next,m,v))return!0;k=k.next}while(k!==m);return!1}(g,d)&&(CP(g,d)&&CP(d,g)&&function(m,v){let k=m,E=!1;const P=(m.x+v.x)/2,O=(m.y+v.y)/2;do k.y>O!=k.next.y>O&&k.next.y!==k.y&&P<(k.next.x-k.x)*(O-k.y)/(k.next.y-k.y)+k.x&&(E=!E),k=k.next;while(k!==m);return E}(g,d)&&(Oc(g.prev,g,d.prev)||Oc(g,d.prev,d))||b3(g,d)&&Oc(g.prev,g,g.next)>0&&Oc(d.prev,d,d.next)>0)}function Oc(g,d,m){return(d.y-g.y)*(m.x-d.x)-(d.x-g.x)*(m.y-d.y)}function b3(g,d){return g.x===d.x&&g.y===d.y}function dCe(g,d,m,v){const k=iF(Oc(g,d,m)),E=iF(Oc(g,d,v)),P=iF(Oc(m,v,g)),O=iF(Oc(m,v,d));return k!==E&&P!==O||!(k!==0||!aF(g,m,d))||!(E!==0||!aF(g,v,d))||!(P!==0||!aF(m,g,v))||!(O!==0||!aF(m,d,v))}function aF(g,d,m){return d.x<=Math.max(g.x,m.x)&&d.x>=Math.min(g.x,m.x)&&d.y<=Math.max(g.y,m.y)&&d.y>=Math.min(g.y,m.y)}function iF(g){return g>0?1:g<0?-1:0}function CP(g,d){return Oc(g.prev,g,g.next)<0?Oc(g,d,g.next)>=0&&Oc(g,g.prev,d)>=0:Oc(g,d,g.prev)<0||Oc(g,g.next,d)<0}function uCe(g,d){const m=Qme(g.i,g.x,g.y),v=Qme(d.i,d.x,d.y),k=g.next,E=d.prev;return g.next=d,d.prev=g,m.next=k,k.prev=m,v.next=m,m.prev=v,E.next=v,v.prev=E,v}function hCe(g,d,m,v){const k=Qme(g,d,m);return v?(k.next=v.next,k.prev=v,v.next.prev=k,v.next=k):(k.prev=k,k.next=k),k}function MP(g){g.next.prev=g.prev,g.prev.next=g.next,g.prevZ&&(g.prevZ.nextZ=g.nextZ),g.nextZ&&(g.nextZ.prevZ=g.prevZ)}function Qme(g,d,m){return{i:g,x:d,y:m,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function TP(g,d){const m=g.length;if(m<=1)return[g];const v=[];let k,E;for(let P=0;P1)for(let P=0;P=Qs&&m>=Qs}static evaluate(d){if(d.length===0)return new lv;let m=[];for(const B of d)m.push(...B.portals);if(m.length===0)return new lv;for(const B of m){const W=B.va,J=B.vb;(lv.isOnBorder(W.x,J.x)||lv.isOnBorder(W.y,J.y))&&(B.type="border")}const v=m.filter(B=>B.type!=="unevaluated"),k=m.filter(B=>B.type==="unevaluated");if(k.length===0)return new lv;k.sort((B,W)=>B.hash===W.hash?B.isTunnel===W.isTunnel?0:B.isTunnel?-1:1:B.hashB.hashE!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new Op(m,{zoom:v,lut:k},E=>E!=="fill-bridge-guard-rail-color")}addVertices(d,m){const v=this.unevalVertices.length;for(let k=0;k=E.min.x&&te.x<=E.max.x&&te.y>=E.min.y&&te.y<=E.max.y||ie.x>=E.min.x&&ie.x<=E.max.x&&ie.y>=E.min.y&&ie.y<=E.max.y||bd(te,ie,O))||this.isOnBorder(te.x,ie.x)||this.isOnBorder(te.y,ie.y))continue;const ce=im.computeEdgeHash(this.unevalVertices[W],this.unevalVertices[J]);let ue,Ne=this.vertexHashLookup.get(im.computePosHash(te));Ne!=null?ue=Ne.next:(Ne=this.vertexHashLookup.get(im.computePosHash(ie)),ue=Ne!=null?Ne.prev:ce),this.unevalEdges.push({polygonIdx:d,a:W,b:J,hash:ce,portalHash:ue,isTunnel:k,type:"unevaluated",featureInfo:P})}}addPortalCandidates(d,m,v,k,E){if(m.length===0)return;this.portalPolygons.add(d,{geometry:m,zLevel:E});const P=m[0];this.vertexHashLookup.clear();let O=im.computeEdgeHash(P[P.length-2],P[P.length-1]);for(let B=0;B({vertexOffset:0,primitiveOffset:this.indexArray.length}),v=ie=>{ie.primitiveLength=this.indexArray.length-ie.primitiveOffset},k=new act(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(d.portals,this.unevalEdges);const E=m(),P=m(),O=m(),B=(ie,ce)=>{ie.sort((Ne,Le)=>Ne.type===ce&&Le.type!==ce?-1:Ne.type!==ce&&Le.type===ce?1:0);const ue=ie.findIndex(Ne=>Ne.type!==ce);return ue>=0?ue:ie.length};let W=0;this.unevalEdges.length>0&&(W=B(this.unevalEdges,"none"),this.constructBridgeStructures(k,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:W},this.tileToMeters)),v(O);const J=m(),te=m();if(this.unevalEdges.length>0){const ie=this.unevalEdges.splice(W),ce=B(ie,"tunnel")+W;this.unevalEdges.push(...ie),this.constructTunnelStructures(k,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:W},{min:W,max:ce})}v(J),k.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),v(te),k.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),v(P),k.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),v(E),this.maskSegments=xo.simpleSegment(0,te.primitiveOffset,0,te.primitiveLength),this.depthSegments=xo.simpleSegment(0,P.primitiveOffset,0,P.primitiveLength),this.renderableBridgeSegments=xo.simpleSegment(0,O.primitiveOffset,0,O.primitiveLength),this.renderableTunnelSegments=xo.simpleSegment(0,J.primitiveOffset,0,J.primitiveLength),this.shadowCasterSegments=xo.simpleSegment(0,E.primitiveOffset,0,E.primitiveLength)}update(d,m,v,k,E,P,O,B){this.bridgeProgramConfigurations.updatePaintArrays(d,m,E,v,k,P,O,B),this.tunnelProgramConfigurations.updatePaintArrays(d,m,E,v,k,P,O,B)}upload(d){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=d.createVertexBuffer(this.vertexPositions,Glt.members),this.vertexBufferNormal=d.createVertexBuffer(this.vertexNormals,Klt.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,k,E){const P=(O,B)=>{for(let W=0;Wne(Fs,m[Bs].x,m[Bs].y,v[Bs]*B),te=ee(),ie=ee(),ce=ee(),ue=ee(),Ne=ee(),Le=(Fs,Bs)=>{const Ds=O.get(im.computePosHash(m[Bs])),Os=Ds.from,ds=Ds.to;if(!Os||!ds)return;J(te,Os),J(ie,Bs),J(ce,ds),lt(ue),rt(te,ie)||(Se(Ne,ie,te),Te(ue,Ne)),rt(ce,ie)||(Se(Ne,ce,ie),le(ue,ue,Te(Ne,Ne)));const is=$e(ue);return is>0?ke(Fs,ue,1/is):void 0};let Ie=Number.POSITIVE_INFINITY;this.sortSubarray(k,E.min,E.max,(Fs,Bs)=>Fs.featureInfo.featureIndex-Bs.featureInfo.featureIndex);const Ge=ee(),Ze=ee(),at=ee(),vt=ee(),pt=ee(),St=ee(),Lt=ee(),Bt=ee(),as=ee(),Wt=[ee(),ee(),ee(),ee()],us=[ee(),ee(),ee(),ee()],bs=[{coord:new es(0,0),height:0},{coord:new es(0,0),height:0}],ws=(Fs,Bs)=>Fs>Bs;for(let Fs=E.min;FsIe.featureInfo.featureIndex-Ge.featureInfo.featureIndex;this.sortSubarray(k,E.min,E.max,B),this.sortSubarray(k,P.min,P.max,B);const W=Ie=>Te(Ie,Ie),J=[{coord:new es(0,0),height:0},{coord:new es(0,0),height:0}],te=(Ie,Ge)=>IeO.hash===B.hash?B.polygonIdx-O.polygonIdx:B.hash>O.hash?1:-1);let v=0,k=0,E=0,P=m[v].polygonIdx;do k++,(k===m.length||m[v].hash!==m[k].hash)&&((k-v==1||m[k-1].polygonIdx!==P)&&(EW.portalHashJ.hash?O++:J.hash>W.portalHash?B++:(W.type=J.type,O++)}}}isOnBorder(d,m){return d<=0&&m<=0||d>=Qs&&m>=Qs}addFeatureSection(d,m,v,k){return d!==m&&(m=d,v.push({featureIndex:d,vertexStart:k.getVertexCount()}),k.clearVertexLookup()),m}sortSubarray(d,m,v,k){const E=d.slice(m,v);E.sort(k),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(im.computePosHash(d))<<32n|BigInt(im.computePosHash(m))}static computePosHash(d){return((65535&d.x)<<16|65535&d.y)>>>0}}var fCe,gCe={exports:{}},xCe=(fCe||(fCe=1,function(g){function d(ft,_t){return ft>_t?1:ft<_t?-1:0}var m=function(ft,_t){ft===void 0&&(ft=d),_t===void 0&&(_t=!1),this._compare=ft,this._root=null,this._size=0,this._noDuplicates=!!_t},v={size:{configurable:!0}};function k(ft,_t,hs,zs,or){var lr=or-zs;if(lr>0){var Or=zs+Math.floor(lr/2),zr={key:_t[Or],data:hs[Or],parent:ft};return zr.left=k(zr,_t,hs,zs,Or),zr.right=k(zr,_t,hs,Or+1,or),zr}return null}function E(ft,_t,hs,zs,or){if(!(hs>=zs)){for(var lr=ft[hs+zs>>1],Or=hs-1,zr=zs+1;;){do Or++;while(or(ft[Or],lr)<0);do zr--;while(or(ft[zr],lr)>0);if(Or>=zr)break;var Sn=ft[Or];ft[Or]=ft[zr],ft[zr]=Sn,Sn=_t[Or],_t[Or]=_t[zr],_t[zr]=Sn}E(ft,_t,hs,zr,or),E(ft,_t,zr+1,zs,or)}}m.prototype.rotateLeft=function(ft){var _t=ft.right;_t&&(ft.right=_t.left,_t.left&&(_t.left.parent=ft),_t.parent=ft.parent),ft.parent?ft===ft.parent.left?ft.parent.left=_t:ft.parent.right=_t:this._root=_t,_t&&(_t.left=ft),ft.parent=_t},m.prototype.rotateRight=function(ft){var _t=ft.left;_t&&(ft.left=_t.right,_t.right&&(_t.right.parent=ft),_t.parent=ft.parent),ft.parent?ft===ft.parent.left?ft.parent.left=_t:ft.parent.right=_t:this._root=_t,_t&&(_t.right=ft),ft.parent=_t},m.prototype._splay=function(ft){for(;ft.parent;){var _t=ft.parent;_t.parent?_t.left===ft&&_t.parent.left===_t?(this.rotateRight(_t.parent),this.rotateRight(_t)):_t.right===ft&&_t.parent.right===_t?(this.rotateLeft(_t.parent),this.rotateLeft(_t)):_t.left===ft&&_t.parent.right===_t?(this.rotateRight(_t),this.rotateLeft(_t)):(this.rotateLeft(_t),this.rotateRight(_t)):_t.left===ft?this.rotateRight(_t):this.rotateLeft(_t)}},m.prototype.splay=function(ft){for(var _t,hs,zs,or,lr;ft.parent;)(hs=(_t=ft.parent).parent)&&hs.parent?((zs=hs.parent).left===hs?zs.left=ft:zs.right=ft,ft.parent=zs):(ft.parent=null,this._root=ft),or=ft.left,lr=ft.right,ft===_t.left?(hs&&(hs.left===_t?(_t.right?(hs.left=_t.right,hs.left.parent=hs):hs.left=null,_t.right=hs,hs.parent=_t):(or?(hs.right=or,or.parent=hs):hs.right=null,ft.left=hs,hs.parent=ft)),lr?(_t.left=lr,lr.parent=_t):_t.left=null,ft.right=_t,_t.parent=ft):(hs&&(hs.right===_t?(_t.left?(hs.right=_t.left,hs.right.parent=hs):hs.right=null,_t.left=hs,hs.parent=_t):(lr?(hs.left=lr,lr.parent=hs):hs.left=null,ft.right=hs,hs.parent=ft)),or?(_t.right=or,or.parent=_t):_t.right=null,ft.left=_t,_t.parent=ft)},m.prototype.replace=function(ft,_t){ft.parent?ft===ft.parent.left?ft.parent.left=_t:ft.parent.right=_t:this._root=_t,_t&&(_t.parent=ft.parent)},m.prototype.minNode=function(ft){if(ft===void 0&&(ft=this._root),ft)for(;ft.left;)ft=ft.left;return ft},m.prototype.maxNode=function(ft){if(ft===void 0&&(ft=this._root),ft)for(;ft.right;)ft=ft.right;return ft},m.prototype.insert=function(ft,_t){var hs=this._root,zs=null,or=this._compare;if(this._noDuplicates)for(;hs;){if(zs=hs,or(hs.key,ft)===0)return;hs=or(hs.key,ft)<0?hs.right:hs.left}else for(;hs;)zs=hs,hs=or(hs.key,ft)<0?hs.right:hs.left;return hs={key:ft,data:_t,left:null,right:null,parent:zs},zs?or(zs.key,hs.key)<0?zs.right=hs:zs.left=hs:this._root=hs,this.splay(hs),this._size++,hs},m.prototype.find=function(ft){for(var _t=this._root,hs=this._compare;_t;){var zs=hs(_t.key,ft);if(zs<0)_t=_t.right;else{if(!(zs>0))return _t;_t=_t.left}}return null},m.prototype.contains=function(ft){for(var _t=this._root,hs=this._compare;_t;){var zs=hs(ft,_t.key);if(zs===0)return!0;_t=zs<0?_t.left:_t.right}return!1},m.prototype.remove=function(ft){var _t=this.find(ft);if(!_t)return!1;if(this.splay(_t),_t.left)if(_t.right){var hs=this.minNode(_t.right);hs.parent!==_t&&(this.replace(hs,hs.right),hs.right=_t.right,hs.right.parent=hs),this.replace(_t,hs),hs.left=_t.left,hs.left.parent=hs}else this.replace(_t,_t.left);else this.replace(_t,_t.right);return this._size--,!0},m.prototype.removeNode=function(ft){if(!ft)return!1;if(this.splay(ft),ft.left)if(ft.right){var _t=this.minNode(ft.right);_t.parent!==ft&&(this.replace(_t,_t.right),_t.right=ft.right,_t.right.parent=_t),this.replace(ft,_t),_t.left=ft.left,_t.left.parent=_t}else this.replace(ft,ft.left);else this.replace(ft,ft.right);return this._size--,!0},m.prototype.erase=function(ft){var _t=this.find(ft);if(_t){this.splay(_t);var hs=_t.left,zs=_t.right,or=null;hs&&(hs.parent=null,or=this.maxNode(hs),this.splay(or),this._root=or),zs&&(hs?or.right=zs:this._root=zs,zs.parent=or),this._size--}},m.prototype.pop=function(){var ft=this._root,_t=null;if(ft){for(;ft.left;)ft=ft.left;_t={key:ft.key,data:ft.data},this.remove(ft.key)}return _t},m.prototype.next=function(ft){var _t=ft;if(_t)if(_t.right)for(_t=_t.right;_t&&_t.left;)_t=_t.left;else for(_t=ft.parent;_t&&_t.right===ft;)ft=_t,_t=_t.parent;return _t},m.prototype.prev=function(ft){var _t=ft;if(_t)if(_t.left)for(_t=_t.left;_t&&_t.right;)_t=_t.right;else for(_t=ft.parent;_t&&_t.left===ft;)ft=_t,_t=_t.parent;return _t},m.prototype.forEach=function(ft){for(var _t=this._root,hs=[],zs=!1,or=0;!zs;)_t?(hs.push(_t),_t=_t.left):hs.length>0?(ft(_t=hs.pop(),or++),_t=_t.right):zs=!0;return this},m.prototype.range=function(ft,_t,hs,zs){for(var or=[],lr=this._compare,Or=this._root;or.length!==0||Or;)if(Or)or.push(Or),Or=Or.left;else{if(lr((Or=or.pop()).key,_t)>0)break;if(lr(Or.key,ft)>=0&&hs.call(zs,Or))return this;Or=Or.right}return this},m.prototype.keys=function(){for(var ft=this._root,_t=[],hs=[],zs=!1;!zs;)ft?(_t.push(ft),ft=ft.left):_t.length>0?(ft=_t.pop(),hs.push(ft.key),ft=ft.right):zs=!0;return hs},m.prototype.values=function(){for(var ft=this._root,_t=[],hs=[],zs=!1;!zs;)ft?(_t.push(ft),ft=ft.left):_t.length>0?(ft=_t.pop(),hs.push(ft.data),ft=ft.right):zs=!0;return hs},m.prototype.at=function(ft){for(var _t=this._root,hs=[],zs=!1,or=0;!zs;)if(_t)hs.push(_t),_t=_t.left;else if(hs.length>0){if(_t=hs.pop(),or===ft)return _t;or++,_t=_t.right}else zs=!0;return null},m.prototype.load=function(ft,_t,hs){if(ft===void 0&&(ft=[]),_t===void 0&&(_t=[]),hs===void 0&&(hs=!1),this._size!==0)throw new Error("bulk-load: tree is not empty");var zs=ft.length;return hs&&E(ft,_t,0,zs-1,this._compare),this._root=k(null,ft,_t,0,zs),this._size=zs,this},m.prototype.min=function(){var ft=this.minNode(this._root);return ft?ft.key:null},m.prototype.max=function(){var ft=this.maxNode(this._root);return ft?ft.key:null},m.prototype.isEmpty=function(){return this._root===null},v.size.get=function(){return this._size},m.createTree=function(ft,_t,hs,zs,or){return new m(hs,or).load(ft,_t,zs)},Object.defineProperties(m.prototype,v);var P=0,O=1,B=2,W=3,J=0,te=1,ie=2,ce=3;function ue(ft,_t,hs){_t===null?(ft.inOut=!1,ft.otherInOut=!0):(ft.isSubject===_t.isSubject?(ft.inOut=!_t.inOut,ft.otherInOut=_t.otherInOut):(ft.inOut=!_t.otherInOut,ft.otherInOut=_t.isVertical()?!_t.inOut:_t.inOut),_t&&(ft.prevInResult=!Ne(_t,hs)||_t.isVertical()?_t.prevInResult:_t));var zs=Ne(ft,hs);ft.resultTransition=zs?function(or,lr){var Or,zr=!or.inOut,Sn=!or.otherInOut;switch(lr){case J:Or=zr&&Sn;break;case te:Or=zr||Sn;break;case ce:Or=zr^Sn;break;case ie:Or=or.isSubject?zr&&!Sn:Sn&&!zr}return Or?1:-1}(ft,hs):0}function Ne(ft,_t){switch(ft.type){case P:switch(_t){case J:return!ft.otherInOut;case te:return ft.otherInOut;case ie:return ft.isSubject&&ft.otherInOut||!ft.isSubject&&!ft.otherInOut;case ce:return!0}break;case B:return _t===J||_t===te;case W:return _t===ie;case O:return!1}return!1}var Le=function(ft,_t,hs,zs,or){this.left=_t,this.point=ft,this.otherEvent=hs,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},Ie={inResult:{configurable:!0}};function Ge(ft,_t){return ft[0]===_t[0]&&ft[1]===_t[1]}Le.prototype.isBelow=function(ft){var _t=this.point,hs=this.otherEvent.point;return this.left?(_t[0]-ft[0])*(hs[1]-ft[1])-(hs[0]-ft[0])*(_t[1]-ft[1])>0:(hs[0]-ft[0])*(_t[1]-ft[1])-(_t[0]-ft[0])*(hs[1]-ft[1])>0},Le.prototype.isAbove=function(ft){return!this.isBelow(ft)},Le.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},Ie.inResult.get=function(){return this.resultTransition!==0},Le.prototype.clone=function(){var ft=new Le(this.point,this.left,this.otherEvent,this.isSubject,this.type);return ft.contourId=this.contourId,ft.resultTransition=this.resultTransition,ft.prevInResult=this.prevInResult,ft.isExteriorRing=this.isExteriorRing,ft.inOut=this.inOut,ft.otherInOut=this.otherInOut,ft},Object.defineProperties(Le.prototype,Ie);var Ze=11102230246251565e-32,at=134217729,vt=(3+8*Ze)*Ze;function pt(ft,_t,hs,zs,or){var lr,Or,zr,Sn,Bn=_t[0],Hn=zs[0],ca=0,en=0;Hn>Bn==Hn>-Bn?(lr=Bn,Bn=_t[++ca]):(lr=Hn,Hn=zs[++en]);var un=0;if(caBn==Hn>-Bn?(zr=lr-((Or=Bn+lr)-Bn),Bn=_t[++ca]):(zr=lr-((Or=Hn+lr)-Hn),Hn=zs[++en]),lr=Or,zr!==0&&(or[un++]=zr);caBn==Hn>-Bn?(zr=lr-((Or=lr+Bn)-(Sn=Or-lr))+(Bn-Sn),Bn=_t[++ca]):(zr=lr-((Or=lr+Hn)-(Sn=Or-lr))+(Hn-Sn),Hn=zs[++en]),lr=Or,zr!==0&&(or[un++]=zr);for(;ca0!=ca>0)return en;var un=Math.abs(Hn+ca);return Math.abs(en)>=Lt*un?en:-function(Fa,Ga,Ka,fi,Pi,Mi,ei){var li,$n,_a,co,Xr,da,Ti,zi,Wi,Go,$i,Qr,_o,gi,to,Ol,bc,pl,fl=Fa-Pi,ac=Ka-Pi,ih=Ga-Mi,qi=fi-Mi;Wt[0]=(to=(zi=fl-(Ti=(da=at*fl)-(da-fl)))*(Go=qi-(Wi=(da=at*qi)-(da-qi)))-((gi=fl*qi)-Ti*Wi-zi*Wi-Ti*Go))-(($i=to-(bc=(zi=ih-(Ti=(da=at*ih)-(da-ih)))*(Go=ac-(Wi=(da=at*ac)-(da-ac)))-((Ol=ih*ac)-Ti*Wi-zi*Wi-Ti*Go)))+(Xr=to-$i))+(Xr-bc),Wt[1]=(_o=gi-((Qr=gi+$i)-(Xr=Qr-gi))+($i-Xr))-(($i=_o-Ol)+(Xr=_o-$i))+(Xr-Ol),Wt[2]=Qr-((pl=Qr+$i)-(Xr=pl-Qr))+($i-Xr),Wt[3]=pl;var zo=function(Py,wd){for(var Iu=wd[0],lm=1;lm<4;lm++)Iu+=wd[lm];return Iu}(0,Wt),Ko=Bt*ei;if(zo>=Ko||-zo>=Ko||(li=Fa-(fl+(Xr=Fa-fl))+(Xr-Pi),_a=Ka-(ac+(Xr=Ka-ac))+(Xr-Pi),$n=Ga-(ih+(Xr=Ga-ih))+(Xr-Mi),co=fi-(qi+(Xr=fi-qi))+(Xr-Mi),li===0&&$n===0&&_a===0&&co===0)||(Ko=as*ei+vt*Math.abs(zo),(zo+=fl*co+qi*li-(ih*_a+ac*$n))>=Ko||-zo>=Ko))return zo;Fs[0]=(to=(zi=li-(Ti=(da=at*li)-(da-li)))*(Go=qi-(Wi=(da=at*qi)-(da-qi)))-((gi=li*qi)-Ti*Wi-zi*Wi-Ti*Go))-(($i=to-(bc=(zi=$n-(Ti=(da=at*$n)-(da-$n)))*(Go=ac-(Wi=(da=at*ac)-(da-ac)))-((Ol=$n*ac)-Ti*Wi-zi*Wi-Ti*Go)))+(Xr=to-$i))+(Xr-bc),Fs[1]=(_o=gi-((Qr=gi+$i)-(Xr=Qr-gi))+($i-Xr))-(($i=_o-Ol)+(Xr=_o-$i))+(Xr-Ol),Fs[2]=Qr-((pl=Qr+$i)-(Xr=pl-Qr))+($i-Xr),Fs[3]=pl;var Nh=pt(4,Wt,4,Fs,us);Fs[0]=(to=(zi=fl-(Ti=(da=at*fl)-(da-fl)))*(Go=co-(Wi=(da=at*co)-(da-co)))-((gi=fl*co)-Ti*Wi-zi*Wi-Ti*Go))-(($i=to-(bc=(zi=ih-(Ti=(da=at*ih)-(da-ih)))*(Go=_a-(Wi=(da=at*_a)-(da-_a)))-((Ol=ih*_a)-Ti*Wi-zi*Wi-Ti*Go)))+(Xr=to-$i))+(Xr-bc),Fs[1]=(_o=gi-((Qr=gi+$i)-(Xr=Qr-gi))+($i-Xr))-(($i=_o-Ol)+(Xr=_o-$i))+(Xr-Ol),Fs[2]=Qr-((pl=Qr+$i)-(Xr=pl-Qr))+($i-Xr),Fs[3]=pl;var Rl=pt(Nh,us,4,Fs,bs);Fs[0]=(to=(zi=li-(Ti=(da=at*li)-(da-li)))*(Go=co-(Wi=(da=at*co)-(da-co)))-((gi=li*co)-Ti*Wi-zi*Wi-Ti*Go))-(($i=to-(bc=(zi=$n-(Ti=(da=at*$n)-(da-$n)))*(Go=_a-(Wi=(da=at*_a)-(da-_a)))-((Ol=$n*_a)-Ti*Wi-zi*Wi-Ti*Go)))+(Xr=to-$i))+(Xr-bc),Fs[1]=(_o=gi-((Qr=gi+$i)-(Xr=Qr-gi))+($i-Xr))-(($i=_o-Ol)+(Xr=_o-$i))+(Xr-Ol),Fs[2]=Qr-((pl=Qr+$i)-(Xr=pl-Qr))+($i-Xr),Fs[3]=pl;var $f=pt(Rl,bs,4,Fs,ws);return ws[$f-1]}(or,lr,Or,zr,Sn,Bn,un)}(ft[0],ft[1],_t[0],_t[1],hs[0],hs[1]);return zs>0?-1:zs<0?1:0}function Ds(ft,_t){var hs=ft.point,zs=_t.point;return hs[0]>zs[0]?1:hs[0]zs[1]?1:-1:function(or,lr,Or,zr){return or.left!==lr.left?or.left?1:-1:Bs(Or,or.otherEvent.point,lr.otherEvent.point)!==0?or.isBelow(lr.otherEvent.point)?-1:1:!or.isSubject&&lr.isSubject?1:-1}(ft,_t,hs)}function Os(ft,_t,hs){var zs=new Le(_t,!1,ft,ft.isSubject),or=new Le(_t,!0,ft.otherEvent,ft.isSubject);return Ge(ft.point,ft.otherEvent.point)&&console.warn("what is that, a collapsed segment?",ft),zs.contourId=or.contourId=ft.contourId,Ds(or,ft.otherEvent)>0&&(ft.otherEvent.left=!0,or.left=!1),ft.otherEvent.otherEvent=or,ft.otherEvent=zs,hs.push(or),hs.push(zs),hs}function ds(ft,_t){return ft[0]*_t[1]-ft[1]*_t[0]}function is(ft,_t){return ft[0]*_t[0]+ft[1]*_t[1]}function Rs(ft,_t,hs){var zs=function(Sn,Bn,Hn,ca,en){var un=[Bn[0]-Sn[0],Bn[1]-Sn[1]],Fa=[ca[0]-Hn[0],ca[1]-Hn[1]];function Ga(da,Ti,zi){return[da[0]+Ti*zi[0],da[1]+Ti*zi[1]]}var Ka=[Hn[0]-Sn[0],Hn[1]-Sn[1]],fi=ds(un,Fa),Pi=fi*fi,Mi=is(un,un);if(Pi>0){var ei=ds(Ka,Fa)/fi;if(ei<0||ei>1)return null;var li=ds(Ka,un)/fi;return li<0||li>1?null:ei===0||ei===1?[Ga(Sn,ei,un)]:li===0||li===1?[Ga(Hn,li,Fa)]:[Ga(Sn,ei,un)]}if((Pi=(fi=ds(Ka,un))*fi)>0)return null;var $n=is(un,Ka)/Mi,_a=$n+is(un,Fa)/Mi,co=Math.min($n,_a),Xr=Math.max($n,_a);return co<=1&&Xr>=0?co===1?[Ga(Sn,co>0?co:0,un)]:Xr===0?[Ga(Sn,Xr<1?Xr:1,un)]:[Ga(Sn,co>0?co:0,un),Ga(Sn,Xr<1?Xr:1,un)]:null}(ft.point,ft.otherEvent.point,_t.point,_t.otherEvent.point),or=zs?zs.length:0;if(or===0||or===1&&(Ge(ft.point,_t.point)||Ge(ft.otherEvent.point,_t.otherEvent.point))||or===2&&ft.isSubject===_t.isSubject)return 0;if(or===1)return Ge(ft.point,zs[0])||Ge(ft.otherEvent.point,zs[0])||Os(ft,zs[0],hs),Ge(_t.point,zs[0])||Ge(_t.otherEvent.point,zs[0])||Os(_t,zs[0],hs),1;var lr=[],Or=!1,zr=!1;return Ge(ft.point,_t.point)?Or=!0:Ds(ft,_t)===1?lr.push(_t,ft):lr.push(ft,_t),Ge(ft.otherEvent.point,_t.otherEvent.point)?zr=!0:Ds(ft.otherEvent,_t.otherEvent)===1?lr.push(_t.otherEvent,ft.otherEvent):lr.push(ft.otherEvent,_t.otherEvent),Or&&zr||Or?(_t.type=O,ft.type=_t.inOut===ft.inOut?B:W,Or&&!zr&&Os(lr[1].otherEvent,lr[0].point,hs),2):zr?(Os(lr[0],lr[1].point,hs),3):lr[0]!==lr[3].otherEvent?(Os(lr[0],lr[1].point,hs),Os(lr[1],lr[2].point,hs),3):(Os(lr[0],lr[1].point,hs),Os(lr[3].otherEvent,lr[2].point,hs),3)}function Js(ft,_t){if(ft===_t)return 0;if(Bs(ft.point,ft.otherEvent.point,_t.point)!==0||Bs(ft.point,ft.otherEvent.point,_t.otherEvent.point)!==0)return Ge(ft.point,_t.point)?ft.isBelow(_t.otherEvent.point)?-1:1:ft.point[0]===_t.point[0]?ft.point[1]<_t.point[1]?-1:1:Ds(ft,_t)===1?_t.isAbove(ft.point)?-1:1:ft.isBelow(_t.point)?-1:1;if(ft.isSubject!==_t.isSubject)return ft.isSubject?-1:1;var hs=ft.point,zs=_t.point;return hs[0]===zs[0]&&hs[1]===zs[1]?(hs=ft.otherEvent.point)[0]===(zs=_t.otherEvent.point)[0]&&hs[1]===zs[1]?0:ft.contourId>_t.contourId?1:-1:Ds(ft,_t)===1?1:-1}var Hs=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function Dr(ft,_t,hs,zs){var or,lr=ft+1,Or=_t[ft].point,zr=_t.length;for(lrzs;)lr--;return lr}Hs.prototype.isExterior=function(){return this.holeOf==null};var ur=Nr,yr=Nr;function Nr(ft,_t){if(!(this instanceof Nr))return new Nr(ft,_t);if(this.data=ft||[],this.length=this.data.length,this.compare=_t||Wn,this.length>0)for(var hs=(this.length>>1)-1;hs>=0;hs--)this._down(hs)}function Wn(ft,_t){return ft<_t?-1:ft>_t?1:0}Nr.prototype={push:function(ft){this.data.push(ft),this.length++,this._up(this.length-1)},pop:function(){if(this.length!==0){var ft=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),ft}},peek:function(){return this.data[0]},_up:function(ft){for(var _t=this.data,hs=this.compare,zs=_t[ft];ft>0;){var or=ft-1>>1,lr=_t[or];if(hs(zs,lr)>=0)break;_t[ft]=lr,ft=or}_t[ft]=zs},_down:function(ft){for(var _t=this.data,hs=this.compare,zs=this.length>>1,or=_t[ft];ft=0)break;_t[ft]=zr,ft=lr}_t[ft]=or}},ur.default=yr;var Gs=Math.max,Sr=Math.min,pn=0;function xa(ft,_t,hs,zs,or,lr){var Or,zr,Sn,Bn,Hn,ca;for(Or=0,zr=ft.length-1;Or0?ca.left=!0:Hn.left=!0;var en=Sn[0],un=Sn[1];or[0]=Sr(or[0],en),or[1]=Sr(or[1],un),or[2]=Gs(or[2],en),or[3]=Gs(or[3],un),zs.push(Hn),zs.push(ca)}}var ba=[];function Ln(ft,_t,hs){typeof ft[0][0][0]=="number"&&(ft=[ft]),typeof _t[0][0][0]=="number"&&(_t=[_t]);var zs=function(un,Fa,Ga){var Ka=null;return un.length*Fa.length==0&&(Ga===J?Ka=ba:Ga===ie?Ka=un:Ga!==te&&Ga!==ce||(Ka=un.length===0?Fa:un)),Ka}(ft,_t,hs);if(zs)return zs===ba?null:zs;var or=[1/0,1/0,-1/0,-1/0],lr=[1/0,1/0,-1/0,-1/0],Or=function(un,Fa,Ga,Ka,fi){var Pi,Mi,ei,li,$n,_a,co=new ur(null,Ds);for(ei=0,li=un.length;eiKa[2]||Ka[0]>Ga[2]||Ga[1]>Ka[3]||Ka[1]>Ga[3])&&(fi===J?Pi=ba:fi===ie?Pi=un:fi!==te&&fi!==ce||(Pi=un.concat(Fa))),Pi}(ft,_t,or,lr,hs))return zs===ba?null:zs;for(var zr=function(un){var Fa,Ga,Ka=function(ei){var li,$n,_a,co,Xr=[];for($n=0,_a=ei.length;$n<_a;$n++)((li=ei[$n]).left&&li.inResult||!li.left&&li.otherEvent.inResult)&&Xr.push(li);for(var da=!1;!da;)for(da=!0,$n=0,_a=Xr.length;$n<_a;$n++)$n+1<_a&&Ds(Xr[$n],Xr[$n+1])===1&&(co=Xr[$n],Xr[$n]=Xr[$n+1],Xr[$n+1]=co,da=!1);for($n=0,_a=Xr.length;$n<_a;$n++)(li=Xr[$n]).otherPos=$n;for($n=0,_a=Xr.length;$n<_a;$n++)(li=Xr[$n]).left||(co=li.otherPos,li.otherPos=li.otherEvent.otherPos,li.otherEvent.otherPos=co);return Xr}(un),fi={},Pi=[],Mi=function(){if(!fi[Fa]){var ei=Pi.length,li=function(Xr,da,Ti){var zi=new Hs;if(Xr.prevInResult!=null){var Wi=Xr.prevInResult,Go=Wi.outputContourId;if(Wi.resultTransition>0){var $i=da[Go];if($i.holeOf!=null){var Qr=$i.holeOf;da[Qr].holeIds.push(Ti),zi.holeOf=Qr,zi.depth=da[Go].depth}else da[Go].holeIds.push(Ti),zi.holeOf=Go,zi.depth=da[Go].depth+1}else zi.holeOf=null,zi.depth=da[Go].depth}else zi.holeOf=null,zi.depth=0;return zi}(Ka[Fa],Pi,ei),$n=function(Xr){fi[Xr]=!0,Xr=Ka.length)&&Ka[_a];);Pi.push(li)}};for(Fa=0,Ga=Ka.length;Faco||Pi===ie&&Xr.point[0]>Ka[2])break;if(Xr.left){ei=Mi=$n.insert(Xr),Mi=Mi!==(li=$n.minNode())?$n.prev(Mi):null,ei=$n.next(ei);var da=Mi?Mi.key:null;if(ue(Xr,da,Pi),ei&&Rs(Xr,ei.key,un)===2&&(ue(Xr,da,Pi),ue(ei.key,Xr,Pi)),Mi&&Rs(Mi.key,Xr,un)===2){var Ti=Mi;ue(da,(Ti=Ti!==li?$n.prev(Ti):null)?Ti.key:null,Pi),ue(Xr,da,Pi)}}else ei=Mi=$n.find(Xr=Xr.otherEvent),Mi&&ei&&(Mi=Mi!==li?$n.prev(Mi):null,ei=$n.next(ei),$n.remove(Xr),ei&&Mi&&Rs(Mi.key,ei.key,un))}return _a}(Or,0,0,or,lr,hs)),Sn=[],Bn=0;Bn * @license MIT * @preserve */function oF(g,d,m,v){const k=[],E=v===0?(P,O,B,W,J,te)=>{P.push(new es(te,B+(te-O)/(W-O)*(J-B)))}:(P,O,B,W,J,te)=>{P.push(new es(O+(te-B)/(J-B)*(W-O),te))};for(const P of g){const O=[];for(const B of P){if(B.length<=2)continue;const W=[];for(let ie=0;ied&&E(W,ce,ue,Ne,Le,d):Ie>m?Ge=d&&E(W,ce,ue,Ne,Le,d),Ge>m&&Ie<=m&&E(W,ce,ue,Ne,Le,m)}let J=B[B.length-1];const te=v===0?J.x:J.y;te>=d&&te<=m&&W.push(J),W.length&&(J=W[W.length-1],W[0].x===J.x&&W[0].y===J.y||W.push(W[0]),O.push(W))}O.length&&k.push(O)}return k}function ict(g,d){const m=tpe(g),v=tpe([d]),k=xCe.intersection(m,v);return k==null?[]:yCe(k)}function oct(g,d){let v=tpe(g,65536);const k=[];for(;d.valid();d.next()){const[E,P]=d.get(),O=E.x*65536,B=E.y*65536,W=P.x*65536,J=P.y*65536,te=W-O,ie=J-B,ce=Math.hypot(te,ie);if(ce===0)continue;const ue=Math.trunc(ie/ce*3),Ne=-Math.trunc(te/ce*3);k.push([[[O,B],[W,J],[W+ue,J+Ne],[O+ue,B+Ne],[O,B]]])}return k.length>0&&(v=xCe.diff(v,k)),yCe(v,1/65536)}function tpe(g,d=1){return[g.map(m=>m.map(v=>[v.x*d,v.y*d]))]}function yCe(g,d=1){return g.map(m=>m.map((v,k)=>{const E=v.map(P=>new es(P[0]*d,P[1]*d).round());return k>0&&E.reverse(),E}))}class spe{constructor(d,m){this.layoutVertexArray=new Ny,this.indexArray=new Il,this.lineIndexArray=new nm,this.triangleSegments=new xo,this.lineSegments=new xo,this.programConfigurations=new Op(d.layers,{zoom:d.zoom,lut:d.lut}),this.uploaded=!1,m&&(this.elevatedLayoutVertexArray=new ex)}update(d,m,v,k,E,P,O,B){this.programConfigurations.updatePaintArrays(d,m,E,v,k,P,O,B)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,Hlt.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,Wlt.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,k,E,P,O){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,m,v,k,E,P,void 0,O)}}class rpe{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 spe(d,!1),this.elevationBufferData=new spe(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,k){}populate(d,m,v,k){this.hasPattern=Jme("fill",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("fill-sort-key"),P=[];for(const{feature:O,id:B,index:W,sourceLayerIndex:J}of d){const te=this.layers[0]._featureFilter.needGeometry,ie=Ht(O,te);if(!this.layers[0]._featureFilter.filter(new Hi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ie,v))continue;const ce=E?E.evaluate(ie,{},v,m.availableImages):void 0,ue={id:B,properties:O.properties,type:O.type,sourceLayerIndex:J,index:W,geometry:te?ie.geometry:Pt(O,v,k),patterns:{},sortKey:ce};P.push(ue)}E&&P.sort((O,B)=>O.sortKey-B.sortKey);for(const O of P){const{geometry:B,index:W,sourceLayerIndex:J}=O;if(this.hasPattern){const te=epe("fill",this.layers,O,this.zoom,this.pixelRatio,m);this.patternFeatures.push(te)}else this.addFeature(O,B,W,v,{},m.availableImages,m.brightness,m.elevationFeatures);m.featureIndex.insert(d[W].feature,B,W,J,this.index)}}update(d,m,v,k,E,P,O){this.bufferData.update(d,m,v,k,E,P,O,this.worldview),this.elevationBufferData.update(d,m,v,k,E,P,O,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(d,m,v,k,E,P,O,this.worldview)}addFeatures(d,m,v,k,E,P){for(const O of this.patternFeatures)this.addFeature(O,O.geometry,O.index,m,v,k,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,k,E,P=[],O,B){const W=TP(m,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(d,W,k,v,B):this.addGeometry(W,this.bufferData),this.bufferData.populatePaintArrays(d,v,E,P,k,O,this.worldview),this.elevationBufferData.populatePaintArrays(d,v,E,P,k,O,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(d,m,v,k,E){this.elevatedStructures&&(this.elevatedStructures.construct(d),this.elevatedStructures.populatePaintArrays(m,v,k,E,this.worldview))}addElevatedRoadFeature(d,m,v,k,E){const P=new Array,O=ii.getElevationFeature(d,E);if(!O)return void this.addGeometry(m,this.bufferData);{const W=this.clipPolygonsToTile(m,1);W.length>0&&P.push({polygons:W,elevationFeature:O,elevationTileID:v})}const B={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(d,{},v),featureIndex:k};for(const W of P)if(W.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new im(W.elevationTileID,this.layers,this.zoom,this.lut));const te=W.elevationFeature.isTunnel();let ie=0;d.properties.hasOwnProperty(Jt)&&(ie=+d.properties[Jt]);for(const ce of W.polygons)this.elevatedStructures.addPortalCandidates(W.elevationFeature.id,ce,te,W.elevationFeature,ie)}W.elevationFeature.constantHeight==null&&(W.polygons=this.prepareElevatedPolygons(W.polygons,W.elevationFeature,W.elevationTileID));const J=new wi(v,W.elevationTileID);this.addElevatedGeometry(W.polygons,J,W.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,k,B)}}addElevatedGeometry(d,m,v,k,E,P){const O={elevation:v,elevationSampler:m,bias:k,index:E,featureInfo:P},[B,W]=this.addGeometry(d,this.elevationBufferData,O);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:B,max:W}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,B),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,W))}addGeometry(d,m,v){let k=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,P=null;v&&(P=v.elevationSampler.constantElevation(v.elevation,v.bias),P!=null&&(k=P,E=P));const O=(B,W,J)=>{if(v!=null)if(W.push(B),P!=null)m.elevatedLayoutVertexArray.emplaceBack(P),J.push(P);else{const te=v.elevationSampler.pointElevation(B,v.elevation,v.bias);m.elevatedLayoutVertexArray.emplaceBack(te),J.push(te),k=Math.min(k,te),E=Math.max(E,te)}};for(const B of d){let W=0;for(const Ze of B)W+=Ze.length;const J=m.triangleSegments.prepareSegment(W,m.layoutVertexArray,m.indexArray),te=J.vertexLength,ie=[],ce=[],ue=[],Ne=[],Le=[],Ie=m.layoutVertexArray.length;for(const Ze of B){if(Ze.length===0)continue;Ze!==B[0]&&ce.push(ie.length/2);const at=m.lineSegments.prepareSegment(Ze.length,m.layoutVertexArray,m.lineIndexArray),vt=at.vertexLength;v&&Le.push(m.layoutVertexArray.length-Ie),O(Ze[0],ue,Ne),m.layoutVertexArray.emplaceBack(Ze[0].x,Ze[0].y),m.lineIndexArray.emplaceBack(vt+Ze.length-1,vt),ie.push(Ze[0].x),ie.push(Ze[0].y);for(let pt=1;pt0&&v&&this.elevationMode==="hd-road-base"){const Ze=v.elevation.isTunnel(),at=v.elevation.safeArea,vt=this.elevatedStructures.addVertices(ue,Ne);this.elevatedStructures.addTriangles(Ge,vt,Ze);const pt=Le.length;if(pt>0){for(let St=0;St=v&&ce.max.x<=E&&ce.min.y>=k&&ce.max.y<=P?B:W).push(ie)}if(B.length===d.length)return d;const J=[new es(v,k),new es(E,k),new es(E,P),new es(v,P),new es(v,k)],te=B;for(const ie of W)te.push(...ict(ie,J));return te}}let vCe,_Ce,bCe,wCe;_r(rpe,"FillBucket",{omit:["layers","patternFeatures"]}),_r(spe,"FillBufferData"),_r(im,"ElevatedStructures");class lF{constructor(d,m,v,k){if(this.triangleCount=m.length/3,this.min=new es(0,0),this.max=new es(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||d.length===0)return;const[E,P]=[d[0].clone(),d[0].clone()];for(let te=1;tete.cellIdx-ie.cellIdx||te.triIdx-ie.triIdx);let J=0;for(;Jthis.max.x||this.min.x>d.x||d.y>this.max.y||this.min.y>d.y)return;const v=Ay(d.x-this.min.x,this.xScale,this.cellsX),k=Ay(d.y-this.min.y,this.yScale,this.cellsY),E=this.cells[k*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 k=Ay(d.x-this.min.x,this.xScale,this.cellsX),E=Ay(m.x-this.min.x,this.xScale,this.cellsX),P=Ay(d.y-this.min.y,this.yScale,this.cellsY),O=Ay(m.y-this.min.y,this.yScale,this.cellsY);for(let B=P;B<=O;B++)for(let W=k;W<=E;W++){const J=this.cells[B*this.cellsX+W];if(J)for(let te=0;tem.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,k){}populate(d,m,v,k){const E=[];for(const{feature:P,id:O,index:B,sourceLayerIndex:W}of d){const J=this.layers[0]._featureFilter.needGeometry,te=Ht(P,J);if(!this.layers[0]._featureFilter.filter(new Hi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),te,v))continue;const ie={id:O,properties:P.properties,type:P.type,sourceLayerIndex:W,index:B,geometry:J?te.geometry:Pt(P,v,k),patterns:{}};E.push(ie)}for(const P of E){const{geometry:O,index:B,sourceLayerIndex:W}=P;this.addFeature(P,O,B,v,{},m.availableImages,m.brightness),m.featureIndex.insert(d[B].feature,O,B,W,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(d){}update(d,m,v,k,E,P,O){}destroy(){}addFeature(d,m,v,k,E,P=[],O){for(const B of TP(m,2)){const W=[],J=[],te=[],ie=new es(1/0,1/0),ce=new es(-1/0,-1/0);for(const Le of B)if(Le.length!==0){Le!==B[0]&&te.push(J.length/2);for(let Ie=0;IeP===k)===void 0}(v,g.clipScope)}function cF(g,d){return g.x-d.x||g.y-d.y}function SCe(g,d){return cF(g.min,d.min)===0&&cF(g.max,d.max)===0}function npe(g,d){return!(g.min.x>d.max.x||g.max.xd.max.y||g.max.ynew es((B.x+E.x*Qs)*O-P.x*Qs,(B.y+E.y*Qs)*O-P.y*Qs))}return ape(m,k,g.indices,0,g.indices.length,0,0)}function TCe(g,d,m,v){const k=Math.pow(2,v.z-m.z);return new es((g+m.x*Qs)*k-v.x*Qs,(d+m.y*Qs)*k-v.y*Qs)}function ACe(g,d){const m=[];d.grid.queryPoint(g,m);const v=d.indices,k=d.vertices;for(let E=0;E0&&(v.length>1&&m.push(v),v=[])}return v.length>1&&m.push(v),m}const ope=Ut.types,xct=["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"],yct=["fill-extrusion-flood-light-ground-radius"],vct=Math.pow(2,13),_ct=Math.pow(2,15)-1,PCe=new es(0,1),cv=2147483648,ICe=7,LCe=450;function EP(g,d,m,v,k,E,P,O){g.emplaceBack((d<<1)+P,(m<<1)+E,(Math.floor(v*vct)<<1)+k,Math.round(O))}function PP(g,d,m){g.emplaceBack(d.x*Qs,d.y*Qs,m?1:0)}function uF(g,d,m,v,k,E){g.emplaceBack(d.x,d.y,(m.x<<1)+v,(m.y<<1)+k,E)}function IP(g,d,m){g.emplaceBack(d.x,d.y,d.z,m[0]*16384,m[1]*16384,m[2]*16384)}class DCe{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class OCe{constructor(){this.centroidXY=new es(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new es(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new es(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new es(this.max.x-this.min.x,this.max.y-this.min.y)}}class RCe{constructor(){this.acc=new es(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 k=!!this.borders;m.xd.max.x&&(d.max.x=m.x,k=!0),m.yd.max.y&&(d.max.y=m.y,k=!0),((m.x===0||m.x===Qs)&&m.x===v.x)!=((m.y===0||m.y===Qs)&&m.y===v.y)&&this.processBorderOverlap(m,v),k&&this.checkBorderIntersection(m,v)}checkBorderIntersection(d,m){m.x<0!=d.x<0&&this.addBorderIntersection(0,Hr(m.y,d.y,(0-m.x)/(d.x-m.x))),m.x>Qs!=d.x>Qs&&this.addBorderIntersection(1,Hr(m.y,d.y,(Qs-m.x)/(d.x-m.x))),m.y<0!=d.y<0&&this.addBorderIntersection(2,Hr(m.x,d.x,(0-m.y)/(d.y-m.y))),m.y>Qs!=d.y>Qs&&this.addBorderIntersection(3,Hr(m.x,d.x,(Qs-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 es(0,0):new es(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((d,m)=>d+ +(m[0]!==Number.MAX_VALUE),0):0}}function FCe(g,d){const m=g.add(d)._unit(),v=ve(g.x*m.x+g.y*m.y,-1,1);var k,E,P;return k=Math.acos(v),Math.min(4,Math.max(-4,Math.tan(k)))/4*_ct*((E=g).x*(P=d).y-E.y*P.x<0?-1:1)}const bct=[g=>g.x<0,g=>g.x>Qs,g=>g.y<0,g=>g.y>Qs];function wct(g,d,m,v){const k=[4];if(v===0)return k;m._mult(v);const E=g.sub(m),P=d.sub(m),O=[g,d,E,P];for(let B=0;B<4;B++)for(const W of O)if(bct[B](W)){k.push(B);break}return k}class lpe{constructor(d){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new aP,this.indexArray=new Il,this.programConfigurations=new Op(d.layers,{zoom:d.zoom,lut:d.lut},m=>yct.includes(m)),this._segments=new xo,this.hiddenByLandmarkVertexArray=new l3,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new xo}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(d,m,v,k=!1){const E=d.length;if(E>2){let P=Math.max(0,this._segments.get().length-1);const O=this._segments._prepareSegment(4*E,this.vertexArray.length,2*this._segmentToGroundQuads[P].length);let B;P!==this._segments.get().length-1&&(P++,this._segmentToGroundQuads[P]=[],this._segmentToRegionTriCounts[P]=[0,0,0,0,0]);{const W=d[0],J=d[1];B=FCe(W.sub(d[E-1])._perp()._unit(),J.sub(W)._perp()._unit())}for(let W=0;Wk.region-E.region);for(let v=0;vB+W,0);let O=0;for(let B=0;B<=4;B++){const W=P[B];if(W!==0){let J=this.regionSegments[B];J||(J=this.regionSegments[B]=new xo);const te={vertexOffset:E.vertexOffset,primitiveOffset:E.primitiveOffset+O,vertexLength:E.vertexLength,primitiveLength:W};J.get().push(te)}O+=W}for(let B=0;B0?this.hiddenByLandmarkVertexBuffer=d.createVertexBuffer(this.hiddenByLandmarkVertexArray,mct.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 hF{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 Il,this.footprintVertices=new Ny,this.footprintSegments=[],this.layoutVertexArray=new n_,this.centroidVertexArray=new JR,this.wallVertexArray=new cw,this.indexArray=new Il,this.programConfigurations=new Op(d.layers,{zoom:d.zoom,lut:d.lut},m=>xct.includes(m)),this.segments=new xo,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.groundEffect=new lpe(d),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,k){}populate(d,m,v,k){this.features=[],this.hasPattern=Jme("fill-extrusion",this.layers,this.pixelRatio,m),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=Be(v),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1)!==0;for(const{feature:E,id:P,index:O,sourceLayerIndex:B}of d){const W=this.layers[0]._featureFilter.needGeometry,J=Ht(E,W);if(!this.layers[0]._featureFilter.filter(new Hi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),J,v))continue;const te={id:P,sourceLayerIndex:B,index:O,geometry:W?J.geometry:Pt(E,v,k),properties:E.properties,type:E.type,patterns:{}},ie=this.layoutVertexArray.length,ce=ope[te.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:E.id,feature:epe("fill-extrusion",this.layers,te,this.zoom,this.pixelRatio,m)});else if(this.wallMode)for(const ue of te.geometry)for(const Ne of ECe(ue,ce))this.addFeature(E.id,te,[Ne],O,v,{},m.availableImages,k,m.brightness);else this.addFeature(E.id,te,te.geometry,O,v,{},m.availableImages,k,m.brightness);m.featureIndex.insert(E,te.geometry,O,B,this.index,ie)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(d,m,v,k,E,P){for(const{featureId:O,feature:B}of this.features){const W=ope[B.type]==="Polygon",{geometry:J}=B;if(this.wallMode)for(const te of J)for(const ie of ECe(te,W))this.addFeature(O,B,[ie],B.index,m,v,k,E,P);else this.addFeature(O,B,J,B.index,m,v,k,E,P)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(d,m,v,k,E,P,O){this.programConfigurations.updatePaintArrays(d,m,E,v,k,P,O,this.worldview),this.groundEffect.update(d,m,E,v,k,P,O,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,fct),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.wallVertexBuffer=d.createVertexBuffer(this.wallVertexArray,hct.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=d.createVertexBuffer(this.layoutVertexExtArray,pct.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,uct.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,k,E,P,O,B,W){const J=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(m,{})/this.tileToMeter,te=[new es(0,0),new es(Qs,Qs)],ie=B.projection,ce=ie.name==="globe",ue=this.wallMode||ope[m.type]==="Polygon",Ne=new RCe;Ne.centroidDataIndex=this.centroidData.length;const Le=new OCe;Le.buildingId=d,m.properties&&m.properties.hasOwnProperty("building_id")&&(Le.buildingId=m.properties.building_id);const Ie=this.layers[0].paint.get("fill-extrusion-base").evaluate(m,{},E)<=0,Ge=this.layers[0].paint.get("fill-extrusion-height").evaluate(m,{},E);let Ze;if(Le.height=Ge,Le.vertexArrayOffset=this.layoutVertexArray.length,Le.groundVertexArrayOffset=this.groundEffect.vertexArray.length,ce&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new s3),this.wallMode){if(ce)return void hr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(v.length!==1)return;Ze=function(Wt){const us=Wt[0].x===Wt[Wt.length-1].x&&Wt[0].y===Wt[Wt.length-1].y;(function(yr){let Nr=0;const Wn=yr.length;for(let Gs=0;Gs=0})(Wt)||(Wt=Wt.reverse());const ws={geometry:[],joinNormals:[],indices:[]},Fs=[],Bs=[],Ds=[];let Os=Wt.length;for(;Os>=2&&Wt[Os-1].equals(Wt[Os-2]);)Os--;if(Os<(us?3:2))return ws;let ds,is,Rs,Js,Hs,Dr=0;for(;Dr0;let pn="miter";const xa=2;pn==="miter"&&Gs>xa&&(pn="bevel"),pn==="bevel"&&(Gs>100&&(pn="flipbevel"),Gs{const hs=new es(Ln.x,Ln.y),zs=new es(Ln.x,Ln.y);hs.x+=Ci.x*_t,hs.y+=Ci.y*_t,zs.x-=Ci.x*Math.max(ft,1),zs.y-=Ci.y*Math.max(ft,1),Ds.push(Ci),Fs.push(hs),Bs.push(zs)};if(pn==="miter")Nr._mult(Gs),ba(ds,Nr,0,0);else if(pn==="flipbevel")Nr=Hs.mult(-1),ba(ds,Nr,0,0),ba(ds,Nr.mult(-1),0,0);else{const Ln=-Math.sqrt(Gs*Gs-1),Ci=Sr?Ln:0,ft=Sr?0:Ln;is&&ba(ds,Js,Ci,ft),Rs&&ba(ds,Hs,Ci,ft)}}ws.geometry=[...Fs,...Bs.reverse(),Fs[0]],ws.joinNormals=[...Ds,...Ds.reverse(),Ds[Ds.length-1]];const ur=ws.geometry.length-1;for(let yr=0;yrWt<(us.length-1)/2||Wt===us.length-1,vt=this.wallMode?[v]:TP(v,500);for(let Wt=vt.length-1;Wt>=0;Wt--){const us=vt[Wt];(us.length===0||(pt=us[0]).every(bs=>bs.x<=0)||pt.every(bs=>bs.x>=Qs)||pt.every(bs=>bs.y<=0)||pt.every(bs=>bs.y>=Qs))&&vt.splice(Wt,1)}var pt;let St;if(ce)St=HCe(vt,te,E);else{St=[];for(const Wt of vt)St.push({polygon:Wt,bounds:te})}const Lt=ue?this.edgeRadius:0,Bt=Lt>0&&this.zoom<17,as=(Wt,us)=>{if(Wt.length===0)return!1;const bs=Wt[Wt.length-1];return us.x===bs.x&&us.y===bs.y};for(const{polygon:Wt,bounds:us}of St){let bs=0,ws=0;for(const Os of Wt)ue&&!Os[0].equals(Os[Os.length-1])&&Os.push(Os[0]),ws+=ue?Os.length-1:Os.length;const Fs=this.segments.prepareSegment((ue?5:4)*ws,this.layoutVertexArray,this.indexArray);Le.footprintSegIdx<0&&(Le.footprintSegIdx=this.footprintSegments.length),Le.polygonSegIdx<0&&(Le.polygonSegIdx=this.polygonSegments.length);const Bs={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Ds=new DCe;if(Ds.vertexOffset=this.footprintVertices.length,Ds.indexOffset=3*this.footprintIndices.length,Ds.ringIndices=[],ue){const Os=[],ds=[];bs=Fs.vertexLength;for(let Rs=0;Rs4&&qCe(ds[ds.length-2],ds[0],ds[1]),Rs=Lt?jct(ds[ds.length-2],ds[0],ds[1],Lt):0;const Js=[];let Hs,Dr,ur;Dr=ds[1].sub(ds[0])._perp()._unit();let yr=!0;for(let Nr=1,Wn=0;Nr0?1:0,Ci=Gs.dist(Sr);if(Wn+Ci>32768&&(Wn=0),Lt){ur=pn.sub(Sr)._perp()._unit();let zs=BCe(Gs,Sr,pn,zCe(Dr,ur),Lt);isNaN(zs)&&(zs=0);const or=Sr.sub(Gs)._unit();Gs=Gs.add(or.mult(Rs))._round(),Sr=Sr.add(or.mult(-zs))._round(),Rs=zs,Dr=ur,Ie&&this.zoom>=17&&(as(Js,Gs)||Js.push(Gs),as(Js,Sr)||Js.push(Sr))}const ft=Fs.vertexLength,_t=ds.length>4&&qCe(Gs,Sr,pn);let hs=UCe(Wn,is,yr);if(EP(this.layoutVertexArray,Gs.x,Gs.y,ba,Ln,0,0,hs),EP(this.layoutVertexArray,Gs.x,Gs.y,ba,Ln,0,1,hs),this.wallMode){const zs=at(Nr-1,ds),or=Ze.joinNormals[Nr-1];PP(this.wallVertexArray,or,zs),PP(this.wallVertexArray,or,zs)}if(Wn+=Ci,hs=UCe(Wn,_t,!yr),is=_t,EP(this.layoutVertexArray,Sr.x,Sr.y,ba,Ln,0,0,hs),EP(this.layoutVertexArray,Sr.x,Sr.y,ba,Ln,0,1,hs),this.wallMode){const zs=at(Nr,ds),or=Ze.joinNormals[Nr];PP(this.wallVertexArray,or,zs),PP(this.wallVertexArray,or,zs)}if(Fs.vertexLength+=4,this.indexArray.emplaceBack(ft+0,ft+1,ft+2),this.indexArray.emplaceBack(ft+1,ft+3,ft+2),Fs.primitiveLength+=2,Lt){const zs=bs+(Nr===1?ds.length-2:Nr-2),or=Nr===1?bs:zs+1;if(this.indexArray.emplaceBack(ft+1,zs,ft+3),this.indexArray.emplaceBack(zs,or,ft+3),Fs.primitiveLength+=2,Hs===void 0&&(Hs=ft),!cpe(pn,ds[Nr],us)){const lr=Nr===ds.length-1?Hs:Fs.vertexLength;this.indexArray.emplaceBack(ft+2,ft+3,lr),this.indexArray.emplaceBack(ft+3,lr+1,lr),this.indexArray.emplaceBack(ft+3,or,lr+1),Fs.primitiveLength+=3}yr=!yr}if(ce){const zs=this.layoutVertexExtArray,or=ie.projectTilePoint(Gs.x,Gs.y,E),lr=ie.projectTilePoint(Sr.x,Sr.y,E),Or=ie.upVector(E,Gs.x,Gs.y),zr=ie.upVector(E,Sr.x,Sr.y);IP(zs,or,Or),IP(zs,or,Or),IP(zs,lr,zr),IP(zs,lr,zr)}}ue&&(bs+=ds.length-1),Ie&&Lt&&this.zoom>=17&&(Js.length!==0&&as(Js,Js[0])&&Js.pop(),this.groundEffect.addData(Js,us,J,Lt>0))}this.footprintSegments.push(Ds),Bs.triangleCount=this.indexArray.length-Bs.triangleArrayOffset,this.polygonSegments.push(Bs),++Le.footprintSegLen,++Le.polygonSegLen}if(Le.vertexCount=this.layoutVertexArray.length-Le.vertexArrayOffset,Le.groundVertexCount=this.groundEffect.vertexArray.length-Le.groundVertexArrayOffset,Le.vertexCount!==0){if(Le.centroidXY=Ne.borders?PCe:this.encodeCentroid(Ne,Le),this.centroidData.push(Le),Ne.borders){this.featuresOnBorder.push(Ne);const Wt=this.featuresOnBorder.length-1;for(let us=0;usthis.featuresOnBorder[m].borders[d][0]-this.featuresOnBorder[v].borders[d][0])}splitToSubtiles(){const d=[];for(let O=0;OQs),J=2*W+(+(B.min.x+B.max.x>Qs)^W);for(let te=0;teO.triangleSegmentIdx===B.triangleSegmentIdx?O.subtile-B.subtile:O.triangleSegmentIdx-B.triangleSegmentIdx);let v=0,k=0,E=0;for(const O of d){if(O.triangleSegmentIdx!==v)break;E++}const P=d.length;for(;k!==d.length;){v=d[k].triangleSegmentIdx;let O=0,B=k,W=k;for(let J=B;J0&&this.triangleSubSegments.push({segment:ce,min:te,max:ie}),B=W;for(let ue=B;ue[Ne[0]*(1-Ie[0])+Le[0]*Ie[0],Ne[1]*(1-Ie[1])+Le[1]*Ie[1]],ce=[],ue=[];for(const Ne of this.triangleSubSegments){ce[0]=Ne.min.x/Qs,ce[1]=Ne.min.y/Qs,ue[0]=Ne.max.x/Qs,ue[1]=Ne.max.y/Qs;const Le=ie(J,te,ce),Ie=ie(J,te,ue);if(new Er([Le[0],Le[1],E],[Ie[0],Ie[1],P]).intersectsPrecise(v)===0){W&&(k.segments.push(W),W=void 0);continue}const Ge=Ne.segment;W&&W.vertexOffset!==Ge.vertexOffset&&(k.segments.push(W),W=void 0),W?(W.vertexLength+=Ge.vertexLength,W.primitiveLength+=Ge.primitiveLength):W={vertexOffset:Ge.vertexOffset,primitiveLength:Ge.primitiveLength,vertexLength:Ge.vertexLength,primitiveOffset:Ge.primitiveOffset,sortKey:void 0,vaos:{}}}return W&&k.segments.push(W),k}encodeCentroid(d,m){const v=d.centroid(),k=m.span(),E=Math.min(7,Math.round(k.x*this.tileToMeter/10)),P=Math.min(7,Math.round(k.y*this.tileToMeter/10));return new es(ve(v.x,1,Qs-1)<<3|E,ve(v.y,1,Qs-1)<<3|P)}encodeBorderCentroid(d){if(!d.borders)return new es(0,0);const m=d.borders,v=Number.MAX_VALUE;if(m[0][0]!==v||m[1][0]!==v){const k=m[0][0]!==v?0:1;return new es(6|(m[0][0]!==v?0:65528),(m[k][0]+m[k][1])/2<<3|6)}{const k=m[2][0]!==v?2:3;return new es((m[k][0]+m[k][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,k=d.flags&cv?PCe:d.centroidXY,E=this.centroidVertexArray.geta_centroid_pos0(m);if(this.centroidVertexArray.geta_centroid_pos1(m)!==k.y||E!==k.x){for(let P=m;PB.max.x||B.min.x>P.max.x||P.min.y>B.max.y||B.min.y>P.max.y||P.footprint.buildingIds.has(B.buildingId)&&(B.flags|=cv);else for(const B of this.centroidData)if(!(B.flags&cv||P.min.x>B.max.x||B.min.x>P.max.x||P.min.y>B.max.y||B.min.y>P.max.y))for(let W=0;Wm!=ce>m&&d<(this.footprintVertices.int16[2*(J+P.vertexOffset)+0]-te)*(m-ie)/(ce-ie)+te&&(k=!k)}O=B}}return k}getHeightAtTileCoord(d,m){let v=Number.NEGATIVE_INFINITY,k=!0;const E=4*(d+Qs)*Qs+(m+Qs);if(this.partLookup.hasOwnProperty(E)){const P=this.partLookup[E];return P?{height:P.height,hidden:!!(P.flags&cv)}: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,k=!!(P.flags&cv));if(v!==Number.NEGATIVE_INFINITY)return{height:v,hidden:k};this.partLookup[E]=void 0}}function zCe(g,d){const m=g.add(d)._unit();return g.x*m.x+g.y*m.y}function jct(g,d,m,v){const k=d.sub(g)._perp()._unit(),E=m.sub(d)._perp()._unit();return BCe(g,d,m,zCe(k,E),v)}function BCe(g,d,m,v,k){const E=Math.sqrt(1-v*v);return Math.min(g.dist(d)/3,d.dist(m)/3,k*E/v)}function cpe(g,d,m){return g.xm[1].x&&d.x>m[1].x||g.ym[1].y&&d.y>m[1].y}function $Ce(g,d){return g.xd[1].x||g.yd[1].y}function qCe(g,d,m){if(g.x<0||g.x>=Qs||d.x<0||d.x>=Qs||m.x<0||m.x>=Qs)return!1;const v=m.sub(d),k=v.perp(),E=g.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&&k.x*E.x+k.y*E.y<0}function UCe(g,d,m){const v=d?2|g:-3&g;return m?1|v:-2&v}function VCe(){const g=Math.PI/32,d=Math.tan(g),m=M;return m*Math.sqrt(1+2*d*d)-m}function HCe(g,d,m){const v=1<{for(const Lt of pt)ue.push({polygon:Lt,bounds:St})},Le=Math.ceil(Math.log2(J)),Ie=Math.ceil(Math.log2(te)),Ge=Le-Ie,Ze=[];for(let pt=0;pt0?0:1);for(let pt=0;ptSt+1?vt.push({polygons:ws,bounds:Bs,depth:St+1}):Ne(ws,Bs)}if(Fs.length){const Bs=[new es(Lt===0?bs:Bt.x,Lt===1?bs:Bt.y),as];Ze.length>St+1?vt.push({polygons:Fs,bounds:Bs,depth:St+1}):Ne(Fs,Bs)}}return ue}(g,d,Math.ceil((E-k)/11.25),Math.ceil((P-O)/11.25),1,(B,W,J)=>{if(B===0)return .5*(W+J);{const te=ge((m.y+W/Qs)/v);return(Y(.5*(ge((m.y+J/Qs)/v)+te))*v-m.y)*Qs}})}function kct(g,d,m,v,k,E){const P=Math.pow(2,v.z-k.z);for(let O=0;O=B[P]&&(O=d,B=g),O[P]k&&ZCe(O,B,P,k),O[P]E&&ZCe(B,O,P,E)}}function mF(g,d,m,v,k,E){const P=[];for(let O=0;O=v&&ue.x>=v||(ce.x>=v?ce=new es(v,ce.y+(v-ce.x)/(ue.x-ce.x)*(ue.y-ce.y))._round():ue.x>=v&&(ue=new es(v,ce.y+(v-ce.x)/(ue.x-ce.x)*(ue.y-ce.y))._round()),ce.y>=k&&ue.y>=k||(ce.y>=k?ce=new es(ce.x+(k-ce.y)/(ue.y-ce.y)*(ue.x-ce.x),k)._round():ue.y>=k&&(ue=new es(ce.x+(k-ce.y)/(ue.y-ce.y)*(ue.x-ce.x),k)._round()),W&&ce.equals(W[W.length-1])||(W=[ce],P.push(W),E&&E.push({progress:{min:Le+XCe(Ie,Ge,ce)*Ne,max:1},parentIndex:O,prevPoint:Ie,nextPoint:Ge})),W.push(ue),E&&(E[E.length-1].progress.max=Le+XCe(Ie,Ge,ue)*Ne,E[E.length-1].nextPoint=Ge)))))}if(E&&te>0)for(let ie=J;ieW.t-J.t);let P=0,O=0,B=[];for(v.push(B);P!==g.length;){if(O===E.length){for(;P!==g.length;)B.length!==0&&B[B.length-1].equals(g[P])||B.push(g[P]),P++;break}E[O].t<=P?(B.length!==0&&B[B.length-1].equals(E[O].point)||B.push(E[O].point),Math.trunc(E[O].t),O++):(B.length!==0&&B[B.length-1].equals(g[P])||B.push(g[P]),P++)}}function XCe(g,d,m){return g.x!==d.x?(m.x-g.x)/(d.x-g.x):g.y!==d.y?(m.y-g.y)/(d.y-g.y):0}function LP(g,d){return g.x*d.x+g.y*d.y}function QCe(g,d){if(g.length===1){let m=0;const v=d[m++];let k;for(;!k||v.equals(k);)if(k=d[m++],!k)return 1/0;for(;m{bs[0]=ws,bs[1]=Fs,bs[2]=Bs,bs[3]=1},us=VCe();ce>0&&(ce+=us),ue+=us;for(const bs of ie){const ws=[],Fs=[];for(const Bs of bs){const Ds=Bs.x+Ne.x,Os=Bs.y+Ne.y,ds=te.projection.projectTilePoint(Ds,Os,vt),is=te.projection.upVector(vt,Bs.x,Bs.y);let Rs=ce,Js=ue;if(Ie){const Hs=t3e(Ds,Os,ce,ue,Ie,Ge,Ze,at);Rs+=Hs.base,Js+=Hs.top}ce!==0?Wt(Bt,ds.x+is[0]*Lt*Rs,ds.y+is[1]*Lt*Rs,ds.z+is[2]*Lt*Rs):Wt(Bt,ds.x,ds.y,ds.z),Wt(as,ds.x+is[0]*Lt*Js,ds.y+is[1]*Lt*Js,ds.z+is[2]*Lt*Js),Rt(Bt,Bt,Le),Rt(as,as,Le),ws.push(new vw(Bt[0],Bt[1],Bt[2])),Fs.push(new vw(as[0],as[1],as[2]))}pt.push(ws),St.push(Fs)}return[pt,St]}(g,d,m,v,k,E,P,O,B,W,J):P?function(te,ie,ce,ue,Ne,Le,Ie,Ge,Ze){const at=[],vt=[],pt=[0,0,0,1];for(const St of te){const Lt=[],Bt=[];for(const as of St){const Wt=as.x+ue.x,us=as.y+ue.y,bs=t3e(Wt,us,ie,ce,Le,Ie,Ge,Ze);pt[0]=Wt,pt[1]=us,pt[2]=bs.base,pt[3]=1,Xe(pt,pt,Ne),pt[3]=Math.max(pt[3],1e-5);const ws=new vw(pt[0]/pt[3],pt[1]/pt[3],pt[2]/pt[3]);pt[0]=Wt,pt[1]=us,pt[2]=bs.top,pt[3]=1,Xe(pt,pt,Ne),pt[3]=Math.max(pt[3],1e-5);const Fs=new vw(pt[0]/pt[3],pt[1]/pt[3],pt[2]/pt[3]);Lt.push(ws),Bt.push(Fs)}at.push(Lt),vt.push(Bt)}return[at,vt]}(d,m,v,k,E,P,O,B,W):function(te,ie,ce,ue,Ne){const Le=[],Ie=[],Ge=Ne[8]*ie,Ze=Ne[9]*ie,at=Ne[10]*ie,vt=Ne[11]*ie,pt=Ne[8]*ce,St=Ne[9]*ce,Lt=Ne[10]*ce,Bt=Ne[11]*ce;for(const as of te){const Wt=[],us=[];for(const bs of as){const ws=bs.x+ue.x,Fs=bs.y+ue.y,Bs=Ne[0]*ws+Ne[4]*Fs+Ne[12],Ds=Ne[1]*ws+Ne[5]*Fs+Ne[13],Os=Ne[2]*ws+Ne[6]*Fs+Ne[14],ds=Ne[3]*ws+Ne[7]*Fs+Ne[15],is=Bs+Ge,Rs=Ds+Ze,Js=Os+at,Hs=Math.max(ds+vt,1e-5),Dr=Bs+pt,ur=Ds+St,yr=Os+Lt,Nr=Math.max(ds+Bt,1e-5);Wt.push(new vw(is/Hs,Rs/Hs,Js/Hs)),us.push(new vw(Dr/Nr,ur/Nr,yr/Nr))}Le.push(Wt),Ie.push(us)}return[Le,Ie]}(d,m,v,k,E)}function t3e(g,d,m,v,k,E,P,O){const B=P*k.getElevationAt(g,d,!0,!0),W=E[0]!==0,J=W?E[1]===0?P*(E[0]/ICe-LCe):P*function(te,ie,ce){const ue=Math.floor(ie[0]/8),Ne=Math.floor(ie[1]/8),Le=10*(ie[0]-8*ue),Ie=10*(ie[1]-8*Ne),Ge=te.getElevationAt(ue,Ne,!0,!0),Ze=te.getMeterToDEM(ce),at=Math.floor(.5*(Le*Ze-1)),vt=Math.floor(.5*(Ie*Ze-1)),pt=te.tileCoordToPixel(ue,Ne),St=2*at+1,Lt=2*vt+1,Bt=function(Fs,Bs,Ds,Os,ds){return[Fs.getElevationAtPixel(Bs,Ds,!0),Fs.getElevationAtPixel(Bs+ds,Ds,!0),Fs.getElevationAtPixel(Bs,Ds+ds,!0),Fs.getElevationAtPixel(Bs+Os,Ds+ds,!0)]}(te,pt.x-at,pt.y-vt,St,Lt),as=Math.abs(Bt[0]-Bt[1]),Wt=Math.abs(Bt[2]-Bt[3]),us=Math.abs(Bt[0]-Bt[2])+Math.abs(Bt[1]-Bt[3]),bs=Math.min(.25,.5*Ze*(as+Wt)/St),ws=Math.min(.25,.5*Ze*us/Lt);return Ge+Math.max(bs*Le,ws*Ie)}(k,E,O):B;return{base:B+(m===0?-1:m),top:W?Math.max(J+v,B+m+2):B+v}}class Sct{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 Cct{constructor(){this.tasks={},this.taskQueue=[],$t(["process"],this),this.invoker=new Sct(this.process),this.nextId=0}add(d,m){const v=this.nextId++,k=function({type:E,isSymbolTile:P,zoom:O}){return O=O||0,E==="message"?0:E!=="maybePrepare"||P?E!=="parseTile"||P?E==="parseTile"&&P?300-O:E==="maybePrepare"&&P?400-O:500:200-O:100-O}(m);if(k===0){try{d()}finally{}return null}return this.tasks[v]={fn:d,metadata:m,priority:k,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 k=0;k{v&&delete this.callbacks[O],this.target.postMessage({id:O,type:"",targetMapId:k,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 k=this.cancelCallbacks[v];delete this.cancelCallbacks[v],k&&k.cancel()}else if(m.mustQueue||fa(self)){const k=this.callbacks[v],E=this.scheduler.add(()=>this.processTask(v,m),k&&k.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(ky(m.error)):v(null,ky(m.data)))}else{const v=new Set,k=m.hasCallback?(P,O)=>{this.target.postMessage({id:d,type:"",sourceMapId:this.mapId,error:P?Yg(P):null,data:Yg(O,v)},v)}:()=>{},E=ky(m.data);if(this.parent[m.type])this.parent[m.type](m.sourceMapId,E,k);else if(this.parent.getWorkerSource){const P=m.type.split("."),{source:O,scope:B}=E;this.parent.getWorkerSource(m.sourceMapId,P[0],O,B)[P[1]](E,k)}else k(new Error(`Could not find function ${m.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var DP={workerUrl:"",workerClass:null,workerParams:void 0};const dpe="mapboxgl_preloaded_worker_pool";class _w{constructor(d){this.active={},this.name=d}acquire(d,m=_w.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{m.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[dpe]}numActive(){return Object.keys(this.active).length}}_w.workerCount=2;class w3{constructor(d,m,v="Worker",k=_w.workerCount){this.workerPool=d,this.actors=[],this.currentActor=0,this.id=zt();const E=this.workerPool.acquire(this.id,k);for(let P=0;P{this.ready=!0})}broadcast(d,m,v){Ct(this.actors,(k,E)=>{k.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 OP,upe;function pF(){return OP||(OP=new _w),OP}w3.Actor=s3e;const hpe=4096;class Mct{constructor(d){this.module=d,this.memoryStack=this.module.malloc(hpe),this.memoryStackNextFree=this.memoryStack}createIntArray(d){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=d.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>hpe?-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>hpe?-1:(new Float32Array(this.module.heapF32.buffer,m,d.length).set(d),m)}readStringBuffer(d){let m="";for(;this.module.heapU8[d]!==0;)m+=String.fromCharCode(this.module.heapU8[d]),++d;return m}setStyle(d){const m=d.normalScale;this.module.setStyle(m[0],m[1],m[2],d.tileToMeters)}setAOOptions(d,m){this.module.setAOOptions(d?1:0,m)}setMetricOptions(d,m){this.module.setMetricOptions(d?1:0,m)}setStructuralOptions(d){this.module.setStructuralOptions(d?1:0)}setFacadeOptions(d,m){this.module.setFacadeOptions(d,m?1:0)}setFauxFacadeOptions(d,m,v){this.module.setFauxFacadeOptions(d?1:0,m?1:0,v)}setFacadeClassifierOptions(d){this.module.setFacadeClassifierOptions(d)}generateMesh(d,m){this.memoryStackNextFree=this.memoryStack;for(const O of d){const B=this.createIntArray(O.ringIndices),W=this.createFloatArray(O.coordinates);if(B===-1||W===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(O.id,O.sourceId,O.minHeight,O.height,O.roofType,W,B,O.ringIndices.length-1)}for(const O of m){let B;B=O.entrances?JSON.parse(O.entrances):[];const W=this.createFloatArray(B),J=this.createFloatArray(O.coordinates);if(W===-1||J===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(O.sourceId,O.crossPerc,O.distanceToRoad,W,B.length,J,O.coordinates.length)}if(!this.module.generateMesh()){const O=this.module.getLastError();return this.readStringBuffer(O)}const v=this.module.getMeshCount(),k=new Array(v);for(let O=0;Ok.arrayBuffer()).then(k=>{d.buffers[m]=k})}function d3e(g,d){const m=g.json.bufferViews[d];return new Uint8Array(g.buffers[m.buffer],m.byteOffset||0,m.byteLength)}function Lct(g,d,m,v){if(g.uri){const k=c3e(g.uri,v);return fetch(k).then(E=>E.blob()).then(E=>createImageBitmap(E)).then(E=>{d.images[m]=E})}if(g.bufferView!==void 0){const k=d3e(d,g.bufferView),E=new Blob([k],{type:g.mimeType});return createImageBitmap(E).then(P=>{d.images[m]=P})}}function u3e(g,d=0,m){const v={json:null,images:[],buffers:[]};if(new Uint32Array(g,d,1)[0]===o3e){const J=new Uint32Array(g,d);let te=2;const ie=(J[te++]>>2)-3,ce=J[te++]>>2;if(te++,v.json=JSON.parse(l3e.decode(J.subarray(te,te+ce))),te+=ce,te{const J=[],te=O&&O.includes(fpe),ie=O&&O.includes(xF);if(te&&J.push(function(){if(!lx)return RP??(RP=function(ce){let ue,Ne=null;function Le(){ue=new Uint8Array(Ne.buffer)}function Ie(){throw new Error("Unexpected Draco error.")}const Ge={a:{a:Ie,d:function(Ze,at,vt){return ue.copyWithin(Ze,at,at+vt)},c:function(Ze){const at=ue.length,vt=Math.max(Ze>>>0,Math.ceil(1.2*at)),pt=Math.ceil((vt-at)/65536);try{return Ne.grow(pt),Le(),!0}catch{return!1}},b:Ie}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(ce,Ge):ce.then(Ze=>Ze.arrayBuffer()).then(Ze=>WebAssembly.instantiate(Ze,Ge))).then(Ze=>{const{Rb:at,Qb:vt,P:pt,T:St,X:Lt,Ja:Bt,La:as,Qa:Wt,Va:us,Wa:bs,eb:ws,jb:Fs,f:Bs,e:Ds,yb:Os,zb:ds,Ab:is,Bb:Rs,Db:Js,Gb:Hs}=Ze.instance.exports;Ne=Ds;const Dr=(()=>{let ur=0,yr=0,Nr=0,Wn=0;return Gs=>{Nr&&(at(Wn),at(ur),yr+=Nr,Nr=ur=0),ur||(yr+=128,ur=vt(yr));const Sr=Gs.length+7&-8;let pn=ur;Sr>=yr&&(Nr=Sr,pn=Wn=vt(Sr));for(let xa=0;xa{lx=ce,RP=void 0}))}()),ie&&J.push(function(){if(ppe)return;const ce=function(ue){let Ne;const Le=WebAssembly.instantiateStreaming(ue,{}).then(Ze=>{Ne=Ze.instance,Ne.exports.__wasm_call_ctors()}),Ie={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Ge={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:Le,supported:!0,decodeGltfBuffer(Ze,at,vt,pt,St,Lt){(function(Bt,as,Wt,us,bs,ws,Fs){const Bs=Bt.exports.sbrk,Ds=us+3&-4,Os=Bs(Ds*bs),ds=Bs(ws.length),is=new Uint8Array(Bt.exports.memory.buffer);is.set(ws,ds);const Rs=as(Os,us,bs,ds,ws.length);if(Rs===0&&Fs&&Fs(Os,Ds,bs),Wt.set(is.subarray(Os,Os+us*bs)),Bs(Os-Bs(0)),Rs!==0)throw new Error(`Malformed buffer data: ${Rs}`)})(Ne,Ne.exports[Ge[St]],Ze,at,vt,pt,Ne.exports[Ie[Lt]])}}}(fetch(a3e()));return ce.ready.then(()=>{ppe=ce})}()),E)for(let ce=0;ce{if(te&&P)for(const{primitives:ce}of P)for(const ue of ce)Ect(ue,v);if(ie&&P&&B)for(const ce of B)Pct(ce,v);return v})})}function h3e(g){return fetch(g).then(d=>d.arrayBuffer()).then(d=>u3e(d,0,g))}function gpe(g){switch(g){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function xpe(g){switch(g){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class ype{constructor(d,m,v,k){this.context=d,this.format=v,this.useMipmap=k&&k.useMipmap,this.texture=d.gl.createTexture(),this.update(m,{premultiply:k&&k.premultiply})}update(d,m){const v=d&&d instanceof HTMLVideoElement&&d.width===0?d.videoWidth:d.width,k=d&&d instanceof HTMLVideoElement&&d.height===0?d.videoHeight:d.height,{context:E}=this,{gl:P}=E,{x:O,y:B}=m&&m.position?m.position:{x:0,y:0},W=O+v,J=B+k;!this.size||this.size[0]===W&&this.size[1]===J||(P.bindTexture(P.TEXTURE_2D,null),P.deleteTexture(this.texture),this.texture=P.createTexture(),this.size=null),P.bindTexture(P.TEXTURE_2D,this.texture),E.pixelStoreUnpackFlipY.set(!1),E.pixelStoreUnpack.set(1),E.pixelStoreUnpackPremultiplyAlpha.set(this.format===P.RGBA8&&(!m||m.premultiply!==!1));const te=d instanceof HTMLImageElement||d instanceof HTMLCanvasElement||d instanceof HTMLVideoElement||d instanceof ImageData||ImageBitmap&&d instanceof ImageBitmap;if(!this.size&&W>0&&J>0){const ie=this.useMipmap?Math.floor(Math.log2(Math.max(W,J)))+1:1;P.texStorage2D(P.TEXTURE_2D,ie,this.format,W,J),this.size=[W,J]}this.size&&(te?P.texSubImage2D(P.TEXTURE_2D,0,O,B,gpe(this.format),xpe(this.format),d):"data"in d&&d.data&&P.texSubImage2D(P.TEXTURE_2D,0,O,B,v,k,gpe(this.format),xpe(this.format),d.data)),this.useMipmap&&P.generateMipmap(P.TEXTURE_2D)}bind(d,m,v=!1){const{context:k}=this,{gl:E}=k;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,k,E){const{context:P}=this,{gl:O}=P;O.bindTexture(O.TEXTURE_2D,this.texture),m!==this.magFilter&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_MAG_FILTER,m),this.magFilter=m),d!==this.minFilter&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_MIN_FILTER,this.useMipmap?d===O.NEAREST?O.NEAREST_MIPMAP_NEAREST:O.LINEAR_MIPMAP_LINEAR:d),this.minFilter=d),v!==this.wrapS&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_S,v),this.wrapS=v),k!==this.wrapT&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_T,k),this.wrapT=k),E!==this.compareMode&&(E?(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_COMPARE_MODE,O.COMPARE_REF_TO_TEXTURE),O.texParameteri(O.TEXTURE_2D,O.TEXTURE_COMPARE_FUNC,E)):O.texParameteri(O.TEXTURE_2D,O.TEXTURE_COMPARE_MODE,O.NONE),this.compareMode=E)}destroy(){const{gl:d}=this.context;d.deleteTexture(this.texture),this.texture=null}}class zP{constructor(d,m){this.context=d,this.texture=m}bind(d,m){const{context:v}=this,{gl:k}=v;k.bindTexture(k.TEXTURE_2D,this.texture),d!==this.minFilter&&(k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,d),k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,d),this.minFilter=d),m!==this.wrapS&&(k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,m),k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,m),this.wrapS=m)}}const Dct=la([{name:"a_pos_3f",components:3,type:"Float32"}]),Oct=la([{name:"a_color_3f",components:3,type:"Float32"}]),Rct=la([{name:"a_color_4f",components:4,type:"Float32"}]),Fct=la([{name:"a_uv_2f",components:2,type:"Float32"}]),zct=la([{name:"a_normal_3f",components:3,type:"Float32"}]),Bct=la([{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"}]),$ct=la([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function m3e(g,d){const m=yF(g.projection,g.zoom,g.width,g.height),v=function(E,P,O,B,W){const J=new x(O.lng-180*p_,O.lat),te=new x(O.lng+180*p_,O.lat),ie=E.project(J.lng,J.lat),ce=E.project(te.lng,te.lat),ue=-Math.atan2(ce.y-ie.y,ce.x-ie.x),Ne=et.fromLngLat(O);Ne.y=ve(Ne.y,-1+p_,1-p_);const Le=Ne.toLngLat(),Ie=E.project(Le.lng,Le.lat),Ge=et.fromLngLat(Le);Ge.x+=p_;const Ze=Ge.toLngLat(),at=E.project(Ze.lng,Ze.lat),vt=f3e(at.x-Ie.x,at.y-Ie.y,ue),pt=et.fromLngLat(Le);pt.y+=p_;const St=pt.toLngLat(),Lt=E.project(St.lng,St.lat),Bt=f3e(Lt.x-Ie.x,Lt.y-Ie.y,ue),as=Math.abs(vt.x)/Math.abs(Bt.y),Wt=j([]);$(Wt,Wt,-ue*(1-(W?0:B)));const us=j([]);return I(us,us,[1,1-(1-as)*B,1]),us[4]=-Bt.x/Bt.y*B,$(us,us,ue),S(us,Wt,us),us}(g.projection,0,g.center,m,d),k=p3e(g);return I(v,v,[k,k,1]),v}function p3e(g){const d=g.projection,m=yF(g.projection,g.zoom,g.width,g.height),v=vpe(d,g.center),k=vpe(d,x.convert(d.center));return Math.pow(2,v*m+(1-m)*k)}function yF(g,d,m,v,k=1/0){const E=g.range;if(!E)return 0;const P=Math.min(k,Math.max(m,v)),O=Math.log2(P/1024);return ze(E[0]+O,E[1]+O,d)}const p_=1/4e4;function vpe(g,d){const m=ve(d.lat,-xe,xe),v=new x(d.lng-180*p_,m),k=new x(d.lng+180*p_,m),E=g.project(v.lng,m),P=g.project(k.lng,m),O=et.fromLngLat(v),B=et.fromLngLat(k),W=P.x-E.x,J=P.y-E.y,te=B.x-O.x,ie=B.y-O.y,ce=Math.sqrt((te*te+ie*ie)/(W*W+J*J));return Math.log2(ce)}function f3e(g,d,m){const v=Math.cos(m),k=Math.sin(m);return{x:g*v-d*k,y:g*k+d*v}}function g3e(g,d,m){j(g),$(g,g,Ir(d[2])),L(g,g,Ir(d[0])),R(g,g,Ir(d[1])),I(g,g,m),S(g,g,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function vF(g,d,m,v,k,E,P,O){const B=[m[0]-d[0],m[1]-d[1],0],W=[v[0]-d[0],v[1]-d[1],0];if(de(B)<1e-12||de(W)<1e-12)return Ye(g);const J=ct([],B,W);Te(J,J),he(W,v,d),B[2]=(E-k)*O,W[2]=(P-k)*O;const te=B;return ct(te,B,W),Te(te,te),ps(g,J,te)}function _F(g,d,m=!1){const v=h_(d.zoom),k=function(E,P,O){const B=P.worldSize,W=[E[12],E[13],E[14]],J=ge(W[1]/B),te=oe(W[0]/B),ie=j([]),ce=ae(1,J)*B,ue=ae(1,0)*B*Ce(J,P.zoom),Ne=1/Kme(B);let Le=ue*Ne;if(O){const at=yF(P.projection,P.zoom,P.width,P.height,1024);Le=Ne*P.projection.pixelSpaceConversion(P.center.lat,B,at)}const Ie=c_(J,te);le(Ie,Ie,ke([],Te([],Ie),ce*Le*W[2]));const Ge=function(at){const vt=[at[0],at[1],at[2]];let pt=[0,1,0];const St=ct([],pt,vt);return ct(pt,vt,St),Ae(pt)===0&&(pt=[0,1,0],ct(St,vt,pt)),Te(St,St),Te(pt,pt),Te(vt,vt),[St[0],St[1],St[2],0,pt[0],pt[1],pt[2],0,vt[0],vt[1],vt[2],0,at[0],at[1],at[2],1]}(Ie);I(ie,ie,[Le,Le,Le*ce]),T(ie,ie,[-W[0],-W[1],-W[2]]);const Ze=S([],P.globeMatrix,Ge);return S(Ze,Ze,ie),S(Ze,Ze,E),Ze}(g,d,m);if(v>0){const E=function(P,O){const B=O.worldSize,W=ae(1,0)*B*Ce(O.center.lat,O.zoom)/Kme(B),J=ae(1,O.center.lat)*B,te=j([]);R(te,te,Ir(O.center.lng)),L(te,te,Ir(O.center.lat)),T(te,te,[0,0,Od]),I(te,te,[W,W,W*J]);const ie=O.point;return T(te,te,[-ie.x,-ie.y,0]),S(te,te,P),S(te,O.globeMatrix,te)}(g,d);return function(P,O,B){const W=(ue,Ne,Le)=>{const Ie=de(ue),Ge=de(Ne),Ze=ox(ue,Ne,Le);return ke(Ze,Ze,1/de(Ze)*Hr(Ie,Ge,Le))},J=W([P[0],P[1],P[2]],[O[0],O[1],O[2]],B),te=W([P[4],P[5],P[6]],[O[4],O[5],O[6]],B),ie=W([P[8],P[9],P[10]],[O[8],O[9],O[10]],B),ce=ox([P[12],P[13],P[14]],[O[12],O[13],O[14]],B);return[J[0],J[1],J[2],0,te[0],te[1],te[2],0,ie[0],ie[1],ie[2],0,ce[0],ce[1],ce[2],1]}(k,E,v)}return k}function _pe(g,d,m,v){const k=Er.projectAabbCorners(v,m);let E=Number.MAX_VALUE;for(let O=0;O0||Le===0&&ue[0]*Ne[0]+ue[1]*Ne[1]>=0&&ue[0]*ue[0]+ue[1]*ue[1]>Ne[0]*Ne[0]+Ne[1]*Ne[1])&&(J=ce)}te=J}while(te!==W);return B.length>0&&B.push(B[0]),B}(k);if(Ua(g,P))return E}const bw=64,S3={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function bF(g,d,m,v,k,E,P,O,B,W=!1){const J=m.zoom,te=m.project(v),ie=Ce(v.lat,J),ce=1/ie;j(g),T(g,g,[te.x+P[0]*ce,te.y+P[1]*ce,P[2]]);let ue=1,Ne=1;const Le=m.worldSize;if(W){if(m.projection.name==="mercator"){let at=0;m.elevation&&(at=m.elevation.getAtPointOrZero(new et(te.x/Le,te.y/Le),0));const vt=Xe([],[te.x,te.y,at,1],m.projMatrix)[3]/m.cameraToCenterDistance;ue=vt,Ne=vt*Ce(m.center.lat,J)}else if(m.projection.name==="globe"){const at=_F(g,m),vt=[0,0,0,1];Xe(vt,vt,S([],m.projMatrix,at));const pt=vt[3]/m.cameraToCenterDistance,St=h_(J),Lt=m.projection.pixelsPerMeter(v.lat,Le)*Ce(v.lat,J),Bt=m.projection.pixelsPerMeter(m.center.lat,Le)*Ce(m.center.lat,J);ue=pt/Hr(Lt,Pe(m.center.lat),St),Ne=pt*ie/Lt,ue*=Bt,Ne*=Bt}}else ue=ce;I(g,g,[ue,ue,Ne]);const Ie=[...g],Ge=d.orientation,Ze=[];if(g3e(Ze,[Ge[0]+(k?k[0]:0),Ge[1]+(k?k[1]:0),Ge[2]+(k?k[2]:0)],E),S(g,Ie,Ze),O&&m.elevation){let at=0;const vt=[];if(B&&m.elevation){at=function(St,Lt,Bt,as,Wt){const us=Lt.elevation;if(!us)return 0;const bs=Er.projectAabbCorners(Bt,as),ws=ae(1,Wt.lat)*Lt.worldSize,Fs=function(yr,Nr){const Wn=[0,0,1],Gs=[{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 Sr of Gs){const pn=yr[Sr.corners[0]],xa=yr[Sr.corners[1]],ba=yr[Sr.corners[2]],Ln=[xa[0]-pn[0],xa[1]-pn[1],Nr*(xa[2]-pn[2])],Ci=ct(Ln,Ln,[ba[0]-pn[0],ba[1]-pn[1],Nr*(ba[2]-pn[2])]);Te(Ci,Ci),Sr.dotProductWithUp=qe(Ci,Wn)}return Gs.sort((Sr,pn)=>Sr.dotProductWithUp-pn.dotProductWithUp),Gs[0].corners}(bs,ws),Bs=bs[Fs[0]],Ds=bs[Fs[1]],Os=bs[Fs[2]],ds=bs[Fs[3]],is=us.getAtPointOrZero(new et(Bs[0]/Lt.worldSize,Bs[1]/Lt.worldSize),0),Rs=us.getAtPointOrZero(new et(Ds[0]/Lt.worldSize,Ds[1]/Lt.worldSize),0),Js=us.getAtPointOrZero(new et(Os[0]/Lt.worldSize,Os[1]/Lt.worldSize),0),Hs=us.getAtPointOrZero(new et(ds[0]/Lt.worldSize,ds[1]/Lt.worldSize),0),Dr=(is+Hs)/2,ur=(Rs+Js)/2;return Dr>ur?Rs=d.gl.NEAREST_MIPMAP_NEAREST}),g.uploaded=!0,g.image=null)}function qct(g,d,m){g.indexBuffer=d.createIndexBuffer(g.indexArray,!1,!0),g.vertexBuffer=d.createVertexBuffer(g.vertexArray,Dct.members,!1,!0),g.normalArray&&(g.normalBuffer=d.createVertexBuffer(g.normalArray,zct.members,!1,!0)),g.texcoordArray&&(g.texcoordBuffer=d.createVertexBuffer(g.texcoordArray,Fct.members,!1,!0)),g.colorArray&&(g.colorBuffer=d.createVertexBuffer(g.colorArray,(g.colorArray.bytesPerElement===12?Oct:Rct).members,!1,!0)),g.featureArray&&(g.pbrBuffer=d.createVertexBuffer(g.featureArray,$ct.members,!0)),g.segments=xo.simpleSegment(0,0,g.vertexArray.length,g.indexArray.length);const v=g.material;v.pbrMetallicRoughness.baseColorTexture&&BP(v.pbrMetallicRoughness.baseColorTexture,d),v.pbrMetallicRoughness.metallicRoughnessTexture&&BP(v.pbrMetallicRoughness.metallicRoughnessTexture,d),v.normalTexture&&BP(v.normalTexture,d),v.occlusionTexture&&BP(v.occlusionTexture,d,m),v.emissionTexture&&BP(v.emissionTexture,d)}function bpe(g,d,m){if(g.meshes)for(const v of g.meshes)qct(v,d,m);if(g.children)for(const v of g.children)bpe(v,d,m)}function wF(g){if(g.meshes)for(const d of g.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(g.children)for(const d of g.children)wF(d)}function wpe(g){if(g.meshes)for(const m of g.meshes)m.vertexBuffer&&(m.vertexBuffer.destroy(),m.indexBuffer.destroy(),m.normalBuffer&&m.normalBuffer.destroy(),m.texcoordBuffer&&m.texcoordBuffer.destroy(),m.colorBuffer&&m.colorBuffer.destroy(),m.pbrBuffer&&m.pbrBuffer.destroy(),m.segments.destroy(),m.material&&((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(g.children)for(const m of g.children)wpe(m)}function ww(g,d){const m=g.json.bufferViews[d.bufferView],v=gF[d.componentType];return new v(g.buffers[m.buffer],(d.byteOffset||0)+(m.byteOffset||0),d.count*(m.byteStride&&m.byteStride!==FP[d.type]*v.BYTES_PER_ELEMENT?m.byteStride/v.BYTES_PER_ELEMENT:FP[d.type]))}function jpe(g,d,m,v){const k=gF[d.componentType],E=function(J){switch(J){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(k),P=g.json.bufferViews[d.bufferView],O=P.byteStride?P.byteStride/k.BYTES_PER_ELEMENT:FP[d.type],B=m.float32,W=B.length/m.capacity;for(let J=0,te=0;J0){for(let Le=0;Le0){E.texcoordArray=new Rf;const ie=d.json.accessors[k.TEXCOORD_0];E.texcoordArray.resize(ie.count);const ce=ww(d,ie);jpe(d,ie,E.texcoordArray,ce)}if(k._FEATURE_ID_RGBA4444!==void 0){const ie=d.json.accessors[k._FEATURE_ID_RGBA4444];d.json.extensionsUsed&&d.json.extensionsUsed.includes("EXT_meshopt_compression")&&(E.featureData=ww(d,ie))}k._FEATURE_RGBA4444!==void 0&&(E.featureData=new Uint32Array(ww(d,d.json.accessors[k._FEATURE_RGBA4444]).buffer));const te=g.material;return E.material=function(ie,ce){const{emissiveFactor:ue=[0,0,0],alphaMode:Ne="OPAQUE",alphaCutoff:Le=.5,normalTexture:Ie,occlusionTexture:Ge,emissiveTexture:Ze,doubleSided:at,name:vt}=ie,{baseColorFactor:pt=[1,1,1,1],metallicFactor:St=1,roughnessFactor:Lt=1,baseColorTexture:Bt,metallicRoughnessTexture:as}=ie.pbrMetallicRoughness||{},Wt=Ge?ce[Ge.index]:void 0;if(Ge&&Ge.extensions&&Ge.extensions.KHR_texture_transform&&Wt){const us=Ge.extensions.KHR_texture_transform;Wt.offsetScale=[us.offset[0],us.offset[1],us.scale[0],us.scale[1]]}return{name:vt,pbrMetallicRoughness:{baseColorFactor:new Fr(...pt),metallicFactor:St,roughnessFactor:Lt,baseColorTexture:Bt?ce[Bt.index]:void 0,metallicRoughnessTexture:as?ce[as.index]:void 0},doubleSided:at,emissiveFactor:new Fr(...ue),alphaMode:Ne,alphaCutoff:Le,normalTexture:Ie?ce[Ie.index]:void 0,occlusionTexture:Wt,emissionTexture:Ze?ce[Ze.index]:void 0,defined:ie.defined===void 0}}(te!==void 0?d.json.materials[te]:{defined:!1},m),E}function y3e(g,d,m){const{matrix:v,rotation:k,translation:E,scale:P,mesh:O,extras:B,children:W,name:J}=g,te={};if(te.name=J,te.localMatrix=v||function(ie,ce,ue,Ne){var Le=ce[0],Ie=ce[1],Ge=ce[2],Ze=ce[3],at=Le+Le,vt=Ie+Ie,pt=Ge+Ge,St=Le*at,Lt=Le*vt,Bt=Le*pt,as=Ie*vt,Wt=Ie*pt,us=Ge*pt,bs=Ze*at,ws=Ze*vt,Fs=Ze*pt,Bs=Ne[0],Ds=Ne[1],Os=Ne[2];return ie[0]=(1-(as+us))*Bs,ie[1]=(Lt+Fs)*Bs,ie[2]=(Bt-ws)*Bs,ie[3]=0,ie[4]=(Lt-Fs)*Ds,ie[5]=(1-(St+us))*Ds,ie[6]=(Wt+bs)*Ds,ie[7]=0,ie[8]=(Bt+ws)*Os,ie[9]=(Wt-bs)*Os,ie[10]=(1-(St+as))*Os,ie[11]=0,ie[12]=ue[0],ie[13]=ue[1],ie[14]=ue[2],ie[15]=1,ie}([],k||[0,0,0,1],E||[0,0,0],P||[1,1,1]),te.globalMatrix=w(te.localMatrix),O!==void 0){te.meshes=m[O];const ie=te.anchor=[0,0];for(const ce of te.meshes){const{min:ue,max:Ne}=ce.aabb;ie[0]+=ue[0]+Ne[0],ie[1]+=ue[1]+Ne[1]}ie[0]=Math.floor(ie[0]/te.meshes.length/2),ie[1]=Math.floor(ie[1]/te.meshes.length/2)}if(B&&(B.id&&(te.id=B.id),B.lights&&(te.lights=function(ie){if(!ie.length)return[];const ce=function(Ge){const Ze=atob(Ge),at=new Uint8Array(Ze.length);for(let vt=0;vt1&&v[v.length-1].equals(v[0])&&v.pop();let k=0;for(let P=0;P0&&v.reverse();const E=_3(v.flatMap(P=>[P.x,P.y]),[]);return E.length===0?null:{vertices:v,indices:E}}function Wct(g,d){const m=[],v=[];let k=0;const E=[];for(const P of g){k=m.length;const O=P.vertexArray.float32,B=P.indexArray.uint16;for(let W=0;W0&&([v[P+1],v[P+2]]=[v[P+2],v[P+1]])}return{vertices:m,indices:v}}function kpe(g){const d=function(B,W){const J=[],te=WebGL2RenderingContext;if(B.json.textures)for(const ie of B.json.textures){const ce={magFilter:te.LINEAR,minFilter:te.NEAREST,wrapS:te.REPEAT,wrapT:te.REPEAT};ie.sampler!==void 0&&Object.assign(ce,B.json.samplers[ie.sampler]),J.push({image:W[ie.source],sampler:ce,uploaded:!1})}return J}(g,g.images),m=function(B,W){const J=[];for(const te of B.json.meshes){const ie=[];for(const ce of te.primitives)ie.push(Uct(ce,B,W));J.push(ie)}return J}(g,d),{scenes:v,scene:k,nodes:E}=g.json,P=v?v[k||0].nodes:[...E.keys()],O=[];for(const B of P)O.push(y3e(E[B],g,m));return function(B,W,J){const te={},ie=new Set;for(let ce=0;ce0){const ce=Array.from(ie.values()).sort((ue,Ne)=>ue-Ne);for(let ue=ce.length-1;ue>=0;ue--)B.splice(ce[ue],1)}}(O,P,g.json.nodes),O}function Gct(g){g.heightmap=new Float32Array(4096),g.heightmap.fill(-1);const d=g.vertexArray.float32,m=g.aabb.min[0]-1,v=g.aabb.min[1]-1,k=bw/(g.aabb.max[0]-m+2),E=bw/(g.aabb.max[1]-v+2);for(let P=0;Pg.heightmap[W*bw+B]&&(g.heightmap[W*bw+B]=O)}}function v3e(g,d,m,v,k){m.reserve(m.length+4*g.length),v.reserve(v.length+10*g.length),k.reserve(k.length+10*g.length);let E=v.length;for(const P of g){const O=Math.min(10,Math.max(4,1.3*P.height))*d,B=[-P.normal[1],P.normal[0],0],W=Math.min(.29,.1*P.width/P.depth),J=P.width-2*P.depth*d*(W+.01),te=We([],P.pos,B,J/2),ie=We([],P.pos,B,-J/2),ce=[te[0],te[1],te[2]+P.height],ue=[ie[0],ie[1],ie[2]+P.height],Ne=We([],P.normal,B,W);ke(Ne,Ne,O);const Le=We([],P.normal,B,-W);ke(Le,Le,O),le(Ne,te,Ne),le(Le,ie,Le),te[2]+=.1,ie[2]+=.1,v.emplaceBack(Ne[0],Ne[1],Ne[2]),v.emplaceBack(Le[0],Le[1],Le[2]),v.emplaceBack(te[0],te[1],te[2]),v.emplaceBack(ie[0],ie[1],ie[2]),v.emplaceBack(ce[0],ce[1],ce[2]),v.emplaceBack(ue[0],ue[1],ue[2]),v.emplaceBack(te[0],te[1],te[2]),v.emplaceBack(ie[0],ie[1],ie[2]),v.emplaceBack(Ne[0],Ne[1],Ne[2]),v.emplaceBack(Le[0],Le[1],Le[2]);const Ie=J/O/2;k.emplaceBack(-Ie-W,-1,Ie,.8),k.emplaceBack(Ie+W,-1,Ie,.8),k.emplaceBack(-Ie,0,Ie,1.3),k.emplaceBack(Ie,0,Ie,1.3),k.emplaceBack(Ie+W,-.8,Ie,.7),k.emplaceBack(Ie+W,-.8,Ie,.7),k.emplaceBack(0,0,Ie,1.3),k.emplaceBack(0,0,Ie,1.3),k.emplaceBack(Ie+W,-1.2,Ie,.8),k.emplaceBack(Ie+W,-1.2,Ie,.8),m.emplaceBack(6+E,4+E,8+E),m.emplaceBack(7+E,9+E,5+E),m.emplaceBack(0+E,1+E,2+E),m.emplaceBack(1+E,3+E,2+E),E+=10}}function Kct(g,d){const m={};m.indexArray=new Il,m.vertexArray=new rm,m.colorArray=new Sy,v3e(g,d,m.indexArray,m.vertexArray,m.colorArray);const v={defined:!0};v.emissiveFactor=Fr.black;const k={};return k.baseColorFactor=Fr.white,v.pbrMetallicRoughness=k,m.material=v,m.aabb=new Er([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),m}const _3e=la([{name:"a_pos_3f",components:3,type:"Float32"}]),Zct=la([{name:"a_normal_3",components:3,type:"Int16"}]),Yct=la([{name:"a_centroid_3",components:3,type:"Int16"}]),b3e=la([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),Xct=la([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),Qct=la([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Jct=la([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),edt=la([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),tdt=la([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),w3e=Ut.types,jF=32767;function sdt(g,d){const m=Qs+d;for(const v of g)for(const k of v)if(k.x<-d||k.x>m||k.y<-d||k.y>m)return!1;return!0}function rdt(g){switch(g){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${g}`)}}class Npe{constructor(){this.layoutVertexArray=new rm,this.layoutAttenuationArray=new Sy,this.layoutColorArray=new nm,this.indexArray=new Il,this.indexArrayForConflation=new Il,this.segmentsBucket=new xo}}class Spe{constructor(d){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new xo,this.entranceBloom=new Npe;const m=66560;this.layoutVertexArray=new rm,this.layoutVertexArray.reserve(m),this.layoutNormalArray=new r_,this.layoutNormalArray.reserve(m),this.layoutCentroidArray=new r_,this.layoutCentroidArray.reserve(m),this.layoutColorArray=new nm,this.layoutColorArray.reserve(m),this.layoutFloodLightDataArray=new Cy,this.layoutFloodLightDataArray.reserve(m),this.layoutAOArray=new l3,this.layoutAOArray.reserve(m),this.indexArray=new Il,this.indexArray.reserve(66560),this.indexArrayForConflation=new Il,this.segmentsBucket=new xo,this.entranceBloom=new Npe,d&&(this.layoutFacadePaintArray=new nm,this.layoutFacadeDataArray=new av,this.layoutFacadeVerticalRangeArray=new nm)}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 j3e{constructor(d){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Rf,this.footprintsIndices=new Cy,this.footprintsMin=new es(1/0,1/0),this.footprintsMax=new es(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Spe(!1),this.buildingWithFacade=new Spe(!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 Op(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 lpe(d),this.groundEffect.groundRadiusArray=new ex,this.hasAppearances=null}updateFootprints(d,m){const v=new lF([],[],1),k={vertices:[],indices:new Uint32Array(0),grid:v,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};m.push({footprint:k,id:d})}updateAppearances(d,m,v,k){}prepare(){return function(){if(fF!=null||r3e!=null)return null;if(N3!=null)return N3;const d=fetch(aa.BUILDING_GEN_URL);return N3=function(m){let v,k,E,P,O;function B(){v=new Uint8Array(O.buffer),k=new Int16Array(O.buffer),E=new Int32Array(O.buffer),P=new Float32Array(O.buffer)}function W(){throw new Error("Unexpected BuildingGen error.")}const J=()=>{},te={a:{a:W,f:function(ie){const ce=v.length,ue=Math.max(ie>>>0,Math.ceil(1.2*ce)),Ne=Math.ceil((ue-ce)/65536);try{return O.grow(Ne),B(),!0}catch{return!1}},g:W,b:J,c:J,d:J,e:J}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(m,te):m.then(ie=>ie.arrayBuffer()).then(ie=>WebAssembly.instantiate(ie,te))).then(ie=>{const ce=ie.instance.exports;return(0,ce.g)(),O=ce.f,B(),new Mct({setStyle:ce.h,setAOOptions:ce.i,setMetricOptions:ce.j,setStructuralOptions:ce.k,setFacadeOptions:ce.l,setFauxFacadeOptions:ce.m,setFacadeClassifierOptions:ce.n,addFeature:ce.o,addFacade:ce.p,generateMesh:ce.q,getLastError:ce.r,getOuterRingLength:ce.s,getMeshCount:ce.t,getPositionsPtr:ce.u,getPositionsLength:ce.v,getNormalsPtr:ce.w,getNormalsLength:ce.x,getAOPtr:ce.y,getAOLength:ce.z,getUVPtr:ce.A,getUVLength:ce.B,getFauxFacadePtr:ce.C,getFauxFacadeLength:ce.D,getIndicesPtr:ce.E,getIndicesLength:ce.F,getBuildingPart:ce.G,getRingCount:ce.H,getRingPtr:ce.I,getRingLength:ce.J,malloc:ce.K,free:ce.L,heapU8:v,heap16:k,heap32:E,heapF32:P})})}(d).then(m=>(N3=null,fF=m,fF)).catch(m=>{hr("Could not load building-gen"),N3=null,r3e=m}),N3}()}populate(d,m,v,k){const E=Tct();if(!E)return;const P=Be(v);this.tileToMeter=P,this.brightness=m.brightness,E.setStyle({normalScale:[1,-1,P],tileToMeters:P}),E.setAOOptions(!1,.3),E.setMetricOptions(!1,16),E.setStructuralOptions(!0),E.setFacadeClassifierOptions(3);const O=new Map,B=new Map;let W=0;for(const{feature:Ie}of d){if(w3e[Ie.type]!=="LineString"){O.set(Ie.id,Ie.properties.source_id);continue}const Ge=this.layers[0]._featureFilter.needGeometry;if(Ge&&!this.layers[0]._featureFilter.filter(new Hi(this.zoom),Ie,v))continue;const Ze=Ht(Ie,Ge);if(!Ge&&!this.layers[0]._featureFilter.filter(new Hi(this.zoom),Ze,v))continue;const at=Ge?Ze.geometry:Pt(Ie,v,k),vt=[];for(const Bt of at)for(const as of Bt)vt.push(as.x),vt.push(as.y);const pt={coordinates:vt,crossPerc:Ie.properties.cross_perc,distanceToRoad:Ie.properties.distance_to_road,entrances:Ie.properties.entrances,sourceId:0},St=Ie.properties.source_id;let Lt=B.get(St);Lt||(Lt=[],B.set(St,Lt)),Lt.push(pt),++W}this.maxHeight=0;const J=new Array,te=new Set,ie=Ie=>{Ie!=null&&te.add(Ie)},ce=(Ie,Ge)=>{Ie!=null&&J.push({buildingId:Ie,footprintIndex:Ge})},ue=64*(d.length-W),Ne=ue/2;this.buildingWithFacade.reserve(ue,Ne,!0),this.buildingWithoutFacade.reserve(2*ue,2*Ne,!1),this.footprintsIndices.reserve(16*(d.length-W)),this.footprintsVertices.reserve(8*(d.length-W));for(const{feature:Ie,id:Ge,index:Ze,sourceLayerIndex:at}of d){if(w3e[Ie.type]==="LineString")continue;const vt=this.layers[0]._featureFilter.needGeometry;if(vt&&!this.layers[0]._featureFilter.filter(new Hi(this.zoom),Ie,v))continue;let pt=null;if(Ie.properties&&Ie.properties.hasOwnProperty("building_id")&&(pt=Ie.properties.building_id,te.has(pt)))continue;const St=Ht(Ie,vt);if(!vt&&!this.layers[0]._featureFilter.filter(new Hi(this.zoom),St,v))continue;const Lt=vt?St.geometry:Pt(Ie,v,k),Bt=TP(Lt,500);let as=!1;for(const Qr of Bt)if(Qr.length!==1){as=!0;break}if(as){ie(pt);continue}if(!sdt(Lt,163)){ie(pt);continue}const Wt=this.layers[0],us=rdt(Wt.layout.get("building-roof-shape").evaluate(Ie,{},v)),bs=Wt.layout.get("building-base").evaluate(Ie,{},v),ws=Wt.layout.get("building-height").evaluate(Ie,{},v),Fs=Wt.layout.get("building-flood-light-ground-radius").evaluate(Ie,{},v),Bs=Wt.paint.get("building-ambient-occlusion-intensity"),Ds=Fs/this.tileToMeter;Ie.properties["building-part"]="roof";const Os=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),ds=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);Ie.properties["building-part"]="wall";const is=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),Rs=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);Ie.properties["building-part"]="window";const Js=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),Hs=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);Ie.properties["building-part"]="door";const Dr=Wt.paint.get("building-color").evaluate(Ie,{},this.canonical).toPremultipliedRenderColor(this.lut),ur=Wt.paint.get("building-emissive-strength").evaluate(Ie,{},this.canonical);let yr=Wt.layout.get("building-flood-light-wall-radius").evaluate(Ie,{},v);yr=ve(yr,0,2048);const Nr=yr/2048*jF,Wn=O.get(Ge),Gs=B.get(Wn)||[],Sr=Gs.length!==0&&Wt.layout.get("building-facade").evaluate(Ie,{},v);E.setFacadeOptions(4,!0),E.setFauxFacadeOptions(Sr,!1,1);let pn=0,xa=0,ba=0,Ln=0,Ci=0,ft=0,_t=0,hs=0,zs=0,or=0,lr=0;if(Sr){let Qr=Math.round(Wt.layout.get("building-facade-floors").evaluate(Ie,{},v));if(bs===0){Qr=Math.max(1,Qr-(Gs.length>0?1:0));let gi=4;if(ws>100){const to=[10,13,15];gi=to[Ie.id?Ie.id%to.length:0]}else ws<=10&&(gi=3);E.setFacadeOptions(gi,!0),Ci=(ws<15?1.3:1.61803)*gi/P}else Ci=bs/P;ft=ws/P,Ci=Math.min(Ci,ft),ba=Wt.layout.get("building-facade-unit-width").evaluate(Ie,{},v)/P,Ln=(ft-Ci)/Qr,E.setFauxFacadeOptions(!0,!0,ba);const _o=Wt.layout.get("building-facade-window").evaluate(Ie,{},v);pn=_o[0],xa=_o[1],_t=Math.floor(65535*Math.min(1,Ci/Qs)),hs=Math.floor(65535*Math.min(1,ft/Qs)),zs=Math.floor(255*pn)<<8|Math.floor(255*xa),or=Math.floor(65535*Math.min(1,ba/Qs)),lr=Math.floor(65535*Math.min(1,Ln/Qs))}const Or=Array(Bt.length),zr={x:1/0,y:1/0},Sn={x:-1/0,y:-1/0},Bn={x:0,y:0};let Hn=0;for(let Qr=0;Qr0){const gi=[],to=Array(_o.length+1);to[0]=0;for(let Ol=0;Ol<_o.length;Ol++){const bc=_o[Ol];for(let pl=0;plQs||zr.y<0||Sn.y>Qs)&&this.featuresOnBorder.push({featureId:Ie.id,footprintIndex:this.footprints.length});{const Qr=_3(Ti,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+Qr.length),this.footprintsIndices.uint16.set(Qr,Xr),this.buildingIds.add(pt??Ie.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,zi.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,zi.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,Wi.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Wi.y);const _o={footprintVertexOffset:da,footprintVertexLength:this.footprintsVertices.length-da,footprintIndexOffset:Xr,footprintIndexLength:this.footprintsIndices.length-Xr,min:zi,max:Wi,hiddenFlags:0,indicesOffset:li,indicesLength:co,bloomIndicesOffset:fi,bloomIndicesLength:Pi,groundEffectVertexOffset:Go,groundEffectVertexLength:$i,hasFauxFacade:Sr,height:$n,promoteId:Ge,feature:St,parts:Ga,buildingBloom:Ka},gi=this.footprints.length;Ie.id!==void 0&&this.featureFootprintLookup.set(Ie.id,gi),ce(pt,gi),this.footprints.push(_o)}this.programConfigurations.populatePaintArrays(en.layoutVertexArray.length,Ie,Ze,{},m.availableImages,v,m.brightness),this.groundEffect.addPaintPropertiesData(Ie,Ze,{},m.availableImages,v,m.brightness),m.featureIndex.insert(Ie,Lt,Ze,at,this.index,Mi)}J.forEach(({buildingId:Ie,footprintIndex:Ge})=>{te.has(Ie)&&(this.footprints[Ge].hiddenFlags|=4)});const Le=new Set;this.buildingIds.forEach((Ie,Ge,Ze)=>{te.has(Ie)||Le.add(Ie)}),this.buildingIds=Le,this.groundEffect.prepareBorderSegments()}update(d,m,v,k,E,P,O){this.programConfigurations.updatePaintArrays(d,m,E,v,k,P,O),this.groundEffect.update(d,m,E,v,k,P,O),this.evaluate(this.layers[0],d),this.colorBufferUploaded=!1}isEmpty(){return this.buildingWithoutFacade.layoutVertexArray.length===0&&this.buildingWithFacade.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(d){const m=v=>{v.layoutVertexBuffer=d.createVertexBuffer(v.layoutVertexArray,_3e.members),v.layoutNormalBuffer=d.createVertexBuffer(v.layoutNormalArray,Zct.members),v.layoutCentroidBuffer=d.createVertexBuffer(v.layoutCentroidArray,Yct.members),v.layoutFloodLightDataBuffer=d.createVertexBuffer(v.layoutFloodLightDataArray,tdt.members),v.layoutFacadeDataArray&&v.layoutFacadeDataArray.length&&(v.layoutFacadeDataBuffer=d.createVertexBuffer(v.layoutFacadeDataArray,Qct.members)),v.layoutFacadeVerticalRangeArray&&v.layoutFacadeVerticalRangeArray.length&&(v.layoutFacadeVerticalRangeBuffer=d.createVertexBuffer(v.layoutFacadeVerticalRangeArray,Jct.members)),v.entranceBloom.layoutVertexArray.length&&(v.entranceBloom.layoutVertexBuffer=d.createVertexBuffer(v.entranceBloom.layoutVertexArray,_3e.members),v.entranceBloom.layoutAttenuationBuffer=d.createVertexBuffer(v.entranceBloom.layoutAttenuationArray,edt.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 k=!1;const E=v?m:0,P=0|(v?-1:~m);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const O of d){const B=this.footprints[O],W=B.hiddenFlags&P|E;B.hiddenFlags!==W&&(B.hiddenFlags=W,k=!0,this.groundEffect.updateHiddenByLandmarkRange(B.groundEffectVertexOffset,B.groundEffectVertexLength,B.hiddenFlags!==0))}return k&&(this.indexArrayForConflationUploaded=!1),k}uploadUpdatedIndexBuffer(d){if(this.groundEffect.uploadHiddenByLandmark(d),this.indexArrayForConflationUploaded)return;const m=k=>{k.indexArray.length!==0&&(k.indexArrayForConflation.resize(k.indexArray.length),k.indexArrayForConflation.uint16.set(k.indexArray.uint16),k.entranceBloom.indexArrayForConflation.resize(k.entranceBloom.indexArray.length),k.entranceBloom.indexArrayForConflation.uint16.set(k.entranceBloom.indexArray.uint16))};m(this.buildingWithoutFacade),m(this.buildingWithFacade);for(const k of this.footprints){const E=k.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,P=k.indicesOffset+k.indicesLength;if(k.hiddenFlags!==0){for(let B=k.indicesOffset;B{k.indexArray.length!==0&&(k.indexBuffer?k.indexBuffer.updateData(k.indexArrayForConflation):k.indexBuffer=d.createIndexBuffer(k.indexArrayForConflation,!0),k.entranceBloom.indexBuffer?k.entranceBloom.indexBuffer.updateData(k.entranceBloom.indexArrayForConflation):k.entranceBloom.indexBuffer=d.createIndexBuffer(k.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,b3e.members,!0),v.layoutFacadePaintArray&&(v.layoutFacadePaintBuffer?v.layoutFacadePaintBuffer.updateData(v.layoutFacadePaintArray):v.layoutFacadePaintBuffer=d.createVertexBuffer(v.layoutFacadePaintArray,Xct.members,!0)),v.entranceBloom.layoutColorBuffer?v.entranceBloom.layoutColorBuffer.updateData(v.entranceBloom.layoutColorArray):v.entranceBloom.layoutColorBuffer=d.createVertexBuffer(v.entranceBloom.layoutColorArray,b3e.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 k of this.footprints){if(4&k.hiddenFlags)continue;const E=m[k.promoteId],P=k.feature;P.properties["building-part"]="roof";const O=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),B=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="wall";const W=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),J=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="window";const te=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),ie=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="door";const ce=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),ue=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical),Ne=k.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Ie of k.parts){let Ge,Ze=O;Ie.part===1?(Ze=O,Ge=B):Ie.part===0?(Ze=W,Ge=J):Ie.part===2?(Ze=te,Ge=ie):Ie.part===3&&(Ze=ce,Ge=ue),Ge=ve(Ge,0,1);for(let at=0;atP.max.x||B.max.xP.max.y||B.max.yO.max.x||O.min.x>d||m>O.max.y||O.min.y>m||O.height<=v||ndt(P,this.footprintsVertices.float32.subarray(2*O.footprintVertexOffset,2*(O.footprintVertexOffset+O.footprintVertexLength)),this.footprintsIndices.uint16.subarray(O.footprintIndexOffset,O.footprintIndexOffset+O.footprintIndexLength))&&(v=O.height,this.footprintLookup[E]=O,k=O.hiddenFlags!==0);if(v!==Number.NEGATIVE_INFINITY)return{height:v,hidden:k};this.footprintLookup[E]=void 0}}function ndt(g,d,m){for(let v=0;v1&&(B=d[++O]);const J=Math.abs(W-B.left),te=Math.abs(W-B.right),ie=Math.min(J,te);let ce;const ue=E/v*(k+1);if(B.isDash){const Ne=k-Math.abs(ue);ce=Math.sqrt(ie*ie+Ne*Ne)}else ce=k-Math.sqrt(ie*ie+ue*ue);this.image.data[P+W]=Math.max(0,Math.min(255,ce+128))}}}addRegularDash(d,m){for(let B=d.length-1;B>=0;--B){const W=d[B],J=d[B+1];W.zeroLength?d.splice(B,1):J&&J.isDash===W.isDash&&(J.left=W.left,d.splice(B,1))}const v=d[0],k=d[d.length-1];v.isDash===k.isDash&&(v.left=k.left-this.width,k.right=v.right+this.width);const E=this.width*this.nextRow;let P=0,O=d[P];for(let B=0;B1&&(O=d[++P]);const W=Math.abs(B-O.left),J=Math.abs(B-O.right),te=Math.min(W,J);this.image.data[E+B]=Math.max(0,Math.min(255,(O.isDash?te:-te)+m+128))}}addDash(d,m){const v=this.getKey(d,m);if(this.positions[v])return this.positions[v];const k=m==="round",E=k?7:0,P=2*E+1;if(this.nextRow+P>this.height)return hr("LineAtlas out of space"),null;d.length===0&&d.push(1);let O=0;for(let J=0;Jm.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 t3,this.layoutVertexArray2=new rm,this.patternVertexArray=new rm,this.indexArray=new Il,this.programConfigurations=new Op(d.layers,{zoom:d.zoom,lut:d.lut}),this.segments=new xo,this.maxLineLength=0,this.zOffsetVertexArray=new rm,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.tessellationStep=d.tessellationStep?d.tessellationStep:Qs/64,this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,k){}populate(d,m,v,k){this.hasPattern=Jme("line",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Be(v);const P=this.layers[0].layout.get("line-elevation-reference");if(P==="hd-road-markup")this.elevationType="road";else{const ie=this.layers[0].layout.get("line-z-offset"),ce=ie.isConstant()&&!ie.constantOr(0);this.elevationType=P!=="sea"&&P!=="ground"&&ce?"none":"offset",this.elevationType==="offset"&&P==="none"&&hr(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}const O=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&O!==void 0;const B=[];for(const{feature:ie,id:ce,index:ue,sourceLayerIndex:Ne}of d){const Le=this.layers[0]._featureFilter.needGeometry,Ie=Ht(ie,Le);if(!this.layers[0]._featureFilter.filter(new Hi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),Ie,v))continue;const Ge=E?E.evaluate(Ie,{},v):void 0,Ze={id:ce,properties:ie.properties,type:ie.type,sourceLayerIndex:Ne,index:ue,geometry:Le?Ie.geometry:Pt(ie,v,k),patterns:{},sortKey:Ge};B.push(Ze)}E&&B.sort((ie,ce)=>ie.sortKey-ce.sortKey);const{lineAtlas:W,featureIndex:J}=m,te=this.addConstantDashes(W);for(const ie of B){const{geometry:ce,index:ue,sourceLayerIndex:Ne}=ie;if(te&&this.addFeatureDashes(ie,W),this.hasPattern){const Le=epe("line",this.layers,ie,this.zoom,this.pixelRatio,m);this.patternFeatures.push(Le)}else this.addFeature(ie,ce,ue,v,W.positions,m.availableImages,m.brightness,m.elevationFeatures);J.insert(d[ue].feature,ce,ue,Ne,this.index)}}addConstantDashes(d){let m=!1;for(const v of this.layers){const k=v.paint.get("line-dasharray").value,E=v.layout.get("line-cap").value;if(k.kind!=="constant"||E.kind!=="constant")m=!0;else{const P=E.value,O=k.value;if(!O)continue;d.addDash(O,P)}}return m}addFeatureDashes(d,m){const v=this.zoom;for(const k of this.layers){const E=k.paint.get("line-dasharray").value,P=k.layout.get("line-cap").value;if(E.kind==="constant"&&P.kind==="constant")continue;let O,B;if(E.kind==="constant"){if(O=E.value,!O)continue}else O=E.evaluate({zoom:v},d);B=P.kind==="constant"?P.value:P.evaluate({zoom:v},d),m.addDash(O,B),d.patterns[k.id]=[m.getKey(O,B)]}}update(d,m,v,k,E,P,O,B){this.programConfigurations.updatePaintArrays(d,m,E,v,k,P,O,B)}addFeatures(d,m,v,k,E,P){for(const O of this.patternFeatures)this.addFeature(O,O.geometry,O.index,m,v,k,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,ddt)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=d.createVertexBuffer(this.patternVertexArray,hdt)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=d.createVertexBuffer(this.zOffsetVertexArray,odt.members,!0)),this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,ldt),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,k;if(m&&m>0?(v=`mapbox_clip_start_${m}`,k=`mapbox_clip_end_${m}`):(v="mapbox_clip_start",k="mapbox_clip_end"),d.properties&&d.properties.hasOwnProperty(v)&&d.properties.hasOwnProperty(k))return{start:+d.properties[v],end:+d.properties[k]}}addFeature(d,m,v,k,E,P,O,B){const W=this.layers[0].layout,J=W.get("line-join").evaluate(d,{}),te=W.get("line-cap").evaluate(d,{}),ie=W.get("line-miter-limit"),ce=W.get("line-round-limit");this.lineClips=this.lineFeatureClips(d),this.lineFeature=d;const ue=!(!d.properties||!d.properties.hasOwnProperty("mapbox_line_metrics"))&&d.properties.mapbox_line_metrics;this.zOffsetValue=W.get("line-z-offset").value;const Ne=this.layers[0].paint.get("line-width").value;if(Ne.kind!=="constant"&&Ne.isLineProgressConstant===!1&&(this.variableWidthValue=Ne),this.elevationType==="road"){const Le=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(d,m,k,B,J,te,ie,ce)){const[Ie,Ge]=this.clipRuntimeLinesToTile(m,1);for(let Ze=0;Ze0?vt.parentIndex:null)}this.fillNonElevatedRoadSegment(Le)}}else for(let Le=0;Le0?Le:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,v,E,P,k,O,void 0,this.worldview)}computeSegNextDir(d,m){return d.nextPoint.sub(m.at(-2)).unit()}computeSegPrevDir(d,m){return m[1].sub(d.prevPoint).unit()}clipLinesToTile(d,m){return mF(d,-m,-m,Qs+m,Qs+m)}clipRuntimeLinesToTile(d,m){const v=[];return[mF(d,-m,-m,Qs+m,Qs+m,v),v]}addElevatedRoadFeature(d,m,v,k,E,P,O,B){const W=[],J=ii.getElevationFeature(d,k);if(J){const te=this.clipLinesToTile(m,1),ie=this.prepareElevatedLines(te,J,v);for(const ce of ie)W.push({geometry:ce,elevation:J,elevationTileID:v,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(W.length===0)return!1;for(const te of W){const ie=this.layoutVertexArray.length;this.addLine(te.geometry,d,v,E,P,O,B);const ce=new wi(v,te.elevationTileID);if(te.elevation)for(let ue=ie;ue>1,this.layoutVertexArray.int16[6*ue+1]>>1),Le=ce.pointElevation(Ne,te.elevation,.05);this.updateHeightRange(Le),this.zOffsetVertexArray.emplaceBack(Le,0,0)}else this.fillNonElevatedRoadSegment(ie)}return!0}prepareElevatedLines(d,m,v){if(m.constantHeight!=null)return d;const k=[],E=1/Be(v);for(const P of d)Nct(P,new Wa(m,E),0,k);return k}fillNonElevatedRoadSegment(d){for(let m=d;m0,ie=B&&B.progress.max<1;if(this.lineClips){let Bt={min:this.lineClips.start,max:this.lineClips.end},as=1;if(B){const bs=this.lineClips.end-this.lineClips.start;Bt=function(ws,Fs,Bs){return{min:Si(ws.min,Fs,Bs),max:Si(ws.max,Fs,Bs)}}(B.progress,{min:0,max:1},Bt),bs>0&&(as=(Bt.max-Bt.min)/bs)}const Wt=+m.properties.mapbox_clip_feature_len,us=+m.properties.mapbox_clip_seg_len;if(Number.isNaN(Wt)||Number.isNaN(us)){for(let ws=0;ws=2&&d[ue-1].equals(d[ue-2]);)ue--;let Ne=0;for(;Ne0,ds=this.overscaling<=16?15*Qs/(512*this.overscaling):0;if(as&&Wt==="round"){if(FsP&&(Wt="bevel"),Wt==="bevel"&&(Fs>2&&(Wt="flipbevel"),Fs2*ds){const Js=Ie.sub(Ie.sub(Ge)._mult(ds/is)._round());this.updateDistance(Ge,Js),this.addCurrentVertex(Js,at,0,0,Le,Lt),Ge=Js}this.updateDistance(Ge,Ie),bs._mult(Fs),this.addCurrentVertex(Ie,bs,0,0,Le,Lt);const Rs=Ie.dist(Ze);if(Rs>2*ds){const Js=Ie.add(Ze.sub(Ie)._mult(ds/Rs)._round());this.updateDistance(Ie,Js),this.addCurrentVertex(Js,vt,0,0,Le,Lt),Ie=Js}}else bs._mult(Fs),this.addCurrentVertex(Ie,bs,0,0,Le,Lt);else if(Wt==="flipbevel"){if(Fs>100)bs=vt.mult(-1);else{const is=Fs*at.add(vt).mag()/at.sub(vt).mag();bs._perp()._mult(is*(Os?-1:1))}this.addCurrentVertex(Ie,bs,0,0,Le,Lt),this.addCurrentVertex(Ie,bs.mult(-1),0,0,Le,Lt)}else if(Wt==="bevel"||Wt==="fakeround"){Lt!=null&&Ge&&this.addCurrentVertex(Ie,St||at,-1,-1,Le,Lt);const is=Ie.dist(Ge)<=2*ds&&Wt!=="bevel",Rs=bs.mult(Os?1:-1);Rs._mult(Fs);const Js=vt.mult(Os?-1:1),Hs=at.mult(Os?-1:1),Dr=this.evaluateLineProgressFeatures(this.distance);if(Lt==null&&(this.addHalfVertex(Ie,Rs.x,Rs.y,!1,!Os,0,Le,Dr),is||this.addHalfVertex(Ie,Rs.x+2*Hs.x,Rs.y+2*Hs.y,!1,Os,0,Le,Dr)),Wt==="fakeround"){const ur=Math.round(180*Bs/Math.PI/20);this.addHalfVertex(Ie,Hs.x,Hs.y,!1,Os,0,Le,Dr);for(let yr=0;yr1){this.lineSoFar=d.w;const Ne=(m.x-d.x)/te,Le=(m.y-d.y)/te,Ie=(m.z-d.z)/te,Ge=(m.w-d.w)/te;for(let Ze=1;Ze=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,J),B.primitiveLength++),P?this.e2=J:this.e1=J,W!=null&&this.zOffsetVertexArray.emplaceBack(W.zOffset,W.variableWidth,W.variableWidth)}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(d,m){this.prevDistance=this.distance,this.distance+=d.dist(m),this.updateScaledDistance()}}function Mpe(g,d,m){return g.xm||g.ym}let C3e,M3e;function T3e(g,d,m){return d*(Qs/(g.tileSize*Math.pow(2,m-g.tileID.overscaledZ)))}_r(Cpe,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const A3e=(g,d,m)=>(1-m)*g+m*d;function E3e(g,d){return 1/T3e(g,1,d.tileZoom)}function P3e(g,d,m,v){return g.translatePosMatrix(v||d.tileID.projMatrix,d,m.paint.get("line-translate"),m.paint.get("line-translate-anchor"))}const I3e=g=>{const d=[];L3e(g)&&d.push("RENDER_LINE_DASH"),g.paint.get("line-gradient")&&d.push("RENDER_LINE_GRADIENT");const m=g.paint.get("line-trim-offset");m[0]===0&&m[1]===0||d.push("RENDER_LINE_TRIM_OFFSET"),g.paint.get("line-border-width").constantOr(1)!==0&&d.push("RENDER_LINE_BORDER");const v=g.layout.get("line-join").constantOr("miter")==="none",k=!!g.paint.get("line-pattern").constantOr(1);return v&&k&&d.push("LINE_JOIN_NONE"),d};function L3e(g){const d=g.paint.get("line-dasharray").value;return d.kind!=="constant"||d.value}let Tpe;const D3e=()=>Tpe||(Tpe={layout:C3e||(C3e=new Mo({"line-cap":new ir(Gt.layout_line["line-cap"]),"line-join":new ir(Gt.layout_line["line-join"]),"line-miter-limit":new Ks(Gt.layout_line["line-miter-limit"]),"line-round-limit":new Ks(Gt.layout_line["line-round-limit"]),"line-sort-key":new ir(Gt.layout_line["line-sort-key"]),"line-z-offset":new ir(Gt.layout_line["line-z-offset"]),"line-elevation-reference":new Ks(Gt.layout_line["line-elevation-reference"]),"line-cross-slope":new Ks(Gt.layout_line["line-cross-slope"]),visibility:new Ks(Gt.layout_line.visibility),"line-width-unit":new Ks(Gt.layout_line["line-width-unit"])})),paint:M3e||(M3e=new Mo({"line-opacity":new ir(Gt.paint_line["line-opacity"]),"line-color":new ir(Gt.paint_line["line-color"]),"line-translate":new Ks(Gt.paint_line["line-translate"]),"line-translate-anchor":new Ks(Gt.paint_line["line-translate-anchor"]),"line-width":new ir(Gt.paint_line["line-width"]),"line-gap-width":new ir(Gt.paint_line["line-gap-width"]),"line-offset":new ir(Gt.paint_line["line-offset"]),"line-blur":new ir(Gt.paint_line["line-blur"]),"line-dasharray":new ir(Gt.paint_line["line-dasharray"]),"line-pattern":new ir(Gt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Ks(Gt.paint_line["line-pattern-cross-fade"]),"line-gradient":new sv(Gt.paint_line["line-gradient"]),"line-trim-offset":new Ks(Gt.paint_line["line-trim-offset"]),"line-trim-fade-range":new Ks(Gt.paint_line["line-trim-fade-range"]),"line-trim-color":new Ks(Gt.paint_line["line-trim-color"]),"line-emissive-strength":new ir(Gt.paint_line["line-emissive-strength"]),"line-border-width":new ir(Gt.paint_line["line-border-width"]),"line-border-color":new ir(Gt.paint_line["line-border-color"]),"line-occlusion-opacity":new Ks(Gt.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"})}))},Tpe);class gdt extends ir{possiblyEvaluate(d,m){return m=new Hi(Math.floor(m.zoom),{now:m.now,fadeDuration:m.fadeDuration,transition:m.transition,worldview:m.worldview}),super.possiblyEvaluate(d,m)}evaluate(d,m,v,k){return m=Object.assign({},m,{zoom:Math.floor(m.zoom)}),super.evaluate(d,m,v,k)}}let $P;function O3e(g,d){return d>0?d+2*g:g}const xdt=la([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),ydt=la([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),vdt=la([{name:"a_projected_pos",components:4,type:"Float32"}],4);la([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const _dt=la([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),bdt=la([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),wdt=la([{name:"a_texb",components:2,type:"Uint16"}]),jdt=la([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),kdt=la([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);la([{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 R3e=la([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ndt=la([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);la([{name:"triangle",components:3,type:"Uint16"}]),la([{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"}]),la([{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"}]),la([{type:"Float32",name:"offsetX"}]),la([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var _c=24;function Sdt(g,d,m){return g.sections.forEach(v=>{v.text=function(k,E,P){const O=E.layout.get("text-transform").evaluate(P,{});return O==="uppercase"?k=k.toLocaleUpperCase():O==="lowercase"&&(k=k.toLocaleLowerCase()),Jg.applyArabicShaping&&(k=Jg.applyArabicShaping(k)),k}(v.text,d,m)}),g}const qP={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Cdt(g){return g==="︶"||g==="﹈"||g==="︸"||g==="﹄"||g==="﹂"||g==="︾"||g==="︼"||g==="︺"||g==="︘"||g==="﹀"||g==="︐"||g==="︓"||g==="︔"||g==="`"||g===" ̄"||g==="︑"||g==="︒"}function Mdt(g){return g==="︵"||g==="﹇"||g==="︷"||g==="﹃"||g==="﹁"||g==="︽"||g==="︻"||g==="︹"||g==="︗"||g==="︿"}const Ape=4294967296,F3e=1/Ape,z3e=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let kF=class{constructor(g=new Uint8Array(16)){this.buf=ArrayBuffer.isView(g)?g:new Uint8Array(g),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(g,d,m=this.length){for(;this.pos>3,E=this.pos;this.type=7&v,g(k,d,this),this.pos===E&&this.skip(v)}return d}readMessage(g,d){return this.readFields(g,d,this.readVarint()+this.pos)}readFixed32(){const g=this.dataView.getUint32(this.pos,!0);return this.pos+=4,g}readSFixed32(){const g=this.dataView.getInt32(this.pos,!0);return this.pos+=4,g}readFixed64(){const g=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Ape;return this.pos+=8,g}readSFixed64(){const g=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Ape;return this.pos+=8,g}readFloat(){const g=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,g}readDouble(){const g=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,g}readVarint(g){const 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(k,E,P){const O=P.buf;let B,W;if(W=O[P.pos++],B=(112&W)>>4,W<128||(W=O[P.pos++],B|=(127&W)<<3,W<128)||(W=O[P.pos++],B|=(127&W)<<10,W<128)||(W=O[P.pos++],B|=(127&W)<<17,W<128)||(W=O[P.pos++],B|=(127&W)<<24,W<128)||(W=O[P.pos++],B|=(1&W)<<31,W<128))return C3(k,B,E);throw new Error("Expected varint not more than 10 bytes")}(m,g,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const g=this.readVarint();return g%2==1?(g+1)/-2:g/2}readBoolean(){return!!this.readVarint()}readString(){const g=this.readVarint()+this.pos,d=this.pos;return this.pos=g,g-d>=12&&z3e?z3e.decode(this.buf.subarray(d,g)):function(m,v,k){let E="",P=v;for(;P239?4:O>223?3:O>191?2:1;if(P+ie>k)break;ie===1?O<128&&(te=O):ie===2?(B=m[P+1],(192&B)==128&&(te=(31&O)<<6|63&B,te<=127&&(te=null))):ie===3?(B=m[P+1],W=m[P+2],(192&B)==128&&(192&W)==128&&(te=(15&O)<<12|(63&B)<<6|63&W,(te<=2047||te>=55296&&te<=57343)&&(te=null))):ie===4&&(B=m[P+1],W=m[P+2],J=m[P+3],(192&B)==128&&(192&W)==128&&(192&J)==128&&(te=(15&O)<<18|(63&B)<<12|(63&W)<<6|63&J,(te<=65535||te>=1114112)&&(te=null))),te===null?(te=65533,ie=1):te>65535&&(te-=65536,E+=String.fromCharCode(te>>>10&1023|55296),te=56320|1023&te),E+=String.fromCharCode(te),P+=ie}return E}(this.buf,d,g)}readBytes(){const g=this.readVarint()+this.pos,d=this.buf.subarray(this.pos,g);return this.pos=g,d}readPackedVarint(g=[],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(g,d){this.writeVarint(g<<3|d)}realloc(g){let d=this.length||16;for(;d268435455||g<0?function(d,m){let v,k;if(d>=0?(v=d%4294967296|0,k=d/4294967296|0):(v=~(-d%4294967296),k=~(-d/4294967296),4294967295^v?v=v+1|0:(v=0,k=k+1|0)),d>=18446744073709552e3||d<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");m.realloc(10),function(E,P,O){O.buf[O.pos++]=127&E|128,E>>>=7,O.buf[O.pos++]=127&E|128,E>>>=7,O.buf[O.pos++]=127&E|128,E>>>=7,O.buf[O.pos++]=127&E|128,O.buf[O.pos]=127&(E>>>=7)}(v,0,m),function(E,P){const O=(7&E)<<4;P.buf[P.pos++]|=O|((E>>>=3)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E)))))}(k,m)}(g,this):(this.realloc(4),this.buf[this.pos++]=127&g|(g>127?128:0),g<=127||(this.buf[this.pos++]=127&(g>>>=7)|(g>127?128:0),g<=127||(this.buf[this.pos++]=127&(g>>>=7)|(g>127?128:0),g<=127||(this.buf[this.pos++]=g>>>7&127))))}writeSVarint(g){this.writeVarint(g<0?2*-g-1:2*g)}writeBoolean(g){this.writeVarint(+g)}writeString(g){g=String(g),this.realloc(4*g.length),this.pos++;const d=this.pos;this.pos=function(v,k,E){for(let P,O,B=0;B55295&&P<57344){if(!O){P>56319||B+1===k.length?(v[E++]=239,v[E++]=191,v[E++]=189):O=P;continue}if(P<56320){v[E++]=239,v[E++]=191,v[E++]=189,O=P;continue}P=O-55296<<10|P-56320|65536,O=null}else O&&(v[E++]=239,v[E++]=191,v[E++]=189,O=null);P<128?v[E++]=P:(P<2048?v[E++]=P>>6|192:(P<65536?v[E++]=P>>12|224:(v[E++]=P>>18|240,v[E++]=P>>12&63|128),v[E++]=P>>6&63|128),v[E++]=63&P|128)}return E}(this.buf,g,this.pos);const m=this.pos-d;m>=128&&B3e(d,m,this),this.pos=d-1,this.writeVarint(m),this.pos+=m}writeFloat(g){this.realloc(4),this.dataView.setFloat32(this.pos,g,!0),this.pos+=4}writeDouble(g){this.realloc(8),this.dataView.setFloat64(this.pos,g,!0),this.pos+=8}writeBytes(g){const d=g.length;this.writeVarint(d),this.realloc(d);for(let m=0;m=128&&B3e(m,v,this),this.pos=m-1,this.writeVarint(v),this.pos+=v}writeMessage(g,d,m){this.writeTag(g,2),this.writeRawMessage(d,m)}writePackedVarint(g,d){d.length&&this.writeMessage(g,Tdt,d)}writePackedSVarint(g,d){d.length&&this.writeMessage(g,Adt,d)}writePackedBoolean(g,d){d.length&&this.writeMessage(g,Idt,d)}writePackedFloat(g,d){d.length&&this.writeMessage(g,Edt,d)}writePackedDouble(g,d){d.length&&this.writeMessage(g,Pdt,d)}writePackedFixed32(g,d){d.length&&this.writeMessage(g,Ldt,d)}writePackedSFixed32(g,d){d.length&&this.writeMessage(g,Ddt,d)}writePackedFixed64(g,d){d.length&&this.writeMessage(g,Odt,d)}writePackedSFixed64(g,d){d.length&&this.writeMessage(g,Rdt,d)}writeBytesField(g,d){this.writeTag(g,2),this.writeBytes(d)}writeFixed32Field(g,d){this.writeTag(g,5),this.writeFixed32(d)}writeSFixed32Field(g,d){this.writeTag(g,5),this.writeSFixed32(d)}writeFixed64Field(g,d){this.writeTag(g,1),this.writeFixed64(d)}writeSFixed64Field(g,d){this.writeTag(g,1),this.writeSFixed64(d)}writeVarintField(g,d){this.writeTag(g,0),this.writeVarint(d)}writeSVarintField(g,d){this.writeTag(g,0),this.writeSVarint(d)}writeStringField(g,d){this.writeTag(g,2),this.writeString(d)}writeFloatField(g,d){this.writeTag(g,5),this.writeFloat(d)}writeDoubleField(g,d){this.writeTag(g,1),this.writeDouble(d)}writeBooleanField(g,d){this.writeVarintField(g,+d)}};function C3(g,d,m){return m?4294967296*d+(g>>>0):4294967296*(d>>>0)+(g>>>0)}function B3e(g,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 k=m.pos-1;k>=g;k--)m.buf[k+v]=m.buf[k]}function Tdt(g,d){for(let m=0;m=0&&v>=d&&NF[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 M3;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(UP.forText(d.scale,d.fontStack||m));const v=this.sections.length-1;for(let k=0;k=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Ppe(g,d,m,v,k,E,P,O,B,W,J,te,ie,ce,ue,Ne=1){const Le=M3.fromFeature(g,k,Ne);te===om.vertical&&Le.verticalizePunctuation(ie);let Ie=[];const Ge=function(St,Lt,Bt,as,Wt,us){if(!St)return[];const bs=[],ws=function(Os,ds,is,Rs,Js,Hs){let Dr=0;for(let ur=0;ur=0;let Bs=0;for(let Os=0;Os0&&Ka>Ln&&(Ln=Ka)}else{const Fa=Bt[zs.fontStack];if(!Fa)continue;Fa[lr]&&(Sn=Fa[lr]);const Ga=Lt[zs.fontStack];if(!Ga)continue;const Ka=Ga.glyphs[lr];if(!Ka)continue;if(zr=Ka.metrics,Hn=lr!==8203?_c:0,Hs){const fi=Ga.ascender!==void 0?Math.abs(Ga.ascender):0,Pi=Ga.descender!==void 0?Math.abs(Ga.descender):0,Mi=(fi+Pi)*Or;Ci-m/2;){if(P--,P<0)return!1;O-=g[P].dist(E),E=g[P]}O+=g[P].dist(g[P+1]),P++;const B=[];let W=0;for(;Ov;)W-=B.shift().angleDelta;if(W>k)return!1;P++,O+=J.dist(te)}return!0}function X3e(g){let d=0;for(let m=0;mW){const ue=(W-B)/ce,Ne=Hr(te.x,ie.x,ue),Le=Hr(te.y,ie.y,ue),Ie=new dv(Ne,Le,0,ie.angleTo(te),J);return!P||Y3e(g,Ie,O,P,d)?Ie:void 0}B+=ce}}function Vdt(g,d,m,v,k,E,P,O,B){const W=Q3e(v,E,P),J=J3e(v,k),te=J*P,ie=g[0].x===0||g[0].x===B||g[0].y===0||g[0].y===B;return d-te=0&&at=0&&vt=0&&ie+W<=J){const pt=new dv(at,vt,0,Ge,ue);v&&!Y3e(g,pt,E,v,k)||ce.push(pt)}}te+=Ie}return O||ce.length||P||(ce=e5e(g,te/2,m,v,k,E,P,!0,B)),ce}function t5e(g){let d=0,m=0;for(const P of g)d+=P.w*P.h,m=Math.max(m,P.w);g.sort((P,O)=>O.h-P.h);const v=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(d/.95)),m),h:1/0}];let k=0,E=0;for(const P of g)for(let O=v.length-1;O>=0;O--){const B=v[O];if(!(P.w>B.w||P.h>B.h)){if(P.x=B.x,P.y=B.y,E=Math.max(E,P.y+P.h),k=Math.max(k,P.x+P.w),P.w===B.w&&P.h===B.h){const W=v.pop();W&&O1?ue-1:ue,zd.copy(te.data,W,{x:0,y:0},{x:Ne,y:Le},te.data,v),zd.copy(te.data,W,{x:0,y:Ge-ue},{x:Ne,y:Le-ue},{width:Ie,height:ue},v),zd.copy(te.data,W,{x:0,y:0},{x:Ne,y:Le+Ge},{width:Ie,height:ue},v),zd.copy(te.data,W,{x:Ie-ue,y:0},{x:Ne-ue,y:Le},{width:ue,height:Ge},v),zd.copy(te.data,W,{x:0,y:0},{x:Ne+Ie,y:Le},{width:ue,height:Ge},v),zd.copy(te.data,W,{x:Ie-ue,y:Ge-ue},{x:Ne-ue,y:Le-ue},{width:ue,height:ue},v),zd.copy(te.data,W,{x:0,y:Ge-ue},{x:Ne+Ie,y:Le-ue},{width:ue,height:ue},v),zd.copy(te.data,W,{x:0,y:0},{x:Ne+Ie,y:Le+Ge},{width:ue,height:ue},v),zd.copy(te.data,W,{x:Ie-ue,y:0},{x:Ne-ue,y:Le+Ge},{width:ue,height:ue},v)}this.lut=v,this.image=W,this.iconPositions=k,this.patternPositions=E}addImages(d,m,v,k){for(const[E,P]of d.entries()){const{bin:O,imagePosition:B,imageVariant:W}=Rpe(E,P,v);m.set(E,B),k.push(O),P.hasRenderCallback&&this.haveRenderCallbacks.push(W.id)}}patchUpdatedImages(d,m,v){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(k=>d.hasImage(k,v)),d.dispatchRenderCallbacks(this.haveRenderCallbacks,v);for(const k of d.getUpdatedImages(v)){for(const E of this.iconPositions.keys()){const P=Wg.parse(E);if(Ys.isEqual(P.id,k)){const O=d.getImage(k,v);this.patchUpdatedImage(this.iconPositions.get(E),O,m,null)}}for(const E of this.patternPositions.keys()){const P=Wg.parse(E);if(Ys.isEqual(P.id,k)){const O=d.getImage(k,v);this.patchUpdatedImage(this.patternPositions.get(E),O,m,this.lut)}}}}patchUpdatedImage(d,m,v,k=null){if(!d||!m||d.version===m.version)return;d.version=m.version;const[E,P]=d.tl,O=d.sdf;if(this.lut||O){const B={width:m.data.width,height:m.data.height},W=new zd(B);zd.copy(m.data,W,{x:0,y:0},{x:0,y:0},B,k,O),v.update(W,{position:{x:E,y:P}})}else v.update(m.data,{position:{x:E,y:P}})}}_r(VP,"ImagePosition"),_r(s5e,"ImageAtlas");const HP=1e20;function r5e(g,d,m,v,k,E,P,O,B){for(let W=d;W-1);B++,E[B]=O,P[B]=W,P[B+1]=HP}for(let O=0,B=0;O{let B=this.entries[E];B||(B=this.entries[E]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let W=B.glyphs[P];if(W!==void 0)return void O(null,{stack:E,id:P,glyph:W});if(W=this._tinySDF(B,E,P),W)return B.glyphs[P]=W,void O(null,{stack:E,id:P,glyph:W});const J=Math.floor(P/256);if(256*J>65535)return hr("glyphs > 65535 not supported"),void O(null,{stack:E,id:P,glyph:W});if(B.ranges[J])return void O(null,{stack:E,id:P,glyph:W});let te=B.requests[J];te||(te=B.requests[J]=[],E3.loadGlyphRange(E,J,k,this.requestManager,(ie,ce)=>{if(ce){B.ascender=ce.ascender,B.descender=ce.descender;for(const ue in ce.glyphs)this._doesCharSupportLocalGlyph(+ue)||(B.glyphs[+ue]=ce.glyphs[+ue]);B.ranges[J]=!0}for(const ue of te)ue(ie,ce);delete B.requests[J]})),te.push((ie,ce)=>{ie?O(ie):ce&&O(null,{stack:E,id:P,glyph:ce.glyphs[P]||null})})},(E,P)=>{if(E)m(E);else if(P){const O={};for(const{stack:B,id:W,glyph:J}of P)O[B]===void 0&&(O[B]={}),O[B].glyphs===void 0&&(O[B].glyphs={}),O[B].glyphs[W]=J&&{id:J.id,bitmap:J.bitmap.clone(),metrics:J.metrics},O[B].ascender=this.entries[B].ascender,O[B].descender=this.entries[B].descender;m(null,O)}})}_doesCharSupportLocalGlyph(d){return this.localGlyphMode!==Fpe.none&&(this.localGlyphMode===Fpe.all?!!this.localFontFamily:!!this.localFontFamily&&(Yr["CJK Unified Ideographs"](d)||Yr["Hangul Syllables"](d)||Yr.Hiragana(d)||Yr.Katakana(d)||Yr["CJK Symbols and Punctuation"](d)||Yr["CJK Unified Ideographs Extension A"](d)||Yr["CJK Unified Ideographs Extension B"](d)||Yr.Osage(d)))}_tinySDF(d,m,v){const k=this.localFontFamily;if(!k||!this._doesCharSupportLocalGlyph(v))return;let E=d.tinySDF;if(!E){let Ne="400";/bold/i.test(m)?Ne="900":/medium/i.test(m)?Ne="500":/light/i.test(m)&&(Ne="200"),E=d.tinySDF=new E3.TinySDF({fontFamily:k,fontWeight:Ne,fontSize:24*dx,buffer:3*dx,radius:8*dx}),E.fontWeight=Ne}if(this.localGlyphs[E.fontWeight][v])return this.localGlyphs[E.fontWeight][v];const P=String.fromCodePoint(v),{data:O,width:B,height:W,glyphWidth:J,glyphHeight:te,glyphLeft:ie,glyphTop:ce,glyphAdvance:ue}=E.draw(P);return this.localGlyphs[E.fontWeight][v]={id:v,bitmap:new m_({width:B,height:W},O),metrics:{width:J/dx,height:te/dx,left:ie/dx,top:ce/dx-27,advance:ue/dx,localGlyph:!0}}}}E3.loadGlyphRange=function(g,d,m,v,k){const E=256*d,P=E+255,O=v.transformRequest(v.normalizeGlyphsURL(m).replace("{fontstack}",g).replace("{range}",`${E}-${P}`),Ug.Glyphs);jh(O,(B,W)=>{if(B)k(B);else if(W){const J={},te=function(ie){return new kF(ie).readFields(Fdt,{})}(W);for(const ie of te.glyphs)J[ie.id]=ie;k(null,{glyphs:J,ascender:te.ascender,descender:te.descender})}})},E3.TinySDF=class{constructor({fontSize:g=24,buffer:d=3,radius:m=8,cutoff:v=.25,fontFamily:k="sans-serif",fontWeight:E="normal",fontStyle:P="normal",lang:O=null}={}){this.buffer=d,this.cutoff=v,this.radius=m,this.lang=O;const B=this.size=g+4*d,W=this._createCanvas(B),J=this.ctx=W.getContext("2d",{willReadFrequently:!0});J.font=`${P} ${E} ${g}px ${k}`,J.textBaseline="alphabetic",J.textAlign="left",J.fillStyle="black",this.gridOuter=new Float64Array(B*B),this.gridInner=new Float64Array(B*B),this.f=new Float64Array(B),this.z=new Float64Array(B+1),this.v=new Uint16Array(B)}_createCanvas(g){const d=document.createElement("canvas");return d.width=d.height=g,d}draw(g){const{width:d,actualBoundingBoxAscent:m,actualBoundingBoxDescent:v,actualBoundingBoxLeft:k,actualBoundingBoxRight:E}=this.ctx.measureText(g),P=Math.ceil(m),O=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(E-k))),B=Math.min(this.size-this.buffer,P+Math.ceil(v)),W=O+2*this.buffer,J=B+2*this.buffer,te=Math.max(W*J,0),ie=new Uint8ClampedArray(te),ce={data:ie,width:W,height:J,glyphWidth:O,glyphHeight:B,glyphTop:P,glyphLeft:0,glyphAdvance:d};if(O===0||B===0)return ce;const{ctx:ue,buffer:Ne,gridInner:Le,gridOuter:Ie}=this;this.lang&&(ue.lang=this.lang),ue.clearRect(Ne,Ne,O,B),ue.fillText(g,Ne,Ne+P);const Ge=ue.getImageData(Ne,Ne,O,B);Ie.fill(HP,0,te),Le.fill(0,0,te);for(let Ze=0;Ze0?St*St:0,Le[pt]=St<0?St*St:0}}r5e(Ie,0,0,W,J,W,this.f,this.v,this.z),r5e(Le,Ne,Ne,O,B,W,this.f,this.v,this.z);for(let Ze=0;Ze{const Fs=MF(Wt.stretch-Ge,Ze,J,g.left*k),Bs=TF(Wt.fixed-pt,St,Wt.stretch,ue),Ds=MF(us.stretch-at,vt,te,g.top*k),Os=TF(us.fixed-Lt,Bt,us.stretch,Ne),ds=MF(bs.stretch-Ge,Ze,J,g.left*k),is=TF(bs.fixed-pt,St,bs.stretch,ue),Rs=MF(ws.stretch-at,vt,te,g.top*k),Js=TF(ws.fixed-Lt,Bt,ws.stretch,Ne),Hs=new es(Fs,Ds),Dr=new es(ds,Ds),ur=new es(ds,Rs),yr=new es(Fs,Rs),Nr=new es(Bs/O,Os/O),Wn=new es(is/O,Js/O),Gs=d*Math.PI/180;if(Gs){const Ci=Math.sin(Gs),ft=Math.cos(Gs),_t=[ft,-Ci,Ci,ft];Hs._matMult(_t),Dr._matMult(_t),yr._matMult(_t),ur._matMult(_t)}const Sr=Wt.stretch+Wt.fixed,pn=bs.stretch+bs.fixed,xa=us.stretch+us.fixed,ba=ws.stretch+ws.fixed,Ln=g.imageSecondary;return{tl:Hs,tr:Dr,bl:yr,br:ur,texPrimary:{x:P.paddedRect.x+Ey+Sr,y:P.paddedRect.y+Ey+xa,w:pn-Sr,h:ba-xa},texSecondary:Ln?{x:Ln.paddedRect.x+Ey+Sr,y:Ln.paddedRect.y+Ey+xa,w:pn-Sr,h:ba-xa}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Nr,pixelOffsetBR:Wn,minFontScaleX:St/O/J,minFontScaleY:Bt/O/te,isSDF:m}};if(v&&(P.stretchX||P.stretchY)){const Wt=i5e(ie,Le,ue),us=i5e(ce,Ie,Ne);for(let bs=0;bsE)&&(E=ue.x),(!ce||ue.y>P)&&(P=ue.y)}const B=Math.min(E-v,P-k);let W=B/2;const J=new bC([],Kdt);if(B===0)return new es(v,k);for(let ce=v;cete.d||!te.d)&&(te=ce,m&&console.log("found best %d after %d probes",Math.round(1e4*ce.d)/1e4,ie)),ce.max-te.d<=d||(W=ce.h/2,J.push(new P3(ce.p.x-W,ce.p.y-W,W,g)),J.push(new P3(ce.p.x+W,ce.p.y-W,W,g)),J.push(new P3(ce.p.x-W,ce.p.y+W,W,g)),J.push(new P3(ce.p.x+W,ce.p.y+W,W,g)),ie+=4)}return m&&(console.log(`num probes: ${ie}`),console.log(`best distance: ${te.d}`)),te.p}function Kdt(g,d){return d.max-g.max}class P3{constructor(d,m,v,k){this.p=new es(d,m),this.h=v,this.d=function(E,P){let O=!1,B=1/0;for(let W=0;WE.y!=Ne.y>E.y&&E.x<(Ne.x-ue.x)*(E.y-ue.y)/(Ne.y-ue.y)+ue.x&&(O=!O),B=Math.min(B,Fo(E,ue,Ne))}}return(O?1:-1)*Math.sqrt(B)}(this.p,k),this.max=this.d+this.h*Math.SQRT2}}const Zdt=Object.keys,Bpe=Number.POSITIVE_INFINITY,Ydt=Math.sqrt(2);function f_(g,d,m,v,k){const E=Lpe(g)&&g.collisionPadding?g.collisionPadding:[0,0,0,0],P={top:g.top-E[1],bottom:g.bottom+E[3],left:g.left-E[0],right:g.right+E[2],scaled:!1};return v!==void 0&&function(O,B){O.top*=B,O.bottom*=B,O.left*=B,O.right*=B,O.scaled=!0}(P,v),m&&function(O,B){if(!B)return;const W=Ir(B),J=new es(O.left,O.top),te=new es(O.right,O.top),ie=new es(O.left,O.bottom),ce=new es(O.right,O.bottom),ue=new es(0,0);J._rotateAround(W,ue),te._rotateAround(W,ue),ie._rotateAround(W,ue),ce._rotateAround(W,ue),O.left=Math.min(J.x,te.x,ie.x,ce.x),O.right=Math.max(J.x,te.x,ie.x,ce.x),O.top=Math.min(J.y,te.y,ie.y,ce.y),O.bottom=Math.max(J.y,te.y,ie.y,ce.y)}(P,m),k&&(P.left+=k[0],P.right+=k[0],P.top+=k[1],P.bottom+=k[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 l5e(g,[d,m]){let v=0,k=0;if(m===Bpe){d<0&&(d=0);const E=d/Ydt;switch(g){case"top-right":case"top-left":k=E-7;break;case"bottom-right":case"bottom-left":k=7-E;break;case"bottom":k=7-d;break;case"top":k=d-7}switch(g){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),g){case"top-right":case"top-left":case"top":k=m-7;break;case"bottom-right":case"bottom-left":case"bottom":k=7-m}switch(g){case"top-right":case"bottom-right":case"right":v=-d;break;case"top-left":case"bottom-left":case"left":v=d}}return[v,k]}function Xdt(g,d,m,v,k,E,P,O,B,W,J,te,ie,ce){const ue=g.layers[0],Ne=ue.appearances;if(Ne.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Le={iconBBox:null,iconVerticalBBox:null},Ie={textBBox:null,textVerticalBBox:null},{baseIconRotate:Ge,baseTextRotate:Ze,iconScaleFactor:at}=function(pt,St,Lt){const Bt=pt.get("icon-rotate").evaluate(St,{},Lt),as=pt.get("text-rotate").evaluate(St,{},Lt),[Wt,us]=pt.get("icon-size-scale-range");return{baseIconRotate:Bt,baseTextRotate:as,iconScaleFactor:ve(1,Wt,us)}}(v,k,E);d&&(Le.iconBBox=f_(d,Le.iconBBox,Ge,P),m)&&(Le.iconVerticalBBox=f_(m,Le.iconVerticalBBox,Ge+90,P));const vt=EF(te.horizontal);vt&&(Ie.textBBox=f_(vt,Ie.textBBox,Ze,1,ce)),te.vertical&&(Ie.textVerticalBBox=f_(te.vertical,Ie.textVerticalBBox,Ze+90,1,ce));for(const pt of Ne)pt.hasIconProperties()&&Qdt(Le,g,ue,pt,k,E,O,Ge,P,B,d,W,at,J),pt.hasTextProperties()&&Jdt(Ie,ue,pt,k,E,ce,Ze,ie,vt,te.vertical);return{iconBBox:Le.iconBBox,iconVerticalBBox:Le.iconVerticalBBox,textBBox:Ie.textBBox,textVerticalBBox:Ie.textVerticalBBox}}function Qdt(g,d,m,v,k,E,P,O,B,W,J,te,ie,ce){const{appearanceIconOffset:ue,appearanceIconRotate:Ne,appearanceIconSize:Le}=function(at,vt,pt,St,Lt,Bt,as,Wt){const us=at.hasProperty("icon-offset")?vt.getAppearanceValueAndResolveTokens(at,"icon-offset",pt,St,[]):null,bs=us&&Array.isArray(us)?us:Lt,ws=at.hasProperty("icon-rotate")?vt.getAppearanceValueAndResolveTokens(at,"icon-rotate",pt,St,[]):null,Fs=typeof ws=="number"?ws:Bt,Bs=at.hasProperty("icon-size")?vt.getAppearanceValueAndResolveTokens(at,"icon-size",pt,St,[]):null;return{appearanceIconOffset:bs,appearanceIconRotate:Fs,appearanceIconSize:typeof Bs=="number"?Bs*Wt.iconScaleFactor:as}}(v,m,k,E,P,O,B,W);let Ie=null,Ge=null,Ze=null;v.hasProperty("icon-image")?Ze=function(at,vt,pt,St,Lt,Bt,as){let Wt=null;const us=vt.getAppearanceValueAndResolveTokens(pt,"icon-image",St,Lt,[]);if(us){const bs=at.getResolvedImageFromTokens(us),ws=pt.getUnevaluatedProperty("icon-size"),Fs=WP(bs,T3(at.zoom,ws,at.worldview),ws,Lt,at.zoom,St,at.pixelRatio,as,at.worldview);Wt=Bt.get(Fs.iconPrimary.toString())}return Wt}(d,m,v,k,E,te,ie):J&&(Ze=J.imagePrimary),Ze&&(Ie=SF(Ze,null,ue,ce),d.allowVerticalPlacement&&(Ge=SF(Ze,null,ue,ce))),Ie&&(g.iconBBox=f_(Ie,g.iconBBox,Ne,Le)),Ge&&(g.iconVerticalBBox=f_(Ge,g.iconVerticalBBox,Ne+90,Le))}function Jdt(g,d,m,v,k,E,P,O,B,W){const{appearanceTextOffset:J,appearanceTextRotate:te,appearanceTextSize:ie}=function(ue,Ne,Le,Ie,Ge,Ze,at){const vt=ue.hasProperty("text-offset")?Ne.getAppearanceValueAndResolveTokens(ue,"text-offset",Le,Ie,[]):null,pt=vt&&Array.isArray(vt)?[vt[0]*_c,vt[1]*_c]:Ge,St=ue.hasProperty("text-rotate")?Ne.getAppearanceValueAndResolveTokens(ue,"text-rotate",Le,Ie,[]):null,Lt=typeof St=="number"?St:Ze,Bt=ue.hasProperty("text-size")?Ne.getAppearanceValueAndResolveTokens(ue,"text-size",Le,Ie,[]):null;return{appearanceTextOffset:pt,appearanceTextRotate:Lt,appearanceTextSize:typeof Bt=="number"?Bt:at}}(m,d,v,k,E,P,O),ce=ie/O;B&&(g.textBBox=f_(B,g.textBBox,te,ce,J)),W&&(g.textVerticalBBox=f_(W,g.textVerticalBBox,te+90,ce,J))}function AF(g,d,m,v,k,E,P,O,B){if(!d||!d.usvg)return;const W=Z3e(v),J=Z3e(k),te=E!=="both"&&E!=="width"||!G3e(v)?1:J.width/W.width,ie=E!=="both"&&E!=="height"||!K3e(v)?1:J.height/W.height;m.scaleSelf(te,ie);const ce=m.toString();P.set(ce,m),O.set(ce,d);const{imagePosition:ue}=Rpe(ce,d,jw);B.set(ce,ue)}function c5e(g,d,m,v,k,E,P,O,B){if(!g)return;const W=function(J,te,ie,ce,ue,Ne){if(J.kind==="camera")return J.maxSize;if(J.kind==="composite"){const Le=te.possiblyEvaluate(new Hi(J.maxZoom,{worldview:Ne}),ie).evaluate(ue,{},ie),Ie=te.possiblyEvaluate(new Hi(J.minZoom,{worldview:Ne}),ie).evaluate(ue,{},ie);return Math.max(Le,Ie)}return te.possiblyEvaluate(new Hi(ce,{worldview:Ne})).evaluate(ue,{},ie)}(d,m,v,k,E,B);return g.scaleSelf(W*O*P)}function WP(g,d,m,v,k,E,P,O,B){return{iconPrimary:c5e(g.getPrimary(),d,m,v,k,E,P,O,B),iconSecondary:c5e(g.getSecondary(),d,m,v,k,E,P,O,B)}}function eut(g,d,m){if(!d)return;const v=m.get(g.toString()),k=m.get(d.toString());v&&k&&(v.paddedRect.w===k.paddedRect.w&&v.paddedRect.h===k.paddedRect.h||hr(`Mismatch in icon variant sizes: ${g.toString()} and ${d.toString()}`),v.usvg!==k.usvg&&hr(`Mismatch in icon variant image types: ${g.id} and ${d.id}`))}function d5e(g,d,m,v){if(!g)return;const k=d.get(m.toString());if(g.imagePrimary=k,v){const E=d.get(v.toString());g.imageSecondary=E}}function tut(g,d){for(const m in g.horizontal)u5e(g.horizontal[m],d);u5e(g.vertical,d)}function u5e(g,d){if(g){for(const m of g.positionedLines)for(const v of m.positionedGlyphs)if(v.image!==null){const k=v.image.toString();v.rect=d.get(k).paddedRect}}}function $pe(g){switch(g){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function sut(g,d,m,v,k,E,P,O,B){const W=EF(E.horizontal)||E.vertical,J=m.get("icon-text-fit-padding").evaluate(v,{},k);let te,ie=d;return d&&B!=="none"&&(g.allowVerticalPlacement&&E.vertical&&(te=Dpe(d,E.vertical,B,J,O,P)),W&&(ie=Dpe(d,W,B,J,O,P))),{defaultShapedIcon:ie,verticallyShapedIcon:te}}function rut(g,d,m,v,k,E,P,O,B,W,J,te,ie,ce,ue,Ne,Le,Ie,Ge,Ze,at,vt,pt,St){let Lt=P.textMaxSize.evaluate(d,{},ie);Lt===void 0?Lt=O*P.textScaleFactor:Lt*=P.textScaleFactor;const Bt=g.layers[0].layout,as=_c,Wt=O*P.textScaleFactor/as,us=EF(m.horizontal)||m.vertical;if(Le!=="none"&&g.appearanceFeatureData&&d.index18&&Rs>2&&(Rs>>=1),Math.max(Qs/(512*Rs),1)*Bt.get("symbol-spacing")),Bs=Bt.get("text-padding")*g.tilePixelRatio,Ds=Bt.get("icon-padding")*g.tilePixelRatio,Os=Ir(Bt.get("text-max-angle")),ds=Bt.get("icon-rotation-alignment")==="map"&&Ze!=="point",is=Fs/2;var Rs;g.hasAnyIconTextFit===!1&&Le!=="none"&&(g.hasAnyIconTextFit=!0);const Js=d.properties?+d.properties[ls]:null,Hs=Js&&g.elevationFeatureIdToIndex?g.elevationFeatureIdToIndex.get(Js):65535,Dr=(ur,yr,Nr)=>{if(yr.x<0||yr.x>=Qs||yr.y<0||yr.y>=Qs)return;let Wn=null;if(bs){const{x:Gs,y:Sr,z:pn}=ce.projectTilePoint(yr.x,yr.y,Nr);Wn={anchor:new dv(Gs,Sr,pn,0,void 0),up:ce.upVector(Nr,yr.x,yr.y)}}(function(Gs,Sr,pn,xa,ba,Ln,Ci,ft,_t,hs,zs,or,lr,Or,zr,Sn,Bn,Hn,ca,en,un,Fa,Ga,Ka,fi,Pi,Mi,ei,li,$n,_a,co,Xr){const da=Gs.addToLineVertexArray(Sr,xa);let Ti,zi,Wi,Go,$i,Qr,_o,gi=0,to=0,Ol=0,bc=0,pl=-1,fl=-1;const ac={};let ih=z1("");const qi=pn?pn.anchor:Sr,zo=ei!=="none";let Ko=0,Nh=0;if(_t._unevaluatedLayout.getValue("text-radial-offset")===void 0){const wd=_t.layout.get("text-offset").evaluate(un,{},fi);Ko=wd[0]*_c,Nh=wd[1]*_c}else Ko=_t.layout.get("text-radial-offset").evaluate(un,{},fi)*_c,Nh=Bpe;if(Gs.allowVerticalPlacement&&ba.vertical){const wd=ba.vertical;if(zr)Qr=qpe(wd),ft&&(_o=qpe(ft));else{const Iu=_t.layout.get("text-rotate").evaluate(un,{},fi)+90;Wi=PF(hs,qi,Sr,zs,or,lr,wd,Or,Iu,Sn,co),ft&&(Go=PF(hs,qi,Sr,zs,or,lr,ft,Hn,Iu,null,_a))}}if(Ln){const wd=Gs.iconSizeData,Iu=_t.layout.get("icon-rotate").evaluate(un,{},fi),lm=zpe(Ln,Iu,Ga,zo,Fa.iconScaleFactor),y_=ft?zpe(ft,Iu,Ga,zo,Fa.iconScaleFactor):void 0;zi=PF(hs,qi,Sr,zs,or,lr,Ln,Hn,Iu,null,$n);const z3=function(px,d6,AMe,fht,EMe,PMe,ght,xht){const IMe=px.layers[0],LMe=IMe.appearances;let B3=d6.length;if(AMe&&(B3=Math.max(B3,AMe.length)),LMe.length===0)return B3;const[yht,vht]=fht.get("icon-size-scale-range"),_ht=ve(1,yht,vht);for(const DMe of LMe){const OMe=DMe.getUnevaluatedProperties();if(OMe._values["icon-image"].value!==void 0){const RMe=IMe.getAppearanceValueAndResolveTokens(DMe,"icon-image",EMe,PMe,[]);if(RMe){const FMe=px.getResolvedImageFromTokens(RMe);if(FMe){const zMe=OMe._values["icon-size"],bht=WP(FMe,T3(px.zoom,zMe,px.worldview),zMe,PMe,px.zoom,EMe,px.pixelRatio,_ht,px.worldview),wht=ght.get(bht.iconPrimary.toString());B3=Math.max(B3,Hdt(wht,xht))}}}}return B3}(Gs,lm,y_,_t.layout,un,fi,Gs.iconAtlasPositions,zo);gi=4*z3;let mx=null;wd.kind==="source"?(mx=[cx*_t.layout.get("icon-size").evaluate(un,{},fi)*Fa.iconScaleFactor],mx[0]>uv&&hr(`${Gs.layerIds[0]}: Value for "icon-size" is >= ${GP}. Reduce your "icon-size".`)):wd.kind==="composite"&&(mx=[cx*Fa.compositeIconSizes[0].evaluate(un,{},fi)*Fa.iconScaleFactor,cx*Fa.compositeIconSizes[1].evaluate(un,{},fi)*Fa.iconScaleFactor],(mx[0]>uv||mx[1]>uv)&&hr(`${Gs.layerIds[0]}: Value for "icon-size" is >= ${GP}. Reduce your "icon-size".`)),Gs.addSymbols(Gs.icon,lm,mx,en,ca,un,void 0,pn,Sr,da.lineStartIndex,da.lineLength,-1,Ka,fi,Pi,Mi,Gs.symbolInstances.length,z3),pl=Gs.icon.placedSymbolArray.length-1,y_&&(to=4*z3,Gs.addSymbols(Gs.icon,y_,mx,en,ca,un,om.vertical,pn,Sr,da.lineStartIndex,da.lineLength,-1,Ka,fi,Pi,Mi,Gs.symbolInstances.length,z3),fl=Gs.icon.placedSymbolArray.length-1)}for(const wd in ba.horizontal){const Iu=wd,lm=ba.horizontal[Iu];Ti||(ih=z1(lm.text),zr?$i=qpe(lm):Ti=PF(hs,qi,Sr,zs,or,lr,lm,Or,_t.layout.get("text-rotate").evaluate(un,{},fi),Sn,co));const y_=lm.positionedLines.length===1;if(Ol+=h5e(Gs,pn,Sr,lm,Ci,_t,zr,un,Sn,da,ba.vertical?om.horizontal:om.horizontalOnly,y_?Zdt(ba.horizontal):[Iu],ac,pl,Fa,Ka,fi,Gs.symbolInstances.length,Pi),y_)break}ba.vertical&&(bc+=h5e(Gs,pn,Sr,ba.vertical,Ci,_t,zr,un,Sn,da,om.vertical,["vertical"],ac,fl,Fa,Ka,fi,Gs.symbolInstances.length,Pi));let Rl=-1;const $f=(wd,Iu)=>wd?Math.max(wd,Iu):Iu;Rl=$f($i,Rl),Rl=$f(Qr,Rl),Rl=$f(_o,Rl);const Py=Rl>-1?1:0;Gs.glyphOffsetArray.length>=65535&&hr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),un.sortKey!==void 0&&Gs.addToSortKeyRanges(Gs.symbolInstances.length,un.sortKey),Gs.symbolInstances.emplaceBack(Sr.x,Sr.y,qi.x,qi.y,qi.z,ac.right>=0?ac.right:-1,ac.center>=0?ac.center:-1,ac.left>=0?ac.left:-1,ac.vertical>=0?ac.vertical:-1,pl,fl,ih,Ti!==void 0?Ti:Gs.collisionBoxArray.length,Ti!==void 0?Ti+1:Gs.collisionBoxArray.length,Wi!==void 0?Wi:Gs.collisionBoxArray.length,Wi!==void 0?Wi+1:Gs.collisionBoxArray.length,zi!==void 0?zi:Gs.collisionBoxArray.length,zi!==void 0?zi+1:Gs.collisionBoxArray.length,Go||Gs.collisionBoxArray.length,Go?Go+1:Gs.collisionBoxArray.length,zs,Ol,bc,gi,to,Py,0,Ko,Nh,Rl,0,zo?1:0,li)})(g,yr,Wn,ur,m,v,E,k,g.layers[0],g.collisionBoxArray,d.index,d.sourceLayerIndex,g.index,Bs,Ge,W,0,Ds,ds,Ie,d,P,J,te,ie,ue,Ne,Le,Hs,at,vt,pt)};if(Ze==="line")for(const ur of mF(d.geometry,0,0,Qs,Qs)){const yr=Vdt(ur,Fs,Os,m.vertical||us,v,as,ws,g.overscaling,Qs);for(const Nr of yr)us&&nut(g,us.text,is,Nr)||Dr(ur,Nr,ie)}else if(Ze==="line-center"){for(const ur of d.geometry)if(ur.length>1){const yr=Udt(ur,Os,m.vertical||us,v,as,ws);yr&&Dr(ur,yr,ie)}}else if(d.type==="Polygon")for(const ur of TP(d.geometry,0)){const yr=Gdt(ur,16);Dr(ur[0],new dv(yr.x,yr.y,0,0,void 0),ie)}else if(d.type==="LineString")for(const ur of d.geometry)Dr(ur,new dv(ur[0].x,ur[0].y,0,0,void 0),ie);else if(d.type==="Point")for(const ur of d.geometry)for(const yr of ur)Dr([yr],new dv(yr.x,yr.y,0,0,void 0),ie)}const GP=255,uv=GP*cx;function h5e(g,d,m,v,k,E,P,O,B,W,J,te,ie,ce,ue,Ne,Le,Ie,Ge){const Ze=function(pt,St,Lt,Bt,as,Wt,us,bs){const ws=[];if(St.positionedLines.length===0)return ws;const Fs=Bt.layout.get("text-rotate").evaluate(Wt,{})*Math.PI/180,Bs=function(Rs){const Js=Rs[0],Hs=Rs[1],Dr=Js*Hs;return Dr>0?[Js,-Hs]:Dr<0?[-Js,Hs]:Js===0?[Hs,Js]:[Hs,-Js]}(Lt);let Ds=Math.abs(St.top-St.bottom);for(const Rs of St.positionedLines)Ds-=Rs.lineOffset;const Os=St.positionedLines.length,ds=Ds/Os;let is=St.top-Lt[1];for(let Rs=0;Rsuv&&hr(`${g.layerIds[0]}: Value for "text-size" is >= ${GP}. Reduce your "text-size".`)):at.kind==="composite"&&(vt=[cx*ue.compositeTextSizes[0].evaluate(O,{},Le)*ue.textScaleFactor,cx*ue.compositeTextSizes[1].evaluate(O,{},Le)*ue.textScaleFactor],(vt[0]>uv||vt[1]>uv)&&hr(`${g.layerIds[0]}: Value for "text-size" is >= ${GP}. Reduce your "text-size".`)),g.addSymbols(g.text,Ze,vt,B,P,O,J,d,m,W.lineStartIndex,W.lineLength,ce,Ne,Le,Ge,!1,Ie,Ze.length);for(const pt of te)ie[pt]=g.text.placedSymbolArray.length-1;return 4*Ze.length}function EF(g){for(const d in g)return g[d];return null}function PF(g,d,m,v,k,E,P,O,B,W,J){let te,ie,ce,ue;if(te=J?J.top:P.top,ie=J?J.bottom:P.bottom,ce=J?J.left:P.left,ue=J?J.right:P.right,Lpe(P)&&P.collisionPadding){const Ne=P.collisionPadding;ce-=Ne[0],te-=Ne[1],ue+=Ne[2],ie+=Ne[3]}if(B){const Ne=new es(ce,te),Le=new es(ue,te),Ie=new es(ce,ie),Ge=new es(ue,ie),Ze=Ir(B);let at=new es(0,0);W&&(at=new es(W[0],W[1])),Ne._rotateAround(Ze,at),Le._rotateAround(Ze,at),Ie._rotateAround(Ze,at),Ge._rotateAround(Ze,at),ce=Math.min(Ne.x,Le.x,Ie.x,Ge.x),ue=Math.max(Ne.x,Le.x,Ie.x,Ge.x),te=Math.min(Ne.y,Le.y,Ie.y,Ge.y),ie=Math.max(Ne.y,Le.y,Ie.y,Ge.y)}return g.emplaceBack(d.x,d.y,d.z,m.x,m.y,ce,te,ue,ie,O,v,k,E),g.length-1}function qpe(g){Lpe(g)&&g.collisionPadding&&(g.top-=g.collisionPadding[1],g.bottom+=g.collisionPadding[3]);const d=g.bottom-g.top;return d>0?Math.max(10,d):null}function nut(g,d,m,v){const k=g.compareText;if(d in k){const E=k[d];for(let P=E.length-1;P>=0;P--)if(v.dist(E[P])Ze&&(at(pt,ws,Lt,Bt,us,bs),at(ws,St,us,bs,as,Wt))}at(te,ie,v,E,k,E),at(ie,ce,k,E,k,P),at(ce,ue,k,P,v,P),at(ue,te,v,P,v,E),Ne-=Ze,Le-=Ze,Ie+=Ze,Ge+=Ze;const vt=1/Math.max(Ie-Ne,Ge-Le);return{scale:vt,x:Ne*vt,y:Le*vt,x2:Ie*vt,y2:Ge*vt,projection:d}}function p5e(g,{x:d,y:m},v=0){return new es(((d-v)*g.scale-g.x)*Qs,(m*g.scale-g.y)*Qs)}const aut=j(new Float32Array(16));class g_{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 x(0,0)}projectTilePoint(d,m,v){return{x:d,y:m,z:0}}locationPoint(d,m,v,k=!0){return d._coordinatePoint(d.locationCoordinate(m,v),k)}pixelsPerMeter(d,m){return ae(1,d)*m}pixelSpaceConversion(d,m,v){return 1}farthestPixelDistance(d){return m5e(d,d.pixelsPerMeter)}pointCoordinate(d,m,v,k){const E=d.horizonLineFromTop(!1),P=new es(m,Math.max(E,v));return d.rayIntersectionCoordinate(d.pointRayIntersection(P,k))}pointCoordinate3D(d,m,v){const k=new es(m,v);if(d.elevation)return d.elevation.pointCoordinate(k);{const E=this.pointCoordinate(d,k.x,k.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<-I3+v&&(m=-I3+v):m>I3-v&&(m=I3-v);const P=E/Math.pow(LF(m),k);let O=P*Math.sin(k*d),B=E-P*Math.cos(k*d);return O=.5*(O/Math.PI+.5),B=.5*(B/Math.PI+.5),{x:O,y:this.southernCenter?B:1-B,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:k}=this,E=k-m,P=Math.sign(E),O=Math.sign(v)*Math.sqrt(d*d+E*E);let B=Math.atan2(d,Math.abs(E))*P;E*v<0&&(B-=Math.PI*Math.sign(d)*P);const W=ve(_i(B/v)+this.center[0],-180,180),J=ve(_i(2*Math.atan(Math.pow(k/O,1/v))-I3),-xe,xe);return new x(W,this.southernCenter?-J:J)}}class f5e extends g_{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:H(d),y:Y(m),z:0}}unproject(d,m){const v=oe(d),k=ge(m);return new x(v,k)}}const g5e=Ir(xe);class dut extends g_{project(d,m){const v=(m=Ir(m))*m,k=v*v;return{x:.5*((d=Ir(d))*(.8707-.131979*v+k*(k*(.003971*v-.001529*k)-.013791))/Math.PI+.5),y:1-.5*(m*(1.007226+v*(.015085+k*(.028874*v-.044475-.005916*k)))/Math.PI+1),z:0}}unproject(d,m){d=(2*d-.5)*Math.PI;let v=m=(2*(1-m)-1)*Math.PI,k=25,E=0,P=v*v;do{P=v*v;const W=P*P;E=(v*(1.007226+P*(.015085+W*(.028874*P-.044475-.005916*W)))-m)/(1.007226+P*(.045255+W*(.259866*P-.311325-.005916*11*W))),v=ve(v-E,-g5e,g5e)}while(Math.abs(E)>1e-6&&--k>0);P=v*v;const O=ve(_i(d/(.8707+P*(P*(P*P*P*(.003971-.001529*P)-.013791)-.131979))),-180,180),B=_i(v);return new x(O,B)}}const x5e=Ir(xe);class uut extends g_{project(d,m){m=Ir(m),d=Ir(d);const v=Math.cos(m),k=2/Math.PI,E=Math.acos(v*Math.cos(d/2)),P=Math.sin(E)/E,O=.5*(d*k+2*v*Math.sin(d/2)/P)||0,B=.5*(m+Math.sin(m)/P)||0;return{x:.5*(O/Math.PI+.5),y:1-.5*(B/Math.PI+1),z:0}}unproject(d,m){let v=d=(2*d-.5)*Math.PI,k=m=(2*(1-m)-1)*Math.PI,E=25;const P=1e-6;let O=0,B=0;do{const W=Math.cos(k),J=Math.sin(k),te=2*J*W,ie=J*J,ce=W*W,ue=Math.cos(v/2),Ne=Math.sin(v/2),Le=2*ue*Ne,Ie=Ne*Ne,Ge=1-ce*ue*ue,Ze=Ge?1/Ge:0,at=Ge?Math.acos(W*ue)*Math.sqrt(1/Ge):0,vt=.5*(2*at*W*Ne+2*v/Math.PI)-d,pt=.5*(at*J+k)-m,St=.5*Ze*(ce*Ie+at*W*ue*ie)+1/Math.PI,Lt=Ze*(Le*te/4-at*J*Ne),Bt=.125*Ze*(te*Ne-at*J*ce*Le),as=.5*Ze*(ie*ue+at*Ie*W)+.5,Wt=Lt*Bt-as*St;O=(pt*Lt-vt*as)/Wt,B=(vt*Bt-pt*St)/Wt,v=ve(v-O,-Math.PI,Math.PI),k=ve(k-B,-x5e,x5e)}while((Math.abs(O)>P||Math.abs(B)>P)&&--E>0);return new x(_i(v),_i(k))}}class y5e extends g_{constructor(d){super(d),this.center=d.center||[0,0],this.parallels=d.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ir(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:k}=this;return{x:Ir(d)*k*v+.5,y:-Math.sin(Ir(m))/k*v+.5,z:0}}unproject(d,m){const{scale:v,cosPhi:k}=this,E=-(m-.5)/v,P=ve(_i((d-.5)/v)/k,-180,180),O=Math.asin(ve(E*k,-1,1)),B=ve(_i(O),-xe,xe);return new x(P,B)}}class hut extends f5e{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 k=jP(d,m,v);return Rt(k,k,nF(Fp(v))),{x:k[0],y:k[1],z:k[2]}}locationPoint(d,m,v){const k=c_(m.lat,m.lng),E=Te([],k),P=v?d._centerAltitude+v:d.elevation?d.elevation.getAtPointOrZero(d.locationCoordinate(m),d._centerAltitude):d._centerAltitude;We(k,k,E,ae(1,0)*Qs*P);const O=j(new Float64Array(16));return S(O,d.pixelMatrix,d.globeMatrix),Rt(k,k,O),new es(k[0],k[1])}pixelsPerMeter(d,m){return ae(1,0)*m}pixelSpaceConversion(d,m,v){const k=ae(1,d)*m,E=Hr(ae(1,45)*m,k,v);return this.pixelsPerMeter(d,m)/E}createTileMatrix(d,m,v){const k=Gme(Fp(v.canonical));return S(new Float64Array(16),d.globeMatrix,k)}createInversionMatrix(d,m){const{center:v}=d,k=nF(Fp(m));return R(k,k,Ir(v.lng)),L(k,k,Ir(v.lat)),I(k,k,[d._pixelsPerMercatorPixel,d._pixelsPerMercatorPixel,1]),Float32Array.from(k)}pointCoordinate(d,m,v,k){return u_(d,m,v,!0)||new et(0,0)}pointCoordinate3D(d,m,v){const k=this.pointCoordinate(d,m,v,0);return[k.x,k.y,k.z]}isPointAboveHorizon(d,m){return!u_(d,m.x,m.y,!1)}farthestPixelDistance(d){const m=function(k,E){const P=k.cameraToCenterDistance,O=k._centerAltitude*E,B=k._camera,W=k._camera.forward(),J=le([],ke([],W,-P),[0,0,O]),te=k.worldSize/(2*Math.PI),ie=[0,0,-te],ce=k.width/k.height,ue=Math.tan(k.fovAboveCenter),Ne=ke([],B.up(),ue),Le=ke([],B.right(),ue*ce),Ie=Te([],le([],le([],W,Ne),Le)),Ge=[];let Ze;if(new kr(J,Ie).closestPointOnSphere(ie,te,Ge)){const at=le([],Ge,ie),vt=Se([],at,J);Ze=Math.cos(k.fovAboveCenter)*de(vt)}else{const at=Se([],J,ie),vt=Se([],ie,J);Te(vt,vt);const pt=de(at)-te;Ze=Math.sqrt(pt*(pt+2*te));const St=Math.acos(Ze/(te+pt))-Math.acos(qe(W,vt));Ze*=Math.cos(St)}return 1.01*Ze}(d,this.pixelsPerMeter(d.center.lat,d.worldSize)),v=h_(d.zoom);if(v>0){const k=m5e(d,ae(1,d.center.lat)*d.worldSize),E=d.worldSize/(2*Math.PI),P=Math.max(d.width,d.height)/d.worldSize*Math.PI;return Hr(m,k+E*(1-Math.cos(P)),Math.pow(v,10))}return m}upVector(d,m,v){return jP(m,v,d,1)}upVectorScale(d){return{metersToTile:zf(rF(Fp(d)))}}}function v5e(g){const d=g.parallels,m=!!d&&Math.abs(d[0]+d[1])<.01;switch(g.name){case"mercator":return new f5e(g);case"equirectangular":return new lut(g);case"naturalEarth":return new dut(g);case"equalEarth":return new out(g);case"winkelTripel":return new uut(g);case"albers":return m?new y5e(g):new iut(g);case"lambertConformalConic":return m?new y5e(g):new cut(g);case"globe":return new hut(g)}throw new Error(`Invalid projection name: ${g.name}`)}const mut=Ut.types,put=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function JP(g,d,m,v,k,E,P,O,B,W,J,te,ie){const ce=O?Math.min(uv,Math.round(O[0])):0,ue=O?Math.min(uv,Math.round(O[1])):0;g.emplaceBack(d,m,Math.round(32*v),Math.round(32*k),E,P,(ce<<1)+(B?1:0),0+(ue<<1),16*W,16*J,256*te,256*ie)}function e6(g,d,m){g.emplaceBack(d,m)}function t6(g,d,m,v,k,E,P){g.emplaceBack(d,m,v,k,E,P)}const DF=(g,d,m,v)=>{for(let k=0;k0&&(this.iconTransitioningVertexBuffer=d.createVertexBuffer(this.iconTransitioningVertexArray,wdt.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=d.createVertexBuffer(this.globeExtVertexArray,ydt.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||E)&&(this.zOffsetVertexBuffer=d.createVertexBuffer(this.zOffsetVertexArray,_dt.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=d.createVertexBuffer(this.orientationVertexArray,bdt.members,!0)),this.opacityVertexBuffer.itemSize=1),(v||k)&&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())}}_r(Upe,"SymbolBuffers");class Vpe{constructor(d,m,v){this.layoutVertexArray=new d,this.layoutAttributes=m,this.indexArray=new v,this.segments=new xo,this.collisionVertexArray=new lP,this.collisionVertexArrayExt=new Sy}upload(d){this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=d.createVertexBuffer(this.collisionVertexArray,jdt.members,!0),this.collisionVertexBufferExt=d.createVertexBuffer(this.collisionVertexArrayExt,kdt.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}_r(Vpe,"CollisionBuffers");class OF{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=j([]),this.placementViewportMatrix=j([]);const m=this.layers[0]._unevaluatedLayout._values;this.worldview=d.worldview,this.localizable=d.localizable,this.textSizeData=T3(this.zoom,m["text-size"],this.worldview),this.iconSizeData=T3(this.zoom,m["icon-size"],this.worldview);const v=this.layers[0].layout,k=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"&&k.constantOr(1)!==void 0,this.sortFeaturesByY=(E==="viewport-y"||E==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=v.get("text-writing-mode").map(P=>om[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 Upe(new Op(this.layers,{zoom:this.zoom,lut:this.lut},d=>d.startsWith("text")||d.startsWith("symbol"))),this.icon=new Upe(new Op(this.layers,{zoom:this.zoom,lut:this.lut},d=>d.startsWith("icon")||d.startsWith("symbol"))),this.glyphOffsetArray=new u3,this.lineVertexArray=new QR,this.symbolInstances=new fP}calculateGlyphDependencies(d,m,v,k,E){for(const P of d){const O=P.codePointAt(0);if(O===void 0)break;if(m[O]=!0,k&&E&&O<=65535){const B=qP[P];B&&(m[B.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(d,m,v,k,E,P){let O=1;const B=d.getUnevaluatedProperties()._values["icon-size"],W=T3(this.zoom,B,this.worldview),J=A3(W,m);if(W.kind!=="constant"&&W.kind!=="camera"||(O=J.uSize),W.kind==="composite"){const{minZoom:te,maxZoom:ie}=W,ce=B.possiblyEvaluate(new Hi(te,{worldview:this.worldview}),k),ue=B.possiblyEvaluate(new Hi(ie,{worldview:this.worldview}),k),Ne=ce.evaluate(v,{},k,E);O=Ne+(ue.evaluate(v,{},k,E)-Ne)*J.uSizeT}return W.kind==="source"&&(O=B.possiblyEvaluate(new Hi(this.zoom,{worldview:this.worldview}),k).evaluate(v,{},k,E)),O*P}updateFootprints(d,m){}updateReplacement(d,m){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const v=m.getReplacementRegionsForTile(d.toUnwrapped(),!0);return!dF(this.activeReplacements,v)&&(this.activeReplacements=v,!0)}getResolvedImageFromTokens(d){return typeof d=="string"?Mu.build(d):d}populate(d,m,v,k){const E=this.layers[0],P=E.layout,O=this.projection.name==="globe",B=P.get("text-font"),W=P.get("text-field"),J=P.get("icon-image"),[te,ie]=P.get("icon-size-scale-range"),ce=ve(m.scaleFactor||1,te,ie),ue=(W.value.kind!=="constant"||W.value.value instanceof Cu&&!W.value.value.isEmpty()||W.value.value.toString().length>0)&&(B.value.kind!=="constant"||B.value.value.length>0),Ne=J.value.kind!=="constant"||!!J.value.value||Object.keys(J.parameters).length>0,Le=this.hasAnyAppearanceProperty("icon-image"),Ie=P.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!ue&&!Ne&&!Le)return;const Ge=m.iconDependencies,Ze=m.glyphDependencies,at=m.availableImages,vt=new Hi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),pt=St=>{const Lt=St.id.toString();Ge.has(Lt)?Ge.get(Lt).push(St):Ge.set(Lt,[St])};for(const St of d){const{feature:Lt,id:Bt,index:as,sourceLayerIndex:Wt}=St,us=E._featureFilter.needGeometry,bs=Ht(Lt,us);if(!E._featureFilter.filter(vt,bs,v))continue;if(us||(bs.geometry=Pt(Lt,v,k)),O&&Lt.type!==1&&v.z<=5){const Rs=bs.geometry,Js=.98078528056,Hs=(Dr,ur)=>qe(jP(Dr.x,Dr.y,v,1),jP(ur.x,ur.y,v,1)){if(!Rs.getProperty("icon-image"))return;const Js=this.getCombinedIconPrimary(Rs,Bs,bs,v,at,ds,ce);Js&&pt(Js)}),ws){const Rs=B.evaluate(bs,{},v).join(","),Js=P.get("text-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(om.vertical)>=0;for(const Hs of ws.sections)if(Hs.image){const Dr=Hs.image.getPrimary().scaleSelf(this.pixelRatio),ur=Dr.id.toString(),yr=Ge.get(ur)||[];yr.push(Dr),Ge.set(ur,yr)}else{const Dr=nw(ws.toString()),ur=Hs.fontStack||Rs,yr=Ze[ur]=Ze[ur]||{};this.calculateGlyphDependencies(Hs.text,yr,Js,this.allowVerticalPlacement,Dr)}}}if(P.get("symbol-placement")==="line"&&(this.features=function(St){const Lt={},Bt={},as=[];let Wt=0;function us(Bs){as.push(St[Bs]),Wt++}function bs(Bs,Ds,Os){const ds=Bt[Bs];return delete Bt[Bs],Bt[Ds]=ds,as[ds].geometry[0].pop(),as[ds].geometry[0]=as[ds].geometry[0].concat(Os[0]),ds}function ws(Bs,Ds,Os){const ds=Lt[Ds];return delete Lt[Ds],Lt[Bs]=ds,as[ds].geometry[0].shift(),as[ds].geometry[0]=Os[0].concat(as[ds].geometry[0]),ds}function Fs(Bs,Ds,Os){const ds=Os?Ds[0][Ds[0].length-1]:Ds[0][0];return`${Bs}:${ds.x}:${ds.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 St of m.elevationFeatures)this.elevationFeatureIdToIndex.set(St.id,this.elevationFeatures.length),this.elevationFeatures.push(St)}}else P.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((St,Lt)=>St.sortKey-Lt.sortKey)}getCombinedIconPrimary(d,m,v,k,E,P,O){let B,W;const J=d.getUnevaluatedProperties();if(J._values["icon-image"].value!==void 0){const te=m.getAppearanceValueAndResolveTokens(d,"icon-image",v,k,E);B=this.getResolvedImageFromTokens(te)}else{const te=m.getValueAndResolveTokens("icon-image",v,k,E);B=this.getResolvedImageFromTokens(te)}if(B){const te=J._values["icon-size"]||m._unevaluatedLayout._values["icon-size"];W=WP(B,T3(this.zoom,te,this.worldview),te,k,this.zoom,P,this.pixelRatio,O,this.worldview).iconPrimary}return W}updateAppearanceBasedIconTextures(d,m,v,k){if(!this.appearanceFeatureData||!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)return!1;const E=this.layers[0];let P=!1,O=0;const B=E.layout,[W,J]=B.get("icon-size-scale-range"),te=ve(1,W,J);for(let ie=0;ie=0){const Le=Ne.id,Ie=m&&Le!==void 0?m[String(Le)]:void 0,Ge={type:"Point",id:Ne.id,properties:Ne.properties,geometry:[]},Ze=this.layers[0].appearances&&this.layers[0].appearances.find(at=>at.isActive({globals:k,feature:Ge,canonical:d,featureState:Ie}));if(Ne.activeAppearance===Ze){O+=ce.numIconVertices;continue}if(Ze){Ne.activeAppearance=Ze;const at=this.getCombinedIconPrimary(Ze,E,Ge,d,v,{sortKey:void 0,text:void 0,icon:null,index:ce.featureIndex,sourceLayerIndex:ce.featureIndex,geometry:[],properties:Ne.properties,type:"Point",id:Ne.id},te);if(!at)continue;const vt=at.toString(),pt=this.iconAtlasPositions&&this.iconAtlasPositions.get(vt);if(pt){const St=E.getAppearanceValueAndResolveTokens(Ze,"icon-offset",Ge,d,v),Lt=St&&Array.isArray(St)?St:[0,0];let Bt=SF(pt,void 0,Lt,E.layout.get("icon-anchor").evaluate(Ge,{},d));const as=E.getAppearanceValueAndResolveTokens(Ze,"icon-rotate",Ge,d,v),Wt=typeof as=="number"?as:0,us=pt.sdf,bs=E.layout.get("icon-text-fit").constantOr("none");bs!=="none"&&Ne.textShaping&&Ne.iconTextFitPadding&&Ne.fontScale&&(Bt=Dpe(Bt,Ne.textShaping,bs,Ne.iconTextFitPadding,Lt,Ne.fontScale));const ws=this.calculateEffectiveAppearanceIconSize(Ze,k.zoom,Ge,d,v,te),Fs=0,Bs=1+(Math.min(uv,Math.round(ws*cx))<<1),Ds=zpe(Bt,Wt,us,bs!=="none",te);Ne.isUsingAppearanceVertexData||(Ne.isUsingAppearanceVertexData=!0,Ne.layoutBasedVertexData=this.icon.getIconVertexData(O,ce.numIconVertices));for(let ds=0;ds0&&(this.icon.updateIconVertexData(O,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(O+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(O+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(O+3,0,0,0,0,0,0,0,0,0,0,0,0),P=!0),O+=ce.numIconVertices,Ne.activeAppearance=null;else if(Ne.isUsingAppearanceVertexData){const vt=Ne.layoutBasedVertexData.length/12;for(let pt=0;pt0||ie>0,Le=ce>0,Ie=this.elevationFeatures[B.elevationFeatureIndex];if(Ie){const Ge=new es(B.tileAnchorX,B.tileAnchorY),Ze=.075+Ie.pointElevation(Ge);B.zOffset!==Ze&&(m=!0,B.zOffset=Ze),Ze!==0&&(this.hasAnyZOffset=!0);const at=Ie.computeSlopeNormal(Ge,k),vt=ps(He(),re(0,0,1),at);Je(W,W,vt),Je(J,J,vt),W[2]*=v,J[2]*=v,W[0]===1&&W[1]===0&&W[2]===0&&J[0]===0&&J[1]===1&&J[2]===0||(E=E||Ne,P=P||Le)}if(Ne&&(DF(this.text.orientationVertexArray,te,W,J),DF(this.text.orientationVertexArray,ie,W,J)),Le){const{placedIconSymbolIndex:Ge,verticalPlacedIconSymbolIndex:Ze}=B;Ge>=0&&DF(this.icon.orientationVertexArray,ce,W,J),Ze>=0&&DF(this.icon.orientationVertexArray,ue,W,J)}}E||(this.text.orientationVertexArray=void 0),P||(this.icon.orientationVertexArray=void 0),m&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const d=(E,P,O)=>{v+=P,v>E.length&&E.resize(v);for(let B=-P;B<0;B++)E.emplace(B+v,O)},m=(E,P,O)=>{k+=P,k>E.length&&E.resize(k);for(let B=-P;B<0;B++)E.emplace(B+k,O)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let v=0,k=0;for(let E=0;E0;if((O>0||B>0)&&(d(this.text.zOffsetVertexArray,O,J),d(this.text.zOffsetVertexArray,B,J)),te){const{placedIconSymbolIndex:ie,verticalPlacedIconSymbolIndex:ce}=P;ie>=0&&m(this.icon.zOffsetVertexArray,W,J),ce>=0&&m(this.icon.zOffsetVertexArray,P.numVerticalIconVertices,J)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(d,m,v,k,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,k){return!!(d&&m&&v)&&!(!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(d,m,v,k)&&this.icon.layoutVertexBuffer&&this.icon.layoutVertexArray.arrayBuffer!==null&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray))}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=v5e(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:k,y:E}of m)this.lineVertexArray.emplaceBack(k,E);return{lineStartIndex:v,lineLength:this.lineVertexArray.length-v}}addSymbols(d,m,v,k,E,P,O,B,W,J,te,ie,ce,ue,Ne,Le,Ie,Ge){const Ze=d.indexArray,at=d.layoutVertexArray,vt=d.globeExtVertexArray,pt=d.segments.prepareSegment(4*Ge,at,Ze,this.canOverlap?P.sortKey:void 0),St=this.glyphOffsetArray.length,Lt=pt.vertexLength,Bt=this.allowVerticalPlacement&&O===om.vertical?Math.PI/2:0,as=P.text&&P.text.sections;for(let bs=0;bs=0?m.rightJustifiedTextSymbolIndex:m.centerJustifiedTextSymbolIndex>=0?m.centerJustifiedTextSymbolIndex:m.leftJustifiedTextSymbolIndex>=0?m.leftJustifiedTextSymbolIndex:m.verticalPlacedTextSymbolIndex>=0?m.verticalPlacedTextSymbolIndex:k),P=Ope(this.textSizeData,d,E)/_c;return this.tilePixelRatio*P}getSymbolInstanceIconSize(d,m,v){const k=this.icon.placedSymbolArray.get(v),E=Ope(this.iconSizeData,d,k);return this.tilePixelRatio*E}_commitDebugCollisionVertexUpdate(d,m,v,k){d.emplaceBack(m,-v,-v,k),d.emplaceBack(m,v,-v,k),d.emplaceBack(m,v,v,k),d.emplaceBack(m,-v,v,k)}_updateTextDebugCollisionBoxes(d,m,v,k,E,P,O){for(let B=k;B0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(d,m){const v=d.placedSymbolArray.get(m),k=v.vertexStartIndex+4*v.numGlyphs;for(let E=v.vertexStartIndex;Ek[O]-k[B]||E[B]-E[O]),P}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let d=0;dthis.symbolInstances.get(m).zOffset-this.symbolInstances.get(d).zOffset)}addToSortKeyRanges(d,m){const v=this.sortKeyRanges[this.sortKeyRanges.length-1];v&&v.sortKey===m?v.symbolInstanceEnd=d+1:this.sortKeyRanges.push({sortKey:m,symbolInstanceStart:d,symbolInstanceEnd:d+1})}sortFeatures(d){if(this.sortFeaturesByY&&this.sortedAngle!==d&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(d),this.sortedAngle=d,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const m of this.symbolInstanceIndexes){const v=this.symbolInstances.get(m);this.featureSortOrder.push(v.featureIndex);const{rightJustifiedTextSymbolIndex:k,centerJustifiedTextSymbolIndex:E,leftJustifiedTextSymbolIndex:P,verticalPlacedTextSymbolIndex:O,placedIconSymbolIndex:B,verticalPlacedIconSymbolIndex:W}=v;k>=0&&this.addIndicesForPlacedSymbol(this.text,k),E>=0&&E!==k&&this.addIndicesForPlacedSymbol(this.text,E),P>=0&&P!==E&&P!==k&&this.addIndicesForPlacedSymbol(this.text,P),O>=0&&this.addIndicesForPlacedSymbol(this.text,O),B>=0&&this.addIndicesForPlacedSymbol(this.icon,B),W>=0&&this.addIndicesForPlacedSymbol(this.icon,W)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getElevationFeatureForText(d){const m=this.symbolInstances.get(this.text.symbolInstanceIndices[d]).elevationFeatureIndex;let v;return this.elevationFeatures&&mv in g?String(g[v]):"")}let b5e,w5e,Hpe;_r(OF,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),OF.addDynamicAttributes=L3;class j5e{constructor(d){this.type=d.property.overrides?d.property.overrides.runtimeType:Ep,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}}_r(j5e,"FormatSectionOverride",{omit:["defaultValue"]});const Wpe=()=>Hpe||(Hpe={layout:b5e||(b5e=new Mo({"symbol-placement":new Ks(Gt.layout_symbol["symbol-placement"]),"symbol-spacing":new Ks(Gt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Ks(Gt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ir(Gt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Ks(Gt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Ks(Gt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Ks(Gt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Ks(Gt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Ks(Gt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Ks(Gt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Ks(Gt.layout_symbol["icon-rotation-alignment"]),"icon-size":new ir(Gt.layout_symbol["icon-size"]),"icon-size-scale-range":new Ks(Gt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new ir(Gt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ir(Gt.layout_symbol["icon-text-fit-padding"]),"icon-image":new ir(Gt.layout_symbol["icon-image"]),"icon-image-use-theme":new Ks({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new ir(Gt.layout_symbol["icon-rotate"]),"icon-padding":new Ks(Gt.layout_symbol["icon-padding"]),"icon-keep-upright":new Ks(Gt.layout_symbol["icon-keep-upright"]),"icon-offset":new ir(Gt.layout_symbol["icon-offset"]),"icon-anchor":new ir(Gt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Ks(Gt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Ks(Gt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Ks(Gt.layout_symbol["text-rotation-alignment"]),"text-field":new ir(Gt.layout_symbol["text-field"]),"text-font":new ir(Gt.layout_symbol["text-font"]),"text-size":new ir(Gt.layout_symbol["text-size"]),"text-size-scale-range":new Ks(Gt.layout_symbol["text-size-scale-range"]),"text-max-width":new ir(Gt.layout_symbol["text-max-width"]),"text-line-height":new ir(Gt.layout_symbol["text-line-height"]),"text-letter-spacing":new ir(Gt.layout_symbol["text-letter-spacing"]),"text-justify":new ir(Gt.layout_symbol["text-justify"]),"text-radial-offset":new ir(Gt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Ks(Gt.layout_symbol["text-variable-anchor"]),"text-anchor":new ir(Gt.layout_symbol["text-anchor"]),"text-max-angle":new Ks(Gt.layout_symbol["text-max-angle"]),"text-writing-mode":new Ks(Gt.layout_symbol["text-writing-mode"]),"text-rotate":new ir(Gt.layout_symbol["text-rotate"]),"text-padding":new Ks(Gt.layout_symbol["text-padding"]),"text-keep-upright":new Ks(Gt.layout_symbol["text-keep-upright"]),"text-transform":new ir(Gt.layout_symbol["text-transform"]),"text-offset":new ir(Gt.layout_symbol["text-offset"]),"text-allow-overlap":new Ks(Gt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Ks(Gt.layout_symbol["text-ignore-placement"]),"text-optional":new Ks(Gt.layout_symbol["text-optional"]),visibility:new Ks(Gt.layout_symbol.visibility)})),paint:w5e||(w5e=new Mo({"icon-opacity":new ir(Gt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ir(Gt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ir(Gt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ir(Gt.paint_symbol["text-emissive-strength"]),"icon-color":new ir(Gt.paint_symbol["icon-color"]),"icon-halo-color":new ir(Gt.paint_symbol["icon-halo-color"]),"icon-halo-width":new ir(Gt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ir(Gt.paint_symbol["icon-halo-blur"]),"icon-translate":new Ks(Gt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Ks(Gt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Ks(Gt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ir(Gt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ir(Gt.paint_symbol["text-occlusion-opacity"]),"text-color":new ir(Gt.paint_symbol["text-color"],{runtimeType:sh,getOverride:g=>g.textColor,hasOverride:g=>!!g.textColor}),"text-halo-color":new ir(Gt.paint_symbol["text-halo-color"]),"text-halo-width":new ir(Gt.paint_symbol["text-halo-width"]),"text-halo-blur":new ir(Gt.paint_symbol["text-halo-blur"]),"text-translate":new Ks(Gt.paint_symbol["text-translate"]),"text-translate-anchor":new Ks(Gt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Ks(Gt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Ks(Gt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Ks(Gt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Ks(Gt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ir(Gt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"})}))},Hpe);class RF extends Eu{constructor(d,m,v,k){super(d,Wpe(),m,v,k,d.layout?d.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=j([]),this.hasOcclusionOpacityProperties=d.paint!==void 0&&("icon-occlusion-opacity"in d.paint||"text-occlusion-opacity"in d.paint)}_handleSpecialPaintPropertyUpdate(d){d!=="icon-occlusion-opacity"&&d!=="text-occlusion-opacity"||(this.hasOcclusionOpacityProperties=!0)}recalculate(d,m){super.recalculate(d,m),this.appearances&&this.appearances.forEach(k=>{k.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 k=[];for(const E of v)k.indexOf(E)<0&&k.push(E);this.layout._values["text-writing-mode"]=k}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(d,m,v,k){return this._saturation===d&&this._contrast===m&&this._brightnessMin===v&&this._brightnessMax===k||(this._colorAdjustmentMatrix=function(E,P,O,B){E=ao(E),P=Na(P);const W=b(),J=E/3,te=1-2*J,ie=[te,J,J,0,J,te,J,0,J,J,te,0,0,0,0,1],ce=.5-.5*P,ue=B-O;return S(W,[ue,0,0,0,0,ue,0,0,0,0,ue,0,O,O,O,1],[P,0,0,0,0,P,0,0,0,0,P,0,ce,ce,ce,1]),S(W,W,ie),W}(d,m,v,k),this._saturation=d,this._contrast=m,this._brightnessMin=v,this._brightnessMax=k),this._colorAdjustmentMatrix}getValueAndResolveTokens(d,m,v,k){const E=this.layout.get(d).evaluate(m,{},v,k),P=this._unevaluatedLayout._values[d];return P.isDataDriven()||sw(P.value)||!E?E:_5e(m.properties,E)}getAppearanceValueAndResolveTokens(d,m,v,k,E){const P=d.getProperty(m);if(!P)return;const O=P.evaluate(v,{},k,E),B=d.getUnevaluatedProperties()._values[m];return B.isDataDriven()||sw(B.value)||!O||typeof O!="string"?O:_5e(v.properties,O)}createBucket(d){return new OF(d)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const d of Wpe().paint.overridableProperties){if(!RF.hasPaintOverride(this.layout,d))continue;const m=this.paint.get(d),v=new j5e(m),k=new $C(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 e_("source",k):new Q0("composite",k,m.value.zoomStops,m.value.interpolationType),this.paint._values[d]=new ev(m.property,E,m.parameters)}}_handleOverridablePaintPropertyUpdate(d,m,v){return!(!this.layout||m.isDataDriven()||v.isDataDriven())&&RF.hasPaintOverride(this.layout,d)}static hasPaintOverride(d,m){const v=d.get("text-field"),k=Wpe().paint.properties[m];let E=!1;const P=O=>{for(const B of O)if(k.overrides&&k.overrides.hasOverride(B))return void(E=!0)};if(v.value.kind==="constant"&&v.value.value instanceof Cu)P(v.value.value.sections);else if(v.value.kind==="source"){const O=W=>{E||(W instanceof Gg&&vc(W.value)===$2?P(W.value.sections):W instanceof Ef?P(W.sections):W.eachChild(O))},B=v.value;B._styleExpression&&O(B._styleExpression.expression)}return E}getProgramIds(){return["symbol"]}getDefaultProgramParams(d,m,v){return{config:new My(this,{zoom:m,lut:v}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let k5e,N5e,S5e,C5e;var Gpe=la([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function FF(g,d,m,v,k,E,P,O){const B=[g,d,1,m,v,1,k,E,1],W=[P,O,1],J=y([],B),[te,ie,ce]=pe(W,W,J);return _(B,B,[te,0,0,0,ie,0,0,0,ce])}function M5e(g,d,m,v,k,E,P,O){const B=function(W,J,te,ie,ce,ue,Ne,Le){const Ie=FF(0,0,1,0,1,1,0,1),Ge=FF(W,J,te,ie,ce,ue,Ne,Le);return _(Ge,Ge,y([],Ie))}(g,d,m,v,k,E,P,O);return[B[2]/B[8]/Qs,B[5]/B[8]/Qs]}function zF(g){return[g[0],Math.min(Math.max(g[1],-xe),xe)]}class T5e extends Ts{constructor(d,m,v,k){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(k),this.options=m,this._dirty=!1}load(d,m){if(this._loaded=m||!1,this.fire(new qm("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return d&&(this.coordinates=d),this._loaded=!0,void this._finishLoading();this._imageRequest=hy(this.map._requestManager.transformRequest(this.url,Ug.Image),(v,k)=>{this._imageRequest=null,this._loaded=!0,v?this.fire(new my(v)):k&&(this.image=k instanceof HTMLImageElement?Pl.getImageData(k):k,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 zP(this.map.painter.context,d.handle),this.width=d.dimensions[0],this.height=d.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new qm("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(d){this.map=d,this.load()}onRemove(d){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof zP||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]xe?this.onNorthPole=!0:k<-xe&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const E=d.map(et.fromLngLat);this.tileID=function(P){let O=1/0,B=1/0,W=-1/0,J=-1/0;for(const Ne of P)O=Math.min(O,Ne.x),B=Math.min(B,Ne.y),W=Math.max(W,Ne.x),J=Math.max(J,Ne.y);const te=Math.max(W-O,J-B),ie=Math.max(0,Math.floor(-Math.log2(te))),ce=Math.pow(2,ie);let ue=Math.floor((O+W)/2*ce);return ue>1&&(ue-=1),new Ei(ie,ue,Math.floor((B+J)/2*ce))}(E),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new qm("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof zP||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(d){for(const Ie in this.tiles){const Ge=this.tiles[Ie];Ge.state!=="loaded"&&(Ge.state="loaded",Ge.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const m=KP(new Ei(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(Ie){const Ge=Ie[1].x-Ie[0].x,Ze=Ie[1].y-Ie[0].y,at=Ie[2].x-Ie[1].x,vt=Ie[2].y-Ie[1].y,pt=Ie[3].x-Ie[2].x,St=Ie[3].y-Ie[2].y,Lt=Ie[0].x-Ie[3].x,Bt=Ie[0].y-Ie[3].y,as=Ge*vt-at*Ze,Wt=at*St-pt*vt,us=pt*Bt-Lt*St,bs=Lt*Ze-Ge*Bt;return as>0&&Wt>0&&us>0&&bs>0||as<0&&Wt<0&&us<0&&bs<0}(v))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const k=KP(this.tileID,this.map.transform.projection),[E,P,O,B]=this.coordinates.map(Ie=>{const Ge=k.projection.project(Ie[0],Ie[1]);return p5e(k,Ge)._round()});this.perspectiveTransform=M5e(E.x,E.y,P.x,P.y,O.x,O.y,B.x,B.y);const W=this._boundsArray=new n_;W.emplaceBack(E.x,E.y,0,0),W.emplaceBack(P.x,P.y,Qs,0),W.emplaceBack(B.x,B.y,0,Qs),W.emplaceBack(O.x,O.y,Qs,Qs),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=d.createVertexBuffer(W,Gpe.members),this.boundsSegments=xo.simpleSegment(0,0,4,2);const J=[],te=[zF((ie=this.coordinates)[0]),zF(ie[1]),zF(ie[2]),zF(ie[3])];var ie;const[ce,ue,Ne,Le]=function(Ie){let Ge=Ie[0][0],Ze=Ge,at=Ie[0][1],vt=at;for(let pt=1;ptZe&&(Ze=Ie[pt][0]),Ie[pt][1]vt&&(vt=Ie[pt][1]);return[Ge,at,Ze-Ge,vt-at]}(te);{const Ie=new n_,[Ge,Ze,at,vt]=function(Ds){let Os=Ds[0].x,ds=Os,is=Ds[0].y,Rs=is;for(let Js=1;Jsds&&(ds=Ds[Js].x),Ds[Js].yRs&&(Rs=Ds[Js].y);return[Os,is,ds-Os,Rs-is]}(v),pt=Ds=>[(Ds.x-Ge)/at,(Ds.y-Ze)/vt],[St,Lt,Bt,as]=v.map(pt),Wt=function(Ds,Os,ds,is,Rs,Js,Hs,Dr){const ur=FF(0,0,1,0,1,1,0,1);return _(ur,ur,y([],FF(Ds,Os,ds,is,Rs,Js,Hs,Dr)))}(St[0],St[1],Lt[0],Lt[1],Bt[0],Bt[1],as[0],as[1]);this.elevatedGlobePerspectiveTransform=M5e(St[0],St[1],Lt[0],Lt[1],Bt[0],Bt[1],as[0],as[1]);const us=(Ds,Os)=>{J.push(Ds.lng);const ds=Math.round((Ds.lng-ce)/Ne*Qs),is=Math.round((Ds.lat-ue)/Le*Qs),Rs=pt(Os),Js=pe([],[Rs[0],Rs[1],1],Wt),Hs=Math.round(Js[0]/Js[2]*Qs),Dr=Math.round(Js[1]/Js[2]*Qs);Ie.emplaceBack(ds,is,Hs,Dr)},bs=v[3].x-v[0].x,ws=v[3].y-v[0].y,Fs=v[2].x-v[1].x,Bs=v[2].y-v[1].y;for(let Ds=0;Ds<65;Ds++){const Os=Ds/64,ds=[v[0].x+Os*bs,v[0].y+Os*ws],is=[v[1].x+Os*Fs,v[1].y+Os*Bs],Rs=is[0]-ds[0],Js=is[1]-ds[1];for(let Hs=0;Hs<65;Hs++){const Dr=Hs/64,ur={x:ds[0]+Rs*Dr,y:ds[1]+Js*Dr};us(m.projection.unproject(ur.x,ur.y),ur)}}this.elevatedGlobeVertexBuffer=d.createVertexBuffer(Ie,Gpe.members)}{this.maxLongitudeTriangleSize=0;let Ie=[],Ge=new Il;const Ze=(at,vt,pt)=>{Ge.emplaceBack(at,vt,pt);const St=J[at],Lt=J[vt],Bt=J[pt],as=Math.min(Math.min(St,Lt),Bt),Wt=Math.max(Math.max(St,Lt),Bt)-as;Wt>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Wt),Ie.push(as+Wt/2)};for(let at=0;at<64;at++)for(let vt=0;vt<64;vt++){const pt=65*at+vt,St=pt+1,Lt=pt+65,Bt=Lt+1;Ze(pt,Lt,St),Ze(St,Lt,Bt)}[Ie,Ge]=function(at,vt){const pt=Array.from({length:at.length},(Bt,as)=>as);pt.sort((Bt,as)=>at[Bt]-at[as]);const St=[],Lt=new Il;for(let Bt=0;Bt{P.segments.push({vertexOffset:0,primitiveOffset:te,vertexLength:m.segments[0].vertexLength,primitiveLength:ie,sortKey:void 0,vaos:{}})},B=.51*this.maxLongitudeTriangleSize;if(Math.abs(v[0]-k)<=B){const te=no(v,0,v.length,k+B);return te===v.length||O(te,nl(v,te+1,v.length,k+360-B)-te),P}kQs?k-Qs:k,new es(Math.trunc(k),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 Ype{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,k){}populate(d,m,v,k){this.tileToMeter=Be(v);const E=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:P,id:O,index:B,sourceLayerIndex:W}of d){const J=O??(P.properties&&P.properties.hasOwnProperty("id")?P.properties.id:void 0),te=Ht(P,E);if(!this.layers[0]._featureFilter.filter(new Hi(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),te,v))continue;const ie={id:J,sourceLayerIndex:W,index:B,geometry:E?te.geometry:Pt(P,v,k),properties:P.properties,type:P.type,patterns:{}},ce=this.addFeature(ie,ie.geometry,te);ce&&m.featureIndex.insert(P,ie.geometry,B,W,this.index,this.instancesPerModel[ce].instancedDataArray.length,Qs/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const d=this.layers[0].modelManager,m=this.layers[0].scope;let v=0;for(const k of this.modelUris){const E=d.getModel(k,m);if(!E)continue;const P=this.instancesPerModel[k];if(P){const O=.5*be(E.aabb.max,E.aabb.min)*P.maxScale+P.maxXYTranslationDistance,B=Math.min(Qs,Math.max(O/this.tileToMeter,Qs/32));v=Math.max(B,v)}}return v}update(d,m,v,k){for(const E in this.instancesPerModel){const P=this.instancesPerModel[E];for(const O in d)P.idToFeaturesIndex.hasOwnProperty(O)&&(this.evaluate(P.features[P.idToFeaturesIndex[O]],d[O],P,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let d=!1;for(const m in this.instancesPerModel){const v=this.instancesPerModel[m];for(const k of v.features){const E=this.layers[0],P=k.feature,O=this.canonical,B=E.paint.get("model-rotation").evaluate(P,{},O),W=E.paint.get("model-scale").evaluate(P,{},O),J=E.paint.get("model-translation").evaluate(P,{},O);rt(k.rotation,B)&&rt(k.scale,W)&&rt(k.translation,J)||(this.evaluate(k,k.featureStates,v,!0),d=!0)}}return d}updateReplacement(d,m,v,k){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const E=m.getReplacementRegionsForTile(d.toUnwrapped(),!0);if(dF(this.activeReplacements,E))return!1;this.activeReplacements=E;let P=!1;for(const O in this.instancesPerModel){const B=this.instancesPerModel[O],W=B.instancedDataArray;for(const J of B.features){const te=J.instancedDataOffset,ie=J.instancedDataCount;for(let ce=0;ceQs;Ne=Le?Ne-Qs:Ne;const Ie=Math.floor(Ne),Ge=Math.floor(W.float32[ue+1]);let Ze=!1;for(const at of this.activeReplacements)if(!NCe(at,v,R5e.Model,k)&&!(at.min.x>Ie||Ie>at.max.x||at.min.y>Ge||Ge>at.max.y)&&(Ze=ACe(TCe(Ie,Ge,d.canonical,at.footprintTileId.canonical),at.footprint),Ze))break;W.float32[ue]=Ze?Ne+Qs:Ne,P=P||Ze!==Le}}}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,Bct.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(d){for(const v in this.instancesPerModel){const k=this.instancesPerModel[v];k.instancedDataArray.length!==0&&k.instancedDataBuffer&&k.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 k=this.layers[0],E=k.layout.get("model-id").evaluate(v,{},this.canonical);if(!E)return hr(`modelId is not evaluated for layer ${k.id} and it is not going to get rendered.`),E;(Zpe(E,!1)||this.styleDefinedModelURLs[E]!==void 0)&&(this.modelUris.includes(E)||this.modelUris.push(E)),this.instancesPerModel[E]||(this.instancesPerModel[E]=new z5e);const P=this.instancesPerModel[E],O=P.instancedDataArray,B=new F5e(v,O.length);for(const W of m)for(const J of W){if(J.x<0||J.x>=Qs||J.y<0||J.y>=Qs)continue;if(this.lookupDim!==0){const ie=(this.lookupDim-1)/Qs,ce=this.lookupDim*(J.y*ie|0)+J.x*ie|0;if(this.lookup){if(this.lookup[ce]!==0)continue;this.lookup[ce]=1}}this.instanceCount++;const te=O.length;O.resize(te+1),P.instancesEvaluatedElevation.push(0),O.float32[16*te]=J.x,O.float32[16*te+1]=J.y}return B.instancedDataCount=P.instancedDataArray.length-B.instancedDataOffset,B.instancedDataCount>0&&(d.id&&(P.idToFeaturesIndex[d.id]=P.features.length),P.features.push(B),this.evaluate(B,{},P,!1)),E}getModelUris(){return this.modelUris}evaluate(d,m,v,k){const E=this.layers[0],P=d.feature,O=this.canonical,B=d.rotation=E.paint.get("model-rotation").evaluate(P,m,O),W=d.scale=E.paint.get("model-scale").evaluate(P,m,O),J=d.translation=E.paint.get("model-translation").evaluate(P,m,O),te=Object.assign({},E.paint.get("model-color").evaluate(P,m,O));te.a=E.paint.get("model-color-mix-intensity").evaluate(P,m,O);const ie=[];this.maxVerticalOffset0?Math.sqrt(ce):0;v.maxScale=Math.max(Math.max(v.maxScale,W[0]),Math.max(W[1],W[2])),v.maxXYTranslationDistance=Math.max(v.maxXYTranslationDistance,ue),this.maxScale=Math.max(Math.max(this.maxScale,W[0]),Math.max(W[1],W[2])),g3e(ie,B,W);const Ne=Math.round(100*te.a)+te.b/1.05;for(let Le=0;Le10?this.tileToMeter:Be(O,vt)),Ze[Ge+4]=J[0],Ze[Ge+5]=J[1],Ze[Ge+6]=J[2]+at,Ze[Ge+7]=ie[0],Ze[Ge+8]=ie[1],Ze[Ge+9]=ie[2],Ze[Ge+10]=ie[4],Ze[Ge+11]=ie[5],Ze[Ge+12]=ie[6],Ze[Ge+13]=ie[8],Ze[Ge+14]=ie[9],Ze[Ge+15]=ie[10],v.instancesEvaluatedElevation[Ie]=J[2]}}}let B5e,$5e;_r(Ype,"ModelBucket",{omit:["layers"]}),_r(z5e,"PerModelAttributes"),_r(F5e,"ModelFeature");class D3{constructor(d,m,v){this._demTile=d,this._dem=this._demTile.dem,this._scale=m,this._offset=v}static create(d,m,v){const k=v||d.findDEMTileFor(m);if(!k||!k.dem)return;const E=k.dem,P=k.tileID,O=1<W.fqid),this.stateDependentLayerIds=this.layers.filter(W=>W.isStateDependent()).map(W=>W.id),this.modelTraits|=S3.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,k&&(this.modelTraits|=S3.HasMapboxMeshFeatures),E&&(this.modelTraits|=S3.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=P,this.worldview=B,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const W of m)this.nodesInfo.push(new H5e(W)),U5e(W,O.featureIndexArray.length,O.grid),O.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,O.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(d,m){for(const v of this.getNodesInfo()){const k=v.node;k.footprint&&m.push({footprint:k.footprint,id:d})}}updateAppearances(d,m,v,k){}update(d){const m=Object.keys(d).length!==0;if(m&&!this.stateDependentLayers.length)return;const v=m?this.stateDependentLayers:this.layers;if(!an(d,this.states))for(const k of v)this.evaluate(k,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 k=v.node;this.uploaded?this.updatePbrBuffer(k):bpe(k,d,!0)}for(const v of m)wF(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 k=d.transform.projectionOptions,E=d.style.getBrightness(),P=this.brightness!==E;if(!this.uploaded||this.dirty||k.name!==this.projection.name||s6(v.paint.get("model-color").value,P)||s6(v.paint.get("model-color-mix-intensity").value,P)||s6(v.paint.get("model-roughness").value,P)||s6(v.paint.get("model-emissive-strength").value,P)||s6(v.paint.get("model-height-based-emissive-strength-multiplier").value,P)){this.projection=k,this.brightness=E;const O=this.getNodesInfo();for(const B of O)B.state=null;return!0}return!1}evaluateTransform(d,m){if(d.transform.zoom===this.zoom)return;this.zoom=d.transform.zoom;const v=this.getNodesInfo(),k=this.id.canonical;for(const E of v){const P=E.feature;E.evaluatedTranslation=m.paint.get("model-translation").evaluate(P,{},k),E.evaluatedScale=m.paint.get("model-scale").evaluate(P,{},k)}}evaluate(d,m){const v=this.getNodesInfo();for(const k of v){if(!k.node.meshes)continue;const E=k.feature,P=m&&m[E.id];if(an(P,k.state))continue;k.state=structuredClone(P);const O=k.node.meshes&&k.node.meshes[0].featureData,B=k.evaluatedColor[2],W=k.evaluatedRMEA[2],J=this.id.canonical;if(k.hasTranslucentParts=!1,O){for(let te=0;te=pt)continue;const Ds=Xpe[Bs],Os=Math.abs(Ds);Os>Wt&&(as=Ds,Wt=Os,us=Fs,bs=ws)}if(Wt>.1){const ws=1-(pt+.5*Math.abs(us*bs))/ue;let Fs=m._dem.get(Lt,St)+as*ws;const Bs=m._dem.get(Lt+us,St+bs),Ds=m._dem.get(Lt-us,St-bs,!0);(Fs-Bs)*(Fs-Ds)>0&&(Fs=(Bs+Ds)/2),Xpe[Bt]=m._dem.set(Lt,St,Fs),kw[Bt]=pt}}}}}O&&(m._demTile.needsDEMTextureUpload=!0,m._dem._timestamp=Pl.now())}setFilter(d){this.filter=d?YC(d):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(d=>this.filter.filter(new Hi(this.id.overscaledZ,{worldview:this.worldview}),d.feature,this.id.canonical)):this.nodesInfo}destroy(){const d=this.getNodesInfo();for(const m of d)wF(m.node),wpe(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 k of this.getNodesInfo()){const E=k.node.footprint;k.hiddenByReplacement=!!E&&!v.find(P=>P.footprint===E)}}getHeightAtTileCoord(d,m){const v=[],k=[0,0,0],E=j([]);for(const P of this.getNodesInfo()){const O=P.node.meshes[0],B=O.transformedAabb;if(dB.max[0]||m>B.max[1])continue;if(P.node.hidden===!0)return{height:1/0,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};N(E,P.node.globalMatrix),k[0]=d,k[1]=m,Rt(k,k,E);const W=(k[0]-O.aabb.min[0])/(O.aabb.max[0]-O.aabb.min[0])*bw|0,J=Math.min(63,(k[1]-O.aabb.min[1])/(O.aabb.max[1]-O.aabb.min[1])*bw|0)*bw+Math.min(63,W),te=O.heightmap[J];if(!(te<0&&P.node.footprint))return P.hiddenByReplacement?void 0:{height:te,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};if(P.node.footprint.grid.query(new es(d,m),new es(d,m),v),v.length>0)return{height:void 0,maxHeight:P.feature.properties.height,hidden:P.hiddenByReplacement,verticalScale:P.evaluatedScale[2]}}}}function s6(g,d){return g instanceof e_&&!g.isLightConstant&&d}function yut(g,d,m,v,k,E,P,O){let B=(61440&d|(61440&d)>>4)>>8,W=(3840&d|(3840&d)>>4)>>4,J=240&d|(240&d)>>4;m[3]>0&&(B=Hr(B,255*m[0],m[3]),W=Hr(W,255*m[1],m[3]),J=Hr(J,255*m[2],m[3]));const te=B<<8|W,ie=J<<8|Math.floor(255*v[3]),ce=function(pt){const St=ve(pt,0,2);return Math.min(Math.round(.5*St*255),255)}(v[2])<<8|15*v[0]<<4|15*v[1],ue=ve(k[0],0,1),Ne=ve(k[1],0,1),Le=ve(k[2],0,1),Ie=ve(k[3],0,1);let Ge,Ze,at,vt;if(ue!==Ne&&P!==E&&Ne!==ue){const pt=P-E;Ze=1/(pt*(Ne-ue)),at=-(E+pt*ue)/(pt*(Ne-ue));const St=ve(k[4],-1,1);vt=Math.pow(10,St),Ge=255*Le<<8|255*Ie}else Ge=65535,Ze=0,at=1,vt=1;if(g.emplaceBack(te,ie,ce,Ge,Ze,at,vt),O){const pt=O.length;O.clear();for(let St=0;St>16&65535,J=E?B>>16&65535:65535&B,te=(15&J)<8?15&J:0,ie=g.evaluatedRMEA[te],ce=g.evaluatedColor[te],ue=g.emissionHeightBasedParams[te];let Ne;if(O&&te===2&&v.lights&&(Ne=new o3,Ne.resize(10*v.lights.length)),yut(P.featureArray,W,ce,ie,ue,P.aabb.min[2],P.aabb.max[2],Ne),Ne&&O){O=!1;const Le=v.meshes[v.lightMeshIndex];Le.featureArray=Ne,Le.featureArray._trim()}}P.featureArray._trim(),k++}}_r($F,"Tiled3dModelBucket",{omit:["layers"]}),_r(H5e,"Tiled3dModelFeature");const _ut=["id","tile","layer","source","sourceLayer","state"];class Nw{constructor(d,m,v,k,E){this.type="Feature",this._vectorTileFeature=d,this._z=m,this._x=v,this._y=k,this.properties=d?d.properties:{},this.id=E}clone(){const d=new Nw(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 _ut)this[m]!==void 0&&(d[m]=this[m]);return d}}class Sw extends Ts{constructor(d,m,v,k){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],k=this._modelsInfo.get(m);if(k){const E=k.model;E.position=v.position!=null?new x(v.position[0],v.position[1]):new x(0,0),E.orientation=v.orientation!=null?v.orientation:[0,0,0],k.modelSpec=v,Sw.applyModelSpecification(E,v),E.computeBoundsAndApplyParent(),this.models.push(E)}else{const E=h3e(this.map._requestManager.transformRequest(v.uri,Ug.Model).url).then(P=>{if(!P)return;const O=kpe(P),B=new x3e(m,v.uri,v.position,v.orientation,O);Sw.applyModelSpecification(B,v),B.computeBoundsAndApplyParent(),this.models.push(B),this._modelsInfo.set(m,{modelSpec:v,model:B})}).catch(P=>{this.fire(new my(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 qm("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(m=>{this._loaded=!0,this.fire(new my(new Error(`Could not load models: ${m.message}`)))})}static applyModelSpecification(d,m){m.nodeOverrides&&Sw.convertNodeOverrides(d,m.nodeOverrides),m.materialOverrides&&Sw.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,k])=>{const E={orientation:[0,0,0]};if(k.hasOwnProperty("orientation")){const P=k.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,k])=>{const E={color:new Fr(1,1,1),colorMix:0,emissionStrength:0,opacity:1},P=k["model-color"];P!==void 0&&(E.color.r=P[0],E.color.g=P[1],E.color.b=P[2]);const O=k["model-color-mix-intensity"];O!==void 0&&(E.colorMix=O);const B=k["model-emissive-strength"];B!==void 0&&(E.emissionStrength=B);const W=k["model-opacity"];W!==void 0&&(E.opacity=W),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=Dp(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 k=d[v];if(this._modelsInfo.has(v)){const E=this._modelsInfo.get(v);E&&E.modelSpec.uri===k.uri&&m.set(v,E)}}this._modelsInfo=m,this._options.models=d,this._loaded=!1,this.load()}}function Qpe(g,d,m,v){const k=1<at.polygon).flat());const Le=ce?O:null,[Ie,Ge]=e3e(E,v,te,J,W,P,Le,ie,ue,E.center.lat,g.tileID.canonical),Ze=g.queryGeometry;return JCe(Ie,Ge,Ze.isPointQuery()?Ze.screenBounds:Ze.screenGeometry)}},building:class extends Eu{constructor(g,d,m,v){super(g,{layout:k3e||(k3e=new Mo({visibility:new Ks(Gt.layout_building.visibility),"building-facade":new ir(Gt.layout_building["building-facade"]),"building-facade-floors":new ir(Gt.layout_building["building-facade-floors"]),"building-facade-unit-width":new ir(Gt.layout_building["building-facade-unit-width"]),"building-facade-window":new ir(Gt.layout_building["building-facade-window"]),"building-roof-shape":new ir(Gt.layout_building["building-roof-shape"]),"building-height":new ir(Gt.layout_building["building-height"]),"building-base":new ir(Gt.layout_building["building-base"]),"building-flood-light-wall-radius":new ir(Gt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new ir(Gt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new ir(Gt.layout_building["building-flip-roof-orientation"])})),paint:N3e||(N3e=new Mo({"building-opacity":new Ks(Gt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Ks(Gt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Ks(Gt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Ks(Gt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Ks(Gt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Ks(Gt.paint_building["building-vertical-scale"]),"building-cast-shadows":new Ks(Gt.paint_building["building-cast-shadows"]),"building-color":new ir(Gt.paint_building["building-color"]),"building-emissive-strength":new ir(Gt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Ks(Gt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Ks(Gt.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Ks(Gt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Ks(Gt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Ks(Gt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new ir({type:"string",default:"default","property-type":"data-driven"})}))},d,m,v),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(g){return new j3e(g)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(g){return!0}queryRadius(g){return 0}queryIntersectsFeature(g,d,m,v,k,E,P,O,B){let W=this.layout.get("building-height").evaluate(d,m);const J=this.layout.get("building-base").evaluate(d,m),te=g.tile.getBucket(this).getFootprint(d);if(te){if(te.hiddenFlags!==0)return!1;W=te.height}const[ie,ce]=e3e(E,v,J,W,new es(0,0),P,null,[0,0],1,E.center.lat,g.tileID.canonical),ue=g.queryGeometry;return JCe(ie,ce,ue.isPointQuery()?ue.screenBounds:ue.screenGeometry)}},line:class extends Eu{constructor(g,d,m,v){const k=D3e();super(g,k,d,m,v),k.layout&&(this.layout=new tv(k.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(g){if(g==="line-gradient"){const d=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=d._styleExpression&&d._styleExpression.expression instanceof Y2,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(g,d){super.recalculate(g,d),this.paint._values["line-floorwidth"]=(()=>{if($P)return $P;const m=D3e();return $P=new gdt(m.paint.properties["line-width"].specification),$P.useIntegerZoom=!0,$P})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,g)}createBucket(g){return new Cpe(g)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(g,d,m){const v=I3e(this);return{config:new My(this,{zoom:d,lut:m}),defines:v,overrideFog:!1}}queryRadius(g){const d=g,m=O3e(Fd("line-width",this,d),Fd("line-gap-width",this,d)),v=Fd("line-offset",this,d);return m/2+Math.abs(v)+Qc(this.paint.get("line-translate"))}queryIntersectsFeature(g,d,m,v,k,E){if(g.queryGeometry.isAboveHorizon)return!1;const P=am(g.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),E.angle,g.pixelToTileUnitsFactor),O=g.pixelToTileUnitsFactor/2*O3e(this.paint.get("line-width").evaluate(d,m),this.paint.get("line-gap-width").evaluate(d,m)),B=this.paint.get("line-offset").evaluate(d,m);return B&&(v=function(W,J){const te=[],ie=new es(0,0);for(let ce=0;ce=3){for(let ue=0;ue>16&255)/255,(g>>8&255)/255,(255&g)/255,1)}function Dut(g,d,m){g===1?(d.rgb_color=HF(m.readVarint()),d.paint="rgb_color"):g===2?(d.linear_gradient_idx=m.readVarint(),d.paint="linear_gradient_idx"):g===3?(d.radial_gradient_idx=m.readVarint(),d.paint="radial_gradient_idx"):g===5?m.readPackedFloat(d.dasharray):g===6?d.dashoffset=m.readFloat():g===7?d.miterlimit=m.readFloat():g===8?d.opacity=m.readVarint():g===9?d.width=m.readFloat():g===10?d.linecap=m.readVarint():g===11&&(d.linejoin=m.readVarint())}function Out(g,d,m){g===1?d.transform=VF(m,m.readVarint()+m.pos):g===2?d.spread_method=m.readVarint():g===3?d.stops.push(Z5e(m,m.readVarint()+m.pos)):g===4?d.x1=m.readFloat():g===5?d.y1=m.readFloat():g===6?d.x2=m.readFloat():g===7&&(d.y2=m.readFloat())}function Z5e(g,d){return g.readFields(Rut,{offset:0,opacity:255,rgb_color:Jpe},d)}function Rut(g,d,m){g===1?d.offset=m.readFloat():g===2?d.opacity=m.readVarint():g===3&&(d.rgb_color=HF(m.readVarint()))}function Fut(g,d,m){g===1?d.transform=VF(m,m.readVarint()+m.pos):g===2?d.spread_method=m.readVarint():g===3?d.stops.push(Z5e(m,m.readVarint()+m.pos)):g===4?d.cx=m.readFloat():g===5?d.cy=m.readFloat():g===6?d.r=m.readFloat():g===7?d.fx=m.readFloat():g===8?d.fy=m.readFloat():g===9&&(d.fr=m.readFloat())}function zut(g,d,m){g===1?d.transform=VF(m,m.readVarint()+m.pos):g===2?d.clip_path_idx=m.readVarint():g===3&&d.children.push(UF(m,m.readVarint()+m.pos))}function But(g,d,m){g===1?d.left=d.top=m.readFloat():g===2?d.width=d.height=m.readFloat():g===3?d.top=m.readFloat():g===4?d.height=m.readFloat():g===5?d.mask_type=m.readVarint():g===6?d.mask_idx=m.readVarint():g===7&&d.children.push(UF(m,m.readVarint()+m.pos))}class $ut{static calculate(d={},m=[]){const v=new Map,k=new Map;if(Object.keys(d).length===0)return v;m.forEach(E=>{k.set(E.name,E.rgb_color||new Fr(0,0,0))});for(const[E,P]of Object.entries(d))k.has(E)?v.set(k.get(E).toString(),P):console.warn(`Ignoring unknown image variable "${E}"`);return v}}function O3(g,d=255,m){const v=d/255,k=g.toString(),E=m.has(k)?m.get(k).clone():g.clone();return E.a*=v,E.toString()}function n6(g,d){if(!zm()){const m=document.createElement("canvas");return m.width=g,m.height=d,m}return new OffscreenCanvas(g,d)}let sfe,a6=null;function rfe(g,d,m,v,k){for(const E of v.children)Y5e(g,d,m,E,k)}function Y5e(g,d,m,v,k){v.group?(g.save(),function(E,P,O,B,W){const J=B.mask_idx!=null?O.masks[B.mask_idx]:null,te=B.clip_path_idx!=null?O.clip_paths[B.clip_path_idx]:null;if(B.transform&&(P=R3(B.transform).preMultiplySelf(P)),!function(ue,Ne,Le){return ue.opacity!==255||Ne||Le}(B,te!=null,J!=null))return void rfe(E,P,O,B,W);const ie=n6(E.canvas.width,E.canvas.height),ce=ie.getContext("2d");rfe(ce,P,O,B,W),te&&rMe(ce,P,O,te),J&&nMe(ce,P,O,J,W),E.globalAlpha=B.opacity/255,E.drawImage(ie,0,0)}(g,d,m,v.group,k),g.restore()):v.path&&(g.save(),function(E,P,O,B,W){E.setTransform(P),B.paint_order===jut.PAINT_ORDER_FILL_AND_STROKE?(X5e(E,O,B,W),J5e(E,O,B,W)):(J5e(E,O,B,W),X5e(E,O,B,W))}(g,d,m,v.path,k),g.restore())}function X5e(g,d,m,v){const k=m.fill;if(!k)return;const E=k.opacity/255;switch(g.save(),g.beginPath(),aMe(m,g),k.paint){case"rgb_color":g.fillStyle=O3(k.rgb_color,k.opacity,v);break;case"linear_gradient_idx":{const P=d.linear_gradients[k.linear_gradient_idx];P.transform&&g.setTransform(R3(P.transform).preMultiplySelf(g.getTransform())),g.fillStyle=eMe(g,P,E,v);break}case"radial_gradient_idx":{const P=d.radial_gradients[k.radial_gradient_idx];P.transform&&g.setTransform(R3(P.transform).preMultiplySelf(g.getTransform())),g.fillStyle=tMe(g,P,E,v)}}g.fill(Q5e(m)),g.restore()}function Q5e(g){return g.rule===efe.PATH_RULE_NON_ZERO?"nonzero":g.rule===efe.PATH_RULE_EVEN_ODD?"evenodd":void 0}function J5e(g,d,m,v){const k=m.stroke;if(!k)return;const E=iMe(m);g.lineWidth=k.width,g.miterLimit=k.miterlimit,g.setLineDash(k.dasharray),g.lineDashOffset=k.dashoffset;const P=k.opacity/255;switch(k.paint){case"rgb_color":g.strokeStyle=O3(k.rgb_color,k.opacity,v);break;case"linear_gradient_idx":g.strokeStyle=eMe(g,d.linear_gradients[k.linear_gradient_idx],P,v,!0);break;case"radial_gradient_idx":g.strokeStyle=tMe(g,d.radial_gradients[k.radial_gradient_idx],P,v,!0)}switch(k.linejoin){case qF.LINE_JOIN_MITER_CLIP:case qF.LINE_JOIN_MITER:g.lineJoin="miter";break;case qF.LINE_JOIN_ROUND:g.lineJoin="round";break;case qF.LINE_JOIN_BEVEL:g.lineJoin="bevel"}switch(k.linecap){case tfe.LINE_CAP_BUTT:g.lineCap="butt";break;case tfe.LINE_CAP_ROUND:g.lineCap="round";break;case tfe.LINE_CAP_SQUARE:g.lineCap="square"}g.stroke(E)}function eMe(g,d,m,v,k=!1){if(d.stops.length===1){const ie=d.stops[0];return O3(ie.rgb_color,ie.opacity*m,v)}const{x1:E,y1:P,x2:O,y2:B}=d;let W=new DOMPoint(E,P),J=new DOMPoint(O,B);if(k){const ie=R3(d.transform);W=ie.transformPoint(W),J=ie.transformPoint(J)}const te=g.createLinearGradient(W.x,W.y,J.x,J.y);for(const ie of d.stops)te.addColorStop(ie.offset,O3(ie.rgb_color,ie.opacity*m,v));return te}function tMe(g,d,m,v,k=!1){if(d.stops.length===1){const Ie=d.stops[0];return O3(Ie.rgb_color,Ie.opacity*m,v)}const E=R3(d.transform),{fx:P,fy:O,fr:B,cx:W,cy:J,r:te}=d;let ie=new DOMPoint(P,O),ce=new DOMPoint(W,J),ue=B,Ne=te;if(k){ie=E.transformPoint(ie),ce=E.transformPoint(ce);const Ie=(E.a+E.d)/2;ue=B*Ie,Ne=d.r*Ie}const Le=g.createRadialGradient(ie.x,ie.y,ue,ce.x,ce.y,Ne);for(const Ie of d.stops)Le.addColorStop(Ie.offset,O3(Ie.rgb_color,Ie.opacity*m,v));return Le}function sMe(g,d,m,v){const k=v.transform?R3(v.transform).preMultiplySelf(d):d,E=n6(g.canvas.width,g.canvas.height),P=E.getContext("2d");for(const B of v.children)if(B.group)sMe(P,k,m,B.group);else if(B.path){const W=B.path,J=new Path2D;J.addPath(iMe(W),k),P.fill(J,Q5e(W))}const O=v.clip_path_idx!=null?m.clip_paths[v.clip_path_idx]:null;O&&rMe(P,k,m,O),g.globalCompositeOperation="source-over",g.drawImage(E,0,0)}function rMe(g,d,m,v){const k=n6(g.canvas.width,g.canvas.height);sMe(k.getContext("2d"),d,m,v),g.globalCompositeOperation="destination-in",g.drawImage(k,0,0)}function nMe(g,d,m,v,k){if(v.children.length===0)return;const E=v.mask_idx!=null?m.masks[v.mask_idx]:null;E&&nMe(g,d,m,E,k);const P=g.canvas.width,O=g.canvas.height,B=n6(P,O),W=B.getContext("2d"),J=v.width,te=v.height,ie=v.left,ce=v.top,ue=new Path2D,Ne=new Path2D;Ne.rect(ie,ce,J,te),ue.addPath(Ne,d),W.clip(ue);for(const Ge of v.children)Y5e(W,d,m,Ge,k);const Le=W.getImageData(0,0,P,O),Ie=Le.data;if(v.mask_type===W5e.MASK_TYPE_LUMINANCE)for(let Ge=0;Ged[P])return null}else{const O=1/v[P];let B=(g[P]-m[P])*O,W=(d[P]-m[P])*O;if(B>W){const J=B;B=W,W=J}if(B>k&&(k=B),WE)return null}return k}function cMe(g,d,m,v,k,E,P,O,B,W,J){const te=v-g,ie=k-d,ce=E-m,ue=P-g,Ne=O-d,Le=B-m,Ie=J[1]*Le-J[2]*Ne,Ge=J[2]*ue-J[0]*Le,Ze=J[0]*Ne-J[1]*ue,at=te*Ie+ie*Ge+ce*Ze;if(Math.abs(at)<1e-15)return null;const vt=1/at,pt=W[0]-g,St=W[1]-d,Lt=W[2]-m,Bt=(pt*Ie+St*Ge+Lt*Ze)*vt;if(Bt<0||Bt>1)return null;const as=St*ce-Lt*ie,Wt=Lt*te-pt*ce,us=pt*ie-St*te,bs=(J[0]*as+J[1]*Wt+J[2]*us)*vt;return bs<0||Bt+bs>1?null:(ue*as+Ne*Wt+Le*us)*vt}function dMe(g,d,m){return(g-d)/(m-d)}function uMe(g,d,m,v,k,E,P,O,B){const W=1<{const Ge=Le?1:0,Ze=(ce+1)*Ne-Ge,at=ue*Ne,vt=(ue+1)*Ne-Ge;Ie[0]=ce*Ne,Ie[1]=at,Ie[2]=Ze,Ie[3]=vt};let te=new oMe(B);const ie=[];for(let ce=0;ce=1;B/=2){const ce=O[O.length-1];te=new oMe(B);for(let ue=0;ue0;){const{idx:ue,t:Ne,nodex:Le,nodey:Ie,depth:Ge}=ce.pop();if(this.leaves[ue]){uMe(Le,Ie,Ge,d,m,v,k,te,ie);const at=1<=Bs[2])return Ne}continue}let Ze=0;for(let at=0;at=W[J[Lt]]&&(J.splice(Lt,0,at),St=!0);St||(J[Ze]=at),Ze++}}for(let at=0;at=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],k=GF.getUnpackVector(m);let E=Math.floor((d+k[3])/k[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 oCe({width:this.stride,height:this.stride},this.pixels)}backfillBorder(d,m,v){if(this.dim!==d.dim)throw new Error("dem dimension mismatch");let k=m*this.dim,E=m*this.dim+this.dim,P=v*this.dim,O=v*this.dim+this.dim;switch(m){case-1:k=E-1;break;case 1:E=k+1}switch(v){case-1:P=O-1;break;case 1:O=P+1}const B=-m*this.dim,W=-v*this.dim;for(let J=P;J=1;v--){const k=v===1?1:0,E=v===2?1:0;for(let P=0;P>>1^-(1&g[d]);return g}function tht(g,d){switch(d){case"uint32":return g;case"uint16":for(let m=0;m>4|(61440&v)>>8|(240&k)<<4|61440&k,g[m+1]=15&v|(3840&v)>>4|(15&k)<<8|(3840&k)<<4}return g;case"uint8":for(let m=0;m>6|(192&k)>>4|(192&E)>>2|192&P,g[m+1]=(48&v)>>4|(48&k)>>2|48&E|(48&P)<<2,g[m+2]=(12&v)>>2|12&k|(12&E)<<2|(12&P)<<4,g[m+3]=3&v|(3&k)<<2|(3&E)<<4|(3&P)<<6}return g;default:throw new Error(`Invalid pixel format, "${d}"`)}}_r(GF,"DEMData"),_r(hMe,"DemMinMaxQuadTree",{omit:["dem"]});var zp=Uint8Array,i6=Uint16Array,sht=Int32Array,pMe=new zp([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]),fMe=new zp([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]),rht=new zp([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gMe=function(g,d){for(var m=new i6(31),v=0;v<31;++v)m[v]=d+=1<>1|(21845&nc)<<1;vMe[nc]=((65280&(F3=(61680&(F3=(52428&F3)>>2|(13107&F3)<<2))>>4|(3855&F3)<<4))>>8|(255&F3)<<8)>>1}var o6=function(g,d,m){for(var v=g.length,k=0,E=new i6(d);k>B]=W;return P},l6=new zp(288);for(nc=0;nc<144;++nc)l6[nc]=8;for(nc=144;nc<256;++nc)l6[nc]=9;for(nc=256;nc<280;++nc)l6[nc]=7;for(nc=280;nc<288;++nc)l6[nc]=8;var _Me=new zp(32);for(nc=0;nc<32;++nc)_Me[nc]=5;var iht=o6(l6,9),oht=o6(_Me,5),afe=function(g){for(var d=g[0],m=1;md&&(d=g[m]);return d},ux=function(g,d,m){var v=d/8|0;return(g[v]|g[v+1]<<8)>>(7&d)&m},ife=function(g,d){var m=d/8|0;return(g[m]|g[m+1]<<8|g[m+2]<<16)>>(7&d)},lht=["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"],hx=function(g,d,m){var v=new Error(d||lht[g]);if(v.code=g,Error.captureStackTrace&&Error.captureStackTrace(v,hx),!m)throw v;return v},cht=new zp(0),dht=typeof TextDecoder<"u"&&new TextDecoder;try{dht.decode(cht,{stream:!0})}catch{}const uht={gzip_data:"gzip"};class Bf extends Error{constructor(d){super(d),this.name="MRTError"}}const hht={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},bMe={uint32:1,uint16:2,uint8:4},mht={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ofe;class KF{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 Bf(`Layer '${d}' not found`);return m}getHeaderLength(d){const m=new Uint8Array(d),v=new DataView(d);if(m[0]!==13)throw new Bf("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 k=new ofe(m.subarray(0,v)).readFields(Hut,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==k.x||this.y!==k.y||this.z!==k.z))throw new Bf(`Invalid attempt to parse header ${k.z}/${k.x}/${k.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=k.x,this.y=k.y,this.z=k.z;for(const E of k.layers)this.layers[E.name]=new wMe(E,{cacheSize:this._cacheSize});return this}createDecodingTask(d){const m=[],v=this.getLayer(d.layerName);for(let k of d.blockIndices){const E=v.dataIndex[k],P=E.firstByte-d.firstByte,O=E.lastByte-d.firstByte;if(v._blocksInProgress.has(k))continue;const B={layerName:v.name,firstByte:P,lastByte:O,pixelFormat:v.pixelFormat,blockIndex:k,blockShape:[E.bands.length].concat(v.bandShape),buffer:v.buffer,codec:E.codec.codec,filters:E.filters.map(W=>W.filter)};v._blocksInProgress.add(k),m.push(B)}return new jMe(m,()=>{m.forEach(k=>v._blocksInProgress.delete(k.blockIndex))},(k,E)=>{if(m.forEach(P=>v._blocksInProgress.delete(P.blockIndex)),k)throw k;E.forEach(P=>{this.getLayer(P.layerName).processDecodedData(P)})})}}class wMe{constructor({version:d,name:m,units:v,tileSize:k,pixelFormat:E,buffer:P,dataIndex:O},B){if(this.version=d,this.version!==1)throw new Bf(`Cannot parse raster layer encoded with MRT version ${d}`);this.name=m,this.units=v,this.tileSize=k,this.buffer=P,this.pixelFormat=hht[E],this.dataIndex=O,this.bandShape=[k+2*P,k+2*P,bMe[this.pixelFormat]],this._decodedBlocks=new WF(B?B.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return bMe[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,k]of this.dataIndex.entries()){for(const[E,P]of k.bands.entries())if(P===d)return{bandIndex:m+E,blockIndex:v,blockBandIndex:E};m+=k.bands.length}break;case"number":for(const[v,k]of this.dataIndex.entries()){if(d>=m&&dthis.cacheSize)throw new Bf(`Number of blocks to decode (${E.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:m,lastByte:v,blockIndices:k}}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 Bf(`Band not found: ${JSON.stringify(d)}`);const k=this._decodedBlocks.get(m.toString());if(!k)throw new Bf(`Data for band ${JSON.stringify(d)} of layer "${this.name}" not decoded.`);const E=this.dataIndex[m],P=this.bandShape.reduce((W,J)=>W*J,1),O=v*P,B=k.subarray(O,O+P);return{data:B,bytes:new Uint8Array(B.buffer).subarray(B.byteOffset,B.byteOffset+B.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:E.offset,scale:E.scale}}}KF.setPbf=function(g){ofe=g};class jMe{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)}}KF.performDecoding=function(g,d){const m=new Uint8Array(g);return Promise.all(d.tasks.map(v=>{const{layerName:k,firstByte:E,lastByte:P,pixelFormat:O,blockShape:B,blockIndex:W,filters:J,codec:te}=v,ie=m.subarray(E,P+1),ce=new Uint32Array(B[0]*B[1]*B[2]);let ue;if(te!=="gzip_data")throw new Bf(`Unhandled codec: ${te}`);return ue=function(Ne,Le){if(!globalThis.DecompressionStream&&Le==="gzip_data")return Promise.resolve(((at=function(St){St[0]==31&&St[1]==139&&St[2]==8||hx(6,"invalid gzip data");var Lt=St[3],Bt=10;4&Lt&&(Bt+=2+(St[10]|St[11]<<8));for(var as=(Lt>>3&1)+(Lt>>4&1);as>0;as-=!St[Bt++]);return Bt+(2&Lt)}(Ze=Ne))+8>Ze.length&&hx(6,"invalid gzip data"),function(St,Lt,Bt,as){var Wt=St.length;if(!Wt||Lt.f&&!Lt.l)return Bt||new zp(0);var us=!Bt,bs=us||Lt.i!=2,ws=Lt.i;us&&(Bt=new zp(3*Wt));var Fs,Bs,Ds=function(Mi){var ei=Bt.length;if(Mi>ei){var li=new zp(Math.max(2*ei,Mi));li.set(Bt),Bt=li}},Os=Lt.f||0,ds=Lt.p||0,is=Lt.b||0,Rs=Lt.l,Js=Lt.d,Hs=Lt.m,Dr=Lt.n,ur=8*Wt;do{if(!Rs){Os=ux(St,ds,1);var yr=ux(St,ds+1,3);if(ds+=3,!yr){var Nr=St[(hs=4+((ds+7)/8|0))-4]|St[hs-3]<<8,Wn=hs+Nr;if(Wn>Wt){ws&&hx(0);break}bs&&Ds(is+Nr),Bt.set(St.subarray(hs,Wn),is),Lt.b=is+=Nr,Lt.p=ds=8*Wn,Lt.f=Os;continue}if(yr==1)Rs=iht,Js=oht,Hs=9,Dr=5;else if(yr==2){var Gs=ux(St,ds,31)+257,Sr=ux(St,ds+10,15)+4,pn=Gs+ux(St,ds+5,31)+1;ds+=14;for(var xa=new zp(pn),ba=new zp(19),Ln=0;Ln>4)<16)xa[Ln++]=hs;else{var or=0,lr=0;for(hs==16?(lr=3+ux(St,ds,3),ds+=2,or=xa[Ln-1]):hs==17?(lr=3+ux(St,ds,7),ds+=3):hs==18&&(lr=11+ux(St,ds,127),ds+=7);lr--;)xa[Ln++]=or}}var Or=xa.subarray(0,Gs),zr=xa.subarray(Gs);Hs=afe(Or),Dr=afe(zr),Rs=o6(Or,Hs),Js=o6(zr,Dr)}else hx(1);if(ds>ur){ws&&hx(0);break}}bs&&Ds(is+131072);for(var Sn=(1<>4;if((ds+=15&or)>ur){ws&&hx(0);break}if(or||hx(2),ca<256)Bt[is++]=ca;else{if(ca==256){Hn=ds,Rs=null;break}var en=ca-254;ca>264&&(en=ux(St,ds,(1<<(Ga=pMe[Ln=ca-257]))-1)+yMe[Ln],ds+=Ga);var un=Js[ife(St,ds)&Bn],Fa=un>>4;if(un||hx(3),ds+=15&un,zr=aht[Fa],Fa>3){var Ga=fMe[Fa];zr+=ife(St,ds)&(1<ur){ws&&hx(0);break}bs&&Ds(is+131072);var Ka=is+en;if(isFs.length)&&(Bs=Fs.length),new zp(Fs.subarray(0,Bs))):Bt.subarray(0,is)}(Ze.subarray(at,-8),{i:2},new zp(((Ie=Ze)[(Ge=Ie.length)-4]|Ie[Ge-3]<<8|Ie[Ge-2]<<16|Ie[Ge-1]<<24)>>>0))));var Ie,Ge,Ze,at;const vt=uht[Le];if(!vt)throw new Error(`Unhandled codec: ${Le}`);const pt=new globalThis.DecompressionStream(vt);return new Response(new Blob([Ne]).stream().pipeThrough(pt)).arrayBuffer().then(St=>new Uint8Array(St))}(ie,te).then(Ne=>(function(Le,Ie){Le.readFields(Xut,Ie)}(new ofe(Ne),ce),new mht[O](ce.buffer))),ue.then(Ne=>{for(let Le=J.length-1;Le>=0;Le--)switch(J[Le]){case"delta_filter":Jut(Ne,B);break;case"zigzag_filter":eht(Ne);break;case"bitshuffle_filter":tht(Ne,O);break;default:throw new Bf(`Unhandled filter "${J[Le]}"`)}return{layerName:k,blockIndex:W,data:Ne}}).catch(Ne=>{throw Ne})}))},_r(jMe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),_r(KF,"MapboxRasterTile"),_r(wMe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class kMe{constructor(d){this._stringToNumber={},this._numberToString=[];for(let m=0;m=0&&ie[3]>=0&&W.insert(B,ie[0],ie[1],ie[2],ie[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Yt(new kF(this.rawTileData)).layers,this.sourceLayerCoder=new kMe(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const d in this.vtLayers)this.vtFeatures[d]=[]}return this.vtLayers}query(d,m){const{tilespaceGeometry:v,transform:k,tileTransform:E,pixelPosMatrix:P,availableImages:O,worldview:B}=m;this.loadVTLayers(),this.serializedLayersCache.clear();const W=m.queryRadius?m.queryRadius:0,J=v.bufferedTilespaceBounds,te=this.grid.query(J.min.x,J.min.y,J.max.x,J.max.y,(Ne,Le,Ie,Ge)=>Pu(v.bufferedTilespaceGeometry,Ne-W,Le-W,Ie+W,Ge+W));te.sort(pht);let ie=null;k.elevation&&te.length>0&&(ie=D3.create(k.elevation,this.tileID));const ce={};let ue;for(let Ne=0;Ne(Ge||(Ge=Pt(Ze,this.tileID.canonical,E)),at.queryIntersectsFeature(v,Ze,vt,Ge,this.z,k,P,ie,pt)))}return ce}loadMatchingFeature(d,m,v,k,E,P){const{featureIndex:O,bucketIndex:B,sourceLayerIndex:W,layoutVertexArrayOffset:J}=m,te=this.bucketLayerIDs[B],ie=v.layers,ce=Object.keys(ie);if(ce.length&&!gr(ce,te))return;const ue=v.sourceCache,Ne=this.sourceLayerCoder.decode(W),Le=this.vtLayers[Ne].feature(O),Ie=this.getId(Le,Ne);for(let Ge=0;Ge`${O.key}: ${O.message}`).join(", ");return void hr(`Failed to create expression for promoteId: ${P}`)}this.promoteIdExpression=E.value}v=this.promoteIdExpression.evaluate({zoom:0},d)}else v=d.properties[k];typeof v=="boolean"&&(v=Number(v))}return v}}function SMe(g,d,m,v,k){return Qt(g,(E,P)=>{const O=d instanceof tv?d.get(P):null;return O&&O.evaluate?O.evaluate(m,v,void 0,k):O})}function pht(g,d){return d-g}_r(NMe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const CMe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class lfe{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 k=v>>4;if(k!==1)throw new Error(`Got v${k} data when expected v1.`);const E=CMe[15&v];if(!E)throw new Error("Unrecognized array type.");const[P]=new Uint16Array(d,2,1),[O]=new Uint32Array(d,4,1);return new lfe(O,P,E,d)}constructor(d,m=64,v=Float64Array,k){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=CMe.indexOf(this.ArrayType),P=2*d*this.ArrayType.BYTES_PER_ELEMENT,O=d*this.IndexArrayType.BYTES_PER_ELEMENT,B=(8-O%8)%8;if(E<0)throw new Error(`Unexpected typed array class: ${v}.`);k&&k instanceof ArrayBuffer?(this.data=k,this.ids=new this.IndexArrayType(this.data,8,d),this.coords=new this.ArrayType(this.data,8+O+B,2*d),this._pos=2*d,this._finished=!0):(this.data=new ArrayBuffer(8+P+O+B),this.ids=new this.IndexArrayType(this.data,8,d),this.coords=new this.ArrayType(this.data,8+O+B,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 cfe(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(d,m,v,k){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:E,coords:P,nodeSize:O}=this,B=[0,E.length-1,0],W=[];for(;B.length;){const J=B.pop()||0,te=B.pop()||0,ie=B.pop()||0;if(te-ie<=O){for(let Le=ie;Le<=te;Le++){const Ie=P[2*Le],Ge=P[2*Le+1];Ie>=d&&Ie<=v&&Ge>=m&&Ge<=k&&W.push(E[Le])}continue}const ce=ie+te>>1,ue=P[2*ce],Ne=P[2*ce+1];ue>=d&&ue<=v&&Ne>=m&&Ne<=k&&W.push(E[ce]),(J===0?d<=ue:m<=Ne)&&(B.push(ie),B.push(ce-1),B.push(1-J)),(J===0?v>=ue:k>=Ne)&&(B.push(ce+1),B.push(te),B.push(1-J))}return W}within(d,m,v){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:k,coords:E,nodeSize:P}=this,O=[0,k.length-1,0],B=[],W=v*v;for(;O.length;){const J=O.pop()||0,te=O.pop()||0,ie=O.pop()||0;if(te-ie<=P){for(let Le=ie;Le<=te;Le++)TMe(E[2*Le],E[2*Le+1],d,m)<=W&&B.push(k[Le]);continue}const ce=ie+te>>1,ue=E[2*ce],Ne=E[2*ce+1];TMe(ue,Ne,d,m)<=W&&B.push(k[ce]),(J===0?d-v<=ue:m-v<=Ne)&&(O.push(ie),O.push(ce-1),O.push(1-J)),(J===0?d+v>=ue:m+v>=Ne)&&(O.push(ce+1),O.push(te),O.push(1-J))}return B}}function cfe(g,d,m,v,k,E){if(k-v<=m)return;const P=v+k>>1;MMe(g,d,P,v,k,E),cfe(g,d,m,v,P-1,1-E),cfe(g,d,m,P+1,k,1-E)}function MMe(g,d,m,v,k,E){for(;k>v;){if(k-v>600){const W=k-v+1,J=m-v+1,te=Math.log(W),ie=.5*Math.exp(2*te/3),ce=.5*Math.sqrt(te*ie*(W-ie)/W)*(J-W/2<0?-1:1);MMe(g,d,m,Math.max(v,Math.floor(m-J*ie/W+ce)),Math.min(k,Math.floor(m+(W-J)*ie/W+ce)),E)}const P=d[2*m+E];let O=v,B=k;for(c6(g,d,v,m),d[2*k+E]>P&&c6(g,d,v,k);OP;)B--}d[2*v+E]===P?c6(g,d,v,B):(B++,c6(g,d,B,k)),B<=m&&(v=B+1),m<=B&&(k=B-1)}}function c6(g,d,m,v){dfe(g,m,v),dfe(d,2*m,2*v),dfe(d,2*m+1,2*v+1)}function dfe(g,d,m){const v=g[d];g[d]=g[m],g[m]=v}function TMe(g,d,m,v){const k=g-m,E=d-v;return k*k+E*E}i.$=fC,i.A=Wg,i.B=Dp,i.C=2,i.D=w3,i.E=Ts,i.F=VP,i.G=t5e,i.H=pC,i.I=Ys,i.J=BR,i.K=Lr,i.L=q1,i.M=zC,i.N=tw,i.O=CR,i.P=es,i.Q=sw,i.R=Ug,i.S=ZC,i.T=ype,i.U=jy,i.V=BF,i.W=XE,i.X=G1,i.Y=W1,i.Z=Z2,i._=Tu,i.a=function(g){return aa.API_CDN_URL_REGEX.test(g)},i.a$=ge,i.a0=dn,i.a1=na,i.a2=Df,i.a3=class extends BF{},i.a4=BC,i.a5=SR,i.a6=Gt,i.a7=function(g){const d=g.value;return d?dn(d)?Zpe(d,!0)?[]:[new BF(g.key,d,`invalid url "${d}"`)]:[new BF(g.key,d,`string expected, "${Lr(d)}" found`)]:[]},i.a8=OR,i.a9=Mo,i.aA=ve,i.aB=S,i.aC=Xe,i.aD=Od,i.aE=Ai,i.aF=H,i.aG=st,i.aH=function(g,d){const m={};for(let v=0;v{v(E,P)},d):v(E,P),()=>{}}return k.callbacks.push(v),k.cancel||(k.cancel=m((E,P)=>{k.result=[E,P];for(const O of k.callbacks)this.scheduler?this.scheduler.add(()=>{O(E,P)},d):O(E,P);setTimeout(()=>delete this.entries[g],3e3)})),()=>{k.result||(k.callbacks=k.callbacks.filter(E=>E!==v),k.callbacks.length||(k.cancel(),delete this.entries[g]))}}},i.aL=function(g,d,m){const v=JSON.stringify(g.request);return g.data&&(this.deduped.entries[v]={result:[null,g.data]}),this.deduped.request(v,{type:"parseTile",isSymbolTile:g.isSymbolTile,zoom:g.tileZoom},k=>{const E=jh(g.request,(P,O,B)=>{P?k(P):O&&k(null,{rawData:O,vectorTile:m?void 0:new Yt(new kF(O)),responseHeaders:new Map(B.entries())})});return()=>{E.cancel(),k()}},d)},i.aM=function(g){return g?{cacheControl:g.get("Cache-Control"),expires:g.get("Expires")}:{cacheControl:void 0,expires:void 0}},i.aN=jl,i.aO=function(g){vd++,vd>R1&&(g.getActor().send("enforceCacheSizeLimit",O1),vd=0)},i.aP=function(g){return g<=1?1:Math.pow(2,Math.floor(Math.log2(g)))},i.aQ=jo,i.aR=A5e,i.aS=O5e,i.aT=x,i.aU=T5e,i.aV=function(g,d){const m=document.createElement("video");m.muted=!0,m.onloadstart=function(){d(null,m)};for(let v=0;v{}}},i.aW=zP,i.aX=Sw,i.aY=$t,i.aZ=KP,i.a_=oe,i.aa=Ks,i.ab=class{constructor(g){this.specification=g}possiblyEvaluate(g,d){return jn(g.expression.evaluate(d))}interpolate(g,d,m){return{x:Hr(g.x,d.x,m),y:Hr(g.y,d.y,m),z:Hr(g.z,d.z,m),azimuthal:Hr(g.azimuthal,d.azimuthal,m),polar:Hr(g.polar,d.polar,m)}}},i.ac=Hi,i.ad=Q0,i.ae=et,i.af=Rt,i.ag=de,i.ah=ze,i.ai=tv,i.aj=h_,i.ak=Hr,i.al=Qs,i.am=H0,i.an=Ir,i.ao=Fr,i.ap=class{constructor(g){this.specification=g}possiblyEvaluate(g,d){return function([m,v]){const k=jn([1,m,v]);return{x:k.x,y:k.y,z:k.z}}(g.expression.evaluate(d))}interpolate(g,d,m){return{x:Hr(g.x,d.x,m),y:Hr(g.y,d.y,m),z:Hr(g.z,d.z,m)}}},i.aq=function(g,d,m=0,v=!0){const k=new es(m,m),E=g.sub(k),P=d.add(k),O=[E,new es(P.x,E.y),P,new es(E.x,P.y)];return v&&O.push(E.clone()),O},i.ar=function(g,d){const m=[];for(let v=0;v1)return!1;const m=d.getSource().maxzoom,v=1<1)return d;const k=v.getSource().maxzoom,E=1<{const O=this.getAtTileOffset(g,k,E,P),B=v.upVector(g.canonical,k.x,k.y);return ke(B,B,O*v.upVectorScale(g.canonical,d,m).metersToTile),B}}getForTilePoints(g,d,m,v){if(this.isUsingMockSource())return!1;const k=D3.create(this,g,v);return!!k&&(d.forEach(E=>{E[2]=this.exaggeration()*k.getElevationAt(E[0],E[1],m)}),!0)}getMinMaxForTile(g){if(this.isUsingMockSource())return null;const d=this.findDEMTileFor(g);if(!d||!d.dem)return null;const m=d.dem.tree,v=d.tileID,k=1<0&&(v+=(g[k]-0)*(g[k]-0)),d[k]<0&&(v+=(0-d[k])*(0-d[k]));return v},i.c0=ACe,i.c1=Ipe,i.c2=l5e,i.c3=$pe,i.c4=lfe,i.c5=ke,i.c6=$e,i.c7=Ye,i.c8=function(g,d,m){m*=.5;var v=d[0],k=d[1],E=d[2],P=d[3],O=Math.sin(m),B=Math.cos(m);return g[0]=v*B+k*O,g[1]=k*B-v*O,g[2]=E*B+P*O,g[3]=P*B-E*O,g},i.c9=tt,i.cA=ee,i.cB=Ja,i.cC=p3e,i.cD=Ei,i.cE=HSe,i.cF=function(g,d,m,v,k,E,P,O,B){if(B.name==="globe")return HSe(g,d,new Ei(m,v,k),!1);const W=KP({z:m,x:v,y:k},B);return new Er([(E+W.x/W.scale)*d,d*(W.y/W.scale),P],[(E+W.x2/W.scale)*d,d*(W.y2/W.scale),O])},i.cG=function(g,d,m){return g[0]=Math.min(d[0],m[0]),g[1]=Math.min(d[1],m[1]),g[2]=Math.min(d[2],m[2]),g[3]=Math.min(d[3],m[3]),g},i.cH=function(g,d,m){return g[0]=Math.max(d[0],m[0]),g[1]=Math.max(d[1],m[1]),g[2]=Math.max(d[2],m[2]),g[3]=Math.max(d[3],m[3]),g},i.cI=function(g){const d=Math.round((g+45+360)%360/90)%4;return rl[d]},i.cJ=xe,i.cK=Ue,i.cL=v3,i.cM=function(g){const d=j(new Float64Array(16));S(d,g.pixelMatrix,g.globeMatrix);const m=[0,Km,0],v=[0,Zm,0];return Rt(m,m,d),Rt(v,v,d),[m[0]>0&&m[0]<=g.width&&m[1]>0&&m[1]<=g.height&&!Zme(g,new x(g.center.lat,90)),v[0]>0&&v[0]<=g.width&&v[1]>0&&v[1]<=g.height&&!Zme(g,new x(g.center.lat,-90))]},i.cN=function(g,d){const{scale:m}=g.tileTransform,v=m*Qs/(g.tileSize*Math.pow(2,d.zoom-g.tileID.overscaledZ+g.tileID.canonical.z));return function(k,E,P){var O=E[1],B=E[2],W=E[3],J=P[0],te=P[1];return k[0]=E[0]*J,k[1]=O*J,k[2]=B*te,k[3]=W*te,k}(new Float32Array(4),d.inverseAdjustmentMatrix,[v,v])},i.cO=yF,i.cP=se,i.cQ=m3e,i.cR=function(g){const d=m3e(g,!0);return p([],[d[0],d[1],d[4],d[5]])},i.cS=I,i.cT=dr,i.cU=L,i.cV=function(g){const{x:d,y:m}=g.point,{lng:v,lat:k}=g._center;return KSe(d,m,g.worldSize,v,k)},i.cW=we,i.cX=_i,i.cY=vo,i.cZ=bd,i.c_=Gm,i.ca=Qa,i.cb=function(g,d){return g[0]=-d[0],g[1]=-d[1],g[2]=-d[2],g[3]=d[3],g},i.cc=X,i.cd=function(g,d,m,v,k){var E=1/Math.tan(d/2);if(g[0]=E/m,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=E,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[11]=-1,g[12]=0,g[13]=0,g[15]=0,k!=null&&k!==1/0){var P=1/(v-k);g[10]=(k+v)*P,g[14]=2*k*v*P}else g[10]=-1,g[14]=-2*v;return g},i.ce=function(g,d,m,v,k,E,P){var O=1/(d-m),B=1/(v-k),W=1/(E-P);return g[0]=-2*O,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=-2*B,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=2*W,g[11]=0,g[12]=(d+m)*O,g[13]=(k+v)*B,g[14]=(P+E)*W,g[15]=1,g},i.cf=ae,i.cg=function(g,d,m){g[4*d+0]=m[0],g[4*d+1]=m[1],g[4*d+2]=m[2],g[4*d+3]=m[3]},i.ch=f3,i.ci=uw,i.cj=Ll,i.ck=Ff,i.cl=mw,i.cm=v5e,i.cn=function(){var g=new u(4);return u!=Float32Array&&(g[1]=0,g[2]=0),g[0]=1,g[3]=1,g},i.co=function(g,d,m){var v=d[0],k=d[1],E=d[2],P=d[3],O=Math.sin(m),B=Math.cos(m);return g[0]=v*B+E*O,g[1]=k*B+P*O,g[2]=v*-O+E*B,g[3]=k*-O+P*B,g},i.cp=function(g,d){return g[0]===d[0]&&g[1]===d[1]&&g[2]===d[2]&&g[3]===d[3]},i.cq=rt,i.cr=function(g){var d=g[0],m=g[1],v=g[2],k=g[3];return Math.sqrt(d*d+m*m+v*v+k*k)},i.cs=rs,i.ct=Je,i.cu=al,i.cv=3,i.cw=2,i.cx=7,i.cy=6,i.cz=De,i.d=function(g){return aa.API_TILEJSON_REGEX.test(g)},i.d$=class{constructor(g,d,m,v){this.context=g,this.format=v,this.size=m,this.texture=g.gl.createTexture();const[k,E,P]=this.size,{gl:O}=g;O.bindTexture(O.TEXTURE_3D,this.texture),g.pixelStoreUnpackFlipY.set(!1),g.pixelStoreUnpack.set(1),g.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in d&&d.data&&O.texImage3D(O.TEXTURE_3D,0,this.format,k,E,P,0,gpe(this.format),xpe(this.format),d.data)}bind(g,d){const{context:m}=this,{gl:v}=m;v.bindTexture(v.TEXTURE_3D,this.texture),g!==this.minFilter&&(v.texParameteri(v.TEXTURE_3D,v.TEXTURE_MAG_FILTER,g),v.texParameteri(v.TEXTURE_3D,v.TEXTURE_MIN_FILTER,g),this.minFilter=g),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:g}=this.context;g.deleteTexture(this.texture),this.texture=null}},i.d0=function(g){return g*g*g*g*g},i.d1=z,i.d2=45,i.d3=g3,i.d4=function(g,d,m){const v=Math.sqrt(g*g+d*d+m*m),k=v>0?Math.acos(m/v)*Xn:0;let E=g!==0||d!==0?Math.atan2(-d,-g)*Xn+90:0;return E<0&&(E+=360),[v,E,k]},i.d5=re,i.d6=jn,i.d7=Be,i.d8=le,i.d9=Er,i.dA=function(g){return g({pluginStatus:Au,pluginURL:Qg}),GC.on("pluginStateChange",g),g},i.dB=hw,i.dC=class extends tx{constructor(g){super(g),this.current=x3}set(g,d,m){if(this.fetchUniformLocation(g,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=Ni,i.dE=function(g,d,m){const v=h_(m.zoom),k=g.style.map._antialias,E=g.terrain&&g.terrain.exaggeration()>0;return v===0&&!k&&!E},i.dF=function(g){const d=g.pixelsPerMeter,m=d/ae(1,g.center.lat),v=j(new Float64Array(16));return T(v,v,[g.point.x,g.point.y,0]),I(v,v,[m,m,d]),Float32Array.from(v)},i.dG=sF,i.dH=function(g){const d=xe-5;g=ve(g,-d,d)/d*90;const m=Math.pow(Math.abs(Math.sin(Ir(g))),3);return Math.round(m*(wP.length-1))},i.dI=function(g,d,m,v){const k=d.getNorth(),E=d.getSouth(),P=d.getWest(),O=d.getEast(),B=1<0){const ue=180/v;_(ce,ce,[ue/W+1,0,0,0,ue/J+1,0,-.5*ue/te,.5*ue/ie,1])}return ce[2]=B,ce[5]=g.x,ce[8]=g.y,ce},i.dJ=Fp,i.dK=function(g,d,m){const v=j(new Float64Array(16)),k=(d/(1<({u_matrix:new mw(g),u_texsize:new Ff(g),u_pixels_to_tile_units:new y3(g),u_device_pixel_ratio:new Ll(g),u_width_scale:new Ll(g),u_floor_width_scale:new Ll(g),u_image:new f3(g),u_units_to_pixels:new Ff(g),u_tile_units_to_pixels:new Ll(g),u_alpha_discard_threshold:new Ll(g),u_trim_offset:new Ff(g),u_trim_fade_range:new Ff(g),u_trim_color:new g3(g),u_zbias_factor:new Ll(g),u_tile_to_meter:new Ll(g),u_ground_shadow_factor:new uw(g),u_pattern_transition:new Ll(g)}),i.dX=g=>({u_matrix:new mw(g),u_pixels_to_tile_units:new y3(g),u_device_pixel_ratio:new Ll(g),u_width_scale:new Ll(g),u_floor_width_scale:new Ll(g),u_units_to_pixels:new Ff(g),u_dash_image:new f3(g),u_gradient_image:new f3(g),u_image_height:new Ll(g),u_texsize:new Ff(g),u_tile_units_to_pixels:new Ll(g),u_alpha_discard_threshold:new Ll(g),u_trim_offset:new Ff(g),u_trim_fade_range:new Ff(g),u_trim_color:new g3(g),u_zbias_factor:new Ll(g),u_tile_to_meter:new Ll(g),u_ground_shadow_factor:new uw(g)}),i.dY=g=>({u_camera_to_center_distance:new Ll(g),u_extrude_scale:new y3(g),u_device_pixel_ratio:new Ll(g),u_matrix:new mw(g),u_inv_rot_matrix:new mw(g),u_merc_center:new Ff(g),u_tile_id:new uw(g),u_zoom_transition:new Ll(g),u_up_dir:new uw(g),u_emissive_strength:new Ll(g)}),i.dZ=i3,i.d_=Ndt,i.da=he,i.db=function(g){return[Math.pow(g[0],1/2.2),Math.pow(g[1],1/2.2),Math.pow(g[2],1/2.2)]},i.dc=h3e,i.dd=kpe,i.de=x3e,i.df=Zpe,i.dg=function(g,d){return g.readFields(kut,{icons:[]},d)},i.dh=pF,i.di=E3,i.dj=Fpe,i.dk=F1,i.dl=aw,i.dm=uy,i.dn=z1,i.dp=gs,i.dq=function(g){const d=g.indexOf(nv);return d>=0?g.slice(0,d):g},i.dr=function(g){return g.indexOf(nv)>=0},i.ds=function(g){const d=g.lastIndexOf(nv);return d>=0?g.slice(d+1):""},i.dt=function(g){const d=[],m=g.id;return m===void 0&&d.push({message:`layers.${m}: missing required property "id"`}),g.render===void 0&&d.push({message:`layers.${m}: missing required method "render"`}),g.renderingMode&&g.renderingMode!=="2d"&&g.renderingMode!=="3d"&&d.push({message:`layers.${m}: property "renderingMode" must be either "2d" or "3d"`}),d},i.du=function(g,d,m,v){return g.type==="custom"?new xut(g,d):new wut[g.type](g,d,m,v)},i.dv=Is,i.dw=function(g){const d=g.indexOf(nv);return d>=0?g.slice(d+1):""},i.dx=class extends Nw{constructor(g,d){super(g._vectorTileFeature,g._z,g._x,g._y,g.id),g.state&&(this.state=Object.assign({},g.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=g.source,this.sourceLayer=g.sourceLayer,this.layer=g.layer)}toJSON(){const g=super.toJSON();return g.target=this.target,g.namespace=this.namespace,g}},i.dy=GC,i.dz=Vg,i.e=aa,i.e$=ne,i.e0=XSe,i.e1=(g,d,m,v,k,E)=>{const P=g.transform,O=P.projection.name==="globe";let B;if(E.paint.get("circle-pitch-alignment")==="map")if(O){const J=GSe(P.zoom,d.canonical)*P._pixelsPerMercatorPixel;B=Float32Array.from([J,0,0,J])}else B=P.calculatePixelsToTileUnitsMatrix(m);else B=new Float32Array([P.pixelsToGLUnits[0],0,0,P.pixelsToGLUnits[1]]);const W={u_camera_to_center_distance:g.transform.getCameraToCenterDistance(P.projection),u_matrix:g.translatePosMatrix(d.projMatrix,m,E.paint.get("circle-translate"),E.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Pl.devicePixelRatio,u_extrude_scale:B,u_inv_rot_matrix:$lt,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:E.paint.get("circle-emissive-strength")};if(O){W.u_inv_rot_matrix=v,W.u_merc_center=k,W.u_tile_id=[d.canonical.x,d.canonical.y,1<{const J=g.transform,te=J.pitch<15?A3e(.07,.7,ve((14-J.zoom)/5,0,1)):.07,ie=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:P3e(g,d,m,v),u_texsize:d.imageAtlasTexture?d.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:J.calculatePixelsToTileUnitsMatrix(d),u_device_pixel_ratio:k,u_width_scale:E,u_floor_width_scale:P,u_image:0,u_tile_units_to_pixels:E3e(d,J),u_units_to_pixels:[1/J.pixelsToGLUnits[0],1/J.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:O,u_trim_fade_range:m.paint.get("line-trim-fade-range"),u_trim_color:m.paint.get("line-trim-color").toPremultipliedRenderColor(ie?null:m.lut).toArray01(),u_zbias_factor:te,u_tile_to_meter:Be(d.tileID.canonical,0),u_ground_shadow_factor:B,u_pattern_transition:W}},i.e5=(g,d,m,v,k,E,P,O,B,W)=>{const J=g.transform,te=J.calculatePixelsToTileUnitsMatrix(d),ie=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none",ce=J.pitch<15?A3e(.07,.7,ve((14-J.zoom)/5,0,1)):.07;return{u_matrix:P3e(g,d,m,v),u_pixels_to_tile_units:te,u_device_pixel_ratio:E,u_width_scale:P,u_floor_width_scale:O,u_units_to_pixels:[1/J.pixelsToGLUnits[0],1/J.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:k,u_texsize:L3e(m)&&d.lineAtlasTexture?d.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:E3e(d,g.transform),u_alpha_discard_threshold:0,u_trim_offset:B,u_trim_fade_range:m.paint.get("line-trim-fade-range"),u_trim_color:m.paint.get("line-trim-color").toPremultipliedRenderColor(ie?null:m.lut).toArray01(),u_zbias_factor:ce,u_tile_to_meter:Be(d.tileID.canonical,0),u_ground_shadow_factor:W}},i.e6=Kt,i.e7=kP,i.e8=fe,i.e9=Xm,i.eA=function(g,d){var m=2*Math.acos(d[3]),v=Math.sin(m/2);return v>c?(g[0]=d[0]/v,g[1]=d[1]/v,g[2]=d[2]/v):(g[0]=1,g[1]=0,g[2]=0),m},i.eB=Qpe,i.eC=bF,i.eD=_F,i.eE=[1,1,1],i.eF=D3,i.eG=ot,i.eH=function(g,d,m,v){var k=d[0],E=d[1],P=d[2],O=d[3];return g[0]=k+v*(m[0]-k),g[1]=E+v*(m[1]-E),g[2]=P+v*(m[2]-P),g[3]=O+v*(m[3]-O),g},i.eI=S3,i.eJ=nm,i.eK=Rf,i.eL=function(g,d,m,v,k,E,P,O,B,W,J,te,ie,ce,ue,Ne){var Le=new u(16);return Le[0]=g,Le[1]=d,Le[2]=m,Le[3]=v,Le[4]=k,Le[5]=E,Le[6]=P,Le[7]=O,Le[8]=B,Le[9]=W,Le[10]=J,Le[11]=te,Le[12]=ie,Le[13]=ce,Le[14]=ue,Le[15]=Ne,Le},i.eM=M,i.eN=i_,i.eO=hP,i.eP=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new es(1/0,1/0),max:new es(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(g,d=!1){const m=CCe(new es(0,0),new es(Qs,Qs),g),v=[];if(d&&!npe(m,this._globalClipBounds))return v;for(const k of this._activeRegions){if(k.hiddenByOverlap||!npe(m,k))continue;const E=gct(k.min,k.max,g);v.push({min:E.min,max:E.max,sourceId:this._sourceIds[k.priority],footprint:k.footprint,footprintTileId:k.tileId,order:k.order,clipMask:k.clipMask,clipScope:k.clipScope})}return v}setSources(g){this._setSources(g.map(d=>({getSourceId:()=>d.cache.id,getFootprints:()=>{const m=[];for(const v of d.cache.getVisibleCoordinates()){const k=d.cache.getTile(v).buckets[d.layer];k&&k.updateFootprints(v.toUnwrapped(),m)}return m},getOrder:()=>d.order,getClipMask:()=>d.clipMask,getClipScope:()=>d.clipScope})))}_addSource(g){const d=g.getFootprints();if(d.length===0)return;const m=g.getOrder(),v=g.getClipMask(),k=g.getClipScope();for(const E of d){if(!E.footprint)continue;const P=CCe(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:k})}this._sourceIds.push(g.getSourceId())}_computeReplacement(){this._activeRegions.sort((d,m)=>d.priority-m.priority||cF(d.min,m.min)||cF(d.max,m.max)||d.order-m.order||d.clipMask-m.clipMask||function(v,k){const E=(P,O)=>P+O;return v.length-k.length||v.reduce(E,"").localeCompare(k.reduce(E,""))}(d.clipScope,m.clipScope));let g=this._activeRegions.length!==this._prevRegions.length;if(!g){let d=0;for(;!g&&d!==this._activeRegions.length;){const m=this._activeRegions[d],v=this._prevRegions[d];g=m.priority!==v.priority||!SCe(m,v)||m.order!==v.order||m.clipMask!==v.clipMask||!an(m.clipScope,v.clipScope),this._activeRegions[d].hiddenByOverlap=v.hiddenByOverlap,++d}}if(g){++this._updateTime;for(const m of this._activeRegions)m.order!==AP&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,m.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,m.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,m.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,m.max.y));const d=m=>{const v=this._activeRegions;if(m>=v.length)return m;const k=v[m].priority;for(;m1){let m=0,v=d(m);for(;m!==v;){let k=m;const E=m;for(;k!==v;){const P=this._activeRegions[k];P.hiddenByOverlap=!1;for(let O=0;O=0;d--)this._addSource(g[d]);this._computeReplacement()}},i.eQ=AP,i.eR=class{constructor(g){this._createGrid(g),this._createPoles(g)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const g of this._poleSegments)g.destroy();for(const g of this._gridSegments)g.withSkirts.destroy(),g.withoutSkirts.destroy()}_fillGridMeshWithLods(g,d){const m=new Ny,v=new Il,k=[],E=g+1+2,P=d[0]+1,O=d[0]+1+(1+d.length),B=(W,J,te)=>{let ie=W===E-1?W-2:W===0?W:W-1;return ie+=te?24575:0,[ie,J]};for(let W=0;W0?(Le=2*Math.sqrt(Ne+1),g[3]=.25*Le,g[0]=(te-ce)/Le,g[1]=(ie-B)/Le,g[2]=(O-W)/Le):P>J&&P>ue?(Le=2*Math.sqrt(1+P-J-ue),g[3]=(te-ce)/Le,g[0]=.25*Le,g[1]=(O+W)/Le,g[2]=(ie+B)/Le):J>ue?(Le=2*Math.sqrt(1+J-P-ue),g[3]=(ie-B)/Le,g[0]=(O+W)/Le,g[1]=.25*Le,g[2]=(te+ce)/Le):(Le=2*Math.sqrt(1+ue-P-J),g[3]=(O-W)/Le,g[0]=(ie+B)/Le,g[1]=(te+ce)/Le,g[2]=.25*Le),g},i.f=function(g){return btoa(encodeURIComponent(g).replace(/%([0-9A-F]{2})/g,(d,m)=>String.fromCharCode(+("0x"+m))))},i.f0=function([g,d,m]){const v=Math.hypot(g,d,m),k=Math.atan2(g,m),E=.5*Math.PI-Math.acos(-d/v);return new x(_i(k),_i(E))},i.f1=Ke,i.f2=vpe,i.f3=function(g){const d=g.navigator?g.navigator.userAgent:null;return!!function(m){if(Qo==null){const v=m.navigator?m.navigator.userAgent:null;Qo=!!m.safari||!(!v||!(/\b(iPad|iPhone|iPod)\b/.test(v)||v.match("Safari")&&!v.match("Chrome")))}return Qo}(g)&&!(!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(g,d){O1=g,R1=d},i.f5=Zme,i.f6=ZSe,i.f7=function(g){const d=[0,0,0],m=j(new Float64Array(16));return S(m,g.pixelMatrix,g.globeMatrix),Rt(d,d,m),new es(d[0],d[1])},i.f8=function(){const g=OP;g&&(g.isPreloaded()&&g.numActive()===1?(g.release(dpe),OP=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(){pF().acquire(dpe)},i.fA=GF,i.fB=Ut,i.fC=function(g){let d=0;if(new Uint32Array(g,0,1)[0]!==o3e){const m=new Uint32Array(g,0,7),[,,v,k,E,P]=m;d=m.byteLength+k+E+P+E,(v!==g.byteLength||d>=g.byteLength)&&hr("Invalid b3dm header information.")}return u3e(g,d)},i.fD=function(g,d){const m=kpe(g);for(const v of m){for(const k of v.meshes)Gct(k);v.lights&&(v.lightMeshIndex=v.meshes.length,v.meshes.push(Kct(v.lights,d)))}return m},i.fE=$F,i.fF=fa,i.fG=s3e,i.fH=Jg,i.fI=kh,i.fJ=function(g){Ld(),Qh!=null&&Qh.then(d=>{d.keys().then(m=>{for(let v=0;vhr(k.message))}).catch(m=>hr(m.message))}).catch(d=>hr(d.message))},i.fa=iw,i.fb=function(g,d,m=!1){if(Au===kh.deferred||Au===kh.loading||Au===kh.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Qg=Pl.resolveURL(g),Au=kh.deferred,tP=d,WC(),m||DR()},i.fc=function(g){j3=Pl.resolveURL(g),k3||(k3=new w3(pF(),new Ts)),k3.broadcast("setMeshoptUrl",j3)},i.fd=a3e,i.fe=function(g){mpe=Pl.resolveURL(g),k3||(k3=new w3(pF(),new Ts)),k3.broadcast("setDracoUrl",mpe)},i.ff=n3e,i.fg=DP,i.fh=function(g){const d=Jh();if(!d)return;const m=d.delete(D1);g&&m.then(()=>g()).catch(g)},i.fi=_w,i.fj=_r,i.fk=m_,i.fl=dx,i.fm=kMe,i.fn=NMe,i.fo=S3e,i.fp=ls,i.fq="hd_road_elevation",i.fr=ii,i.fs=Qt,i.ft=lv,i.fu=Rpe,i.fv=jw,i.fw=function(g,d,m,v,k,E,P,O=1,B,W,J){g.createArrays(),g.tilePixelRatio=Qs/(512*g.overscaling),g.compareText={},g.iconsNeedLinear=!1;const te=g.layers[0].layout,ie=g.layers[0]._unevaluatedLayout._values,ce={};ce.scaleFactor=O,ce.textSizeScaleRange=te.get("text-size-scale-range"),ce.iconSizeScaleRange=te.get("icon-size-scale-range");const[ue,Ne]=ce.textSizeScaleRange,[Le,Ie]=ce.iconSizeScaleRange;ce.textScaleFactor=ve(ce.scaleFactor,ue,Ne),ce.iconScaleFactor=ve(ce.scaleFactor,Le,Ie);const Ge=ie["text-size"],Ze=ie["icon-size"];if(g.textSizeData.kind==="composite"){const{minZoom:Bt,maxZoom:as}=g.textSizeData;ce.compositeTextSizes=[Ge.possiblyEvaluate(new Hi(Bt,{worldview:J}),E),Ge.possiblyEvaluate(new Hi(as,{worldview:J}),E)]}if(g.iconSizeData.kind==="composite"){const{minZoom:Bt,maxZoom:as}=g.iconSizeData;ce.compositeIconSizes=[Ze.possiblyEvaluate(new Hi(Bt,{worldview:J}),E),Ze.possiblyEvaluate(new Hi(as,{worldview:J}),E)]}ce.layoutTextSize=Ge.possiblyEvaluate(new Hi(P+1,{worldview:J}),E),ce.layoutIconSize=Ze.possiblyEvaluate(new Hi(P+1,{worldview:J}),E),ce.textMaxSize=Ge.possiblyEvaluate(new Hi(18,{worldview:J}),E);const at=te.get("symbol-placement"),vt=te.get("text-rotation-alignment")==="map"&&at!=="point",pt=te.get("text-size");let St=!1;const Lt=[];for(const Bt of g.features){const as=te.get("text-font").evaluate(Bt,{},E).join(","),Wt=pt.evaluate(Bt,{},E)*ce.textScaleFactor,us=ce.layoutTextSize.evaluate(Bt,{},E)*ce.textScaleFactor,bs=ce.layoutIconSize.evaluate(Bt,{},E)*ce.iconScaleFactor,ws={horizontal:{},vertical:void 0},Fs=Bt.text;let Bs,Ds=[0,0];if(Fs){const Ln=Fs.toString(),Ci=te.get("text-letter-spacing").evaluate(Bt,{},E)*_c,ft=te.get("text-line-height").evaluate(Bt,{},E)*_c,_t=JE(Ln)?Ci:0,hs=te.get("text-anchor").evaluate(Bt,{},E),zs=te.get("text-variable-anchor");if(!zs){const Sn=te.get("text-radial-offset").evaluate(Bt,{},E);if(Sn)Ds=l5e(hs,[Sn*_c,Bpe]);else{const Bn=te.get("text-offset").evaluate(Bt,{},E);Ds=[Bn[0]*_c,Bn[1]*_c]}}let or=vt?"center":te.get("text-justify").evaluate(Bt,{},E);const lr=at==="point",Or=lr?te.get("text-max-width").evaluate(Bt,{},E)*_c:1/0,zr=Sn=>{g.allowVerticalPlacement&&nw(Ln)&&(ws.vertical=Ppe(Fs,d,m,k,as,Or,ft,hs,Sn,_t,Ds,om.vertical,!0,us,Wt,B))};if(!vt&&zs){const Sn=or==="auto"?zs.map(Hn=>$pe(Hn)):[or];let Bn=!1;for(let Hn=0;Hn=0||!nw(Ln)){const Sn=Ppe(Fs,d,m,k,as,Or,ft,hs,or,_t,Ds,om.horizontal,!1,us,Wt,B);Sn&&(ws.horizontal[or]=Sn)}zr(lr?"left":or)}}let Os,ds,is,Rs,Js,Hs,Dr=!1;const ur=te.get("icon-text-fit").evaluate(Bt,{},E);if(Bt.icon&&Bt.icon.hasPrimary()){const Ln=WP(Bt.icon,g.iconSizeData,ie["icon-size"],E,g.zoom,Bt,B,ce.iconScaleFactor,J);Os=Ln.iconPrimary,is=Ln.iconSecondary;const Ci=Os.toString();if(ds=v.get(Ci),ds&&(Js=te.get("icon-offset").evaluate(Bt,{},E),Hs=te.get("icon-anchor").evaluate(Bt,{},E),Bs=SF(k.get(Ci),is?k.get(is.toString()):void 0,Js,Hs),Dr=ds.sdf,g.sdfIcons===void 0?g.sdfIcons=ds.sdf:g.sdfIcons!==ds.sdf&&hr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(ds.pixelRatio!==g.pixelRatio||te.get("icon-rotate").constantOr(1)!==0)&&(g.iconsNeedLinear=!0)),is){const ft=is.toString();Rs=v.get(ft)}}St=St||!(!Bt.icon||!Bt.icon.hasSecondary());const yr=EF(ws.horizontal)||ws.vertical;g.iconsInText||(g.iconsInText=!!yr&&yr.iconsInText);const Nr=us*ce.textScaleFactor/_c,{defaultShapedIcon:Wn,verticallyShapedIcon:Gs}=sut(g,Bs,te,Bt,E,ws,Nr,Js,ur);ur!=="none"&&Bs&&(G3e(Bs)||K3e(Bs))&&(AF(0,ds,Os,Bs,Wn,ur,W,v,k),AF(0,Rs,is,Bs,Wn,ur,W,v,k),Gs&&(AF(0,ds,Os,Bs,Gs,ur,W,v,k),AF(0,Rs,is,Bs,Gs,ur,W,v,k))),Bs=Wn;const{iconBBox:Sr,iconVerticalBBox:pn,textBBox:xa,textVerticalBBox:ba}=Xdt(g,Bs,Gs,te,Bt,E,bs,Js,ce,k,Hs,ws,us,Ds);Lt.push({feature:Bt,shapedTextOrientations:ws,shapedText:yr,shapedIcon:Bs,iconPrimary:Os,iconSecondary:is,iconOffset:Js,iconAnchor:Hs,verticallyShapedIcon:Gs,layoutTextSize:us,layoutIconSize:bs,textOffset:Ds,isSDFIcon:Dr,iconTextFit:ur,iconCollisionBounds:Sr,iconVerticalCollisionBounds:pn,textCollisionBounds:xa,textVerticalCollisionBounds:ba})}return{featureData:Lt,sizes:ce,hasAnySecondaryIcon:St,textAlongLine:vt,symbolPlacement:at}},i.fx=s5e,i.fy=function(g,d,m,v,k,E,P,O,B,W){g.iconAtlasPositions=W.iconPositions;const{featureData:J,hasAnySecondaryIcon:te,sizes:ie,textAlongLine:ce,symbolPlacement:ue}=d;for(const Ne of J){const{shapedIcon:Le,verticallyShapedIcon:Ie,feature:Ge,shapedTextOrientations:Ze,shapedText:at,layoutTextSize:vt,textOffset:pt,isSDFIcon:St,iconPrimary:Lt,iconSecondary:Bt,iconTextFit:as,iconOffset:Wt,iconCollisionBounds:us,iconVerticalCollisionBounds:bs,textCollisionBounds:ws}=Ne;d5e(Le,W.iconPositions,Lt,Bt),d5e(Ie,W.iconPositions,Lt,Bt),tut(Ze,W.iconPositions),eut(Lt,Bt,W.iconPositions),(at||Le)&&rut(g,Ge,Ze,Le,Ie,B,ie,vt,0,pt,St,v,k,P,O,te,as,Wt,ce,ue,us,bs,ws)}m&&g.generateCollisionDebugBuffers(E,g.collisionBoxArray,ie.textScaleFactor)},i.fz=Yt,i.g=function(g,d){return Vg(Object.assign(g,{method:"GET"}),d)},i.h=function(g){return g.indexOf("mapbox:")===0},i.i=function(g){return aa.API_STYLE_REGEX.test(g)&&!yc(g)},i.j=io,i.k=su,i.l=function(g){return decodeURIComponent(atob(g).split("").map(d=>"%"+("00"+d.charCodeAt(0).toString(16)).slice(-2)).join(""))},i.m=function(g,d){return Vg(Object.assign(g,{type:"json"}),d)},i.n=hy,i.o=Pl,i.p=function(g,d){return Vg(Object.assign(g,{method:"POST"}),d)},i.q=zd,i.r=zm,i.s=function(g){try{const d=self[g];return d.setItem("_mapbox_test_",1),d.removeItem("_mapbox_test_"),!0}catch{return!1}},i.t=function(){return upe||(upe=new _w("ImageRasterizer")),upe},i.u=function(){return function g(d){return d?(d^Math.random()*(16>>d/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,g)}()},i.v=function(g){return!!g&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(g)},i.w=hr,i.x=nfe,i.y=my,i.z=qm}),o(["./shared"],function(i){function c(Vt){const ve=Vt?Vt.url.toString():void 0;return ve?performance.getEntriesByName(ve):[]}function u(Vt){if(typeof Vt=="number"||typeof Vt=="boolean"||typeof Vt=="string"||Vt==null)return JSON.stringify(Vt);if(Array.isArray(Vt)){let ze="[";for(const Qe of Vt)ze+=`${u(Qe)},`;return`${ze}]`}let ve="{";for(const ze of Object.keys(Vt).sort())ve+=`${ze}:${u(Vt[ze])},`;return`${ve}}`}function p(Vt){let ve="";for(const ze of i.bx)ve+=`/${u(Vt[ze])}`;return ve}class f{constructor(ve){this.keyCache={},this._layers={},this._layerConfigs={},ve&&this.replace(ve)}replace(ve,ze){this._layerConfigs={},this._layers={},this.update(ve,[],ze)}update(ve,ze,Qe){this._options=Qe;for(const Nt of ve)this._layerConfigs[Nt.id]=Nt,(this._layers[Nt.id]=i.du(Nt,this.scope,null,this._options)).compileFilter(Qe),this.keyCache[Nt.id]&&delete this.keyCache[Nt.id];for(const Nt of ze)delete this.keyCache[Nt],delete this._layerConfigs[Nt],delete this._layers[Nt];this.familiesBySource={};const Ct=function(Nt,zt){const Kt={};for(let Qt=0;Qtthis._layers[gr.id]),Kt=zt[0];if(Kt.visibility==="none")continue;const $t=Kt.source||"";let Qt=this.familiesBySource[$t];Qt||(Qt=this.familiesBySource[$t]={});const Is=Kt.sourceLayer||"_geojsonTileLayer";let gs=Qt[Is];gs||(gs=Qt[Is]=[]),gs.push(zt)}}}const y=1*i.fl;class _{constructor(ve){const ze={},Qe=[];for(const Kt in ve){const $t=ve[Kt],Qt=ze[Kt]={};for(const Is in $t.glyphs){const gs=$t.glyphs[+Is];if(!gs||gs.bitmap.width===0||gs.bitmap.height===0)continue;const gr=gs.metrics.localGlyph?y:1,qr={x:0,y:0,w:gs.bitmap.width+2*gr,h:gs.bitmap.height+2*gr};Qe.push(qr),Qt[Is]=qr}}const{w:Ct,h:Nt}=i.G(Qe),zt=new i.fk({width:Ct||1,height:Nt||1});for(const Kt in ve){const $t=ve[Kt];for(const Qt in $t.glyphs){const Is=$t.glyphs[+Qt];if(!Is||Is.bitmap.width===0||Is.bitmap.height===0)continue;const gs=ze[Kt][Qt],gr=Is.metrics.localGlyph?y:1;i.fk.copy(Is.bitmap,zt,{x:0,y:0},{x:gs.x+gr,y:gs.y+gr},Is.bitmap)}}this.image=zt,this.positions=ze}}function b(Vt,ve,ze){Vt[ve]?ze&&(Vt[ve].center=ze):Vt[ve]={floorIds:new Set,center:ze||[0,0],floors:{}}}function w(Vt,ve,ze,Qe){for(const Ct of ve)b(Vt,Ct),Vt[Ct].floors[ze]=Qe,Vt[Ct].floorIds.add(ze)}function j(Vt){return{id:Vt.properties.id.toString(),center:Vt.properties.center.toString().split(";").map(Number)}}function N(Vt){return{id:Vt.properties.id.toString(),isDefault:!!Vt.properties.is_default&&Vt.properties.is_default,connections:Vt.properties.connected_floor_ids?new Set(Vt.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:Vt.properties.conflicted_floor_ids?new Set(Vt.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:Vt.properties.building_ids?new Set(Vt.properties.building_ids.toString().split(";")):new Set,name:Vt.properties.name.toString(),zIndex:Vt.properties.z_index}}function S(Vt,ve){return ve.every(ze=>Vt.properties&&Vt.properties[ze]!=null)}function T(Vt){return S(Vt,["type","id","name"])&&Vt.properties.type==="building"}function I(Vt){return S(Vt,["type","id","name","z_index"])&&Vt.properties.type==="floor"}i.fj(_,"GlyphAtlas");class L{constructor(ve){this.tileID=new i.aQ(ve.tileID.overscaledZ,ve.tileID.wrap,ve.tileID.canonical.z,ve.tileID.canonical.x,ve.tileID.canonical.y),this.tileZoom=ve.tileZoom,this.uid=ve.uid,this.zoom=ve.zoom,this.lut=ve.lut,this.canonical=ve.tileID.canonical,this.pixelRatio=ve.pixelRatio,this.tileSize=ve.tileSize,this.source=ve.source,this.scope=ve.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=ve.showCollisionBoxes,this.collectResourceTiming=!!ve.request&&ve.request.collectResourceTiming,this.promoteId=ve.promoteId,this.isSymbolTile=ve.isSymbolTile,this.tileTransform=i.aZ(ve.tileID.canonical,ve.projection),this.projection=ve.projection,this.worldview=ve.worldview,this.localizableLayerIds=ve.localizableLayerIds,this.brightness=ve.brightness,this.extraShadowCaster=!!ve.extraShadowCaster,this.tessellationStep=ve.tessellationStep,this.scaleFactor=ve.scaleFactor,this.worldview=ve.worldview,this.indoor=ve.indoor}parse(ve,ze,Qe,Ct,Nt,zt){this.status="parsing",this.data=ve,this.collisionBoxArray=new i.b3;const Kt=new i.fm(Object.keys(ve.layers).sort()),$t=new i.fn(this.tileID,this.promoteId);$t.bucketLayerIDs=[];const Qt={},Is=new i.fo(256,256),gs={featureIndex:$t,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Is,availableImages:Qe,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const Cn=this.indoor.indoorState.activeFloorsVisible,Mn=function(jn,fa,go){const Qo=function(no,Na){if(!no)return i.w("No source layers defined in indoor specification"),Na;if(no.size===0)return Na;const ao=no.difference(Na);for(const Si of ao)i.w(`Missing source layer required in indoor specification: ${Si}`);return Na.intersection(Na)}(fa.sourceLayers,new Set(Object.keys(jn.layers))),Qa=fa.indoorState,nl=function(no,Na,ao,Si){const aa=new Set,io=new Set,yc=new Set,Lc=new Map,eu={},Cf=El=>{const th=Lc.get(El)||new Set;for(const yd of aa)if((Lc.get(yd)||new Set).has(El)||th.has(yd))return!0;return!1};for(const El of Na){const th=no.layers[El];if(th)for(let yd=0;yd=ao.maxzoom||ao.visibility==="none")continue;R(Na,this.zoom,gs.brightness,Qe,this.worldview);const Si=Qt[ao.id]=ao.createBucket({index:$t.bucketLayerIDs.length,layers:Na,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Qo,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:Ct,worldview:this.worldview,localizable:nl});$t.bucketLayerIDs.push(Na.map(io=>i.B(io.id,io.scope)));let aa=Si.prepare?Si.prepare():null;aa!=null?(aa=aa.then(()=>Si.populate(Qa,gs,this.tileID.canonical,this.tileTransform)),gr.push(aa)):Si.populate(Qa,gs,this.tileID.canonical,this.tileTransform)}}const hr=()=>{let Cn,Mn,jn,fa,go,Qo;Is.trim();const Qa={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},nl=()=>{if(Cn)return this.status="done",zt(Cn);if(this.extraShadowCaster)this.status="done",zt(null,{buckets:Object.values(Qt).filter(Na=>!Na.isEmpty()),featureIndex:$t,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:gs.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Mn&&jn&&fa){const Na=new _(Mn),ao=new Map;for(const[io,yc]of jn.entries()){const{imagePosition:Lc}=i.fu(io,yc,i.fv);ao.set(io,Lc)}const Si={};for(const io in Qt){const yc=Qt[io];yc instanceof i.b4&&(R(yc.layers,this.zoom,gs.brightness,Qe,this.worldview),Si[io]=i.fw(yc,Mn,Na.positions,jn,ao,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,go,this.worldview))}const aa={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(Nt,jn,go,()=>{aa.iconsPending=!1,no(Si,Na,aa)}),this.rasterizeIfNeeded(Nt,fa,Qo,()=>{aa.patternsPending=!1,no(Si,Na,aa)})}},no=(Na,ao,Si,aa)=>{if(Si.iconsPending||Si.patternsPending)return;const io=new i.fx(jn,fa,this.lut);for(const yc in Qt){const Lc=Qt[yc];if(yc in Na)i.fy(Lc,Na[yc],this.showCollisionBoxes,Qe,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,jn,io);else if(Lc.hasPattern&&(Lc instanceof i.ba||Lc instanceof i.bb||Lc instanceof i.ea)){R(Lc.layers,this.zoom,gs.brightness,Qe,this.worldview);const eu=Object.fromEntries(io.patternPositions);Lc.addFeatures(gs,this.tileID.canonical,eu,Qe,this.tileTransform,this.brightness)}}this.status="done",zt(null,{buckets:Object.values(Qt).filter(yc=>!yc.isEmpty()),featureIndex:$t,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:ao.image,lineAtlas:Is,imageAtlas:io,brightness:gs.brightness})};if(!this.extraShadowCaster){const Na=i.fs(gs.glyphDependencies,aa=>Object.keys(aa).map(Number));Object.keys(Na).length?Nt.send("getGlyphs",{uid:this.uid,stacks:Na},(aa,io)=>{Cn||(Cn=aa,Mn=io,nl())},void 0,!1,Qa):Mn={};const ao=Array.from(gs.iconDependencies.keys()).map(aa=>i.I.parse(aa));ao.length?Nt.send("getImages",{images:ao,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(aa,io)=>{Cn||(Cn=aa,jn=new Map,go=this.updateImageMapAndGetImageTaskQueue(jn,io,gs.iconDependencies),nl())},void 0,!1,Qa):(jn=new Map,go=new Map);const Si=Array.from(gs.patternDependencies.keys()).map(aa=>i.I.parse(aa));Si.length?Nt.send("getImages",{images:Si,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(aa,io)=>{Cn||(Cn=aa,fa=new Map,Qo=this.updateImageMapAndGetImageTaskQueue(fa,io,gs.patternDependencies),nl())},void 0,!1,Qa):(fa=new Map,Qo=new Map)}if(gs.elevationFeatures&&gs.elevationFeatures.length>0){const Na=[];for(const Si of Object.values(Qt))if(Si instanceof i.bb){const aa=Si.getUnevaluatedPortalGraph();aa&&Na.push(aa)}const ao=i.ft.evaluate(Na);for(const Si of Object.values(Qt))if(Si instanceof i.bb){const aa=ve.layers[Kt.decode(Si.sourceLayerIndex)];Si.setEvaluatedPortalGraph(ao,aa,this.tileID.canonical,gs.availableImages,gs.brightness)}}nl()};gr.length>0?Promise.allSettled(gr).then(hr).catch(zt):hr()}updateParameters(ve){this.scaleFactor=ve.scaleFactor,this.showCollisionBoxes=ve.showCollisionBoxes,this.projection=ve.projection,this.brightness=ve.brightness,this.tileTransform=i.aZ(ve.tileID.canonical,ve.projection),this.extraShadowCaster=ve.extraShadowCaster,this.lut=ve.lut,this.worldview=ve.worldview,this.indoor=ve.indoor}rasterizeIfNeeded(ve,ze,Qe,Ct){Array.from(ze.values()).some(Nt=>Nt.usvg)?this.rasterize(ve,ze,Qe,Ct):Ct()}updateImageMapAndGetImageTaskQueue(ve,ze,Qe){const Ct=new Map;for(const Nt of ze.keys()){const zt=Qe.get(Nt)||[];for(const Kt of zt){const $t=Kt.toString(),Qt=ze.get(Kt.id.toString());Qt.usvg?Ct.has($t)||(Ct.set($t,Kt),ve.set($t,Object.assign({},Qt))):ve.set($t,Qt)}}return Ct}rasterize(ve,ze,Qe,Ct){this.rasterizeTask=ve.send("rasterizeImages",{scope:this.scope,tasks:Qe},(Nt,zt)=>{if(!Nt)for(const[Kt,$t]of zt.entries()){const Qt=Object.assign(ze.get(Kt),{data:$t});ze.set(Kt,Qt)}Ct()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function R(Vt,ve,ze,Qe,Ct){const Nt=new i.ac(ve,{brightness:ze,worldview:Ct});for(const zt of Vt)zt.recalculate(Nt,Qe)}class $ extends i.E{constructor(ve,ze,Qe,Ct,Nt,zt,Kt){super(),this.actor=ve,this.layerIndex=ze,this.availableImages=Qe,this.availableModels=Ct,this.loadVectorData=zt||i.aL,this.loading={},this.loaded={},this.deduped=new i.aK(ve.scheduler),this.isSpriteLoaded=Nt,this.scheduler=ve.scheduler,this.brightness=Kt}loadTile(ve,ze){const Qe=ve.uid,Ct=ve&&ve.request,Nt=Ct&&Ct.collectResourceTiming,zt=this.loading[Qe]=new L(ve);zt.abort=this.loadVectorData(ve,(Kt,$t)=>{const Qt=!this.loading[Qe];if(delete this.loading[Qe],zt.cancelRasterize(),Qt||Kt||!$t)return zt.status="done",Qt||(this.loaded[Qe]=zt),ze(Kt);const Is=$t.rawData,gs={},gr=i.aM($t.responseHeaders);gr&&gr.expires&&(gs.expires=gr.expires),gr&&gr.cacheControl&&(gs.cacheControl=gr.cacheControl),zt.vectorTile=$t.vectorTile||new i.fz(new i.bt(Is));const qr=()=>{zt.parse(zt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(hr,Cn)=>{if(hr||!Cn)return ze(hr);const Mn={};if(Nt){const jn=c(Ct);jn.length>0&&(Mn.resourceTiming=JSON.parse(JSON.stringify(jn)))}ze(null,Object.assign({rawTileData:Is.slice(0),responseHeaders:$t.responseHeaders},Cn,gs,Mn))})};this.isSpriteLoaded?qr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(qr,{type:"parseTile",isSymbolTile:ve.isSymbolTile,zoom:ve.tileZoom}):qr()}),this.loaded=this.loaded||{},this.loaded[Qe]=zt})}reloadTile(ve,ze){const Qe=this.loaded,Ct=ve.uid;if(Qe&&Qe[Ct]){const Nt=Qe[Ct];Nt.updateParameters(ve);const zt=(Kt,$t)=>{const Qt=Nt.reloadCallback;Qt&&(delete Nt.reloadCallback,Nt.parse(Nt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Qt)),ze(Kt,$t)};Nt.status==="parsing"?Nt.reloadCallback=zt:Nt.status==="done"&&(Nt.vectorTile?Nt.parse(Nt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,zt):zt())}else ze(null,void 0)}abortTile(ve,ze){const Qe=ve.uid,Ct=this.loading[Qe];Ct&&(Ct.abort&&Ct.abort(),delete this.loading[Qe]),ze()}removeTile(ve,ze){const Qe=this.loaded,Ct=ve.uid;Qe&&Qe[Ct]&&delete Qe[Ct],ze()}}class q{loadTile(ve,ze){const{uid:Qe,encoding:Ct,rawImageData:Nt,padding:zt}=ve,Kt=ImageBitmap&&Nt instanceof ImageBitmap?this.getImageData(Nt,zt):Nt;ze(null,new i.fA(Qe,Kt,Ct,zt<1))}reloadTile(ve,ze){ze(null,null)}abortTile(ve,ze){ze()}removeTile(ve,ze){ze()}getImageData(ve,ze){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(ve.width,ve.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=ve.width,this.offscreenCanvas.height=ve.height,this.offscreenCanvasContext.drawImage(ve,0,0,ve.width,ve.height);const Qe=this.offscreenCanvasContext.getImageData(-ze,-ze,ve.width+2*ze,ve.height+2*ze);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Qe}}i.bs.setPbf(i.bt);class U{constructor(ve){this._mrt=new i.bs(ve.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=ve.uid,this.tileID=ve.tileID,this.source=ve.source}parse(ve,ze){const Qe=this._mrt;this.status="parsing",this._entireBuffer=ve;try{Qe.parseHeader(ve),this._isHeaderLoaded=!0;const Ct=[];for(const Nt in Qe.layers){const zt=Qe.getLayer(Nt),Kt=zt.getDataRange(zt.getBandList()),$t=Qe.createDecodingTask(Kt),Qt=ve.slice(Kt.firstByte,Kt.lastByte+1),Is=i.bs.performDecoding(Qt,$t).then(gs=>$t.complete(null,gs)).catch(gs=>$t.complete(gs,null));Ct.push(Is)}Promise.allSettled(Ct).then(()=>ze(null,Qe)).catch(Nt=>ze(Nt))}catch(Ct){ze(Ct)}}}class V{constructor(ve){this.actor=ve,this.loading={},this.loaded={}}loadTile(ve,ze){const Qe=ve.uid,Ct=ve.request,Nt=this.loading[Qe]=new U(ve),{cancel:zt}=i.bu(Ct,(Kt,$t,Qt)=>{const Is=!this.loading[Qe];if(delete this.loading[Qe],Is||Kt||!$t)return Nt.status="done",Is||(this.loaded[Qe]=Nt),ze(Kt);Nt.parse($t,(gs,gr)=>{if(gs||!gr)return ze(gs);ze(null,gr,Qt)}),this.loaded[Qe]=Nt});Nt.abort=zt}reloadTile(ve,ze){ze(null,void 0)}abortTile(ve,ze){const Qe=ve.uid,Ct=this.loading[Qe];Ct&&(Ct.abort&&Ct.abort(),delete this.loading[Qe]),ze()}removeTile(ve,ze){const Qe=ve.uid;this.loaded[Qe]&&delete this.loaded[Qe],ze()}decodeRasterArray(ve,ze){i.bs.performDecoding(ve.buffer,ve.task).then(Qe=>ze(null,Qe)).catch(Qe=>ze(Qe))}}const X=i.fB.prototype.toGeoJSON;class se{constructor(ve){this._feature=ve,this.extent=i.al,this.type=ve.type,this.properties=ve.tags,"id"in ve&&!isNaN(ve.id)&&(this.id=parseInt(ve.id,10))}loadGeometry(){if(this._feature.type===1){const ve=[];for(const ze of this._feature.geometry)ve.push([new i.P(ze[0],ze[1])]);return ve}{const ve=[];for(const ze of this._feature.geometry){const Qe=[];for(const Ct of ze)Qe.push(new i.P(Ct[0],Ct[1]));ve.push(Qe)}return ve}}toGeoJSON(ve,ze,Qe){return X.call(this,ve,ze,Qe)}}class ee{constructor(ve,ze){this.name=ve,this.extent=i.al,this.length=ze.length,this._jsonFeatures=ze}feature(ve){return new se(this._jsonFeatures[ve])}}class Q{constructor(ve){this.layers={},this.extent=i.al;for(const ze of Object.keys(ve))this.layers[ze]=new ee(ze,ve[ze])}}const de=64/4096,re=128;class ne{constructor(){this.features=new Map}clear(){this.features.clear()}load(ve=[],ze){for(const Qe of ve){const Ct=Qe.id;if(Ct==null)continue;let Nt=this.features.get(Ct);Nt&&this.updateCache(Nt,ze),Qe.geometry?(Nt=he(Qe),this.updateCache(Nt,ze),this.features.set(Ct,Nt)):this.features.delete(Ct),this.updateCache(Nt,ze)}}updateCache(ve,ze){for(const{canonical:Qe,uid:Ct}of Object.values(ze)){const{z:Nt,x:zt,y:Kt}=Qe;le(ve,Math.pow(2,Nt),zt,Kt)&&delete ze[Ct]}}getTile(ve,ze,Qe){const Ct=Math.pow(2,ve),Nt=[];for(const zt of this.features.values())le(zt,Ct,ze,Qe)&&Nt.push(ke(zt,Ct,ze,Qe));return{features:Nt}}getFeatures(){return[...this.features.values()]}}function le({minX:Vt,minY:ve,maxX:ze,maxY:Qe},Ct,Nt,zt){return Vt<(Nt+1+de)/Ct&&ve<(zt+1+de)/Ct&&ze>(Nt-de)/Ct&&Qe>(zt-de)/Ct}function he(Vt){const{id:ve,geometry:ze,properties:Qe}=Vt;if(!ze)return;if(ze.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:Ct,coordinates:Nt}=ze,zt={id:ve,type:1,geometry:[],tags:Qe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Kt=zt.geometry;if(Ct==="Point")we(Nt,Kt,zt);else if(Ct==="MultiPoint")for(const $t of Nt)we($t,Kt,zt);else if(Ct==="LineString")zt.type=2,ye(Nt,Kt,zt);else if(Ct==="MultiLineString")zt.type=2,je(Nt,Kt,zt);else if(Ct==="Polygon")zt.type=3,je(Nt,Kt,zt,!0);else{if(Ct!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");zt.type=3;for(const $t of Nt)je($t,Kt,zt,!0)}return zt}function we([Vt,ve],ze,Qe){const Ct=i.aF(Vt);let Nt=i.aJ(ve);Nt=Nt<0?0:Nt>1?1:Nt,ze.push(Ct,Nt),Qe.minX=Math.min(Qe.minX,Ct),Qe.minY=Math.min(Qe.minY,Nt),Qe.maxX=Math.max(Qe.maxX,Ct),Qe.maxY=Math.max(Qe.maxY,Nt)}function ye(Vt,ve,ze,Qe=!1,Ct=!1){const Nt=[];for(const zt of Vt)we(zt,Nt,ze);ve.push(Nt),Qe&&function(zt,Kt){let $t=0;for(let Qt=0,Is=zt.length,gs=Is-2;Qt0===Kt)for(let Qt=0,Is=zt.length;Qt=zt&&gs>=zt||(Qt>=zt?(Is+=Math.round(hr*((zt-Qt)/qr)),Qt=zt):gs>=zt&&(gr=Is+Math.round(hr*((zt-Qt)/qr)),gs=zt),Is>=zt&&gr>=zt||(Is>=zt?(Qt+=Math.round(qr*((zt-Is)/hr)),Is=zt):gr>=zt&&(gs=Qt+Math.round(qr*((zt-Is)/hr)),gr=zt),Kt&&Qt===Kt[Kt.length-1][0]&&Is===Kt[Kt.length-1][1]||(Kt=[[Qt,Is]],Ct.push(Kt)),Kt.push([gs,gr])))))}}function be(Vt,ve,ze,Qe,Ct){const Nt=(ze-de)/ve,zt=(Qe-de)/ve,Kt=(ze+1+de)/ve,$t=(Qe+1+de)/ve;function Qt(gr,qr){let hr=0;return grKt&&(hr|=2),qr$t&&(hr|=8),hr}let Is=[];for(let gr=1;gr<=8;gr*=2){let qr=Vt[Vt.length-2],hr=Vt[Vt.length-1],Cn=!(Qt(qr,hr)&gr);for(let Mn=0;Mn>31}function ct(Vt,ve){const{geometry:ze,type:Qe}=Vt;let Ct=0,Nt=0;if(Qe===1){ve.writeVarint(Te(1,ze.length));for(const zt of ze){const Kt=zt[0]-Ct,$t=zt[1]-Nt;ve.writeVarint(qe(Kt)),ve.writeVarint(qe($t)),Ct+=Kt,Nt+=$t}}else for(const zt of ze){ve.writeVarint(Te(1,1));const Kt=zt.length-(Qe===3?1:0);for(let $t=0;$tVt},pe=Math.fround||(Je=new Float32Array(1),Vt=>(Je[0]=+Vt,Je[0]));var Je;const lt=3,rt=5,Se=6;class it{constructor(ve){this.options=Object.assign(Object.create(Rt),ve),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(ve){const{log:ze,minZoom:Qe,maxZoom:Ct}=this.options;ze&&console.time("total time");const Nt=`prepare ${ve.length} points`;ze&&console.time(Nt),this.points=ve;const zt=[];for(let $t=0;$t=Qe;$t--){const Qt=+Date.now();Kt=this.trees[$t]=this._createTree(this._cluster(Kt,$t)),ze&&console.log("z%d: %d clusters in %dms",$t,Kt.numItems,+Date.now()-Qt)}return ze&&console.timeEnd("total time"),this}getClusters(ve,ze){let Qe=((ve[0]+180)%360+360)%360-180;const Ct=Math.max(-90,Math.min(90,ve[1]));let Nt=ve[2]===180?180:((ve[2]+180)%360+360)%360-180;const zt=Math.max(-90,Math.min(90,ve[3]));if(ve[2]-ve[0]>=360)Qe=-180,Nt=180;else if(Qe>Nt){const gs=this.getClusters([Qe,Ct,180,zt],ze),gr=this.getClusters([-180,Ct,Nt,zt],ze);return gs.concat(gr)}const Kt=this.trees[this._limitZoom(ze)],$t=Kt.range(Ue(Qe),Ke(zt),Ue(Nt),Ke(Ct)),Qt=Kt.data,Is=[];for(const gs of $t){const gr=this.stride*gs;Is.push(Qt[gr+rt]>1?$e(Qt,gr,this.clusterProps):this.points[Qt[gr+lt]])}return Is}getChildren(ve){const ze=this._getOriginId(ve),Qe=this._getOriginZoom(ve),Ct="No cluster with the specified id.",Nt=this.trees[Qe];if(!Nt)throw new Error(Ct);const zt=Nt.data;if(ze*this.stride>=zt.length)throw new Error(Ct);const Kt=this.options.radius/(this.options.extent*Math.pow(2,Qe-1)),$t=Nt.within(zt[ze*this.stride],zt[ze*this.stride+1],Kt),Qt=[];for(const Is of $t){const gs=Is*this.stride;zt[gs+4]===ve&&Qt.push(zt[gs+rt]>1?$e(zt,gs,this.clusterProps):this.points[zt[gs+lt]])}if(Qt.length===0)throw new Error(Ct);return Qt}getLeaves(ve,ze,Qe){const Ct=[];return this._appendLeaves(Ct,ve,ze=ze||10,Qe=Qe||0,0),Ct}getTile(ve,ze,Qe){const Ct=this.trees[this._limitZoom(ve)],Nt=Math.pow(2,ve),{extent:zt,radius:Kt}=this.options,$t=Kt/zt,Qt=(Qe-$t)/Nt,Is=(Qe+1+$t)/Nt,gs={features:[]};return this._addTileFeatures(Ct.range((ze-$t)/Nt,Qt,(ze+1+$t)/Nt,Is),Ct.data,ze,Qe,Nt,gs),ze===0&&this._addTileFeatures(Ct.range(1-$t/Nt,Qt,1,Is),Ct.data,Nt,Qe,Nt,gs),ze===Nt-1&&this._addTileFeatures(Ct.range(0,Qt,$t/Nt,Is),Ct.data,-1,Qe,Nt,gs),gs.features.length?gs:null}getClusterExpansionZoom(ve){let ze=this._getOriginZoom(ve)-1;for(;ze<=this.options.maxZoom;){const Qe=this.getChildren(ve);if(ze++,Qe.length!==1)break;ve=Qe[0].properties.cluster_id}return ze}_appendLeaves(ve,ze,Qe,Ct,Nt){const zt=this.getChildren(ze);for(const Kt of zt){const $t=Kt.properties;if($t&&$t.cluster?Nt+$t.point_count<=Ct?Nt+=$t.point_count:Nt=this._appendLeaves(ve,$t.cluster_id,Qe,Ct,Nt):Nt1;let Is,gs,gr;if(Qt)Is=ot(ze,$t,this.clusterProps),gs=ze[$t],gr=ze[$t+1];else{const Cn=this.points[ze[$t+lt]];Is=Cn.properties;const[Mn,jn]=Cn.geometry.coordinates;gs=Ue(Mn),gr=Ke(jn)}const qr={type:1,geometry:[[Math.round(this.options.extent*(gs*Nt-Qe)),Math.round(this.options.extent*(gr*Nt-Ct))]],tags:Is};let hr;hr=Qt||this.options.generateId?ze[$t+lt]:this.points[ze[$t+lt]].id,hr!==void 0&&(qr.id=hr),zt.features.push(qr)}}_limitZoom(ve){return Math.max(this.options.minZoom,Math.min(Math.floor(+ve),this.options.maxZoom+1))}_cluster(ve,ze){const{radius:Qe,extent:Ct,reduce:Nt,minPoints:zt}=this.options,Kt=Qe/(Ct*Math.pow(2,ze)),$t=ve.data,Qt=[],Is=this.stride;for(let gs=0;gs<$t.length;gs+=Is){if($t[gs+2]<=ze)continue;$t[gs+2]=ze;const gr=$t[gs],qr=$t[gs+1],hr=ve.within($t[gs],$t[gs+1],Kt),Cn=$t[gs+rt];let Mn=Cn;for(const jn of hr){const fa=jn*Is;$t[fa+2]>ze&&(Mn+=$t[fa+rt])}if(Mn>Cn&&Mn>=zt){let jn,fa=gr*Cn,go=qr*Cn,Qo=-1;const Qa=(gs/Is<<5)+(ze+1)+this.points.length;for(const nl of hr){const no=nl*Is;if($t[no+2]<=ze)continue;$t[no+2]=ze;const Na=$t[no+rt];fa+=$t[no]*Na,go+=$t[no+1]*Na,$t[no+4]=Qa,Nt&&(jn||(jn=this._map($t,gs,!0),Qo=this.clusterProps.length,this.clusterProps.push(jn)),Nt(jn,this._map($t,no)))}$t[gs+4]=Qa,Qt.push(fa/Mn,go/Mn,1/0,Qa,-1,Mn),Nt&&Qt.push(Qo)}else{for(let jn=0;jn1)for(const jn of hr){const fa=jn*Is;if(!($t[fa+2]<=ze)){$t[fa+2]=ze;for(let go=0;go>5}_getOriginZoom(ve){return(ve-this.points.length)%32}_map(ve,ze,Qe){if(ve[ze+rt]>1){const zt=this.clusterProps[ve[ze+Se]];return Qe?Object.assign({},zt):zt}const Ct=this.points[ve[ze+lt]].properties,Nt=this.options.map(Ct);return Qe&&Nt===Ct?Object.assign({},Nt):Nt}}function $e(Vt,ve,ze){return{type:"Feature",id:Vt[ve+lt],properties:ot(Vt,ve,ze),geometry:{type:"Point",coordinates:[(Qe=Vt[ve],360*(Qe-.5)),Xe(Vt[ve+1])]}};var Qe}function ot(Vt,ve,ze){const Qe=Vt[ve+rt],Ct=Qe>=1e4?`${Math.round(Qe/1e3)}k`:Qe>=1e3?Math.round(Qe/100)/10+"k":Qe,Nt=Vt[ve+Se],zt=Nt===-1?{}:Object.assign({},ze[Nt]);return Object.assign(zt,{cluster:!0,cluster_id:Vt[ve+lt],point_count:Qe,point_count_abbreviated:Ct})}function Ue(Vt){return Vt/360+.5}function Ke(Vt){const ve=Math.sin(Vt*Math.PI/180),ze=.5-.25*Math.log((1+ve)/(1-ve))/Math.PI;return ze<0?0:ze>1?1:ze}function Xe(Vt){const ve=(180-360*Vt)*Math.PI/180;return 360*Math.atan(Math.exp(ve))/Math.PI-90}function He(Vt,ve,ze,Qe){let Ct=Qe;const Nt=ve+(ze-ve>>1);let zt,Kt=ze-ve;const $t=Vt[ve],Qt=Vt[ve+1],Is=Vt[ze],gs=Vt[ze+1];for(let gr=ve+3;grCt)zt=gr,Ct=qr;else if(qr===Ct){const hr=Math.abs(gr-Nt);hrQe&&(zt-ve>3&&He(Vt,ve,zt,Qe),Vt[zt+2]=Ct,ze-zt>3&&He(Vt,zt,ze,Qe))}function Ye(Vt,ve,ze,Qe,Ct,Nt){let zt=Ct-ze,Kt=Nt-Qe;if(zt!==0||Kt!==0){const $t=((Vt-ze)*zt+(ve-Qe)*Kt)/(zt*zt+Kt*Kt);$t>1?(ze=Ct,Qe=Nt):$t>0&&(ze+=zt*$t,Qe+=Kt*$t)}return zt=Vt-ze,Kt=ve-Qe,zt*zt+Kt*Kt}function tt(Vt,ve,ze,Qe){const Ct={id:Vt??null,type:ve,geometry:ze,tags:Qe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(ve==="Point"||ve==="MultiPoint"||ve==="LineString")Et(Ct,ze);else if(ve==="Polygon")Et(Ct,ze[0]);else if(ve==="MultiLineString")for(const Nt of ze)Et(Ct,Nt);else if(ve==="MultiPolygon")for(const Nt of ze)Et(Ct,Nt[0]);return Ct}function Et(Vt,ve){for(let ze=0;ze0&&(zt+=Qe?(Ct*Is-Qt*Nt)/2:Math.sqrt(Math.pow(Qt-Ct,2)+Math.pow(Is-Nt,2))),Ct=Qt,Nt=Is}const Kt=ve.length-3;ve[2]=1,He(ve,0,Kt,ze),ve[Kt+2]=1,ve.size=Math.abs(zt),ve.start=0,ve.end=ve.size}function rs(Vt,ve,ze,Qe){for(let Ct=0;Ct1?1:ze}function jt(Vt,ve,ze,Qe,Ct,Nt,zt,Kt){if(Qe/=ve,Nt>=(ze/=ve)&&zt=Qe)return null;const $t=[];for(const Qt of Vt){const Is=Qt.geometry;let gs=Qt.type;const gr=Ct===0?Qt.minX:Qt.minY,qr=Ct===0?Qt.maxX:Qt.maxY;if(gr>=ze&&qr=Qe)continue;let hr=[];if(gs==="Point"||gs==="MultiPoint")As(Is,hr,ze,Qe,Ct);else if(gs==="LineString")Ps(Is,hr,ze,Qe,Ct,!1,Kt.lineMetrics);else if(gs==="MultiLineString")Dn(Is,hr,ze,Qe,Ct,!1);else if(gs==="Polygon")Dn(Is,hr,ze,Qe,Ct,!0);else if(gs==="MultiPolygon")for(const Cn of Is){const Mn=[];Dn(Cn,Mn,ze,Qe,Ct,!0),Mn.length&&hr.push(Mn)}if(hr.length){if(Kt.lineMetrics&&gs==="LineString"){for(const Cn of hr)$t.push(tt(Qt.id,gs,Cn,Qt.tags));continue}gs!=="LineString"&&gs!=="MultiLineString"||(hr.length===1?(gs="LineString",hr=hr[0]):gs="MultiLineString"),gs!=="Point"&&gs!=="MultiPoint"||(gs=hr.length===3?"Point":"MultiPoint"),$t.push(tt(Qt.id,gs,hr,Qt.tags))}}return $t.length?$t:null}function As(Vt,ve,ze,Qe,Ct){for(let Nt=0;Nt=ze&&zt<=Qe&&Va(ve,Vt[Nt],Vt[Nt+1],Vt[Nt+2])}}function Ps(Vt,ve,ze,Qe,Ct,Nt,zt){let Kt=ar(Vt);const $t=Ct===0?pa:qa;let Qt,Is,gs=Vt.start;for(let Mn=0;Mnze&&(Is=$t(Kt,jn,fa,Qo,Qa,ze),zt&&(Kt.start=gs+Qt*Is)):nl>Qe?no=ze&&(Is=$t(Kt,jn,fa,Qo,Qa,ze),Na=!0),no>Qe&&nl<=Qe&&(Is=$t(Kt,jn,fa,Qo,Qa,Qe),Na=!0),!Nt&&Na&&(zt&&(Kt.end=gs+Qt*Is),ve.push(Kt),Kt=ar(Vt)),zt&&(gs+=Qt)}let gr=Vt.length-3;const qr=Vt[gr],hr=Vt[gr+1],Cn=Ct===0?qr:hr;Cn>=ze&&Cn<=Qe&&Va(Kt,qr,hr,Vt[gr+2]),gr=Kt.length-3,Nt&&gr>=3&&(Kt[gr]!==Kt[0]||Kt[gr+1]!==Kt[1])&&Va(Kt,Kt[0],Kt[1],Kt[2]),Kt.length&&ve.push(Kt)}function ar(Vt){const ve=[];return ve.size=Vt.size,ve.start=Vt.start,ve.end=Vt.end,ve}function Dn(Vt,ve,ze,Qe,Ct,Nt){for(const zt of Vt)Ps(zt,ve,ze,Qe,Ct,Nt,!1)}function Va(Vt,ve,ze,Qe){Vt.push(ve,ze,Qe)}function pa(Vt,ve,ze,Qe,Ct,Nt){const zt=(Nt-ve)/(Qe-ve);return Va(Vt,Nt,ze+(Ct-ze)*zt,1),zt}function qa(Vt,ve,ze,Qe,Ct,Nt){const zt=(Nt-ze)/(Ct-ze);return Va(Vt,ve+(Qe-ve)*zt,Nt,1),zt}function Kr(Vt,ve){const ze=[];for(let Qe=0;Qe0&&ve.size<(Ct?zt:Qe))return void(ze.numPoints+=ve.length/3);const Kt=[];for(let $t=0;$tzt)&&(ze.numSimplified++,Kt.push(ve[$t],ve[$t+1])),ze.numPoints++;Ct&&function($t,Qt){let Is=0;for(let gs=0,gr=$t.length,qr=gr-2;gs0===Qt)for(let gs=0,gr=$t.length;gs24)throw new Error("maxZoom should be in the 0-24 range");if(ze.promoteId&&ze.generateId)throw new Error("promoteId and generateId cannot be used together.");let Ct=function(Nt,zt){const Kt=[];if(Nt.type==="FeatureCollection")for(let $t=0;$t1&&console.time("creation"),qr=this.tiles[gr]=Zt(ve,ze,Qe,Ct,Qt),this.tileCoords.push({z:ze,x:Qe,y:Ct}),Is)){Is>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",ze,Qe,Ct,qr.numFeatures,qr.numPoints,qr.numSimplified),console.timeEnd("creation"));const Na=`z${ze}`;this.stats[Na]=(this.stats[Na]||0)+1,this.total++}if(qr.source=ve,Nt==null){if(ze===Qt.indexMaxZoom||qr.numPoints<=Qt.indexMaxPoints)continue}else{if(ze===Qt.maxZoom||ze===Nt)continue;if(Nt!=null){const Na=Nt-ze;if(Qe!==zt>>Na||Ct!==Kt>>Na)continue}}if(qr.source=null,ve.length===0)continue;Is>1&&console.time("clipping");const hr=.5*Qt.buffer/Qt.extent,Cn=.5-hr,Mn=.5+hr,jn=1+hr;let fa=null,go=null,Qo=null,Qa=null,nl=jt(ve,gs,Qe-hr,Qe+Mn,0,qr.minX,qr.maxX,Qt),no=jt(ve,gs,Qe+Cn,Qe+jn,0,qr.minX,qr.maxX,Qt);ve=null,nl&&(fa=jt(nl,gs,Ct-hr,Ct+Mn,1,qr.minY,qr.maxY,Qt),go=jt(nl,gs,Ct+Cn,Ct+jn,1,qr.minY,qr.maxY,Qt),nl=null),no&&(Qo=jt(no,gs,Ct-hr,Ct+Mn,1,qr.minY,qr.maxY,Qt),Qa=jt(no,gs,Ct+Cn,Ct+jn,1,qr.minY,qr.maxY,Qt),no=null),Is>1&&console.timeEnd("clipping"),$t.push(fa||[],ze+1,2*Qe,2*Ct),$t.push(go||[],ze+1,2*Qe,2*Ct+1),$t.push(Qo||[],ze+1,2*Qe+1,2*Ct),$t.push(Qa||[],ze+1,2*Qe+1,2*Ct+1)}}getTile(ve,ze,Qe){ve=+ve,ze=+ze,Qe=+Qe;const Ct=this.options,{extent:Nt,debug:zt}=Ct;if(ve<0||ve>24)return null;const Kt=1<1&&console.log("drilling down to z%d-%d-%d",ve,ze,Qe);let Qt,Is=ve,gs=ze,gr=Qe;for(;!Qt&&Is>0;)Is--,gs>>=1,gr>>=1,Qt=this.tiles[Xn(Is,gs,gr)];return Qt&&Qt.source?(zt>1&&(console.log("found parent tile z%d-%d-%d",Is,gs,gr),console.time("drilling down")),this.splitTile(Qt.source,Is,gs,gr,ve,ze,Qe),zt>1&&console.timeEnd("drilling down"),this.tiles[$t]?mn(this.tiles[$t],Nt):null):null}}function Xn(Vt,ve,ze){return 32*((1<Qt.tags&&"3d_elevation_id"in Qt.tags&&"source"in Qt.tags&&Qt.tags.source==="elevation",Nt=Qe.features.filter(Qt=>Ct(Qt));let zt={_geojsonTileLayer:Qe.features};Nt.length>0&&(zt={_geojsonTileLayer:Qe.features.filter(Qt=>!Ct(Qt)),hd_road_elevation:Nt});const Kt=new Q(zt),$t=function(Qt){const Is=new i.bt;for(const gs of Object.keys(Qt))Is.writeMessage(3,Me,{name:gs,features:Qt[gs]});return Is.finish()}(zt).buffer;ve(null,{vectorTile:Kt,rawData:$t})}class _i extends ${constructor(ve,ze,Qe,Ct,Nt,zt,Kt){super(ve,ze,Qe,Ct,Nt,Ir,Kt),zt&&(this.loadGeoJSON=zt),this._dynamicIndex=new ne}loadData(ve,ze){const Qe=ve&&ve.request,Ct=Qe&&Qe.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(ve,(Nt,zt)=>{if(Nt||!zt)return ze(Nt);if(typeof zt!="object")return ze(new Error(`Input data given to '${ve.source}' is not a valid GeoJSON object.`));{try{if(ve.filter){const $t=i.U(ve.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if($t.result==="error")throw new Error($t.value.map(Qt=>`${Qt.key}: ${Qt.message}`).join(", "));zt.features=zt.features.filter(Qt=>$t.value.evaluate({zoom:0},Qt))}ve.dynamic?(zt.type==="Feature"&&(zt={type:"FeatureCollection",features:[zt]}),ve.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(zt.features,this.loaded),ve.cluster&&(zt.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=ve.cluster?new it(function({superclusterOptions:$t,clusterProperties:Qt}){if(!Qt||!$t)return $t;const Is={},gs={},gr={accumulated:null,zoom:0},qr={properties:null},hr=Object.keys(Qt);for(const Cn of hr){const[Mn,jn]=Qt[Cn],fa=i.U(jn),go=i.U(typeof Mn=="string"?[Mn,["accumulated"],["get",Cn]]:Mn);Is[Cn]=fa.value,gs[Cn]=go.value}return $t.map=Cn=>{qr.properties=Cn;const Mn={};for(const jn of hr)Mn[jn]=Is[jn].evaluate(gr,qr);return Mn},$t.reduce=(Cn,Mn)=>{qr.properties=Mn;for(const jn of hr)gr.accumulated=Cn[jn],Cn[jn]=gs[jn].evaluate(gr,qr)},$t}(ve)).load(zt.features):ve.dynamic?this._dynamicIndex:function($t,Qt){return new Ha($t,Qt)}(zt,ve.geojsonVtOptions)}catch($t){return ze($t)}const Kt={};if(Ct){const $t=c(Qe);$t&&(Kt.resourceTiming={},Kt.resourceTiming[ve.source]=JSON.parse(JSON.stringify($t)))}ze(null,Kt)}})}reloadTile(ve,ze){const Qe=this.loaded;return Qe&&Qe[ve.uid]?ve.partial?ze(null,void 0):super.reloadTile(ve,ze):this.loadTile(ve,ze)}loadGeoJSON(ve,ze){if(ve.request)i.m(ve.request,ze);else{if(typeof ve.data!="string")return ze(new Error(`Input data given to '${ve.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return ze(null,JSON.parse(ve.data))}catch{return ze(new Error(`Input data given to '${ve.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(ve,ze){try{ze(null,this._geoJSONIndex.getClusterExpansionZoom(ve.clusterId))}catch(Qe){ze(Qe)}}getClusterChildren(ve,ze){try{ze(null,this._geoJSONIndex.getChildren(ve.clusterId))}catch(Qe){ze(Qe)}}getClusterLeaves(ve,ze){try{ze(null,this._geoJSONIndex.getLeaves(ve.clusterId,ve.limit,ve.offset))}catch(Qe){ze(Qe)}}}class rl{constructor(ve,ze,Qe){this.tileID=new i.aQ(ve.tileID.overscaledZ,ve.tileID.wrap,ve.tileID.canonical.z,ve.tileID.canonical.x,ve.tileID.canonical.y),this.tileZoom=ve.tileZoom,this.uid=ve.uid,this.zoom=ve.zoom,this.canonical=ve.tileID.canonical,this.pixelRatio=ve.pixelRatio,this.tileSize=ve.tileSize,this.source=ve.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=ve.projection,this.brightness=ze,this.worldview=Qe}parse(ve,ze,Qe,Ct){this.status="parsing";const Nt=new i.aQ(Qe.tileID.overscaledZ,Qe.tileID.wrap,Qe.tileID.canonical.z,Qe.tileID.canonical.x,Qe.tileID.canonical.y),zt=[],Kt=ze.familiesBySource[Qe.source],$t=new i.fn(Nt,Qe.promoteId);$t.bucketLayerIDs=[],$t.is3DTile=!0,i.fC(ve).then(Qt=>{if(!Qt)return Ct(new Error("Could not parse tile"));const Is=Qt.json.extensionsUsed&&Qt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Qt.json.asset.extras&&Qt.json.asset.extras.MAPBOX_mesh_features,gs=Qt.json.extensionsUsed&&Qt.json.extensionsUsed.includes("EXT_meshopt_compression"),gr=new i.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const qr in Kt)for(const hr of Kt[qr]){const Cn=hr[0];$t.bucketLayerIDs.push(hr.map(fa=>i.B(fa.id,fa.scope))),Cn.recalculate(gr,[]);const Mn=i.fD(Qt,1/i.d7(Qe.tileID.canonical)),jn=new i.fE(hr,Mn,Nt,Is,gs,this.brightness,$t,this.worldview);Is||(jn.needsUpload=!0),zt.push(jn),jn.evaluate(Cn)}this.status="done",Ct(null,{buckets:zt,featureIndex:$t,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Qt=>Ct(new Error(Qt.message)))}}class Ni{constructor(ve,ze,Qe,Ct,Nt,zt,Kt,$t){this.actor=ve,this.layerIndex=ze,this.availableImages=Qe,this.availableModels=Ct,this.brightness=Kt,this.loading={},this.loaded={},this.worldview=$t}loadTile(ve,ze){const Qe=ve.uid,Ct=this.loading[Qe]=new rl(ve,this.brightness,this.worldview);i.bu(ve.request,(Nt,zt)=>{const Kt=!this.loading[Qe];return delete this.loading[Qe],Kt||Nt?(Ct.status="done",Kt||(this.loaded[Qe]=Ct),ze(Nt)):zt&&zt.byteLength!==0?void Ct.parse(zt,this.layerIndex,ve,($t,Qt)=>{Ct.status="done",this.loaded=this.loaded||{},this.loaded[Qe]=Ct,$t||!Qt?ze($t):ze(null,Qt)}):(Ct.status="done",this.loaded[Qe]=Ct,ze())})}reloadTile(ve,ze){const Qe=this.loaded,Ct=ve.uid;if(Qe&&Qe[Ct]){const Nt=Qe[Ct];Nt.projection=ve.projection,Nt.brightness=ve.brightness;const zt=(Kt,$t)=>{Nt.reloadCallback&&(delete Nt.reloadCallback,this.loadTile(ve,ze)),ze(Kt,$t)};Nt.status==="parsing"?Nt.reloadCallback=zt:Nt.status==="done"&&this.loadTile(ve,ze)}}abortTile(ve,ze){const Qe=ve.uid;this.loading[Qe]&&delete this.loading[Qe],ze()}removeTile(ve,ze){const Qe=this.loaded,Ct=ve.uid;Qe&&Qe[Ct]&&delete Qe[Ct],ze()}}class sc{constructor(ve){this.self=ve,this.actor=new i.fG(ve,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new i.x,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=i.cm({name:"mercator"}),this.workerSourceTypes={vector:$,geojson:_i,"raster-dem":q,"raster-array":V,"batched-model":Ni},this.workerSources={},this.self.registerWorkerSource=(ze,Qe)=>{if(this.workerSourceTypes[ze])throw new Error(`Worker source with name "${ze}" already registered.`);this.workerSourceTypes[ze]=Qe},this.self.registerRTLTextPlugin=ze=>{if(i.fH.isParsed())throw new Error("RTL text plugin already registered.");i.fH.setState({pluginStatus:i.fI.parsed,pluginURL:i.fH.getPluginURL()}),i.fH.applyArabicShaping=ze.applyArabicShaping,i.fH.processBidirectionalText=ze.processBidirectionalText,i.fH.processStyledBidirectionalText=ze.processStyledBidirectionalText;for(const Qe of this.rtlPluginParsingListeners)Qe(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(ve,ze,Qe){delete this.layerIndexes[ve],delete this.availableImages[ve],delete this.availableModels[ve],delete this.workerSources[ve],Qe()}checkIfReady(ve,ze,Qe){Qe()}setReferrer(ve,ze){this.referrer=ze}spriteLoaded(ve,ze){this.isSpriteLoaded[ve]||(this.isSpriteLoaded[ve]={});const{scope:Qe,isLoaded:Ct}=ze;if(this.isSpriteLoaded[ve][Qe]=Ct,this.workerSources[ve]&&this.workerSources[ve][Qe])for(const Nt in this.workerSources[ve][Qe]){const zt=this.workerSources[ve][Qe][Nt];for(const Kt in zt){const $t=zt[Kt];$t instanceof $&&($t.isSpriteLoaded=Ct,$t.fire(new i.z("isSpriteLoaded")))}}}setImages(ve,ze,Qe){this.availableImages[ve]||(this.availableImages[ve]={});const{scope:Ct,images:Nt}=ze;if(this.availableImages[ve][Ct]=Nt,this.workerSources[ve]&&this.workerSources[ve][Ct]){for(const zt in this.workerSources[ve][Ct]){const Kt=this.workerSources[ve][Ct][zt];for(const $t in Kt)Kt[$t].availableImages=Nt}Qe()}else Qe()}setModels(ve,{scope:ze,models:Qe},Ct){if(this.availableModels[ve]||(this.availableModels[ve]={}),this.availableModels[ve][ze]=Qe,this.workerSources[ve]&&this.workerSources[ve][ze]){for(const Nt in this.workerSources[ve][ze]){const zt=this.workerSources[ve][ze][Nt];for(const Kt in zt)zt[Kt].availableModels=Qe}Ct()}else Ct()}setProjection(ve,ze){this.projections[ve]=i.cm(ze)}setBrightness(ve,ze,Qe){this.brightness=ze,Qe()}setWorldview(ve,ze,Qe){this.worldview=ze,Qe()}setLayers(ve,ze,Qe){this.getLayerIndex(ve,ze.scope).replace(ze.layers,ze.options),Qe()}updateLayers(ve,ze,Qe){this.getLayerIndex(ve,ze.scope).update(ze.layers,ze.removedIds,ze.options),Qe()}loadTile(ve,ze,Qe){ze.projection=this.projections[ve]||this.defaultProjection,this.getWorkerSource(ve,ze.type,ze.source,ze.scope).loadTile(ze,Qe)}decodeRasterArray(ve,ze,Qe){this.getWorkerSource(ve,ze.type,ze.source,ze.scope).decodeRasterArray(ze,Qe)}reloadTile(ve,ze,Qe){ze.projection=this.projections[ve]||this.defaultProjection,this.getWorkerSource(ve,ze.type,ze.source,ze.scope).reloadTile(ze,Qe)}abortTile(ve,ze,Qe){this.getWorkerSource(ve,ze.type,ze.source,ze.scope).abortTile(ze,Qe)}removeTile(ve,ze,Qe){this.getWorkerSource(ve,ze.type,ze.source,ze.scope).removeTile(ze,Qe)}removeSource(ve,ze,Qe){if(!(this.workerSources[ve]&&this.workerSources[ve][ze.scope]&&this.workerSources[ve][ze.scope][ze.type]&&this.workerSources[ve][ze.scope][ze.type][ze.source]))return;const Ct=this.workerSources[ve][ze.scope][ze.type][ze.source];delete this.workerSources[ve][ze.scope][ze.type][ze.source],Ct.removeSource!==void 0?Ct.removeSource(ze,Qe):Qe()}loadWorkerSource(ve,ze,Qe){try{this.self.importScripts(ze.url),Qe()}catch(Ct){Qe(Ct)}}syncRTLPluginState(ve,ze,Qe){if(i.fH.isParsed())Qe(null,!0);else if(i.fH.isParsing())this.rtlPluginParsingListeners.push(Qe);else try{i.fH.setState(ze);const Ct=i.fH.getPluginURL();!i.fH.isLoaded()||i.fH.isParsed()||i.fH.isParsing()||Ct==null||(i.fH.setState({pluginStatus:i.fI.parsing,pluginURL:i.fH.getPluginURL()}),this.self.importScripts(Ct),i.fH.isParsed()?Qe(null,!0):this.rtlPluginParsingListeners.push(Qe))}catch(Ct){Qe(Ct)}}setDracoUrl(ve,ze){this.dracoUrl=ze}getAvailableImages(ve,ze){this.availableImages[ve]||(this.availableImages[ve]={});let Qe=this.availableImages[ve][ze];return Qe||(Qe=[]),Qe}getAvailableModels(ve,ze){this.availableModels[ve]||(this.availableModels[ve]={});let Qe=this.availableModels[ve][ze];return Qe||(Qe={}),Qe}getLayerIndex(ve,ze){this.layerIndexes[ve]||(this.layerIndexes[ve]={});let Qe=this.layerIndexes[ve][ze];return Qe||(Qe=this.layerIndexes[ve][ze]=new f,Qe.scope=ze),Qe}getWorkerSource(ve,ze,Qe,Ct){const Nt=this.workerSources;return Nt[ve]||(Nt[ve]={}),Nt[ve][Ct]||(Nt[ve][Ct]={}),Nt[ve][Ct][ze]||(Nt[ve][Ct][ze]={}),this.isSpriteLoaded[ve]||(this.isSpriteLoaded[ve]={}),Nt[ve][Ct][ze][Qe]||(Nt[ve][Ct][ze][Qe]=new this.workerSourceTypes[ze]({send:(zt,Kt,$t,Qt,Is,gs)=>this.actor.send(zt,Kt,$t,ve,Is,gs),scheduler:this.actor.scheduler},this.getLayerIndex(ve,Ct),this.getAvailableImages(ve,Ct),this.getAvailableModels(ve,Ct),this.isSpriteLoaded[ve][Ct],void 0,this.brightness,this.worldview)),Nt[ve][Ct][ze][Qe]}rasterizeImagesWorker(ve,ze,Qe){const Ct=new Map;for(const[Nt,{image:zt,imageVariant:Kt}]of ze.tasks.entries()){const $t=this.imageRasterizer.rasterize(Kt,zt,ze.scope,ve);Ct.set(Nt,$t)}Qe(void 0,Ct)}removeRasterizedImages(ve,ze,Qe){this.imageRasterizer.removeImagesFromCacheByIds(ze.imageIds,ze.scope,ve),Qe()}enforceCacheSizeLimit(ve,ze){i.fJ(ze)}getWorkerPerformanceMetrics(ve,ze,Qe){Qe(void 0,void 0)}}return i.fF(self)&&(self.worker=new sc(self)),sc}),o(["./shared"],function(i){var c="3.17.0";const u={create:"create",load:"load",fullLoad:"fullLoad"},p={mark(M){performance.mark(M)},measure(M,h,x){performance.measure(M,h,x)}};function f(M){const h=M.name.split("?")[0];return i.a(h)&&h.includes("mapbox-gl.js")?"javascript":i.a(h)&&h.includes("mapbox-gl.css")?"css":i.b(h)?"fontRange":i.c(h)?"sprite":i.i(h)?"style":i.d(h)?"tilejson":"other"}var y,_={},b=function(){if(y)return _;function M(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,H=new Blob([""],{type:"text/javascript"}),Y=URL.createObjectURL(H);try{z=new Worker(Y),F=!0}catch{F=!1}return z&&z.terminate(),URL.revokeObjectURL(Y),F}()?function(){var F=document.createElement("canvas");F.width=F.height=1;var z=F.getContext("2d");if(!z)return!1;var H=z.getImageData(0,0,1,1);return H&&H.width===F.width}()?(x[D=A&&A.failIfMajorPerformanceCaveat]===void 0&&(x[D]=function(F){var z,H=function(Y){var ae=document.createElement("canvas"),oe=Object.create(M.webGLContextAttributes);return oe.failIfMajorPerformanceCaveat=Y,ae.getContext("webgl2",oe)}(F);if(!H)return!1;try{z=H.createShader(H.VERTEX_SHADER)}catch{return!1}return!(!z||H.isContextLost())&&(H.shaderSource(z,"void main() {}"),H.compileShader(z),H.getShaderParameter(z,H.COMPILE_STATUS)===!0)}(D)),x[D]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var D}y=1,_.supported=M,_.notSupportedReason=h;var x={};return M.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},_}();function w(M,h,x){const A=document.createElement(M);return h!=null&&(A.className=h),x&&x.appendChild(A),A}function j(M,h,x){const A=document.createElementNS("http://www.w3.org/2000/svg",M);for(const D of Object.keys(h))A.setAttributeNS(null,D,String(h[D]));return x&&x.appendChild(A),A}const N=typeof document<"u"?document.documentElement&&document.documentElement.style:null,S=N&&N.userSelect!==void 0?"userSelect":"WebkitUserSelect";let T;function I(){N&&S&&(T=N[S],N[S]="none")}function L(){N&&S&&(N[S]=T)}function R(M){M.preventDefault(),M.stopPropagation(),window.removeEventListener("click",R,!0)}function $(){window.addEventListener("click",R,!0),window.setTimeout(()=>{window.removeEventListener("click",R,!0)},0)}function q(M,h){const x=M.getBoundingClientRect();return X(M,x,h)}function U(M,h){const x=M.getBoundingClientRect(),A=[];for(let D=0;Dthis._skuTokenExpiresAt}transformRequest(h,x){return this._transformRequestFn&&this._transformRequestFn(h,x)||{url:h}}normalizeStyleURL(h,x){if(!i.h(h))return h;const A=re(h);return A.params.push(`sdk=js-${c}`),A.path=`/styles/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||x)}normalizeGlyphsURL(h,x){if(!i.h(h))return h;const A=re(h);return A.path=`/fonts/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||x)}normalizeModelURL(h,x){if(!i.h(h))return h;const A=re(h);return A.path=`/models/v1${A.path}`,this._makeAPIURL(A,this._customAccessToken||x)}normalizeSourceURL(h,x,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||x)}normalizeIconsetURL(h,x){const A=re(h);return i.h(h)?(A.path=`/styles/v1${A.path}/iconset.pbf`,this._makeAPIURL(A,this._customAccessToken||x)):ne(A)}normalizeSpriteURL(h,x,A,D){const F=re(h);return i.h(h)?(F.path=`/styles/v1${F.path}/sprite${x}${A}`,this._makeAPIURL(F,this._customAccessToken||D)):(F.path+=`${x}${A}`,ne(F))}normalizeTileURL(h,x,A){if(this._isSkuTokenExpired()&&this._createSkuToken(),h&&!i.h(h))return h;const D=re(h);D.path=D.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${x||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 H of z){const Y=H.match(/^access_token=(.*)$/);if(Y)return Y[1]}return null}(D.params)||i.e.ACCESS_TOKEN;return i.e.REQUIRE_ACCESS_TOKEN&&F&&this._skuToken&&D.params.push(`sku=${this._skuToken}`),this._makeAPIURL(D,F)}canonicalizeTileURL(h,x){const 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 x&&(F=F.filter(z=>!z.match(/^access_token=/))),F.length&&(D+=`?${F.join("&")}`),D}canonicalizeTileset(h,x){const A=!!x&&i.h(x),D=[];for(const F of h.tiles||[])i.j(F)?D.push(this.canonicalizeTileURL(F,A)):D.push(F);return D}_makeAPIURL(h,x){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 ne(h);if(x=x||i.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!x)throw new Error(`An API access token is required to use Mapbox GL. ${A}`);if(x[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=${x||""}`),ne(h)}}const de=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function re(M){const h=M.match(de);if(!h)throw new Error("Unable to parse URL object");return{protocol:h[1],authority:h[2],path:h[3]||"/",params:h[4]?h[4].split("&"):[]}}function ne(M){const h=M.params.length?`?${M.params.join("&")}`:"";return`${M.protocol}://${M.authority}${M.path}${h}`}const le="mapbox.eventData";function he(M){if(!M)return null;const h=M.split(".");if(!h||h.length!==3)return null;try{return JSON.parse(i.l(h[1]))}catch{return null}}class we{constructor(h){this.type=h,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(h){const x=he(i.e.ACCESS_TOKEN);let A="";return A=x&&x.u?i.f(x.u):i.e.ACCESS_TOKEN||"",h?`${le}.${h}:${A}`:`${le}:${A}`}fetchEventData(){const h=i.s("localStorage"),x=this.getStorageKey(),A=this.getStorageKey("uuid"),D=this.getStorageKey("uuidTimestamp");if(h)try{const F=localStorage.getItem(x);F&&(this.eventData=JSON.parse(F));const z=localStorage.getItem(A);z&&(this.anonId=z);const H=localStorage.getItem(D);H&&(this.anonIdTimestamp=Number(H));const Y=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(x,JSON.stringify(this.eventData)),z&&localStorage.setItem(D,z.toString())}catch{i.w("Unable to write to LocalStorage")}}processRequests(h){}postEvent(h,x,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()},H=x?Object.assign(z,x):z,Y={url:ne(F),headers:{"Content-Type":"text/plain"},body:JSON.stringify([H])};this.pendingRequest=i.p(Y,ae=>{this.pendingRequest=null,A(ae),this.saveEventData(),this.processRequests(D)})}queueRequest(h,x){this.queue.push(h),this.processRequests(x)}}class ye extends we{constructor(h){super("metrics"),h&&(this.data=h)}postMetricsEvent(h){if(!i.e.EVENTS_URL||!h&&!i.e.ACCESS_TOKEN)return;this.anonId||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID();const x=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:x},h)}processRequests(h){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:x,payload:A}=this.queue.shift();this.postEvent(x,A,()=>{},h)}}const je=new class extends we{constructor(M){super("appUserTurnstile"),this._customAccessToken=M}postTurnstileEvent(M,h){i.e.EVENTS_URL&&i.e.ACCESS_TOKEN&&Array.isArray(M)&&M.some(x=>i.h(x)||i.j(x))&&this.queueRequest(Date.now(),h)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const h=he(i.e.ACCESS_TOKEN),x=h?h.u:i.e.ACCESS_TOKEN;let A=x!==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),H=(D-this.eventData.lastSuccess)/864e5;A=A||H>=1||H<-1||F.getDate()!==z.getDate()}else A=!0;A?this.postEvent(D,{sdkIdentifier:"mapbox-gl-js",sdkVersion:c,skuId:se,"enabled.telemetry":!1,userId:this.anonId},F=>{F||(this.eventData.lastSuccess=D,this.eventData.tokenU=x)},M):this.processRequests()}},ke=je.postTurnstileEvent.bind(je),We=new class extends we{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(M,h,x,A){this.skuToken=h,this.errorCb=A,i.e.EVENTS_URL&&(x||i.e.ACCESS_TOKEN?this.queueRequest({id:M,timestamp:Date.now()},x):this.errorCb(new Error(ee)))}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:x}=this.queue.shift();h&&this.success[h]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),i.v(this.anonId)||this.refreshUUID(),this.postEvent(x,{sdkIdentifier:"mapbox-gl-js",sdkVersion:c,skuId:se,skuToken:this.skuToken,userId:this.anonId},A=>{A?this.errorCb(A):h&&(this.success[h]=!0)},M))}remove(){this.errorCb=null}},be=We.postMapLoadEvent.bind(We),Me=new class extends we{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(M){let h=this.mapInstanceIdMap.get(M);return h||(h=i.u(),this.mapInstanceIdMap.set(M,h)),h}getEventId(M){const h=this.eventIdPerMapInstanceMap.get(M)||0;return this.eventIdPerMapInstanceMap.set(M,h+1),h}postStyleLoadEvent(M,h){const{map:x,style:A,importedStyles:D}=h;if(!i.e.EVENTS_URL||!M&&!i.e.ACCESS_TOKEN)return;const F=this.getMapInstanceId(x),z={mapInstanceId:F,eventId:this.getEventId(F),style:A};D.length&&(z.importedStyles=D),this.queueRequest({timestamp:Date.now(),payload:z},M)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,payload:x}=this.queue.shift();this.postEvent(h,x,()=>{},M)}},Ae=Me.postStyleLoadEvent.bind(Me),Re=new ye({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Te=Re.postMetricsEvent.bind(Re),qe=new ye({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),ct=qe.postMetricsEvent.bind(qe),De=new class extends we{constructor(){super("gljs.performance")}postPerformanceEvent(M,h){i.e.EVENTS_URL&&(M||i.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:h},M)}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:h,performanceData:x}=this.queue.shift(),A=function(D){const F=performance.getEntriesByType("resource"),z=performance.getEntriesByType("mark"),H=function(xe){const Pe={};if(xe){for(const Ce in xe)if(Ce!=="other")for(const Ve of xe[Ce]){const Be=`${Ce}ResolveRangeMin`,et=`${Ce}ResolveRangeMax`,ut=`${Ce}RequestCount`,st=`${Ce}RequestCachedCount`;Pe[Be]=Math.min(Pe[Be]||1/0,Ve.startTime),Pe[et]=Math.max(Pe[et]||-1/0,Ve.responseEnd);const Mt=yt=>{Pe[yt]===void 0&&(Pe[yt]=0),++Pe[yt]};Ve.transferSize!==void 0&&Ve.transferSize===0&&Mt(st),Mt(ut)}}return Pe}(function(xe,Pe){const Ce={};if(xe)for(const Ve of xe){const Be=Pe(Ve);Ce[Be]===void 0&&(Ce[Be]=[]),Ce[Be].push(Ve)}return Ce}(F,f)),Y=window.devicePixelRatio,ae=navigator.connection||navigator.mozConnection||navigator.webkitConnection,oe=ae?ae.effectiveType:void 0,ge={counters:[],metadata:[],attributes:[]},fe=(xe,Pe,Ce)=>{Ce!=null&&xe.push({name:Pe,value:Ce.toString()})};for(const xe in H)fe(ge.counters,xe,H[xe]);if(D.interactionRange[0]!==1/0&&D.interactionRange[1]!==-1/0&&(fe(ge.counters,"interactionRangeMin",D.interactionRange[0]),fe(ge.counters,"interactionRangeMax",D.interactionRange[1])),z)for(const xe of Object.values(u)){const Pe=z.find(Ce=>Ce.name===xe);Pe&&fe(ge.counters,xe,Pe.startTime)}return fe(ge.counters,"visibilityHidden",D.visibilityHidden),fe(ge.attributes,"style",function(xe){if(xe)for(const Pe of xe){const Ce=Pe.name.split("?")[0];if(i.i(Ce)){const Ve=Ce.split("/").slice(-2);if(Ve.length===2)return`mapbox://styles/${Ve[0]}/${Ve[1]}`}}}(F)),fe(ge.attributes,"terrainEnabled",D.terrainEnabled?"true":"false"),fe(ge.attributes,"fogEnabled",D.fogEnabled?"true":"false"),fe(ge.attributes,"projection",D.projection),fe(ge.attributes,"zoom",D.zoom),fe(ge.metadata,"devicePixelRatio",Y),fe(ge.metadata,"connectionEffectiveType",oe),fe(ge.metadata,"navigatorUserAgent",navigator.userAgent),fe(ge.metadata,"screenWidth",window.screen.width),fe(ge.metadata,"screenHeight",window.screen.height),fe(ge.metadata,"windowWidth",window.innerWidth),fe(ge.metadata,"windowHeight",window.innerHeight),fe(ge.metadata,"mapWidth",D.width/Y),fe(ge.metadata,"mapHeight",D.height/Y),fe(ge.metadata,"webglRenderer",D.renderer),fe(ge.metadata,"webglVendor",D.vendor),fe(ge.metadata,"sdkVersion",c),fe(ge.metadata,"sdkIdentifier","mapbox-gl-js"),ge}(x);for(const D of A.metadata);for(const D of A.counters);for(const D of A.attributes);this.postEvent(h,A,()=>{},M)}},Rt=De.postPerformanceEvent.bind(De),pe=new class extends we{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(M,h,x,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:ne(D),headers:{"Content-Type":"text/plain"}};this.pendingRequest=i.g(F,z=>{this.pendingRequest=null,x(z),this.saveEventData(),this.processRequests(A)})}getSessionAPI(M,h,x,A){this.skuToken=h,this.errorCb=A,i.e.SESSION_PATH&&i.e.API_URL&&(x||i.e.ACCESS_TOKEN?this.queueRequest({id:M,timestamp:Date.now()},x):this.errorCb(new Error(ee)))}processRequests(M){if(this.pendingRequest||this.queue.length===0)return;const{id:h,timestamp:x}=this.queue.shift();h&&this.success[h]||this.getSession(x,this.skuToken,A=>{A?this.errorCb(A):h&&(this.success[h]=!0)},M)}remove(){this.errorCb=null}},Je=pe.getSessionAPI.bind(pe),lt=new Set;function rt(M,h){h?lt.add(M):lt.delete(M)}class Se{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(h,x){this._updatedSourceCaches[h]=x,this.setDirty()}discardSourceCacheUpdate(h){delete this._updatedSourceCaches[h]}updateLayer(h){const x=h.scope;this._updatedLayers[x]=this._updatedLayers[x]||new Set,this._updatedLayers[x].add(h.id),this.setDirty()}removeLayer(h){const x=h.scope;this._removedLayers[x]=this._removedLayers[x]||{},this._updatedLayers[x]=this._updatedLayers[x]||new Set,this._removedLayers[x][h.id]=h,this._updatedLayers[x].delete(h.id),this._updatedPaintProps.delete(h.fqid),this.setDirty()}getRemovedLayer(h){return this._removedLayers[h.scope]?this._removedLayers[h.scope][h.id]:null}discardLayerRemoval(h){this._removedLayers[h.scope]&&delete this._removedLayers[h.scope][h.id]}getLayerUpdatesByScope(){const h={};for(const x in this._updatedLayers)h[x]=h[x]||{},h[x].updatedIds=Array.from(this._updatedLayers[x].values());for(const x in this._removedLayers)h[x]=h[x]||{},h[x].removedIds=Object.keys(this._removedLayers[x]);return h}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(h){this._updatedPaintProps.add(h.fqid),this.setDirty()}getUpdatedImages(h){return this._updatedImages[h]?Array.from(this._updatedImages[h].values()):[]}updateImage(h,x){this._updatedImages[x]=this._updatedImages[x]||new Set,this._updatedImages[x].add(i.I.toString(h)),this.setDirty()}resetUpdatedImages(h){this._updatedImages[h]&&this._updatedImages[h].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function it(M){const{userImage:h}=M;return!!(h&&h.render&&h.render())&&(M.data.replace(new Uint8Array(h.data.buffer)),!0)}class $e extends i.E{constructor(h){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.dirty=!0,this.spriteFormat=h,h!=="raster"&&i.r()&&(this.imageRasterizerDispatcher=new i.D(i.t(),this,"Image Rasterizer Worker",1))}addScope(h){this.loaded.set(h,!1),this.imageProviders.set(h,new Map),this.images.set(h,new Map),this.updatedImages.set(h,new Set),this.callbackDispatchedThisFrame.set(h,new Set),this.patterns.set(h,new Map),this.atlasImage.set(h,new i.q({width:1,height:1}))}removeScope(h){this.loaded.delete(h),this.imageProviders.delete(h),this.images.delete(h),this.updatedImages.delete(h),this.callbackDispatchedThisFrame.delete(h),this.patterns.delete(h),this.atlasImage.delete(h);const x=this.atlasTexture.get(h);x&&(x.destroy(),this.atlasTexture.delete(h))}addImageProvider(h,x){this.imageProviders.has(x)||this.imageProviders.set(x,new Map),this.imageProviders.get(x).set(h.id,h)}removeImageProvider(h,x){this.imageProviders.has(x)&&this.imageProviders.get(x).delete(h)}getPendingImageProviders(){const h=[];for(const x of this.imageProviders.values())for(const A of x.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,x){if(this.loaded.get(x)!==h&&(this.loaded.set(x,h),h)){for(const{ids:A,callback:D}of this.requestors)this._notify(A,x,D);this.requestors=[]}}hasImage(h,x){return!!this.getImage(h,x)}getImage(h,x){return this.images.get(x).get(h.toString())}addImage(h,x,A){this._validate(h,A)&&this.images.get(x).set(h.toString(),A)}_validate(h,x){let A=!0;return this._validateStretch(x.stretchX,x.data&&x.data.width)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchX" value`))),A=!1),this._validateStretch(x.stretchY,x.data&&x.data.height)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "stretchY" value`))),A=!1),this._validateContent(x.content,x)||(this.fire(new i.y(new Error(`Image "${h.name}" has invalid "content" value`))),A=!1),A}_validateStretch(h,x){if(!h)return!0;let A=0;for(const D of h){if(D[0]i.I.from(x))}getImages(h,x,A){const D=[],F=[],z=this.imageProviders.get(x);for(const oe of h){if(!oe.iconsetId){D.push(oe);continue}const ge=z.get(oe.iconsetId);ge&&(this.getImage(oe,x)?F.push(oe):ge.addPendingRequest(oe))}if(D.length===0)return void this._notify(F,x,A);let H=!0;const Y=!!this.loaded.get(x),ae=this.images.get(x);if(!Y)for(const oe of D)ae.has(oe.toString())||(H=!1);Y||H?this._notify(D,x,A):this.requestors.push({ids:D,scope:x,callback:A})}rasterizeImages(h,x){const A=new Map,{tasks:D,scope:F}=h;for(const[z,H]of D.entries()){const Y=this.getImage(H.id,F);Y&&A.set(z,{image:Y,imageVariant:H})}this._rasterizeImages(F,A,x)}_rasterizeImages(h,x,A){if(i.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:x,scope:h},A);else{const D=new Map;for(const[F,{image:z,imageVariant:H}]of x.entries())D.set(F,this.imageRasterizer.rasterize(H,z,h,0));A(void 0,D)}}getUpdatedImages(h){return this.updatedImages.get(h)||new Set}_notify(h,x,A){const D=this.images.get(x),F=new Map;for(const z of h){if(!D.get(z.toString())){if(z.iconsetId)continue;this.fire(new i.z("styleimagemissing",{id:z.name}))}const H=D.get(z.toString());if(!H){i.w(`Image "${z.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const Y={data:H.usvg?null:H.data.clone(),pixelRatio:H.pixelRatio,sdf:H.sdf,usvg:H.usvg,version:H.version,stretchX:H.stretchX,stretchY:H.stretchY,content:H.content,hasRenderCallback:!!(H.userImage&&H.userImage.render)};H.usvg&&Object.assign(Y,{width:H.icon.usvg_tree.width,height:H.icon.usvg_tree.height}),F.set(i.I.toString(z),Y)}A(null,F)}getPixelSize(h){const{width:x,height:A}=this.atlasImage.get(h);return{width:x,height:A}}getPattern(h,x,A){const D=h.toString(),F=this.patterns.get(x),z=F.get(D),H=this.getImage(h,x);if(!H)return null;if(z){if(z.position.version===H.version)return z.position;z.position.version=H.version}else{if(H.usvg&&!H.data){const Y=this.getPatternInFlightId(D,x);if(this.patternsInFlight.has(Y))return null;this.patternsInFlight.add(Y);const ae=new i.A(h).scaleSelf(i.o.devicePixelRatio),oe=new Map([[ae.toString(),{image:H,imageVariant:ae}]]);return this._rasterizeImages(x,oe,(ge,fe)=>this.storePatternImage(ae,x,H,A,fe)),null}this.storePattern(h,x,H)}return this._updatePatternAtlas(x,A),F.get(D).position}getPatternInFlightId(h,x){return i.B(h,x)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(h,x,A,D,F){const z=h.toString(),H=F?F.get(z):void 0;H&&(A.data=H,this.storePattern(h.id,x,A),this._updatePatternAtlas(x,D),this.patternsInFlight.delete(this.getPatternInFlightId(h.id.toString(),x)))}storePattern(h,x,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(x).set(h.toString(),{bin:D,position:F})}destroyAtlasTextures(){for(const h of this.atlasTexture.values())h&&h.destroy();this.atlasTexture.clear()}bind(h,x){const A=h.gl;let D=this.atlasTexture.get(x);D?this.dirty&&(D.update(this.atlasImage.get(x)),this.dirty=!1):(D=new i.T(h,this.atlasImage.get(x),A.RGBA8),this.atlasTexture.set(x,D)),D.bind(A.LINEAR,A.CLAMP_TO_EDGE)}_updatePatternAtlas(h,x){const A=this.patterns.get(h),D=Array.from(A.values()).map(({bin:ae})=>ae),{w:F,h:z}=i.G(D),H=this.atlasImage.get(h);H.resize({width:F||1,height:z||1});const Y=this.images.get(h);for(const[ae,{bin:oe,position:ge}]of A.entries()){let fe=ge.padding;const xe=oe.x+fe,Pe=oe.y+fe,Ce=Y.get(ae).data,Ve=Ce.width,Be=Ce.height;fe=fe>1?fe-1:fe,i.q.copy(Ce,H,{x:0,y:0},{x:xe,y:Pe},{width:Ve,height:Be},x),i.q.copy(Ce,H,{x:0,y:Be-fe},{x:xe,y:Pe-fe},{width:Ve,height:fe},x),i.q.copy(Ce,H,{x:0,y:0},{x:xe,y:Pe+Be},{width:Ve,height:fe},x),i.q.copy(Ce,H,{x:Ve-fe,y:0},{x:xe-fe,y:Pe},{width:fe,height:Be},x),i.q.copy(Ce,H,{x:0,y:0},{x:xe+Ve,y:Pe},{width:fe,height:Be},x),i.q.copy(Ce,H,{x:Ve-fe,y:Be-fe},{x:xe-fe,y:Pe-fe},{width:fe,height:fe},x),i.q.copy(Ce,H,{x:0,y:Be-fe},{x:xe+Ve,y:Pe-fe},{width:fe,height:fe},x),i.q.copy(Ce,H,{x:0,y:0},{x:xe+Ve,y:Pe+Be},{width:fe,height:fe},x),i.q.copy(Ce,H,{x:Ve-fe,y:0},{x:xe-fe,y:Pe+Be},{width:fe,height:fe},x)}this.dirty=!0}beginFrame(){for(const h of this.images.keys())this.callbackDispatchedThisFrame.set(h,new Set)}dispatchRenderCallbacks(h,x){const A=this.images.get(x);for(const D of h){if(this.callbackDispatchedThisFrame.get(x).has(D.toString()))continue;this.callbackDispatchedThisFrame.get(x).add(D.toString());const F=A.get(D.toString());it(F)&&this.updateImage(D,x,F)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function ot(M){const h=M.value,x=M.valueSpec,A=M.style,D=M.styleSpec,F=M.key,z=M.arrayElementValidator||Kr;if(!Array.isArray(h))return[new i.V(F,h,`array expected, ${i.K(h)} found`)];if(x.length&&h.length!==x.length)return[new i.V(F,h,`array length ${x.length} expected, length ${h.length} found`)];if(x["min-length"]&&h.lengthD)return[new i.V(h,x,`${x} is greater than the maximum value ${D}`)]}return[]}function Ke(M){const h=M.key,x=M.value;if(!i.H(x))return[new i.V(h,x,`object expected, ${i.K(x)} found`)];const A=M.valueSpec,D=i.J(x.type);let F,z,H,Y={};const ae=D!=="categorical"&&x.property===void 0,oe=!ae,ge=function(Ce){const Ve=Ce.stops;return Array.isArray(Ve)&&Array.isArray(Ve[0])&&i.H(Ve[0][0])}(x),fe=Yn({key:M.key,value:M.value,valueSpec:M.styleSpec.function,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{stops:function(Ce){if(D==="identity")return[new i.V(Ce.key,Ce.value,'identity function may not have a "stops" property')];let Ve=[];const Be=Ce.value;return Ve=Ve.concat(ot({key:Ce.key,value:Be,valueSpec:Ce.valueSpec,style:Ce.style,styleSpec:Ce.styleSpec,arrayElementValidator:xe})),Array.isArray(Be)&&Be.length===0&&Ve.push(new i.V(Ce.key,Be,"array must have at least one stop")),Ve},default:function(Ce){return Kr({key:Ce.key,value:Ce.value,valueSpec:A,style:Ce.style,styleSpec:Ce.styleSpec})}}});return D==="identity"&&ae&&fe.push(new i.V(M.key,M.value,'missing required property "property"')),D==="identity"||x.stops||fe.push(new i.V(M.key,M.value,'missing required property "stops"')),D==="exponential"&&A.expression&&!i.M(A)&&fe.push(new i.V(M.key,M.value,"exponential functions not supported")),M.styleSpec.$version>=8&&(oe&&!i.N(A)?fe.push(new i.V(M.key,M.value,"property functions not supported")):ae&&!i.O(A)&&fe.push(new i.V(M.key,M.value,"zoom functions not supported"))),D!=="categorical"&&!ge||x.property!==void 0||fe.push(new i.V(M.key,M.value,'"property" property is required')),fe;function xe(Ce){let Ve=[];const Be=Ce.value,et=Ce.key;if(!Array.isArray(Be))return[new i.V(et,Be,`array expected, ${i.K(Be)} found`)];if(Be.length!==2)return[new i.V(et,Be,`array length 2 expected, length ${Be.length} found`)];if(ge){if(!i.H(Be[0]))return[new i.V(et,Be,`object expected, ${i.K(Be[0])} found`)];const ut=Be[0];if(ut.zoom===void 0)return[new i.V(et,Be,"object stop key must have zoom")];if(ut.value===void 0)return[new i.V(et,Be,"object stop key must have value")];const st=i.J(ut.zoom);if(typeof st!="number")return[new i.V(et,ut.zoom,"stop zoom values must be numbers")];if(H&&H>st)return[new i.V(et,ut.zoom,"stop zoom values must appear in ascending order")];st!==H&&(H=st,z=void 0,Y={}),Ve=Ve.concat(Yn({key:`${et}[0]`,value:Be[0],valueSpec:{zoom:{}},style:Ce.style,styleSpec:Ce.styleSpec,objectElementValidators:{zoom:Ue,value:Pe}}))}else Ve=Ve.concat(Pe({key:`${et}[0]`,value:Be[0],style:Ce.style,styleSpec:Ce.styleSpec},Be));return i.Q(i.S(Be[1]))?Ve.concat([new i.V(`${et}[1]`,Be[1],"expressions are not allowed in function stops.")]):Ve.concat(Kr({key:`${et}[1]`,value:Be[1],valueSpec:A,style:Ce.style,styleSpec:Ce.styleSpec}))}function Pe(Ce,Ve){const Be=i.K(Ce.value),et=i.J(Ce.value),ut=Ce.value!==null?Ce.value:Ve;if(F){if(Be!==F)return[new i.V(Ce.key,ut,`${Be} stop domain type must match previous stop domain type ${F}`)]}else F=Be;if(Be!=="number"&&Be!=="string"&&Be!=="boolean"&&typeof et!="number"&&typeof et!="string"&&typeof et!="boolean")return[new i.V(Ce.key,ut,"stop domain value must be a number, string, or boolean")];if(Be!=="number"&&D!=="categorical"){let st=`number expected, ${Be} found`;return i.N(A)&&D===void 0&&(st+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(Ce.key,ut,st)]}return D!=="categorical"||Be!=="number"||typeof et=="number"&&isFinite(et)&&Math.floor(et)===et?D!=="categorical"&&Be==="number"&&typeof et=="number"&&typeof z=="number"&&z!==void 0&&etnew i.V(`${M.key}${A.key}`,M.value,A.message));const x=h.value.expression||h.value._styleExpression.expression;if(M.expressionContext==="property"&&M.propertyKey==="text-font"&&!x.outputDefined())return[new i.V(M.key,M.value,`Invalid data expression for "${M.propertyKey}". Output values must be contained as literals within the expression.`)];if(M.expressionContext==="property"&&M.propertyType==="layout"&&!i.Z(x))return[new i.V(M.key,M.value,'"feature-state" data expressions are not supported with layout properties.')];if(M.expressionContext==="filter")return He(x,M);if(M.expressionContext==="appearance")return Ye(x,M);if(M.expressionContext&&M.expressionContext.indexOf("cluster")===0){if(!i.X(x,["zoom","feature-state"]))return[new i.V(M.key,M.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(M.expressionContext==="cluster-initial"&&!i.Y(x))return[new i.V(M.key,M.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function He(M,h){const x=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)x.delete(D);if(x.size===0)return[];const A=[];return M instanceof i._&&x.has(M.name)?[new i.V(h.key,h.value,`["${M.name}"] expression is not supported in a filter for a ${h.object.type} layer with id: ${h.object.id}`)]:(M.eachChild(D=>{A.push(...He(D,h))}),A)}function Ye(M,h){const x=new Set;if(h.valueSpec&&h.valueSpec.expression)for(const D of h.valueSpec.expression.parameters)x.add(D);if(x.size===0)return[];const A=[];return M instanceof i._&&!x.has(M.name)?[new i.V(h.key,h.value,`["${M.name}"] is not an allowed parameter`)]:(M.eachChild(D=>{A.push(...Ye(D,h))}),A)}function tt(M){const h=M.key,x=M.value,A=M.valueSpec,D=[];return Array.isArray(A.values)?A.values.indexOf(i.J(x))===-1&&D.push(new i.V(h,x,`expected one of [${A.values.join(", ")}], ${JSON.stringify(x)} found`)):Object.keys(A.values).indexOf(i.J(x))===-1&&D.push(new i.V(h,x,`expected one of [${Object.keys(A.values).join(", ")}], ${JSON.stringify(x)} found`)),D}function Et(M){return i.a2(i.S(M.value))?Xe(Object.assign({},M,{expressionContext:"filter",valueSpec:M.styleSpec[`filter_${M.layerType||"fill"}`]})):qt(M)}function qt(M){const h=M.value,x=M.key;if(!Array.isArray(h))return[new i.V(x,h,`array expected, ${i.K(h)} found`)];if(h.length<1)return[new i.V(x,h,"filter array must have at least 1 element")];const A=M.styleSpec;let D=tt({key:`${x}[0]`,value:h[0],valueSpec:A.filter_operator});const F=()=>{h.length>=2&&(i.a0(h[1])||D.push(new i.V(`${x}[1]`,h[1],`string expected, ${i.K(h[1])} found`)));for(let z=2;z":case">=":h.length>=2&&i.J(h[1])==="$type"&&D.push(new i.V(x,h,`"$type" cannot be use with operator "${h[0]}"`)),h.length!==3&&D.push(new i.V(x,h,`filter array for operator "${h[0]}" must have 3 elements`)),F();break;case"==":case"!=":h.length!==3&&D.push(new i.V(x,h,`filter array for operator "${h[0]}" must have 3 elements`)),F();break;case"in":case"!in":F();break;case"any":case"all":case"none":for(let z=1;z{ae in x&&h.push(new i.V(A,x[ae],`"${ae}" is prohibited for ref layers`))}),D.layers.forEach(ae=>{i.J(ae.id)===H&&(Y=ae)}),Y?Y.ref?h.push(new i.V(A,x.ref,"ref cannot reference another ref layer")):z=i.J(Y.type):typeof H=="string"&&h.push(new i.V(A,x.ref,`ref layer "${H}" not found`))}else if(z!=="background"&&z!=="sky"&&z!=="slot")if(x.source)if(i.a0(x.source)){const Y=D.sources&&D.sources[x.source],ae=Y&&i.J(Y.type);Y?ae==="vector"&&z==="raster"?h.push(new i.V(A,x.source,`layer "${x.id}" requires a raster source`)):ae==="raster"&&z!=="raster"?h.push(new i.V(A,x.source,`layer "${x.id}" requires a vector source`)):ae!=="vector"||x["source-layer"]?ae==="raster-dem"&&z!=="hillshade"?h.push(new i.V(A,x.source,"raster-dem source can only be used with layer type 'hillshade'.")):ae!=="raster-array"||["raster","raster-particle"].includes(z)?z==="line"&&x.paint&&(x.paint["line-gradient"]||x.paint["line-trim-offset"])&&ae==="geojson"&&!Y.lineMetrics?h.push(new i.V(A,x,`layer "${x.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):z==="raster-particle"&&ae!=="raster-array"&&h.push(new i.V(A,x.source,`layer "${x.id}" requires a 'raster-array' source.`)):h.push(new i.V(A,x.source,"raster-array source can only be used with layer type 'raster'.")):h.push(new i.V(A,x,`layer "${x.id}" must specify a "source-layer"`)):h.push(new i.V(A,x.source,`source "${x.source}" not found`))}else h.push(new i.V(`${A}.source`,x.source,'"source" must be a string'));else h.push(new i.V(A,x,'missing required property "source"'));return h=h.concat(Yn({key:A,value:x,valueSpec:F.layer,style:M.style,styleSpec:M.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Kr({key:`${A}.type`,value:x.type,valueSpec:F.layer.type,style:M.style,styleSpec:M.styleSpec,object:x,objectKey:"type"}),filter:Y=>Et(Object.assign({layerType:z},Y)),layout:Y=>Yn({layer:x,key:Y.key,value:Y.value,valueSpec:{},style:Y.style,styleSpec:Y.styleSpec,objectElementValidators:{"*":ae=>rs(Object.assign({layerType:z},ae))}}),paint:Y=>Yn({layer:x,key:Y.key,value:Y.value,valueSpec:{},style:Y.style,styleSpec:Y.styleSpec,objectElementValidators:{"*":ae=>Xt(Object.assign({layerType:z,layer:x},ae))}}),appearances(Y){const ae=ot({key:Y.key,value:Y.value,valueSpec:Y.valueSpec,style:Y.style,styleSpec:Y.styleSpec,arrayElementValidator:fe=>function(xe){const{key:Pe,layer:Ce,layerType:Ve}=xe,Be=i.J(xe.value),et=i.J(Be.name),ut=i.J(Be.condition),st=Yn({key:Pe,value:Be,valueSpec:xe.styleSpec.appearance,style:xe.style,styleSpec:xe.styleSpec,objectElementValidators:{condition:Mt=>function(yt){const kt=[];return kt.push(...Xe({key:yt.key,value:yt.object.condition,valueSpec:i.a6.appearance.condition,expressionContext:"appearance"})),kt}(Object.assign({layer:Ce,layerType:Ve},Mt)),properties:Mt=>function(yt){const kt=[],{styleSpec:gt,layer:mt,layerType:Pt}=yt,Ht=gt[`paint_${Pt}`],Ut=gt[`layout_${Pt}`],ts=yt.object[yt.objectKey];for(const ns in ts){const fs=ns in Ht?"paint":ns in Ut?"layout":void 0;if(!fs){kt.push(new i.V(yt.key,ns,`unknown property "${ns}" for layer type "${Pt}"`));continue}const qs=Object.assign({},yt,{key:`${yt.key}.${ns}`,object:ts,objectKey:ns,layer:mt,layerType:Pt,value:ts[ns],valueSpec:fs==="paint"?Ht[ns]:Ut[ns]});kt.push(...ms(qs,fs))}return kt}(Object.assign({layer:Ce,layerType:Ve},Mt))}});return et!=="hidden"&&ut===void 0&&st.push(new i.V(xe.key,"name",'Appearance with name different than "hidden" must have a condition')),st}(Object.assign({layerType:z,layer:x},fe))}),oe=Array.isArray(Y.value)?Y.value:[],ge=new Set;return oe.forEach((fe,xe)=>{const Pe=i.J(fe.name);if(Pe)if(ge.has(Pe)){const Ce=i.J(x.id);ae.push(new i.V(Y.key,Pe,`Duplicated appearance name "${Pe}" for layer "${Ce}"`))}else ge.add(Pe)}),ae}}})),h}function Ms({key:M,value:h}){return i.a0(h)?[]:[new i.V(M,h,`string expected, ${i.K(h)} found`)]}const jt={promoteId:function M({key:h,value:x}){if(i.a0(x))return Ms({key:h,value:x});if(Array.isArray(x)){const D=[],F=i.S(x),z=i.U(F);return z.result==="error"&&z.value.forEach(H=>{D.push(new i.V(`${h}${H.key}`,null,`${H.message}`))}),i.X(z.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||D.push(new i.V(`${h}`,null,"promoteId expression should be only feature dependent")),D}if(!i.H(x))return[new i.V(h,x,`string, expression or object expected, "${i.K(x)}" found`)];const A=[];for(const D in x)A.push(...M({key:`${h}.${D}`,value:x[D]}));return A}};function As(M){const h=M.value,x=M.key,A=M.styleSpec,D=M.style;if(!i.H(h))return[new i.V(x,h,`object expected, ${i.K(h)} found`)];if(!("type"in h))return[new i.V(x,h,'"type" is required')];const F=i.J(h.type);let z=[];switch(["vector","raster","raster-dem","raster-array"].includes(F)&&("url"in h||"tiles"in h||z.push(new i.a3(x,h,'Either "url" or "tiles" is required.'))),F){case"vector":case"raster":case"raster-dem":case"raster-array":return z=z.concat(Yn({key:x,value:h,valueSpec:A[`source_${F.replace("-","_")}`],style:M.style,styleSpec:A,objectElementValidators:jt})),z;case"geojson":if(z=Yn({key:x,value:h,valueSpec:A.source_geojson,style:D,styleSpec:A,objectElementValidators:jt}),"cluster"in h&&"clusterProperties"in h){if(!i.H(h.clusterProperties))return[new i.V(`${x}.clusterProperties`,h,`object expected, ${i.K(h)} found`)];for(const H in h.clusterProperties){const Y=h.clusterProperties[H];if(!Array.isArray(Y))return[new i.V(`${x}.clusterProperties.${H}`,Y,"array expected")];const[ae,oe]=Y,ge=typeof ae=="string"?[ae,["accumulated"],["get",H]]:ae;z.push(...Xe({key:`${x}.${H}.map`,value:oe,expressionContext:"cluster-map"})),z.push(...Xe({key:`${x}.${H}.reduce`,value:ge,expressionContext:"cluster-reduce"}))}}return z;case"video":return Yn({key:x,value:h,valueSpec:A.source_video,style:D,styleSpec:A});case"image":return Yn({key:x,value:h,valueSpec:A.source_image,style:D,styleSpec:A});case"canvas":return[new i.V(x,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return tt({key:`${x}.type`,value:h.type,valueSpec:{values:Ps(A)}})}}function Ps(M){return M.source.reduce((h,x)=>{const A=M[x];return A.type.type==="enum"&&(h=h.concat(Object.keys(A.type.values||{}))),h},[])}function ar(M){const h=M.value,x=M.styleSpec,A=x.light,D=M.style;if(h===void 0)return[];if(!i.H(h))return[new i.V("light",h,`object expected, ${i.K(h)} found`)];let F=[];for(const z in h){const H=z.match(/^(.*)-transition$/),Y=z.match(/^(.*)-use-theme$/);F=F.concat(Y&&A[Y[1]]?Kr({key:z,value:h[z],valueSpec:{type:"string"},style:D,styleSpec:x}):H&&A[H[1]]&&A[H[1]].transition?Kr({key:z,value:h[z],valueSpec:x.transition,style:D,styleSpec:x}):A[z]?Kr({key:z,value:h[z],valueSpec:A[z],style:D,styleSpec:x}):[new i.V(z,h[z],`unknown property "${z}"`)])}return F}function Dn(M){const h=M.value;if(!h)return[];const x=M.key;if(!i.H(h))return[new i.V(x,h,`object expected, ${i.K(h)} found`)];let A=[];const D=M.styleSpec,F=D["light-3d"],z=M.style,H=M.style.lights;for(const oe of["type","id"])if(!(oe in h))return A=A.concat([new i.V(x,h,`missing property "${oe}"`)]),A;if(!i.a0(h.type))return A=A.concat([new i.V(`${x}.type`,h.type,"string expected")]),A;if(H)for(let oe=0;oe[],array:ot,boolean:function(M){const h=M.value,x=M.key;return i.$(h)?[]:[new i.V(x,h,`boolean expected, ${i.K(h)} found`)]},number:Ue,color:function({key:M,value:h}){return i.a0(h)?i.a1.parseCSSColor(h)===null?[new i.V(M,h,`color expected, "${h}" found`)]:[]:[new i.V(M,h,`color expected, ${i.K(h)} found`)]},enum:tt,filter:Et,function:Ke,layer:ps,object:Yn,source:As,model:i.a7,light:ar,"light-3d":Dn,terrain:Va,fog:pa,string:Ms,formatted:function(M){return Ms(M).length===0?[]:Xe(M)},resolvedImage:function(M){return Ms(M).length===0?[]:Xe(M)},projection:function(M){const h=M.value,x=M.styleSpec,A=x.projection,D=M.style;if(i.H(h)){let F=[];for(const z in h)F=F.concat(Kr({key:z,value:h[z],valueSpec:A[z],style:D,styleSpec:x}));return F}return i.a0(h)?[]:[new i.V("projection",h,`object or string expected, ${i.K(h)} found`)]},import:function(M){const h=M.key,{value:x,styleSpec:A}=M;if(!i.H(x))return[new i.V(h,x,"import must be an object")];const{data:D,...F}=x;Object.defineProperty(F,"__line__",{value:x.__line__,enumerable:!1});let z=Yn(Object.assign({},M,{value:F,valueSpec:A.import}));return i.J(F.id)===""&&z.push(new i.V(`${M.key}.id`,F,"import id can't be an empty string")),D&&(z=z.concat(Gn(D,A,{key:`${M.key}.data`}))),z},iconset:function(M){const h=M.value,x=M.key,A=M.styleSpec,D=M.style;if(!i.H(h))return[new i.V(x,h,"object expected")];if(!h.type)return[new i.V(x,h,'"type" is required')];const F=i.J(h.type);let z=[];if(z=z.concat(Yn({key:x,value:h,valueSpec:A[`iconset_${F}`],style:D,styleSpec:A})),function(H,Y){return!(H!=="source"||!Y.source)}(F,h)){const H=D.sources&&D.sources[h.source],Y=H&&i.J(H.type);H?Y!=="raster-array"&&z.push(new i.V(x,h.source,`iconset cannot be used with a source of type ${String(Y)}, it only be used with a "raster-array" source type`)):z.push(new i.V(x,h.source,`source "${h.source}" not found`))}return z}};function Kr(M,h=!1){const x=M.value,A=M.valueSpec,D=M.styleSpec;if(A.expression){if(i.a4(i.J(x)))return Ke(M);if(i.Q(i.S(x)))return Xe(M)}if(A.type&&qa[A.type]){const F=qa[A.type](M);return h===!0&&F.length>0&&Array.isArray(M.value)?Xe(M):F}return Yn(Object.assign({},M,{valueSpec:A.type?D[A.type]:A}))}function Yn(M){const h=M.key,x=M.value,A=M.valueSpec||{},D=M.objectElementValidators||{},F=M.style,z=M.styleSpec;if(!i.H(x))return[new i.V(h,x,`object expected, ${i.K(x)} found`)];let H=[];for(const Y in x){const ae=Y.split(".")[0];let oe;D[ae]?oe=D[ae]:A[ae]?oe=Kr:D["*"]?oe=D["*"]:A["*"]&&(oe=Kr),oe?H=H.concat(oe({key:(h&&`${h}.`)+Y,value:x[Y],valueSpec:A[ae]||A["*"],style:F,styleSpec:z,object:x,objectKey:Y},x)):H.push(new i.a3(h,x[Y],`unknown property "${Y}"`))}for(const Y in A){if(D[Y])continue;const ae=A[Y];ae.required&&ae.default===void 0&&x[Y]===void 0&&H.push(new i.V(h,x,`missing required property "${Y}"`))}return H}function mn({key:M,value:h}){const x=Ms({key:M,value:h});if(x.length)return x;const A=h;return A.indexOf("{fontstack}")===-1&&x.push(new i.V(M,h,'"glyphs" url must include a "{fontstack}" token')),A.indexOf("{range}")===-1&&x.push(new i.V(M,h,'"glyphs" url must include a "{range}" token')),x}function Gn(M,h=i.a6,x={}){return Yn({key:x.key||"",value:M,valueSpec:Object.assign(h.$root,{"*":{type:"*"}}),styleSpec:h,style:M,objectElementValidators:{glyphs:mn}})}function Zt(M,h=i.a6){return ze(Gn(M,h))}const $r=M=>ze(As(M)),es=M=>ze(ar(M)),an=M=>ze(Dn(M)),Ha=M=>ze(Va(M)),Xn=M=>ze(pa(M)),Ir=M=>ze(function(h){const x=h.value,A=h.style,D=h.styleSpec,F=D.snow;if(x===void 0)return[];if(!i.H(x))return[new i.V("snow",x,`object expected, ${i.K(x)} found`)];let z=[];for(const H in x){const Y=H.match(/^(.*)-transition$/);z=z.concat(Y&&F[Y[1]]&&F[Y[1]].transition?Kr({key:H,value:x[H],valueSpec:D.transition,style:A,styleSpec:D}):F[H]?Kr({key:H,value:x[H],valueSpec:F[H],style:A,styleSpec:D}):[new i.a3(H,x[H],`unknown property "${H}"`)])}return z}(M)),_i=M=>ze(function(h){const x=h.value,A=h.style,D=h.styleSpec,F=D.rain;if(x===void 0)return[];if(!i.H(x))return[new i.V("rain",x,`object expected, ${i.K(x)} found`)];let z=[];for(const H in x){const Y=H.match(/^(.*)-transition$/);z=z.concat(Y&&F[Y[1]]&&F[Y[1]].transition?Kr({key:H,value:x[H],valueSpec:D.transition,style:A,styleSpec:D}):F[H]?Kr({key:H,value:x[H],valueSpec:F[H],style:A,styleSpec:D}):[new i.a3(H,x[H],`unknown property "${H}"`)])}return z}(M)),rl=M=>ze(ps(M)),Ni=M=>ze(Et(M)),sc=M=>ze(Xt(M)),Vt=M=>ze(rs(M)),ve=M=>ze(i.a7(M));function ze(M){return M.slice().sort((h,x)=>h.line&&x.line?h.line-x.line:0)}function Qe(M,h){let x=!1;if(h&&h.length)for(const A of h)A instanceof i.a3?i.w(A.message):(M.fire(new i.y(new Error(A.message))),x=!0);return x}const Ct=i.a6.light;let Nt;class zt extends i.E{constructor(h,x="flat"){super(),this._transitionable=new i.a8(Nt||(Nt=new i.a9({anchor:new i.aa(Ct.anchor),position:new i.ab(Ct.position),color:new i.aa(Ct.color),intensity:new i.aa(Ct.intensity)}))),this.setLight(h,x),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(h,x,A={}){this._validate(es,h,A)||(this._transitionable.setTransitionOrValue(h),this.id=x)}updateTransitions(h){this._transitioning=this._transitionable.transitioned(h,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(h){this.properties=this._transitioning.possiblyEvaluate(h)}_validate(h,x,A){return(!A||A.validate!==!1)&&Qe(this,h.call(Zt,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}const Kt=i.a6.terrain;let $t=class extends i.E{constructor(M,h,x,A,D){super(),this.scope=x,this._transitionable=new i.a8(new i.a9({source:new i.aa(Kt.source),exaggeration:new i.aa(Kt.exaggeration)}),x,A),this._transitionable.setTransitionOrValue(M,A),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=h,this.worldview=D}get(){return this._transitionable.serialize()}set(M,h){this._transitionable.setTransitionOrValue(M,h)}updateTransitions(M){this._transitioning=this._transitionable.transitioned(M,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(M){this.properties=this._transitioning.possiblyEvaluate(M)}getExaggeration(M){return this._transitioning.possiblyEvaluate(new i.ac(M,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const M=this._transitionable._values.exaggeration;if(!M)return null;const h=M.value.expression;if(!h)return null;let x=-1,A=-1,D=1;for(const F of h.zoomStops)D=h.evaluate(new i.ac(F,{worldview:this.worldview})),D>.01?(x=F,A=-1):A=F;return D<.01&&x>0&&A>x?[x,A]:null}isZoomDependent(){const M=this._transitionable._values.exaggeration;return M!=null&&M.value!=null&&M.value.expression!=null&&M.value.expression instanceof i.ad}};const Qt=45,Is=65,gs=.05;function gr(M,h,x,A){const D=i.ah(Qt,Is,x),[F,z]=qr(M,A);let H=1-Math.min(1,Math.exp((h-F)/(z-F)*-6));return H*=H*H,H=Math.min(1,1.00747*H),H*D*M.alpha}function qr(M,h){const x=.5/Math.tan(.5*h);return[M.range[0]+x,M.range[1]+x]}function hr(M,h,x,A,D){const F=i.af([],[h,x,A],D.mercatorFogMatrix);return gr(M,i.ag(F),D.pitch,D._fov)}function Cn(M,h,x,A,D,F,z){const H=[[x,A,0],[D,A,0],[D,F,0],[x,F,0]];let Y=Number.MAX_VALUE,ae=-Number.MAX_VALUE;for(const oe of H){const ge=i.af([],oe,h),fe=i.ag(ge);Y=Math.min(Y,fe),ae=Math.max(ae,fe)}return[gr(M,Y,z.pitch,z._fov),gr(M,ae,z.pitch,z._fov)]}const Mn=i.a6.fog;class jn extends i.E{constructor(h,x,A,D){super();const F=new i.a9({range:new i.aa(Mn.range),color:new i.aa(Mn.color),"color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new i.aa(Mn["high-color"]),"high-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new i.aa(Mn["space-color"]),"space-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new i.aa(Mn["horizon-blend"]),"star-intensity":new i.aa(Mn["star-intensity"]),"vertical-range":new i.aa(Mn["vertical-range"])});this._transitionable=new i.a8(F,A,new Map(D)),this.set(h,D),this._transitioning=this._transitionable.untransitioned(),this._transform=x,this.properties=new i.ai(F),this.scope=A}get state(){const h=this._transform,x=h.projection.name==="globe",A=i.aj(h.zoom),D=this.properties.get("range"),F=[.5,3];return{range:x?[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,x,A={}){if(this._validate(Xn,h,A))return;const D=Object.assign({},h);for(const F of Object.keys(Mn))D[F]===void 0&&(D[F]=Mn[F].default);this._options=D,this._transitionable.setTransitionOrValue(this._options,x)}getOpacity(h){if(!this._transform.projection.supportsFog)return 0;const x=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:i.ah(Qt,Is,h))*x.a}getOpacityAtLatLng(h,x){return this._transform.projection.supportsFog?function(A,D,F){const z=i.ae.fromLngLat(D),H=F.elevation?F.elevation.getAtPointOrZero(z):0;return hr(A,z.x,z.y,H,F)}(this.state,h,x):0}getOpacityForTile(h){if(!this._transform.projection.supportsFog)return[1,1];const x=this._transform.calculateFogTileMatrix(h.toUnwrapped());return Cn(this.state,x,0,0,i.al,i.al,this._transform)}getOpacityForBounds(h,x,A,D,F){return this._transform.projection.supportsFog?Cn(this.state,h,x,A,D,F,this._transform):[1,1]}getFovAdjustedRange(h){return this._transform.projection.supportsFog?qr(this.state,h):[0,1]}isVisibleOnFrustum(h){if(!this._transform.projection.supportsFog)return!1;const x=[4,5,6,7];for(const A of x){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(hr(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,x,A){return(!A||A.validate!==!1)&&Qe(this,h.call(Zt,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}let fa,go,Qo,Qa,nl=class extends i.E{constructor(M,h,x,A){super();const D=fa||(fa=new i.a9({density:new i.aa(i.a6.snow.density),intensity:new i.aa(i.a6.snow.intensity),color:new i.aa(i.a6.snow.color),opacity:new i.aa(i.a6.snow.opacity),vignette:new i.aa(i.a6.snow.vignette),"vignette-color":new i.aa(i.a6.snow["vignette-color"]),"center-thinning":new i.aa(i.a6.snow["center-thinning"]),direction:new i.aa(i.a6.snow.direction),"flake-size":new i.aa(i.a6.snow["flake-size"])}));this._transitionable=new i.a8(D,x,new Map(A)),this.set(M,A),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=x}get state(){const M=this.properties.get("opacity"),h=this.properties.get("color"),x=this.properties.get("direction"),A=i.an(x[0]),D=-Math.max(i.an(x[1]),.01),F=[Math.cos(A)*Math.cos(D),Math.sin(A)*Math.cos(D),Math.sin(D)],z=this.properties.get("vignette"),H=this.properties.get("vignette-color");return H.a=z,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new i.ao(h.r,h.g,h.b,h.a*M),direction:F,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:H}}get(){return this._transitionable.serialize()}set(M,h,x={}){if(this._validate(Ir,M,x))return;const A=Object.assign({},M),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(M){this._transitionable.setTransitionOrValue(this._options,new Map(M))}updateTransitions(M){this._transitioning=this._transitionable.transitioned(M,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(M){this.properties=this._transitioning.possiblyEvaluate(M)}_validate(M,h,x){return(!x||x.validate!==!1)&&Qe(this,M.call(Zt,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}},no=class extends i.E{constructor(M,h,x,A){super();const D=go||(go=new i.a9({density:new i.aa(i.a6.rain.density),intensity:new i.aa(i.a6.rain.intensity),color:new i.aa(i.a6.rain.color),opacity:new i.aa(i.a6.rain.opacity),vignette:new i.aa(i.a6.rain.vignette),"vignette-color":new i.aa(i.a6.rain["vignette-color"]),"center-thinning":new i.aa(i.a6.rain["center-thinning"]),direction:new i.aa(i.a6.rain.direction),"droplet-size":new i.aa(i.a6.rain["droplet-size"]),"distortion-strength":new i.aa(i.a6.rain["distortion-strength"])}));this._transitionable=new i.a8(D,x,new Map(A)),this.set(M,A),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(D),this.scope=x}get state(){const M=this.properties.get("opacity"),h=this.properties.get("color"),x=this.properties.get("direction"),A=i.an(x[0]),D=-Math.max(i.an(x[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*M),direction:F,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:z}}get(){return this._transitionable.serialize()}set(M,h,x={}){if(this._validate(_i,M,x))return;const A=Object.assign({},M),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(M){this._transitionable.setTransitionOrValue(this._options,new Map(M))}updateTransitions(M){this._transitioning=this._transitionable.transitioned(M,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(M){this.properties=this._transitioning.possiblyEvaluate(M)}_validate(M,h,x){return(!x||x.validate!==!1)&&Qe(this,M.call(Zt,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}};class Na extends i.E{constructor(h,x,A,D){super(),this.scope=A,this._options=h,this.properties=new i.ai(x),this._transitionable=new i.a8(x,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,x){this._options=h,this._transitionable.setTransitionOrValue(h.properties,x)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}class ao{constructor(h,x,A){this.screenBounds=h,this.cameraPoint=A.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=x,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,A)}static createFromScreenPoints(h,x){let A,D;if(h instanceof i.P||typeof h[0]=="number"){const F=i.P.convert(h);A=[F],D=x.isPointAboveHorizon(F)}else{const F=i.P.convert(h[0]),z=i.P.convert(h[1]),H=F.add(z)._div(2);A=[F,z],D=i.aq(F,z).every(Y=>x.isPointAboveHorizon(Y))&&x.isPointAboveHorizon(H)}return new ao(A,D,x)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(h){return i.aq(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],h)}bufferedCameraGeometry(h){const x=this.screenBounds[0],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(x,A,0,!1);return this.cameraPoint.y>A.y&&(this.cameraPoint.x>x.x&&this.cameraPoint.x=A.x?D[2]=this.cameraPoint:this.cameraPoint.x<=x.x&&(D[3]=this.cameraPoint)),i.ar(D,h)}bufferedCameraGeometryGlobe(h){const x=this.screenBounds[0],A=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],D=i.aq(x,A,h),F=this.cameraPoint.clone();switch(3*((F.y>x.y)+(F.y>A.y))+((F.x>x.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,x,A,D=0){const F=Math.max(h.queryPadding,h.evaluateQueryRenderedFeaturePadding())/x._pixelsPerMercatorPixel+1,z=A?this._bufferedCameraMercator(F,x):this._bufferedScreenMercator(F,x);let H=h.tileID.wrap+(z.unwrapped?D:0);const Y=z.polygon.map(Ve=>i.as(h.tileTransform,Ve,H));if(!i.at(Y,0,0,i.al,i.al))return;H=h.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const ae=this.screenGeometryMercator.polygon.map(Ve=>i.au(h.tileTransform,Ve,H)),oe=ae.map(Ve=>new i.P(Ve[0],Ve[1])),ge=x.getFreeCameraOptions().position||new i.ae(0,0,0),fe=i.au(h.tileTransform,ge,H),xe=ae.map(Ve=>{const Be=i.av(Ve,Ve,fe);return i.aw(Be,Be),new i.ax(fe,Be)}),Pe=i.ay(h,1,x.zoom)*x._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:oe,tilespaceRays:xe,bufferedTilespaceGeometry:Y,bufferedTilespaceBounds:(Ce=i.az(Y),Ce.min.x=i.aA(Ce.min.x,0,i.al),Ce.min.y=i.aA(Ce.min.y,0,i.al),Ce.max.x=i.aA(Ce.max.x,0,i.al),Ce.max.y=i.aA(Ce.max.y,0,i.al),Ce),tile:h,tileID:h.tileID,pixelToTileUnitsFactor:Pe};var Ce}_bufferedScreenMercator(h,x){const A=io(h);if(this._screenRaycastCache[A])return this._screenRaycastCache[A];{let D;return D=x.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(h),x):{polygon:this.bufferedScreenGeometry(h).map(F=>x.pointCoordinate3D(F)),unwrapped:!0},this._screenRaycastCache[A]=D,D}}_bufferedCameraMercator(h,x){const A=io(h);if(this._cameraRaycastCache[A])return this._cameraRaycastCache[A];{let D;return D=x.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(h),x):{polygon:this.bufferedCameraGeometry(h).map(F=>x.pointCoordinate3D(F)),unwrapped:!0},this._cameraRaycastCache[A]=D,D}}_projectAndResample(h,x){const A=function(F,z){const H=i.aB([],z.pixelMatrix,z.globeMatrix),Y=[0,-i.aD,0,1],ae=[0,i.aD,0,1],oe=[0,0,0,1];i.aC(Y,Y,H),i.aC(ae,ae,H),i.aC(oe,oe,H);const ge=new i.P(Y[0]/Y[3],Y[1]/Y[3]),fe=new i.P(ae[0]/ae[3],ae[1]/ae[3]),xe=i.aE(F,ge)&&Y[3]1?Si(F.slice(0,Ve),z):[],ut=Venew i.P(aa(kt.x),kt.y)),ut=ut.map(kt=>new i.P(aa(kt.x),kt.y));const st=[...et];st.length===0&&st.push(ut[ut.length-1]);const Mt=i.ak(st[st.length-1].y,(ut.length===0?et[0]:ut[0]).y,Be);let yt;return yt=xe?[new i.P(0,Mt),new i.P(0,0),new i.P(1,0),new i.P(1,Mt)]:[new i.P(1,Mt),new i.P(1,1),new i.P(0,1),new i.P(0,Mt)],st.push(...yt),ut.length===0?st.push(et[0]):st.push(...ut),{polygon:st.map(kt=>new i.ae(kt.x,kt.y)),unwrapped:!1}}(h,x);if(A)return A;const D=function(F,z){let H=!1,Y=-1/0,ae=0;for(let ge=0;geY&&(Y=F[ge].x,ae=ge);for(let ge=0;ge.5&&(xe.x{ge.x-=1}),{polygon:F,unwrapped:H}}(Si(h,x).map(F=>new i.P(aa(F.x),F.y)),x);return{polygon:D.polygon.map(F=>new i.ae(F.x,F.y)),unwrapped:D.unwrapped}}}function Si(M,h){return i.aG(M,x=>{const A=h.pointCoordinate3D(x);x.x=A.x,x.y=A.y},1/256)}function aa(M){return M<0?1+M%1:M%1}function io(M){return 100*M|0}function yc(M,h,x,A,D){const F=function(H,Y){if(H)return D(H);if(Y){if(M.url&&Y.tiles&&M.tiles&&delete M.tiles,Y.variants){if(!Array.isArray(Y.variants))return D(new Error("variants must be an array"));for(const oe of Y.variants){if(oe==null||typeof oe!="object"||oe.constructor!==Object)return D(new Error("variant must be an object"));if(!Array.isArray(oe.capabilities))return D(new Error("capabilities must be an array"));if(oe.capabilities.length===1&&oe.capabilities[0]==="meshopt"){Y=Object.assign(Y,oe);break}}}const ae=i.aH(Object.assign({},Y,M),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);ae.tiles=h.canonicalizeTileset(ae,M.url),D(null,ae)}},z=function(H,Y,ae){if(!H)return null;if(!Y&&!ae)return H;ae=ae||H.worldview_default;const oe=Object.values(H.language||{});if(oe.length===0)return null;const ge=Object.values(H.worldview||{});if(ge.length===0)return null;const fe=oe.every(Pe=>Pe===Y),xe=ge.every(Pe=>Pe===ae);return fe&&xe?H:Y in(H.language_options||{})||ae in(H.worldview_options||{})?null:H.language_options&&H.worldview_options?H:null}(M.data,x,A);return z?i.o.frame(()=>F(null,z)):M.url?i.m(h.transformRequest(h.normalizeSourceURL(M.url,null,x,A),i.R.Source),F):i.o.frame(()=>{const{data:H,...Y}=M;F(null,Y)})}function Lc(M,h){const x=Math.pow(2,h.z),A=Math.floor(i.aF(M.getWest())*x),D=Math.floor(i.aJ(M.getNorth())*x),F=Math.ceil(i.aF(M.getEast())*x),z=Math.ceil(i.aJ(M.getSouth())*x);return h.x>=A&&h.x=D&&h.ythis.maxzoom||h.z{if(this._tileJSONRequest=null,this._loaded=!0,D)x&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${x}`),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=eu.fromTileJSON(F),ke(F.tiles,this.map._requestManager._customAccessToken),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}h&&h(D)})}loaded(){return this._loaded}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}onAdd(h){this.map=h,this.load()}reload(){this.cancelTileJSONRequest();const h=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(h))}setTiles(h){return this._options.tiles=h,this.reload(),this}setUrl(h){return this.url=h,this._options.url=h,this.reload(),this}onRemove(h){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(h,x){const 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,H=z?{image:z.image.clone()}:null,Y={request:F,data:void 0,uid:h.uid,tileID:h.tileID,tileZoom:h.tileZoom,zoom:h.tileID.overscaledZ,maxZoom:this.maxzoom,lut:H,tileSize:this.tileSize*h.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:h.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:h.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};if(this.hasWorldviews&&i.h(A)&&(Y.localizableLayerIds=this.localizableLayerIds),Y.request.collectResourceTiming=this._collectResourceTiming,h.actor&&h.state!=="expired")h.state==="loading"?h.reloadCallback=x:h.request=h.actor.send("reloadTile",Y,ae.bind(this));else if(h.actor=this._tileWorkers[D]=this._tileWorkers[D]||this.dispatcher.getActor(),this.dispatcher.ready)h.request=h.actor.send("loadTile",Y,ae.bind(this),void 0,!0);else{const oe=i.aL.call({deduped:this._deduped},Y,(ge,fe)=>{if(ge||!fe)ae.call(this,ge);else{const xe=i.aM(fe.responseHeaders);Y.data={rawData:fe.rawData.slice(0),expires:xe.expires,cacheControl:xe.cacheControl},h.actor&&h.actor.send("loadTile",Y,ae.bind(this),void 0,!0)}},!0);h.request={cancel:oe}}function ae(oe,ge){return delete h.request,h.aborted?x(null):oe&&oe instanceof i.aN&&oe.status!==404?x(oe):(ge&&ge.resourceTiming&&(h.resourceTiming=ge.resourceTiming),this.map._refreshExpiredTiles&&ge&&h.setExpiryData(ge),h.loadVectorData(ge,this.map.painter),i.aO(this.dispatcher),x(null,ge),void(h.reloadCallback&&(this.loadTile(h,h.reloadCallback),h.reloadCallback=null)))}}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.actor&&h.actor.send("abortTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(h,x){h.actor&&h.actor.send("removeTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope}),h.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class El extends i.E{constructor(h,x,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"},x),Object.assign(this,i.aH(x,["url","scheme","tileSize"]))}load(h){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const x=this.map.getWorldview();this._tileJSONRequest=yc(this._options,this.map._requestManager,null,x,(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=eu.fromTileJSON(D),ke(D.tiles),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))),h&&h(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,x){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,H)=>{if(delete h.request,h.aborted)return h.state="unloaded",x(null);if(F)return h.state="errored",x(F);if(!z)return x(null);const Y=i.aM(H);this.map._refreshExpiredTiles&&h.setExpiryData(Y),h.setTexture(z,this.map.painter),h.state="loaded",i.aO(this.dispatcher),x(null)})}abortTile(h,x){h.request&&(h.request.cancel(),delete h.request),x&&x()}unloadTile(h,x){h.texture&&h.texture instanceof i.T?(h.destroy(!1),h.texture&&h.texture instanceof i.T&&this.map.painter.saveTileTexture(h.texture)):h.destroy(),x&&x()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function th([M,h],x,A,{scaled:D=!0}={}){const{tileSize:F,buffer:z}=A,{x:H,y:Y,z:ae}=x;if(!isFinite(H)||!isFinite(Y)||!isFinite(ae))throw new Error("Invalid MRT header");const oe=2**ae,ge=oe*i.aF(M),fe=oe*i.aJ(h);return function([xe,Pe],Ce,{scaled:Ve=!0}={}){if(!Ce)throw new Error("bandView is undefined");const{data:Be,tileSize:et,buffer:ut,offset:st,scale:Mt,dimension:yt}=Ce;if(xe<-ut||xe>et+ut||Pe<-ut||Pe>et+ut)throw new Error(`Point (${xe}, ${Pe}) out of bounds for tileSize=${et}, buffer=${ut}`);const kt=(Pe+ut)*(et+2*ut)+(xe+ut);if(new Uint32Array(Be.buffer)[kt]===4294967295)return null;let gt=[];gt=Ve?[]:new Ce.data.constructor(yt);for(let mt=0;mt{if(delete h.request,h.aborted)return h.state="unloaded",x(null);if(H)return H.name==="AbortError"?void 0:(h.state="errored",x(H));if(this.map._refreshExpiredTiles&&Y){const oe=i.aM(ae);h.setExpiryData(oe)}if(this.partial&&h.state!=="expired")h.state="empty";else if(!this.partial){if(!Y)return x(null);h.state="loaded",h._isHeaderLoaded=!0,h._mrt=Y}x(null)};h.request=this.partial?h.fetchHeader(void 0,z.bind(this)):h.actor.send("loadTile",F,z.bind(this),void 0,!0)}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.actor&&h.actor.send("abortTile",{uid:h.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(h,x){const 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,x,A,D){h._isHeaderLoaded&&(h.state!=="empty"&&(h.state="reloading"),h.fetchBandForRender(x,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 x=this.rasterLayers.find(({id:F})=>F===h),A=x&&x.fields,D=A&&A.bands&&A.bands;return D?D[0]:0}getTextureDescriptor(h,x,A){if(!h)return;const D=x.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!D)return;let F=null;x instanceof i.aR?F=x.paint.get("raster-array-band"):x instanceof i.aS&&(F=x.paint.get("raster-particle-array-band"));const z=F||this.getInitialBand(D);if(z==null)return;if(!h.textureDescriptorPerLayer.get(x.id))return void this.prepareTile(h,D,x.id,z);if(h.updateNeeded(x.id,z)&&!A)return;const H=h.textureDescriptorPerLayer.get(x.id);return Object.assign({},H,{texture:h.texturePerLayer.get(x.id)})}getImages(h,x){const A=new Map;for(const D of h)for(const F of x){const[z,H]=F.split("/"),Y=D.getLayer(z);if(!Y||!Y.hasBand(H)||!Y.hasDataForBand(H))continue;const{bytes:ae,tileSize:oe,buffer:ge}=Y.getBandView(H),fe=oe+2*ge,xe={data:new i.q({width:fe,height:fe},ae),pixelRatio:2,sdf:!1,usvg:!1,version:0};A.set(F,xe)}return A}queryRasterArrayValueByBandId(h,x,A){const D=x._mrt;return new Promise(F=>{const z={},H=new Set;for(const[Y,ae]of Object.entries(D.layers)){if(A.layerName&&Y!==A.layerName)continue;const oe={};z[Y]=oe;for(const{bands:ge}of ae.dataIndex)for(const fe of ge)A.bands&&!A.bands.includes(fe)||(H.add(i.B(Y,fe)),x.fetchBand(Y,null,fe,xe=>{i.o.frame(()=>{oe[fe]=xe?null:th([h.lng,h.lat],D,ae.getBandView(fe)),H.delete(i.B(Y,fe)),H.size===0&&F(z)})},!1))}H.size===0&&F(z)})}_loadTileForQuery(h,x){if(this._loadTileLoaded[h.uid])return void x(null,h._mrt);if(this._loadTilePending[h.uid])return void this._loadTilePending[h.uid].push(x);this._loadTilePending[h.uid]=[x];const 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,H)=>{if(F)return this._loadTilePending[h.uid].forEach(Y=>Y(F,null)),void delete this._loadTilePending[h.uid];if(!z)return this._loadTilePending[h.uid].forEach(Y=>Y(null,null)),void delete this._loadTilePending[h.uid];if(this.map._refreshExpiredTiles&&z){const Y=i.aM(H);h.setExpiryData(Y)}h._mrt=z,h._isHeaderLoaded=!0,h.state="loaded",this._loadTilePending[h.uid].forEach(Y=>Y(null,z)),this._loadTileLoaded[h.uid]=!0,delete this._loadTilePending[h.uid]},void 0,!0)}queryRasterArrayValueByAllBands(h,x,A){return new Promise((D,F)=>{this._loadTileForQuery(x,(z,H)=>{z?F(z):D(H?this.queryRasterArrayValueByBandId(h,x,A):null)})})}queryRasterArrayValue(h,x){const A=i.aT.convert(h),D=this.findLoadedParent(A);return D&&D._mrt?x.bands||!this.partial?this.queryRasterArrayValueByBandId(A,D,x):this.queryRasterArrayValueByAllBands(A,D,x):Promise.resolve(null)}findLoadedParent(h){const x=i.ae.fromLngLat(h,this.map.transform.tileSize),A=this.maxzoom+1,D=1<0&&(H[new i.aQ(M.overscaledZ,D,h.z,A,h.y-1).key]={backfilled:!1},H[new i.aQ(M.overscaledZ,M.wrap,h.z,h.x,h.y-1).key]={backfilled:!1},H[new i.aQ(M.overscaledZ,z,h.z,F,h.y-1).key]={backfilled:!1}),h.y+1{if(this._loaded=!0,this._pendingLoad=null,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]),M&&(this._partialReload=!0),this.fire(new i.z("data",F)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(M),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const M=i.B(this.id,this.scope);this.map.style.clearSource(M),this._updateWorkerData()}loadTile(M,h){const x=M.actor?"reloadTile":"loadTile";M.actor=this.actor;const 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:M.uid,tileID:M.tileID,tileZoom:M.tileZoom,zoom:M.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:D,scope:this.scope,pixelRatio:i.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:M.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:F,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};M.request=this.actor.send(x,z,(H,Y)=>F&&!Y?(M.state="loaded",h(null)):(delete M.request,M.destroy(!1),M.aborted?h(null):H?h(H):(M.loadVectorData(Y,this.map.painter,x==="reloadTile"),h(null))),void 0,x==="loadTile")}abortTile(M){M.request&&(M.request.cancel(),delete M.request),M.aborted=!0}unloadTile(M,h){this.actor.send("removeTile",{uid:M.uid,type:this.type,source:this.id,scope:this.scope}),M.destroy()}onRemove(M){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends i.aU{constructor(M,h,x,A){super(M,h,x,A),this.roundZoom=!0,this.type="video",this.options=h}load(){this._loaded=!1;const M=this.options;this.urls=[];for(const h of M.urls)this.urls.push(this.map._requestManager.transformRequest(h,i.R.Source).url);i.aV(this.urls,(h,x)=>{this._loaded=!0,h?this.fire(new i.y(h)):x&&(this.video=x,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(M){if(this.video){const h=this.video.seekable;Mh.end(0)?this.fire(new i.y(new i.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${h.start(0)} and ${h.end(0)}-second mark.`))):this.video.currentTime=M}}getVideo(){return this.video}onAdd(M){this.map||(this.map=M,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const M=this.map.painter.context,h=M.gl;this.texture?this.video.paused||(this.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),h.texSubImage2D(h.TEXTURE_2D,0,0,0,h.RGBA,h.UNSIGNED_BYTE,this.video)):(this.texture=new i.T(M,this.video,h.RGBA8),this.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(M)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:i.aU,model:i.aX,"batched-model":class extends i.E{constructor(M,h,x,A){super(),this.type="batched-model",this.id=M,this.tileSize=512,this._options=h,this.tiles=this._options.tiles,this.maxzoom=h.maxzoom||19,this.minzoom=h.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=x,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(A)}onAdd(M){this.map=M,this.load()}reload(){this.cancelTileJSONRequest();const M=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(M))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(M){this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"}));const h=Array.isArray(this.map._language)?this.map._language.join():this.map._language,x=this.map.getWorldview();this._tileJSONRequest=yc(this._options,this.map._requestManager,h,x,(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}`),x&&x.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${x}`),this.fire(new i.y(A))):D&&(Object.assign(this,D),D.bounds&&(this.tileBounds=new eu(D.bounds,this.minzoom,this.maxzoom)),ke(D.tiles,this.map._requestManager._customAccessToken),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))),M&&M(A)})}hasTransition(){return!1}hasTile(M){return!this.tileBounds||this.tileBounds.contains(M.canonical)}loaded(){return this._loaded}loadTile(M,h){const x=this.map._requestManager.normalizeTileURL(M.tileID.canonical.url(this.tiles,this.scheme)),A={request:this.map._requestManager.transformRequest(x,i.R.Tile),data:void 0,uid:M.uid,tileID:M.tileID,tileZoom:M.tileZoom,zoom:M.tileID.overscaledZ,tileSize:this.tileSize*M.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:M.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:i.o.devicePixelRatio,promoteId:this.promoteId};if(M.actor&&M.state!=="expired")if(M.state==="loading")M.reloadCallback=h;else{if(M.buckets){const F=Object.values(M.buckets);for(const z of F)z.dirty=!0;return void(M.state="loaded")}M.request=M.actor.send("reloadTile",A,D.bind(this))}else M.actor=this.dispatcher.getActor(),M.request=M.actor.send("loadTile",A,D.bind(this),void 0,!0);function D(F,z){return M.aborted?h(null):F&&F.status!==404?h(F):(this.map._refreshExpiredTiles&&z&&M.setExpiryData(z),M.loadModelData(z,this.map.painter),M.state="loaded",void h(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends i.aU{constructor(M,h,x,A){super(M,h,x,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.${M}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.y(new i.V(`sources.${M}`,null,'missing required property "coordinates"'))),h.animate&&typeof h.animate!="boolean"&&this.fire(new i.y(new i.V(`sources.${M}`,null,'optional "animate" property must be a boolean value'))),h.canvas?typeof h.canvas=="string"||h.canvas instanceof HTMLCanvasElement||this.fire(new i.y(new i.V(`sources.${M}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new i.y(new i.V(`sources.${M}`,null,'missing required property "canvas"'))),this.options=h,this.animate=h.animate===void 0||h.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.y(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(M){this.map=M,this.load(),this.canvas&&this.animate&&this.play()}onRemove(M){this.pause()}prepare(){let M=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,M=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,M=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const h=this.map.painter.context;this.texture?!M&&!this._playing||this.texture instanceof i.aW||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.T(h,this.canvas,h.gl.RGBA8,{premultiply:!0}),this._prepareData(h)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const M of[this.canvas.width,this.canvas.height])if(isNaN(M)||M<=0)return!0;return!1}},custom:class extends i.E{constructor(M,h,x,A){super(),this.id=M,this.type="custom",this._dataType="raster",this._dispatcher=x,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 eu(this._implementation.bounds,this.minzoom,this.maxzoom)),h.update=this._update.bind(this),h.clearTiles=this._clearTiles.bind(this),h.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,i.aH(h,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return i.aH(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(M){this.map=M,this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(M),this.load()}onRemove(M){this._implementation.onRemove&&this._implementation.onRemove(M)}hasTile(M){if(this._implementation.hasTile){const{x:h,y:x,z:A}=M.canonical;return this._implementation.hasTile({x:h,y:x,z:A})}return!this.tileBounds||this.tileBounds.contains(M.canonical)}loadTile(M,h){const{x,y:A,z:D}=M.tileID.canonical,F=new AbortController;M.request=Promise.resolve(this._implementation.loadTile({x,y:A,z:D},{signal:F.signal})).then((function(z){return delete M.request,M.aborted?(M.state="unloaded",h(null)):z===void 0?(M.state="errored",h(null)):z===null?(this.loadTileData(M,{width:this.tileSize,height:this.tileSize,data:null}),M.state="loaded",h(null)):function(H){return H instanceof ImageData||H instanceof HTMLCanvasElement||H instanceof ImageBitmap||H instanceof HTMLImageElement}(z)?(this.loadTileData(M,z),M.state="loaded",void h(null)):(M.state="errored",h(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(z=>{z.name!=="AbortError"&&(M.state="errored",h(z))}),M.request.cancel=()=>F.abort()}loadTileData(M,h){M.setTexture(h,this.map.painter)}unloadTile(M,h){if(M.texture&&M.texture instanceof i.T?(M.destroy(!1),M.texture&&M.texture instanceof i.T&&this.map.painter.saveTileTexture(M.texture)):M.destroy(),this._implementation.unloadTile){const{x,y:A,z:D}=M.tileID.canonical;this._implementation.unloadTile({x,y:A,z:D})}h&&h()}abortTile(M,h){M.request&&M.request.cancel&&(M.request.cancel(),delete M.request),h&&h()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(M=>({x:M.canonical.x,y:M.canonical.y,z:M.canonical.z}))}_clearTiles(){const M=i.B(this.id,this.scope);this.map.style.clearSource(M)}_update(){this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}}},Pl=function(M,h,x,A){const D=new zm[h.type](M,h,x,A);if(D.id!==M)throw new Error(`Expected Source id to be ${M} instead of ${D.id}`);return i.aY(["load","abort","unload","serialize","prepare"],D),D};function qg(M,h,x=""){return`${x}:${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}`:""}`}}(M.target)}`}function uy(M,h,x,A=""){if(M.uniqueFeatureID){const D=qg(M,h,A);if(x.has(D))return!0;x.add(D)}return!1}function D1(M,h,x,A,D=!1){const F=h.sourceCache.transform,z=h.sourceCache.tilesIn(M,h.has3DLayers,D);z.sort(Tp);const H=[];for(const Y of z){const ae=Y.tile.queryRenderedFeatures(h,Y,x,A,F,D);Object.keys(ae).length&&H.push({wrappedTileID:Y.tile.tileID.wrapped().key,queryResults:ae})}for(const Y in h.layers){const ae=h.layers[Y];if(ae.styleLayer){const oe=ae.styleLayer.queryRenderedFeatures(M,h.sourceCache,A);Object.keys(oe).length&&H.push({wrappedTileID:0,queryResults:oe})}}return H.length===0?{}:function(Y){const ae={},oe={};for(const ge of Y){const fe=ge.queryResults,xe=ge.wrappedTileID,Pe=oe[xe]=oe[xe]||{};for(const Ce in fe){const Ve=fe[Ce],Be=Pe[Ce]=Pe[Ce]||{},et=ae[Ce]=ae[Ce]||[];for(const ut of Ve)Be[ut.featureIndex]||(Be[ut.featureIndex]=!0,et.push(ut))}}return ae}(H)}function O1(M,h,x,A,D,F){const z={},H=A.queryRenderedSymbols(M),Y=[];for(const ae of Object.keys(H).map(Number))Y.push(D[ae]);Y.sort(Tp);for(const ae of Y){const oe=ae.featureIndex.lookupSymbolFeatures(H[ae.bucketInstanceId],ae.bucketIndex,ae.sourceLayerIndex,h,x,F);for(const ge in oe){const fe=z[ge]=z[ge]||[],xe=oe[ge];xe.sort((Pe,Ce)=>{const Ve=ae.featureSortOrder;if(Ve){const Be=Ve.indexOf(Pe.featureIndex);return Ve.indexOf(Ce.featureIndex)-Be}return Ce.featureIndex-Pe.featureIndex});for(const Pe of xe)fe.push(Pe)}}return z}function R1(M,h){const x=M.getRenderableIds().map(F=>M.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)x[F.fqid]=A}}return x}const tu=32,Jh=33,Ld=new Uint16Array(8184);for(let M=0;M<2046;M++){let h=M+2,x=0,A=0,D=0,F=0,z=0,H=0;for(1&h?D=F=z=tu:x=A=H=tu;(h>>=1)>1;){const ae=x+D>>1,oe=A+F>>1;1&h?(D=x,F=A,x=z,A=H):(x=D,A=F,D=z,F=H),z=ae,H=oe}const Y=4*M;Ld[Y+0]=x,Ld[Y+1]=A,Ld[Y+2]=D,Ld[Y+3]=F}const vd=new Uint16Array(2178),su=new Uint8Array(1089),Mf=new Uint16Array(1089);function Tf(M){return M===0?-.03125:M===32?.03125:0}const Bm={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 $m{constructor(h,x,A,D,F,z){this.tileID=h,this.uid=i.b2(),this.uses=0,this.tileSize=x,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 x=h+this.timeAdded;xA)D=!1;else if(x)if(this.expirationTimeA.appearances&&A.appearances.length>0))return!0;return!1}updateBuckets(h,x){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],H=z.layers[0],Y=H.sourceLayer||"_geojsonTileLayer",ae=h.style.getLayerSourceCache(H);let oe={};ae&&(oe=ae._state.getState(Y,void 0));const ge=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},fe=Object.keys(oe).length>0&&!x;z.hasAppearances=z.layers.some(Ce=>Ce.appearances&&Ce.appearances.length>0);const xe=fe?z.stateDependentLayers:z.layers;if(fe&&z.stateDependentLayers.length!==0||x){const Ce=this.latestFeatureIndex.loadVTLayers();z.update(oe,Ce[Y],A,ge,xe,x,D)}if(fe&&z.stateDependentLayers.length!==0||x||z.hasAppearances){const Ce={zoom:h.transform.zoom,pitch:h.transform.pitch,brightness:h.style.getBrightness()||0,worldview:h.worldview};z.updateAppearances(this.tileID.canonical,oe,A,Ce)}(z instanceof i.ba||z instanceof i.bb)&&h._terrain&&h._terrain.enabled&&ae&&z.uploadPending()&&h._terrain._clearRenderCacheForTile(ae.id,this.tileID);const Pe=h&&h.style&&h.style.getOwnLayer(F);Pe&&(this.queryPadding=Math.max(this.queryPadding,Pe.queryRadius(z)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;Ve--){const Be=4*Ve,et=Ld[Be+0],ut=Ld[Be+1],st=Ld[Be+2],Mt=Ld[Be+3],yt=et+st>>1,kt=ut+Mt>>1,gt=yt+kt-ut,mt=kt+et-yt,Pt=ut*Jh+et,Ht=Mt*Jh+st,Ut=kt*Jh+yt,ts=Math.hypot((vd[2*Pt+0]+vd[2*Ht+0])/2-vd[2*Ut+0],(vd[2*Pt+1]+vd[2*Ht+1])/2-vd[2*Ut+1])>=16;su[Ut]=su[Ut]||(ts?1:0),Ve<1022&&(su[Ut]=su[Ut]||su[(ut+mt>>1)*Jh+(et+gt>>1)]||su[(Mt+mt>>1)*Jh+(st+gt>>1)])}const ge=new i.b1,fe=new i.b0;let xe=0;function Pe(Ve,Be){const et=Be*Jh+Ve;return Mf[et]===0&&(ge.emplaceBack(vd[2*et+0],vd[2*et+1],Ve*i.al/tu,Be*i.al/tu),Mf[et]=++xe),Mf[et]-1}function Ce(Ve,Be,et,ut,st,Mt){const yt=Ve+et>>1,kt=Be+ut>>1;if(Math.abs(Ve-st)+Math.abs(Be-Mt)>1&&su[kt*Jh+yt])Ce(st,Mt,Ve,Be,yt,kt),Ce(et,ut,st,Mt,yt,kt);else{const gt=Pe(Ve,Be),mt=Pe(et,ut),Pt=Pe(st,Mt);fe.emplaceBack(gt,mt,Pt)}}return Ce(0,0,tu,tu,tu,0),Ce(tu,tu,0,0,0,tu),{vertices:ge,indices:fe}}(this.tileID.canonical,x);D=z.vertices,F=z.indices}else{D=new i.b1,F=new i.b0;for(const{x:H,y:Y}of A)D.emplaceBack(H,Y,0,0);const z=i.bh(D.int16.subarray(0,4*D.length),void 0,4);for(let H=0;H0&&(Y=i.bl(new Float64Array(16),x.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(h,D,x,z,Y,H),this._makeGlobeTileDebugTextBuffer(h,D,x,z,Y,H)}_globePoint(h,x,A,D,F,z,H){let Y=i.bm(h,x,A);if(z){const ae=1<.5?xe=-1:fe<-.5&&(xe=1);let Pe=(h/i.al+A.x)/ae+xe,Ce=(x/i.al+A.y)/ae;Pe=(Pe-oe)*D._pixelsPerMercatorPixel+oe,Ce=(Ce-ge)*D._pixelsPerMercatorPixel+ge;const Ve=[Pe*D.worldSize,Ce*D.worldSize,0];i.af(Ve,Ve,z),Y=i.bn(Y,Ve,H)}return i.af(Y,Y,F)}_makeGlobeTileDebugBorderBuffer(h,x,A,D,F,z){const H=new i.bd,Y=new i.be,ae=new i.bo,oe=(fe,xe,Pe,Ce,Ve)=>{const Be=(Pe-fe)/(Ve-1),et=(Ce-xe)/(Ve-1),ut=H.length;for(let st=0;stge*xe+Pe;for(let xe=0;xe{if(F)x(F);else try{const Y=A.getHeaderLength(z);if(Y>h)return void(this.request=this.fetchHeader(Y,x));A.parseHeader(z),this._isHeaderLoaded=!0;let ae=0;for(const oe of Object.values(A.layers))ae=Math.max(ae,oe.dataIndex[oe.dataIndex.length-1].lastByte);z.byteLength>=ae&&(this.entireBuffer=z),x(null,this.entireBuffer||z,H)}catch(Y){x(Y)}}),this.request}fetchBandForRender(h,x,A,D){this.fetchBand(h,x,A,F=>{if(F)return void D(F);this.updateTextureDescriptor(h,x,A);const z=this.textureDescriptorPerLayer.get(x);D(null,z?z.img:null)})}fetchBand(h,x,A,D,F=!0){const z=this._mrt;if(!this._isHeaderLoaded||!z)return void D(new Error("Tile header is not ready"));const H=this.actor;if(!H)return void D(new Error("Can't fetch tile band without an actor"));let Y;const ae=i.B(String(A),i.B(this.tileID.key,h));let oe=this._taskQueue.get(ae);oe?oe.add(D):(oe=new Set,oe.add(D),this._taskQueue.set(ae,oe));const ge=(Ce,Ve)=>{Y.complete(Ce,Ve),Ce?D(Ce):(oe.forEach(Be=>Be(null,Ve)),this._taskQueue.delete(ae))},fe=(Ce,Ve)=>{if(Ce)return D(Ce);const Be=H.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:Ve,task:Y},ge,void 0,!0);if(x!==null){const et=this._workQueuePerLayer.get(x)||[];et.push(()=>{Be&&Be.cancel(),Y.cancel()}),this._workQueuePerLayer.has(x)||this._workQueuePerLayer.set(x,et)}};let xe;try{xe=z.getLayer(h)}catch(Ce){if(this.state==="reloading")return;throw Ce}if(!xe)return void D(new Error(`Unknown sourceLayer "${h}"`));if(xe.hasDataForBand(A))return oe.forEach(Ce=>Ce(null,null)),void this._taskQueue.delete(ae);const Pe=xe.getDataRange([A]);if(Y=z.createDecodingTask(Pe),!Y||Y.tasks.length)if(x!==null&&this.flushQueues(x),this.entireBuffer)fe(null,this.entireBuffer.slice(Pe.firstByte,Pe.lastByte+1));else{const Ce=Object.assign({},this.requestParams,{headers:{Range:`bytes=${Pe.firstByte}-${Pe.lastByte}`}}),Ve=i.bu(Ce,fe);if(x!==null){const Be=this._fetchQueuePerLayer.get(x)||[];Be.push(()=>{Ve.cancel(),Y.cancel()}),this._fetchQueuePerLayer.has(x)||this._fetchQueuePerLayer.set(x,Be)}}}updateNeeded(h,x){return(!this.textureDescriptorPerLayer.get(h)||this.textureDescriptorPerLayer.get(h).band!==x||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(h,x,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:H,offset:Y,scale:ae}=D.getBandView(A),oe=z+2*H,ge=new i.q({width:oe,height:oe},F),fe=this.texturePerLayer.get(x);fe&&fe instanceof i.T&&fe.update(ge,{premultiply:!1}),this.textureDescriptorPerLayer.set(x,{layer:h,band:A,img:ge,buffer:H,offset:Y,tileSize:z,format:D.pixelFormat,mix:[ae,256*ae,65536*ae,16777216*ae]})}destroy(h=!1){if(super.destroy(h),delete this._mrt,!h)for(const x of this.texturePerLayer.values())x&&x instanceof i.T&&x.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1}}class $0{constructor(h,x){this.max=h,this.onRemove=x,this.reset()}reset(){for(const h in this.data)for(const x of this.data[h])x.timeout&&clearTimeout(x.timeout),this.onRemove(x.value);return this.data={},this.order=[],this}add(h,x,A){const D=h.wrapped().key;this.data[D]===void 0&&(this.data[D]=[]);const F={value:x,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 x=this.data[h].shift();return x.timeout&&clearTimeout(x.timeout),this.data[h].length===0&&delete this.data[h],this.order.splice(this.order.indexOf(h),1),x.value}getByKey(h){const x=this.data[h];return x?x[0].value:null}get(h){return this.has(h)?this.data[h.wrapped().key][0].value:null}remove(h,x){if(!this.has(h))return this;const A=h.wrapped().key,D=x===void 0?0:this.data[A].indexOf(x),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 x=this._getAndRemoveByKey(this.order[0]);x&&this.onRemove(x)}return this}filter(h){const x=[];for(const A in this.data)for(const D of this.data[A])h(D.value)||x.push(D);for(const A of x)this.remove(A.value.tileID,A)}}class Ug{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(h,x,A){const D=String(x);if(this.stateChanges[h]=this.stateChanges[h]||{},this.stateChanges[h][D]=this.stateChanges[h][D]||{},Object.assign(this.stateChanges[h][D],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,x,A){if(this.deletedStates[h]===null)return;const D=String(x);if(this.deletedStates[h]=this.deletedStates[h]||{},A&&x!==void 0)this.deletedStates[h][D]!==null&&(this.deletedStates[h][D]=this.deletedStates[h][D]||{},this.deletedStates[h][D][A]=null);else if(x!==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,x){const A=this.state[h]||{},D=this.stateChanges[h]||{},F=this.deletedStates[h];if(F===null)return{};if(x!==void 0){const H=String(x),Y=Object.assign({},A[H],D[H]);if(F){const ae=F[x];if(ae===null)return{};for(const oe in ae)delete Y[oe]}return Y}const z=Object.assign({},A,D);if(F)for(const H in F)delete z[H];return z}initializeTileState(h,x){h.refreshFeatureState(x)}coalesceChanges(h,x){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 H of Object.keys(this.deletedStates[D][z]))delete this.state[D][z][H];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(x)}}class jl extends i.E{constructor(h,x,A){super(),this.id=h,this._onlySymbols=A,x.on("data",D=>{D.dataType==="source"&&D.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&D.dataType==="source"&&D.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),x.on("error",()=>{this._sourceErrored=!0}),this._source=x,this._tiles={},this._cache=new $0(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=x.minTileCacheSize,this._maxTileCacheSize=x.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Ug,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="raster-array"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(h){this.map=h,this._minTileCacheSize=this._minTileCacheSize===void 0&&h?h._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&h?h._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const h in this._tiles)if(!this._tiles[h].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const h=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,h&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(h,x){return h.isSymbolTile=this._onlySymbols,h.isExtraShadowCaster=this._shadowCasterTiles[h.tileID.key],this._source.loadTile(h,x)}_unloadTile(h){if(this._source.unloadTile)return this._source.unloadTile(h)}_abortTile(h){if(this._source.abortTile)return this._source.abortTile(h)}serialize(){return this._source.serialize()}prepare(h){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const x in this._tiles){const A=this._tiles[x];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(F1).map(h=>h.key)}getRenderableIds(h,x){const A=[];for(const D in this._tiles)this._isIdRenderable(+D,h,x)&&A.push(this._tiles[D]);return h?A.sort((D,F)=>{const z=D.tileID,H=F.tileID,Y=new i.P(z.canonical.x,z.canonical.y)._rotate(this.transform.angle),ae=new i.P(H.canonical.x,H.canonical.y)._rotate(this.transform.angle);return z.overscaledZ-H.overscaledZ||ae.y-Y.y||ae.x-Y.x}).map(D=>D.tileID.key):A.map(D=>D.tileID).sort(F1).map(D=>D.key)}hasRenderableParent(h){const x=this.findLoadedParent(h,0);return!!x&&this._isIdRenderable(x.tileID.key)}_isIdRenderable(h,x,A){return this._tiles[h]&&this._tiles[h].hasData()&&!this._coveredTiles[h]&&(x||!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,x){const A=this._tiles[h];A&&(A.state!=="loading"&&(A.state=x),this._loadTile(A,this._tileLoaded.bind(this,A,h,x)))}_tileLoaded(h,x,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 H=this.map.painter.terrain;this.update(this.transform,H.getScaledDemTileSize(),!0),H.resetTileLookupCache(this.id)}else this.update(this.transform)}return}h.timeAdded=i.o.now(),A==="expired"&&(h.refreshedUponExpiration=!0),this._setTileReloadTimer(x,h),this._source.type==="raster-dem"&&h.dem&&this._backfillDEM(h),this._state.initializeTileState(h,this.map?this.map.painter:null);let z=new Map;F&&F.responseHeaders&&(z=F.responseHeaders),this._source.fire(new i.z("data",{dataType:"source",tile:h,coord:h.tileID,sourceCacheId:this.id,responseHeaders:z}))}_backfillDEM(h){const x=this.getRenderableIds();for(let D=0;D1||(Math.abs(z)>1&&(Math.abs(z+Y)===1?z+=Y:Math.abs(z-Y)===1&&(z-=Y)),F.dem&&D.dem&&(D.dem.backfillBorder(F.dem,z,H),D.neighboringTiles&&D.neighboringTiles[ae]&&(D.neighboringTiles[ae].backfilled=!0)))}}getTile(h){return this.getTileByID(h.key)}getTileByID(h){return this._tiles[h]}_retainLoadedChildren(h,x,A,D){for(const F in this._tiles){let z=this._tiles[F];if(D[F]||!z.hasData()||z.tileID.overscaledZ<=x||z.tileID.overscaledZ>A)continue;let H=z.tileID;for(;z&&z.tileID.overscaledZ>x+1;){const ae=z.tileID.scaledTo(z.tileID.overscaledZ-1);z=this._tiles[ae.key],z&&z.hasData()&&(H=ae)}let Y=H;for(;Y.overscaledZ>x;)if(Y=Y.scaledTo(Y.overscaledZ-1),h[Y.key]){D[H.key]=H;break}}}findLoadedParent(h,x){if(h.key in this._loadedParentTiles){const A=this._loadedParentTiles[h.key];return A&&A.tileID.overscaledZ>=x?A:null}for(let A=h.overscaledZ-1;A>=x;A--){const D=h.scaledTo(A),F=this._getLoadedTile(D);if(F)return F}}_getLoadedTile(h){const x=this._tiles[h.key];return x&&x.hasData()?x:this._cache.getByKey(this._source.reparseOverscaled?h.wrapped().key:h.canonical.key)}updateCacheSize(h,x){x=x||this._source.tileSize;const A=Math.ceil(h.width/x)+1,D=Math.ceil(h.height/x)+1,F=Math.floor(A*D*5),z=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,F):F,H=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,z):z;this._cache.setMaxSize(H)}handleWrapJump(h){const x=Math.round((h-(this._prevLng===void 0?h:this._prevLng))/360);if(this._prevLng=h,x){const A={};for(const D in this._tiles){const F=this._tiles[D];F.tileID=F.tileID.unwrapTo(F.tileID.wrap+x),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,x,A,D,F){if(this.transform=h,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!A)return;this.updateCacheSize(h,x),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const z=this._source.type==="batched-model";let H,Y=this._source.maxzoom;const ae=this.map&&this.map.painter?this.map.painter._terrain:null;if(ae&&ae.sourceCache===this&&ae.attenuationRange()){const fe=ae.attenuationRange()[0],xe=Math.floor(fe)-Math.log2(ae.getDemUpscale());Y>xe&&(Y=xe)}if(this.used||this.usedForTerrain){if(this._source.tileID)H=h.getVisibleUnwrappedCoordinates(this._source.tileID).map(fe=>new i.aQ(fe.canonical.z,fe.wrap,fe.canonical.z,fe.canonical.x,fe.canonical.y));else if(this.tileCoverLift!==0){const fe=h.clone();fe.tileCoverLift=this.tileCoverLift,H=fe.coveringTiles({tileSize:x||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:Y,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.minzoom<=1&&h.projection.name==="globe"&&(H.push(new i.aQ(1,0,1,0,0)),H.push(new i.aQ(1,0,1,1,0)),H.push(new i.aQ(1,0,1,0,1)),H.push(new i.aQ(1,0,1,1,1)))}else if(H=h.coveringTiles({tileSize:x||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:Y,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.hasTile){const fe=this._source.hasTile.bind(this._source);H=H.filter(xe=>fe(xe))}}else H=[];if(H.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!Vg(this._source.type)){const fe=h.coveringZoomLevel({tileSize:x||this._source.tileSize,roundZoom:this._source.roundZoom&&!A}),xe=Math.min(fe,this._source.maxzoom);if(z){const Pe=h.extendTileCover(H,xe);for(const Ce of Pe)H.push(Ce)}else if(F){const Pe=h.extendTileCoverToNearPlane(H,this.transform.getFrustum(xe),xe);for(const Ce of Pe)H.push(Ce)}else if(this.castsShadows&&D){const Pe=h.extendTileCover(H,xe,D,16);for(const Ce of Pe)this._shadowCasterTiles[Ce.key]=!0,H.push(Ce)}}const oe=this._updateRetainedTiles(H);if(Vg(this._source.type)&&H.length!==0){const fe={},xe={},Pe=Object.keys(oe);for(const Ve of Pe){const Be=oe[Ve],et=this._tiles[Ve];if(!et||et.fadeEndTime&&et.fadeEndTime<=i.o.now())continue;const ut=this.findLoadedParent(Be,Math.max(Be.overscaledZ-jl.maxOverzooming,this._source.minzoom));ut&&(this._addTile(ut.tileID),fe[ut.tileID.key]=ut.tileID),xe[Ve]=Be}const Ce=H[H.length-1].overscaledZ;for(const Ve in this._tiles){const Be=this._tiles[Ve];if(oe[Ve]||!Be.hasData())continue;let et=Be.tileID;for(;et.overscaledZ>Ce;){et=et.scaledTo(et.overscaledZ-1);const ut=this._tiles[et.key];if(ut&&ut.hasData()&&xe[et.key]){oe[Ve]=Be.tileID;break}}}for(const Ve in fe)oe[Ve]||(this._coveredTiles[Ve]=!0,oe[Ve]=fe[Ve])}for(const fe in oe)this._tiles[fe].clearFadeHold();const ge=i.bv(this._tiles,oe);for(const fe of ge){const xe=this._tiles[fe];xe.hasSymbolBuckets&&!xe.holdingForFade()?xe.setHoldDuration(this.map._fadeDuration):xe.hasSymbolBuckets&&!xe.symbolFadeFinished()||this._removeTile(+fe)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const h in this._tiles)this._tiles[h].holdingForFade()&&this._removeTile(+h)}_updateRetainedTiles(h){const x={};if(h.length===0)return x;const A={},D=h.reduce((ae,oe)=>Math.min(ae,oe.overscaledZ),1/0),F=h[0].overscaledZ,z=Math.max(F-jl.maxOverzooming,this._source.minzoom),H=Math.max(F+jl.maxUnderzooming,this._source.minzoom),Y={};for(const ae of h){const oe=this._addTile(ae);x[ae.key]=ae,oe.hasData()||D=this._source.maxzoom){const fe=ae.children(this._source.maxzoom)[0],xe=this.getTile(fe);if(xe&&xe.hasData()){x[fe.key]=fe;continue}}else{const fe=ae.children(this._source.maxzoom);if(x[fe[0].key]&&x[fe[1].key]&&x[fe[2].key]&&x[fe[3].key])continue}let ge=oe.wasRequested();for(let fe=ae.overscaledZ-1;fe>=z;--fe){const xe=ae.scaledTo(fe);if(A[xe.key]||(A[xe.key]=!0,oe=this.getTile(xe),!oe&&ge&&(oe=this._addTile(xe)),oe&&(x[xe.key]=xe,ge=oe.wasRequested(),oe.hasData())))break}}return x}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const h in this._tiles){const x=[];let A,D=this._tiles[h].tileID;for(;D.overscaledZ>0;){if(D.key in this._loadedParentTiles){A=this._loadedParentTiles[D.key];break}x.push(D.key);const F=D.scaledTo(D.overscaledZ-1);if(A=this._getLoadedTile(F),A)break;D=F}for(const F of x)this._loadedParentTiles[F]=A}}_addTile(h){let x=this._tiles[h.key];if(x)return x.isExtraShadowCaster!==!0||this._shadowCasterTiles[h.key]||this._reloadTile(h.key,"reloading"),x;x=this._cache.getAndRemove(h),x&&(this._setTileReloadTimer(h.key,x),x.tileID=h,this._state.initializeTileState(x,this.map?this.map.painter:null),this._cacheTimers[h.key]&&(clearTimeout(this._cacheTimers[h.key]),delete this._cacheTimers[h.key],this._setTileReloadTimer(h.key,x)));const A=!!x;if(!A){const D=this.map?this.map.painter:null,F=this._source.tileSize*h.overscaleFactor();x=this._source.type==="raster-array"?new _d(h,F,this.transform.tileZoom,D,this._isRaster):new $m(h,F,this.transform.tileZoom,D,this._isRaster,this._source.worldview),this._loadTile(x,this._tileLoaded.bind(this,x,h.key,x.state))}return x.uses++,this._tiles[h.key]=x,A||this._source.fire(new i.z("dataloading",{tile:x,coord:x.tileID,dataType:"source"})),x}_setTileReloadTimer(h,x){h in this._timers&&(clearTimeout(this._timers[h]),delete this._timers[h]);const A=x.getExpiryTimeout();A&&(this._timers[h]=setTimeout(()=>{this._reloadTile(h,"expired"),delete this._timers[h]},A))}_removeTile(h){const x=this._tiles[h];x&&(x.uses--,delete this._tiles[h],this._timers[h]&&(clearTimeout(this._timers[h]),delete this._timers[h]),x.uses>0||(x.hasData()&&x.state!=="reloading"||x.state==="empty"?this._cache.add(x.tileID,x,x.getExpiryTimeout()):(x.aborted=!0,this._abortTile(x),this._unloadTile(x))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const h in this._tiles)this._removeTile(+h);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(h,x,A){const D=[],F=this.transform;if(!F)return D;const z=F.projection.name==="globe",H=i.aF(F.center.lng);for(const Y in this._tiles){const ae=this._tiles[Y];if(A&&ae.clearQueryDebugViz(),ae.holdingForFade())continue;let oe;if(z){const ge=ae.tileID.canonical;if(ge.z===0){const fe=[Math.abs(i.aA(H,...jh(ge,-1))-H),Math.abs(i.aA(H,...jh(ge,1))-H)];oe=[0,2*fe.indexOf(Math.min(...fe))-1]}else{const fe=[Math.abs(i.aA(H,...jh(ge,-1))-H),Math.abs(i.aA(H,...jh(ge,0))-H),Math.abs(i.aA(H,...jh(ge,1))-H)];oe=[fe.indexOf(Math.min(...fe))-1]}}else oe=[0];for(const ge of oe){const fe=h.containsTile(ae,F,x,ge);fe&&D.push(fe)}}return D}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(h){return this._getRenderableCoordinates(h)}_getRenderableCoordinates(h,x){const A=this.getRenderableIds(h,x).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 x=h.slice(),A=this.transform._camera.position,D=this.transform._camera.forward(),F={};for(const z of x){const H=1/(1<F[z.key]-F[H.key]),x}hasTransition(){if(this._source.hasTransition())return!0;if(Vg(this._source.type))for(const h in this._tiles){const x=this._tiles[h];if(x.fadeEndTime!==void 0&&x.fadeEndTime>=i.o.now())return!0}return!1}setFeatureState(h,x,A){this._state.updateState(h=h||"_geojsonTileLayer",x,A)}removeFeatureState(h,x,A){this._state.removeFeatureState(h=h||"_geojsonTileLayer",x,A)}getFeatureState(h,x){return this._state.getState(h=h||"_geojsonTileLayer",x)}setDependencies(h,x,A){const D=this._tiles[h];D&&D.setDependencies(x,A)}reloadTilesForDependencies(h,x){for(const A in this._tiles)this._tiles[A].hasDependency(h,x)&&this._reloadTile(+A,"reloading");this._cache.filter(A=>!A.hasDependency(h,x))}_preloadTiles(h,x){if(!this._sourceLoaded){const Y=()=>{this._sourceLoaded&&(this._source.off("data",Y),this._preloadTiles(h,x))};return void this._source.on("data",Y)}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 Y of D){const ae=Y.coveringTiles({tileSize:z,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const oe of ae)A.set(oe.key,oe);this.usedForTerrain&&Y.updateElevation(!1)}const H=Array.from(A.values());i.bw(H,(Y,ae)=>{const oe=new $m(Y,this._source.tileSize*Y.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(oe,ge=>{this._source.type==="raster-dem"&&oe.dem&&this._backfillDEM(oe),ae(ge,oe)})},x)}}function F1(M,h){const x=Math.abs(2*M.wrap)-+(M.wrap<0),A=Math.abs(2*h.wrap)-+(h.wrap<0);return M.overscaledZ-h.overscaledZ||A-x||h.canonical.y-M.canonical.y||h.canonical.x-M.canonical.x}function Vg(M){return M==="raster"||M==="image"||M==="video"||M==="custom"}function jh(M,h){const x=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&&x.visible,x.visible=D}}updateZOffset(h,x){this.currentBuildingBuckets=[];for(const D of this.layers){const F=D.layer,z=this.style.getLayerSourceCache(F);let H=1;F.type==="fill-extrusion"?H=D.visible?F.paint.get("fill-extrusion-vertical-scale"):0:F.type==="building"&&(H=D.visible?F.paint.get("building-vertical-scale"):0);let Y=z?z.getTile(x):null;if(!Y&&z)for(const ae in z._tiles){const oe=z._tiles[ae];if(x.canonical.isChildOf(oe.tileID.canonical)){Y=oe;break}}this.currentBuildingBuckets.push({bucket:Y?Y.getBucket(F):null,tileID:Y?Y.tileID:x,verticalScale:H})}h.hasAnyZOffset=!1;let A=!1;for(let D=0;D{A in h&&(x[A]=h[A])}),x}function q0(M){M=M.slice();const h=Object.create(null);for(let x=0;x0?(D-z)/H:0;return this.points[F].mult(1-Y).add(this.points[x].mult(Y))}}class B2{constructor(h,x,A){const D=this.boxCells=[],F=this.circleCells=[];this.xCellCount=Math.ceil(h/A),this.yCellCount=Math.ceil(x/A);for(let z=0;zthis.width||D<0||x>this.height)return!F&&[];const H=[];if(h<=0&&x<=0&&this.width<=A&&this.height<=D){if(F)return!0;for(let Y=0;Y0:H}_queryCircle(h,x,A,D,F){const z=h-A,H=h+A,Y=x-A,ae=x+A;if(H<0||z>this.width||ae<0||Y>this.height)return!D&&[];const oe=[];return this._forEachCell(z,Y,H,ae,this._queryCellCircle,oe,{hitTest:D,circle:{x:h,y:x,radius:A},seenUids:{box:{},circle:{}}},F),D?oe.length>0:oe}query(h,x,A,D,F){return this._query(h,x,A,D,!1,F)}hitTest(h,x,A,D,F){return this._query(h,x,A,D,!0,F)}hitTestCircle(h,x,A,D){return this._queryCircle(h,x,A,!0,D)}_queryCell(h,x,A,D,F,z,H,Y){const ae=H.seenUids,oe=this.boxCells[F];if(oe!==null){const fe=this.bboxes;for(const xe of oe)if(!ae.box[xe]){ae.box[xe]=!0;const Pe=4*xe;if(h<=fe[Pe+2]&&x<=fe[Pe+3]&&A>=fe[Pe+0]&&D>=fe[Pe+1]&&(!Y||Y(this.boxKeys[xe]))){if(H.hitTest)return z.push(!0),!0;z.push({key:this.boxKeys[xe],x1:fe[Pe],y1:fe[Pe+1],x2:fe[Pe+2],y2:fe[Pe+3]})}}}const ge=this.circleCells[F];if(ge!==null){const fe=this.circles;for(const xe of ge)if(!ae.circle[xe]){ae.circle[xe]=!0;const Pe=3*xe;if(this._circleAndRectCollide(fe[Pe],fe[Pe+1],fe[Pe+2],h,x,A,D)&&(!Y||Y(this.circleKeys[xe]))){if(H.hitTest)return z.push(!0),!0;{const Ce=fe[Pe],Ve=fe[Pe+1],Be=fe[Pe+2];z.push({key:this.circleKeys[xe],x1:Ce-Be,y1:Ve-Be,x2:Ce+Be,y2:Ve+Be})}}}}}_queryCellCircle(h,x,A,D,F,z,H,Y){const ae=H.circle,oe=H.seenUids,ge=this.boxCells[F];if(ge!==null){const xe=this.bboxes;for(const Pe of ge)if(!oe.box[Pe]){oe.box[Pe]=!0;const Ce=4*Pe;if(this._circleAndRectCollide(ae.x,ae.y,ae.radius,xe[Ce+0],xe[Ce+1],xe[Ce+2],xe[Ce+3])&&(!Y||Y(this.boxKeys[Pe])))return z.push(!0),!0}}const fe=this.circleCells[F];if(fe!==null){const xe=this.circles;for(const Pe of fe)if(!oe.circle[Pe]){oe.circle[Pe]=!0;const Ce=3*Pe;if(this._circlesCollide(xe[Ce],xe[Ce+1],xe[Ce+2],ae.x,ae.y,ae.radius)&&(!Y||Y(this.circleKeys[Pe])))return z.push(!0),!0}}}_forEachCell(h,x,A,D,F,z,H,Y){const ae=this._convertToXCellCoord(h),oe=this._convertToYCellCoord(x),ge=this._convertToXCellCoord(A),fe=this._convertToYCellCoord(D);for(let xe=ae;xe<=ge;xe++)for(let Pe=oe;Pe<=fe;Pe++)if(F.call(this,h,x,A,D,this.xCellCount*Pe+xe,z,H,Y))return}_convertToXCellCoord(h){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(h*this.xScale)))}_convertToYCellCoord(h){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(h*this.yScale)))}_circlesCollide(h,x,A,D,F,z){const H=D-h,Y=F-x,ae=A+z;return ae*ae>H*H+Y*Y}_circleAndRectCollide(h,x,A,D,F,z,H){const Y=(z-D)/2,ae=Math.abs(h-(D+Y));if(ae>Y+A)return!1;const oe=(H-F)/2,ge=Math.abs(x-(F+oe));if(ge>oe+A)return!1;if(ae<=Y||ge<=oe)return!0;const fe=ae-Y,xe=ge-oe;return fe*fe+xe*xe<=A*A}}const xt={unknown:0,flipRequired:1,flipNotRequired:2},Ts=Math.tan(85*Math.PI/180);function Ys(M,h,x,A,D,F,z){const H=i.bC();if(x)if(F.name==="globe"){const Y=i.bD(D,h);i.aB(H,H,Y)}else{const Y=i.bE([],z);H[0]=Y[0],H[1]=Y[1],H[4]=Y[2],H[5]=Y[3],A||i.bB(H,H,D.angle)}else i.aB(H,D.labelPlaneMatrix,M);return H}function ln(M,h,x,A,D,F,z){const H=Ys(M,h,x,A,D,F,z);return F.name==="globe"&&x||(H[2]=H[6]=H[10]=H[14]=0),H}function cn(M,h,x,A,D,F,z){if(x){if(F.name==="globe"){const H=Ys(M,h,x,A,D,F,z);return i.bl(H,H),i.aB(H,M,H),H}{const H=i.bz(M),Y=i.bA([]);return Y[0]=z[0],Y[1]=z[1],Y[4]=z[2],Y[5]=z[3],i.aB(H,H,Y),A||i.bB(H,H,-D.angle),H}}return D.glCoordMatrix}function na(M,h,x,A){const D=[M,h,x,1];x?i.aC(D,D,A):Rr(D,D,A);const F=D[3];return D[0]/=F,D[1]/=F,D[2]/=F,D}function Fr(M,h){return Math.min(.5+M/h*.5,1.5)}function oo(M,h){const x=M[0]/M[3],A=M[1]/M[3];return x>=-h[0]&&x<=h[0]&&A>=-h[1]&&A<=h[1]}function Hg(M,h,x,A,D,F,z,H,Y,ae,oe=1){const ge=x.transform,fe=A?M.textSizeData:M.iconSizeData,xe=i.bK(fe,x.transform.zoom,oe),Pe=ge.projection.name==="globe",Ce=[256/x.width*2+1,256/x.height*2+1],Ve=A?M.text.dynamicLayoutVertexArray:M.icon.dynamicLayoutVertexArray;Ve.clear();let Be=null;Pe&&(Be=A?M.text.globeExtVertexArray:M.icon.globeExtVertexArray);const et=M.lineVertexArray,ut=A?M.text.placedSymbolArray:M.icon.placedSymbolArray,st=x.transform.width/x.transform.height;let Mt,yt=!1;for(let kt=0;ktMath.abs(x)?{useVertical:!0}:M===i.bL.vertical?A>0?{needsFlipping:!0}:null:h!==xt.unknown&&function(D,F){return D===0||Math.abs(F/D)>Ts}(x,A)?h===xt.flipRequired?{needsFlipping:!0}:null:x<0?{needsFlipping:!0}:null}function H0(M,h,x,A,D,F,z,H,Y,ae,oe,ge,fe,xe,Pe,Ce,Ve,Be,et,ut){const st=h/24,Mt=M.lineOffsetX*st,yt=M.lineOffsetY*st,{lineStartIndex:kt,glyphStartIndex:gt,numGlyphs:mt,segment:Pt,writingMode:Ht,flipState:Ut}=M,ts=kt+M.lineLength,ns=fs=>{if(oe){const[ls,Jt,Ls]=fs.up,er=ae.length;i.bN(oe,er+0,ls,Jt,Ls),i.bN(oe,er+1,ls,Jt,Ls),i.bN(oe,er+2,ls,Jt,Ls),i.bN(oe,er+3,ls,Jt,Ls)}const[qs,Yt,Ft]=fs.point;i.bO(ae,qs,Yt,Ft,fs.angle)};if(mt>1){const fs=Ap(st,H,Mt,yt,x,ge,fe,M,Y,F,xe,Ce,!1,Ve,Be,et,ut);if(!fs)return{notEnoughRoom:!0};if(A&&!x){let[qs,Yt,Ft]=fs.first.point,[ls,Jt,Ls]=fs.last.point;[qs,Yt]=na(qs,Yt,Ft,z),[ls,Jt]=na(ls,Jt,Ls,z);const er=Hr(Ht,Ut,(ls-qs)*Pe,Jt-Yt);if(M.flipState=er&&er.needsFlipping?xt.flipRequired:xt.flipNotRequired,er)return er}ns(fs.first);for(let qs=gt+1;qs0?ls:Um(fe,Ft,qs,1,D,void 0,Ve,Be.canonical),Ls=Hr(Ht,Ut,(Jt[0]-qs[0])*Pe,Jt[1]-qs[1]);if(M.flipState=Ls&&Ls.needsFlipping?xt.flipRequired:xt.flipNotRequired,Ls)return Ls}const fs=B1(st*H.getoffsetX(gt),Mt,yt,x,ge,fe,Pt,kt,ts,Y,F,xe,Ce,!1,!1,Ve,Be,et,ut);if(!fs)return{notEnoughRoom:!0};ns(fs)}return{}}function W0(M,h,x,A,D){const{x:F,y:z,z:H}=A.projectTilePoint(M.x,M.y,h);if(!D)return na(F,z,H,x);const[Y,ae,oe]=D.getElevation(M,D.elevation,D.elevationFeature);return na(F+Y,z+ae,H+oe,x)}function Um(M,h,x,A,D,F,z,H){const Y=W0(M.sub(h)._unit()._add(M),H,D,z,F);return i.av(Y,x,Y),i.aw(Y,Y),i.bH(Y,x,Y,A)}function B1(M,h,x,A,D,F,z,H,Y,ae,oe,ge,fe,xe,Pe,Ce,Ve,Be,et){const ut=A?M-h:M+h;let st=ut>0?1:-1,Mt=0;A&&(st*=-1,Mt=Math.PI),st<0&&(Mt+=Math.PI);let yt=H+z+(st>0?0:1)|0,kt=D,gt=D,mt=0,Pt=0;const Ht=Math.abs(ut),Ut=[],ts=[];let ns=F,fs=ns,qs=i.bF([]);const Yt=()=>Um(fs,ns,gt,Ht-mt+1,oe,fe,Ce,Ve.canonical);for(;mt+Pt<=Ht;){if(yt+=st,yt=Y)return null;if(gt=kt,fs=ns,Ut.push(gt),xe&&ts.push(fs),ns=new i.P(ae.getx(yt),ae.gety(yt)),kt=ge[yt],!kt){const kr=W0(ns,Ve.canonical,oe,Ce,fe);kt=kr[3]>0?ge[yt]=kr:Yt()}mt+=Pt;const Vs=i.av([],kt,gt),Cr=i.bG(gt,kt);if(x&&Cr>0&&Pt>0&&i.bJ(qs,Vs)/(Pt*Cr)0,ut),kt=ae*yt.perspectiveRatio,gt=(A.x1*x+H.x-A.padding)*kt+yt.point.x,mt=(A.y1*x+H.y-A.padding)*kt+yt.point.y,Pt=(A.x2*x+H.x+A.padding)*kt+yt.point.x,Ht=(A.y2*x+H.y+A.padding)*kt+yt.point.y,Ut=yt.perspectiveRatio<=.55||yt.occluded;return!this.isInsideGrid(gt,mt,Pt,Ht)||!Y&&this.grid.hitTest(gt,mt,Pt,Ht,ge)||Ut?{box:[],offscreen:!1,occluded:yt.occluded}:{box:[gt,mt,Pt,Ht],offscreen:this.isOffscreen(gt,mt,Pt,Ht),occluded:!1}}placeCollisionCircles(h,x,A,D,F,z,H,Y,ae,oe,ge,fe,xe,Pe,Ce,Ve){const Be=[],et=this.transform.elevation,ut=h.getProjection(),st=h.elevationType==="road",Mt=!!et||st,yt=i.bV.getAtTileOffsetFunc(Ve,this.transform.center.lat,this.transform.worldSize,ut),kt=new i.P(A.tileAnchorX,A.tileAnchorY),gt=new i.P(A.tileAnchorX,A.tileAnchorY);let{x:mt,y:Pt,z:Ht}=ut.projectTilePoint(gt.x,gt.y,Ve.canonical),Ut=null;if(Mt){const Cr=st?h.getElevationFeatureForText(D):null;Ut={getElevation:yt,elevation:et,elevationFeature:Cr};const[kr,dr,xr]=yt(kt,et,Cr);mt+=kr,Pt+=dr,Ht+=xr}const ts=ut.name==="globe",ns=this.projectAndGetPerspectiveRatio(Y,mt,Pt,Ht,Ve,ts||!!et||this.transform.pitch>0,ut),{perspectiveRatio:fs}=ns,qs=(fe?H/fs:H*fs)/i.bY,Yt=na(mt,Pt,Ht,ae),Ft=A.lineOffsetX*qs,ls=A.lineOffsetY*qs,Jt=i.an(h.layers[0].layout.get("text-max-angle")),Ls=Math.cos(Jt),er=ns.signedDistanceFromCamera>0?Ap(qs,z,Ft,ls,st&&A.flipState===1,Yt,gt,A,F,ae,{},Mt&&!fe?Ut:null,fe&&Mt,ut,Ve,fe,Ls):null;let pr=!1,Xs=!1,Vs=!0;if(er&&!ns.occluded){const Cr=.5*Pe*fs+Ce,kr=new i.P(-100,-100),dr=new i.P(this.screenRightBoundary,this.screenBottomBoundary),xr=new my,{first:Vr,last:kn}=er,ga=Vr.path.length;let Ja=[];for(let _n=ga-1;_n>=1;_n--)Ja.push(Vr.path[_n]);for(let _n=1;_n(Mt&&!ts&&(wi=yt(pi_n[3]<=0)&&(Ja=[]));let Wa=[];if(Ja.length>0){let _n=1/0,ii=-1/0,wi=1/0,pi=-1/0;for(const Ua of Ja)_n=Math.min(_n,Ua[0]),wi=Math.min(wi,Ua[1]),ii=Math.max(ii,Ua[0]),pi=Math.max(pi,Ua[1]);ii>=kr.x&&_n<=dr.x&&pi>=kr.y&&wi<=dr.y&&(Wa=[Ja.map(Ua=>new i.P(Ua[0],Ua[1]))],(_ndr.x||widr.y)&&(Wa=i.bW(Wa,kr.x,kr.y,dr.x,dr.y)))}for(const _n of Wa){xr.reset(_n,.25*Cr);let ii=0;ii=xr.length<=.5*Cr?1:Math.ceil(xr.paddedLength/Er)+1;for(let wi=0;wi0?(i.aC(Y,Y,h),this.fogState&&F&&H.name!=="globe"&&(ae=function(fe,xe,Pe,Ce,Ve,Be){const et=Be.calculateFogTileMatrix(Ve),ut=[xe,Pe,Ce];return i.af(ut,ut,et),gr(fe,i.ag(ut),Be.pitch,Be._fov)}(this.fogState,x,A,D,F.toUnwrapped(),this.transform)>.9)):Rr(Y,Y,h);const oe=Y[3];return{point:new i.P((Y[0]/oe+1)/2*this.transform.width+Ca,(-Y[1]/oe+1)/2*this.transform.height+Ca),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(H)/oe*.5,1.5),signedDistanceFromCamera:oe,occluded:z&&Y[2]>oe||ae}}isOffscreen(h,x,A,D){return A=this.screenRightBoundary||Dthis.screenBottomBoundary}isInsideGrid(h,x,A,D){return A>=0&&h=0&&xA.collisionGroupID===x}}return this.collisionGroups[h]}}function Dd(M,h,x,A,D){const{horizontalAlign:F,verticalAlign:z}=i.c1(M),H=-(F-.5)*h,Y=-(z-.5)*x,ae=i.c2(M,A);return new i.P(H+ae[0]*D,Y+ae[1]*D)}function ml(M,h,x,A,D){const F=new i.P(M,h);return x&&F._rotate(A?D:-D),F}class mme{constructor(h,x,A,D,F,z){this.transform=h.clone(),this.projection=h.projection.name,this.collisionIndex=new bi(this.transform,F),this.buildingIndex=z,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=x,this.retainedQueryData={},this.collisionGroups=new q2(A),this.collisionCircleArrays={},this.prevPlacement=D,D&&(D.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(h,x,A,D,F=1){const z=A.getBucket(x),H=A.latestFeatureIndex;if(!z||!H||x.fqid!==z.layerIds[0])return;const Y=z.layers[0].layout,ae=z.layers[0].paint,oe=A.collisionBoxArray,ge=Math.pow(2,this.transform.zoom-A.tileID.overscaledZ),fe=A.tileSize/i.al,xe=A.tileID.toUnwrapped();this.transform.setProjection(z.projection);const Pe=(Ce=A.tileID,Ve=z.getProjection(),Be=this.transform,Ve.name===this.projection?Be.calculateProjMatrix(Ce.toUnwrapped()):z2(Be,Ve,Ce));var Ce,Ve,Be;const et=Y.get("text-pitch-alignment")==="map",ut=Y.get("text-rotation-alignment")==="map";x.compileFilter(x.options);const st=x.dynamicFilter(),Mt=x.dynamicFilterNeedsFeature(),yt=this.transform.calculatePixelsToTileUnitsMatrix(A),kt=ln(Pe,A.tileID.canonical,et,ut,this.transform,z.getProjection(),yt);let gt=null;const mt=z.getProjection().createInversionMatrix(this.transform,A.tileID.canonical);if(et){const Ft=cn(Pe,A.tileID.canonical,et,ut,this.transform,z.getProjection(),yt);gt=i.aB([],this.transform.labelPlaneMatrix,Ft)}let Pt=null;st&&A.latestFeatureIndex&&(Pt={unwrappedTileID:xe,dynamicFilter:st,dynamicFilterNeedsFeature:Mt}),this.retainedQueryData[z.bucketInstanceId]=new $2(z.bucketInstanceId,H,z.sourceLayerIndex,z.index,A.tileID);const[Ht,Ut]=z.layers[0].layout.get("text-size-scale-range"),ts=i.aA(F,Ht,Ut),[ns,fs]=Y.get("icon-size-scale-range"),qs=i.aA(F,ns,fs),Yt={bucket:z,layout:Y,paint:ae,posMatrix:Pe,invMatrix:mt,mercatorCenter:[i.aF(this.transform.center.lng),i.aJ(this.transform.center.lat)],textLabelPlaneMatrix:kt,labelToScreenMatrix:gt,clippingData:Pt,scale:ge,textPixelRatio:fe,holdingForFade:A.holdingForFade(),collisionBoxArray:oe,partiallyEvaluatedTextSize:i.bK(z.textSizeData,this.transform.zoom,ts),partiallyEvaluatedIconSize:i.bK(z.iconSizeData,this.transform.zoom,qs),collisionGroup:this.collisionGroups.get(z.sourceID),latestFeatureIndex:A.latestFeatureIndex};if(D)for(const Ft of z.sortKeyRanges){const{sortKey:ls,symbolInstanceStart:Jt,symbolInstanceEnd:Ls}=Ft;h.push({sortKey:ls,symbolInstanceStart:Jt,symbolInstanceEnd:Ls,parameters:Yt})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:z.symbolInstances.length,parameters:Yt})}attemptAnchorPlacement(h,x,A,D,F,z,H,Y,ae,oe,ge,fe,xe,Pe,Ce,Ve,Be,et,ut,st,Mt){const{textOffset0:yt,textOffset1:kt,crossTileID:gt}=Ce,mt=[yt,kt],Pt=Dd(h,z,H,mt,Y),Ht=this.collisionIndex.placeCollisionBox(Be,Y,x,A,D,F,ml(Pt.x,Pt.y,ae,oe,this.transform.angle),Pe,ge,fe,xe.predicate);if(ut){const Ut=Be.getSymbolInstanceIconSize(Mt,this.transform.zoom,Ce.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(Be,Ut,ut,A,D,F,ml(Pt.x,Pt.y,ae,oe,this.transform.angle),Pe,ge,fe,xe.predicate).box.length===0)return}if(Ht.box.length>0){let Ut;return this.prevPlacement&&this.prevPlacement.variableOffsets[gt]&&this.prevPlacement.placements[gt]&&this.prevPlacement.placements[gt].text&&(Ut=this.prevPlacement.variableOffsets[gt].anchor),this.variableOffsets[gt]={textOffset:mt,width:z,height:H,anchor:h,textScale:Y,prevAnchor:Ut},this.markUsedJustification(Be,h,Ce,et),Be.allowVerticalPlacement&&(this.markUsedOrientation(Be,et,Ce),this.placedOrientations[gt]=et),{shift:Pt,placedGlyphBoxes:Ht}}}placeLayerBucketPart(h,x,A,D,F=1){const{bucket:z,layout:H,paint:Y,posMatrix:ae,textLabelPlaneMatrix:oe,labelToScreenMatrix:ge,clippingData:fe,textPixelRatio:xe,mercatorCenter:Pe,invMatrix:Ce,holdingForFade:Ve,collisionBoxArray:Be,partiallyEvaluatedTextSize:et,partiallyEvaluatedIconSize:ut,collisionGroup:st,latestFeatureIndex:Mt}=h.parameters,yt=H.get("text-optional"),kt=H.get("icon-optional"),gt=H.get("text-allow-overlap"),mt=H.get("icon-allow-overlap"),Pt=H.get("text-rotation-alignment")==="map",Ht=H.get("icon-rotation-alignment")==="map",Ut=H.get("text-pitch-alignment")==="map",ts=Y.get("symbol-z-offset"),ns=H.get("symbol-elevation-reference")==="sea",fs=H.get("symbol-placement"),[qs,Yt]=H.get("text-size-scale-range"),[Ft,ls]=H.get("icon-size-scale-range"),Jt=i.aA(F,qs,Yt),Ls=i.aA(F,Ft,ls),er=H.get("text-variable-anchor"),pr=Pt&&fs!=="point",Xs=Ht&&fs!=="point",Vs=er&&z.hasTextData(),Cr=z.hasIconTextFit()&&Vs&&z.hasIconData();this.transform.setProjection(z.projection);const kr=Vs||pr,dr=Xs||Cr;let xr=gt&&(mt||!z.hasIconData()||kt),Vr=mt&&(gt||!z.hasTextData()||yt);const kn=!ts.isConstant();!z.collisionArrays&&Be&&z.deserializeCollisionBoxes(Be),A&&D&&z.updateCollisionDebugBuffers(this.transform.zoom,Be,Jt,Ls);const ga=(Er,Wa,_n)=>{const{crossTileID:ii,numVerticalGlyphVertices:wi}=Er;let pi=null;if(fe&&fe.dynamicFilterNeedsFeature||kn){const To=this.retainedQueryData[z.bucketInstanceId];pi=Mt.loadFeature({featureIndex:Er.featureIndex,bucketIndex:To.bucketIndex,sourceLayerIndex:To.sourceLayerIndex,layoutVertexArrayOffset:0});const Wo=pi.properties?pi.properties.worldview:null;if(z.localizable&&z.worldview&&typeof Wo=="string")if(Wo==="all")pi.properties.$localized=!0;else{if(!Wo.split(",").includes(z.worldview))return;pi.properties.$localized=!0,pi.properties.worldview=z.worldview}}if(fe&&!(0,fe.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:z.worldview},pi,this.retainedQueryData[z.bucketInstanceId].tileID.canonical,new i.P(Er.tileAnchorX,Er.tileAnchorY),this.transform.calculateDistanceTileData(fe.unwrappedTileID)))return this.placements[ii]=new ui(!1,!1,!1,!0),void x.add(ii);const Ua=ts.evaluate(pi,{});if(x.has(ii))return;if(Ve)return void(this.placements[ii]=new ui(!1,!1,!1));let Fn=!1,si=!1,wo=!0,eo=!1,oi=!1,Pa=null,zn={box:null,offscreen:null,occluded:null},Zi={box:null},Fo=null,yo=null,Ai=null,Pu=0,bd=0,Dl=0;_n.textFeatureIndex?Pu=_n.textFeatureIndex:Er.useRuntimeCollisionCircles&&(Pu=Er.featureIndex),_n.verticalTextFeatureIndex&&(bd=_n.verticalTextFeatureIndex);const Rd=z.elevationFeatures?z.elevationFeatures[Er.elevationFeatureIndex]:void 0,Fd=To=>{To.tileID=this.retainedQueryData[z.bucketInstanceId].tileID;const Wo=this.transform.elevation;To.elevation=ns?Ua:Ua+i.bV.getAtTileOffset(To.tileID,new i.P(To.tileAnchorX,To.tileAnchorY),Wo,Rd),To.elevation+=Er.zOffset},Qc=_n.textBox;if(Qc){Fd(Qc);const To=Ei=>{let al=i.bL.horizontal;if(z.allowVerticalPlacement&&!Ei&&this.prevPlacement){const jo=this.prevPlacement.placedOrientations[ii];jo&&(this.placedOrientations[ii]=jo,al=jo,this.markUsedOrientation(z,al,Er))}return al},Wo=(Ei,al)=>{if(z.allowVerticalPlacement&&wi>0&&_n.verticalTextBox){for(const jo of z.writingModes)if(jo===i.bL.vertical?(zn=al(),Zi=zn):zn=Ei(),zn&&zn.box&&zn.box.length)break}else zn=Ei()};if(er){let Ei=er;if(this.prevPlacement&&this.prevPlacement.variableOffsets[ii]){const vo=this.prevPlacement.variableOffsets[ii];Ei.indexOf(vo.anchor)>0&&(Ei=Ei.filter(Xm=>Xm!==vo.anchor),Ei.unshift(vo.anchor))}const al=(vo,Xm,gw)=>{const Rp=z.getSymbolInstanceTextSize(et,Er,this.transform.zoom,Wa),xw=(vo.x2-vo.x1)*Rp+2*vo.padding,d_=(vo.y2-vo.y1)*Rp+2*vo.padding,zf=Er.hasIconTextFit&&!mt?Xm:null;zf&&Fd(zf);let ax={box:[],offscreen:!1,occluded:!1};const u_=gt?2*Ei.length:Ei.length;for(let Ty=0;Ty=Ei.length,Er,Wa,z,gw,zf,et,ut);if(ix&&(ax=ix.placedGlyphBoxes,ax&&ax.box&&ax.box.length)){Fn=!0,Pa=ix.shift;break}}return ax};Wo(()=>al(Qc,_n.iconBox,i.bL.horizontal),()=>{const vo=_n.verticalTextBox;return vo&&Fd(vo),z.allowVerticalPlacement&&!(zn&&zn.box&&zn.box.length)&&wi>0&&vo?al(vo,_n.verticalIconBox,i.bL.vertical):{box:null,offscreen:null,occluded:null}}),zn&&(Fn=zn.box,wo=zn.offscreen,eo=zn.occluded);const jo=To(!(!zn||!zn.box));if(!Fn&&this.prevPlacement){const vo=this.prevPlacement.variableOffsets[ii];vo&&(this.variableOffsets[ii]=vo,this.markUsedJustification(z,vo.anchor,Er,jo))}}else{const Ei=(al,jo)=>{const vo=z.getSymbolInstanceTextSize(et,Er,this.transform.zoom,Wa),Xm=this.collisionIndex.placeCollisionBox(z,vo,al,Pe,Ce,kr,new i.P(0,0),gt,xe,ae,st.predicate);return Xm&&Xm.box&&Xm.box.length&&(this.markUsedOrientation(z,jo,Er),this.placedOrientations[ii]=jo),Xm};Wo(()=>Ei(Qc,i.bL.horizontal),()=>{const al=_n.verticalTextBox;return z.allowVerticalPlacement&&wi>0&&al?(Fd(al),Ei(al,i.bL.vertical)):{box:null,offscreen:null,occluded:null}}),To(!!(zn&&zn.box&&zn.box.length))}}if(Fo=zn,Fn=Fo&&Fo.box&&Fo.box.length>0,wo=Fo&&Fo.offscreen,eo=Fo&&Fo.occluded,Er.useRuntimeCollisionCircles){const To=Er.centerJustifiedTextSymbolIndex>=0?Er.centerJustifiedTextSymbolIndex:Er.verticalPlacedTextSymbolIndex,Wo=z.text.placedSymbolArray.get(To),Ei=i.bM(z.textSizeData,et,Wo),al=H.get("text-padding");yo=this.collisionIndex.placeCollisionCircles(z,gt,Wo,To,z.lineVertexArray,z.glyphOffsetArray,Ei,ae,oe,ge,A,Ut,st.predicate,Er.collisionCircleDiameter*Ei/i.bY,al,this.retainedQueryData[z.bucketInstanceId].tileID),Fn=gt||yo.circles.length>0&&!yo.collisionDetected,wo=wo&&yo.offscreen,eo=yo.occluded}if(_n.iconFeatureIndex&&(Dl=_n.iconFeatureIndex),_n.iconBox){const To=Wo=>{Fd(Wo);const Ei=Er.hasIconTextFit&&Pa?ml(Pa.x,Pa.y,Pt,Ut,this.transform.angle):new i.P(0,0),al=z.getSymbolInstanceIconSize(ut,this.transform.zoom,Er.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(z,al,Wo,Pe,Ce,dr,Ei,mt,xe,ae,st.predicate)};Zi&&Zi.box&&Zi.box.length&&_n.verticalIconBox?(Ai=To(_n.verticalIconBox),si=Ai.box.length>0):(Ai=To(_n.iconBox),si=Ai.box.length>0),wo=wo&&Ai.offscreen,oi=Ai.occluded}const am=yt||Er.numHorizontalGlyphVertices===0&&wi===0,Ym=kt||Er.numIconVertices===0;if(am||Ym?Ym?am||(si=si&&Fn):Fn=si&&Fn:si=Fn=si&&Fn,Fn&&Fo&&Fo.box&&this.collisionIndex.insertCollisionBox(Fo.box,H.get("text-ignore-placement"),z.bucketInstanceId,Zi&&Zi.box&&bd?bd:Pu,st.ID),si&&Ai&&this.collisionIndex.insertCollisionBox(Ai.box,H.get("icon-ignore-placement"),z.bucketInstanceId,Dl,st.ID),yo&&(Fn&&this.collisionIndex.insertCollisionCircles(yo.circles,H.get("text-ignore-placement"),z.bucketInstanceId,Pu,st.ID),A)){const To=z.bucketInstanceId;let Wo=this.collisionCircleArrays[To];Wo===void 0&&(Wo=this.collisionCircleArrays[To]=new uC);for(let Ei=0;Ei=0;--Wa){const _n=Er[Wa];ga(z.symbolInstances.get(_n),_n,z.collisionArrays[_n])}z.hasAnyZOffset&&i.w(`${z.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(z.hasAnyZOffset){const Er=z.getSortedIndexesByZOffset();for(let Wa=0;Wa=0&&(h.text.placedSymbolArray.get(F).crossTileID=ge>=0&&F!==ge?0:ae),z>=0&&(h.text.placedSymbolArray.get(z).crossTileID=ge>=0&&z!==ge?0:ae),H>=0&&(h.text.placedSymbolArray.get(H).crossTileID=ge>=0&&H!==ge?0:ae),Y>=0&&(h.text.placedSymbolArray.get(Y).crossTileID=ge>=0&&Y!==ge?0:ae)}markUsedOrientation(h,x,A){const D=x===i.bL.horizontal||x===i.bL.horizontalOnly?x:0,F=x===i.bL.vertical?x:0,{leftJustifiedTextSymbolIndex:z,centerJustifiedTextSymbolIndex:H,rightJustifiedTextSymbolIndex:Y,verticalPlacedTextSymbolIndex:ae}=A,oe=h.text.placedSymbolArray;z>=0&&(oe.get(z).placedOrientation=D),H>=0&&(oe.get(H).placedOrientation=D),Y>=0&&(oe.get(Y).placedOrientation=D),ae>=0&&(oe.get(ae).placedOrientation=F)}commit(h){this.commitTime=h,this.zoomAtLastRecencyCheck=this.transform.zoom;const x=this.prevPlacement;let A=!1;this.prevZoomAdjustment=x?x.zoomAdjustment(this.transform.zoom):0;const D=x?x.symbolFadeChange(h):1,F=x?x.opacities:{},z=x?x.variableOffsets:{},H=x?x.placedOrientations:{};for(const Y in this.placements){const ae=this.placements[Y],oe=F[Y];oe?(this.opacities[Y]=new Af(oe,D,ae.text,ae.icon,null,ae.clipped),A=A||ae.text!==oe.text.placed||ae.icon!==oe.icon.placed):(this.opacities[Y]=new Af(null,D,ae.text,ae.icon,ae.skipFade,ae.clipped),A=A||ae.text||ae.icon)}for(const Y in F){const ae=F[Y];if(!this.opacities[Y]){const oe=new Af(ae,D,!1,!1);oe.isHidden()||(this.opacities[Y]=oe,A=A||ae.text.placed||ae.icon.placed)}}for(const Y in z)this.variableOffsets[Y]||!this.opacities[Y]||this.opacities[Y].isHidden()||(this.variableOffsets[Y]=z[Y]);for(const Y in H)this.placedOrientations[Y]||!this.opacities[Y]||this.opacities[Y].isHidden()||(this.placedOrientations[Y]=H[Y]);A?this.lastPlacementChangeTime=h:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=x?x.lastPlacementChangeTime:h)}updateLayerOpacities(h,x,A,D){D&&(this.lastReplacementSourceUpdateTime=D.updateTime);const F=new Set;for(const z of x){const H=z.getBucket(h);H&&z.latestFeatureIndex&&h.fqid===H.layerIds[0]&&(this.updateBucketOpacities(H,F,z,z.collisionBoxArray,A,D,z.tileID,h.scope),H.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(H,z.tileID),H.elevationType==="road"&&H.updateRoadElevation(z.tileID.canonical),H.updateZOffset())}}updateBucketOpacities(h,x,A,D,F,z,H,Y){h.hasTextData()&&h.text.opacityVertexArray.clear(),h.hasIconData()&&h.icon.opacityVertexArray.clear(),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexArray.clear(),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexArray.clear();const ae=h.layers[0].layout,oe=h.layers[0].paint,ge=!!h.layers[0].dynamicFilter(),fe=new Af(null,0,!1,!1,!0),xe=ae.get("text-allow-overlap"),Pe=ae.get("icon-allow-overlap"),Ce=ae.get("text-variable-anchor"),Ve=ae.get("text-rotation-alignment")==="map",Be=ae.get("text-pitch-alignment")==="map",et=oe.get("symbol-z-offset"),ut=ae.get("symbol-elevation-reference")==="sea",st=!et.isConstant(),Mt=new Af(null,0,xe&&(Pe||!h.hasIconData()||ae.get("icon-optional")),Pe&&(xe||!h.hasTextData()||ae.get("text-optional")),!0);!h.collisionArrays&&D&&(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData())&&h.deserializeCollisionBoxes(D);const yt=(gt,mt,Pt)=>{for(let Ht=0;Ht0||Ht>0,er=ts>0,pr=this.placedOrientations[Ut],Xs=pr===i.bL.vertical,Vs=pr===i.bL.horizontal||pr===i.bL.horizontalOnly;!Ls&&!er||Jt.isHidden()||kt++;let Cr=!1;if((Ls||er)&&z)for(const kr of h.activeReplacements){if(i.bZ(kr,F,i.b_.Symbol,Y)||kr.min.x>ns||ns>kr.max.x||kr.min.y>fs||fs>kr.max.y)continue;const dr=i.b$(ns,fs,H.canonical,kr.footprintTileId.canonical);if(Cr=i.c0(dr,kr.footprint),Cr)break}if(Ls){const kr=Cr?G0:Mu(Jt.text);yt(h.text,Pt,Xs?G0:kr),yt(h.text,Ht,Vs?G0:kr);const dr=Jt.text.isHidden(),{leftJustifiedTextSymbolIndex:xr,centerJustifiedTextSymbolIndex:Vr,rightJustifiedTextSymbolIndex:kn,verticalPlacedTextSymbolIndex:ga}=mt,Ja=h.text.placedSymbolArray,Er=dr||Xs?1:0;xr>=0&&(Ja.get(xr).hidden=Er),Vr>=0&&(Ja.get(Vr).hidden=Er),kn>=0&&(Ja.get(kn).hidden=Er),ga>=0&&(Ja.get(ga).hidden=dr||Vs?1:0);const Wa=this.variableOffsets[Ut];Wa&&this.markUsedJustification(h,Wa.anchor,mt,pr);const _n=this.placedOrientations[Ut];_n&&(this.markUsedJustification(h,"left",mt,_n),this.markUsedOrientation(h,_n,mt))}if(er){const kr=Cr?G0:Mu(Jt.icon),{placedIconSymbolIndex:dr,verticalPlacedIconSymbolIndex:xr}=mt,Vr=h.icon.placedSymbolArray,kn=Jt.icon.isHidden()?1:0;dr>=0&&(yt(h.icon,ts,Xs?G0:kr),Vr.get(dr).hidden=kn),xr>=0&&(yt(h.icon,mt.numVerticalIconVertices,Vs?G0:kr),Vr.get(xr).hidden=kn)}if(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData()){const kr=h.collisionArrays[gt];if(kr){let dr=new i.P(0,0),xr=!0;if(kr.textBox||kr.verticalTextBox){if(Ce){const kn=this.variableOffsets[Ut];kn?(dr=Dd(kn.anchor,kn.width,kn.height,kn.textOffset,kn.textScale),Ve&&dr._rotate(Be?this.transform.angle:-this.transform.angle)):xr=!1}ge&&(xr=!Jt.clipped),kr.textBox&&py(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!xr||Xs,Ft,ut,dr.x,dr.y),kr.verticalTextBox&&py(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!xr||Vs,Ft,ut,dr.x,dr.y)}const Vr=xr&&!!(!Vs&&kr.verticalIconBox);kr.iconBox&&py(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,Vr,Ft,ut,mt.hasIconTextFit?dr.x:0,mt.hasIconTextFit?dr.y:0),kr.verticalIconBox&&py(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,!Vr,Ft,ut,mt.hasIconTextFit?dr.x:0,mt.hasIconTextFit?dr.y:0)}}}if(h.fullyClipped=kt===0,h.sortFeatures(this.transform.angle),this.retainedQueryData[h.bucketInstanceId]&&(this.retainedQueryData[h.bucketInstanceId].featureSortOrder=h.featureSortOrder),h.hasTextData()&&h.text.opacityVertexBuffer&&h.text.opacityVertexBuffer.updateData(h.text.opacityVertexArray),h.hasIconData()&&h.icon.opacityVertexBuffer&&h.icon.opacityVertexBuffer.updateData(h.icon.opacityVertexArray),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexBuffer&&h.iconCollisionBox.collisionVertexBuffer.updateData(h.iconCollisionBox.collisionVertexArray),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexBuffer&&h.textCollisionBox.collisionVertexBuffer.updateData(h.textCollisionBox.collisionVertexArray),h.bucketInstanceId in this.collisionCircleArrays){const gt=this.collisionCircleArrays[h.bucketInstanceId];h.placementInvProjMatrix=gt.invProjMatrix,h.placementViewportMatrix=gt.viewportMatrix,h.collisionCircleArray=gt.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 py(M,h,x,A,D,F,z){M.emplaceBack(h?1:0,x?1:0,F||0,z||0,A,D?1:0),M.emplaceBack(h?1:0,x?1:0,F||0,z||0,A,D?1:0),M.emplaceBack(h?1:0,x?1:0,F||0,z||0,A,D?1:0),M.emplaceBack(h?1:0,x?1:0,F||0,z||0,A,D?1:0)}const bE=Math.pow(2,25),U2=Math.pow(2,24),hC=Math.pow(2,17),wE=Math.pow(2,16),mC=Math.pow(2,9),Cu=Math.pow(2,8),Wg=Math.pow(2,1);function Mu(M){if(M.opacity===0&&!M.placed)return 0;if(M.opacity===1&&M.placed)return 4294967295;const h=M.placed?1:0,x=Math.floor(127*M.opacity);return x*bE+h*U2+x*hC+h*wE+x*mC+h*Cu+x*Wg+h}const G0=0;class $1{constructor(h){this._sortAcrossTiles=h.layout.get("symbol-z-order")!=="viewport-y"&&h.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(h,x,A,D,F,z){const H=this._bucketParts;for(;this._currentTileIndexY.sortKey-ae.sortKey));this._currentPartIndex{const Y=i.o.now()-z;return!this._forceFullPlacement&&Y>2};for(;this._currentPlacementIndex>=0;){const Y=x[h[this._currentPlacementIndex]],ae=this.placement.collisionIndex.transform.zoom;if(Y.type==="symbol"&&Y.visibility!=="none"&&(!Y.minzoom||Y.minzoom<=ae)&&(!Y.maxzoom||Y.maxzoom>ae)){const oe=Y,ge=oe.layout.get("symbol-z-elevate"),fe=oe.layout.get("symbol-sort-key").constantOr(1)!==void 0,xe=oe.layout.get("symbol-z-order"),Pe=xe==="viewport-y"||xe==="auto"&&!(xe!=="viewport-y"&&fe),Ce=oe.layout.get("text-allow-overlap")||oe.layout.get("icon-allow-overlap")||oe.layout.get("text-ignore-placement")||oe.layout.get("icon-ignore-placement"),Ve=Pe&&Ce,Be=this._inProgressLayer=this._inProgressLayer||new $1(oe),et=i.B(Y.source,Y.scope);if(Be.continuePlacement(ge||Ve?D[et]:A[et],this.placement,this._showCollisionBoxes,Y,H,F))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(h){return this.placement.commit(h),this.placement}}const Vm=512/i.al/2;class Gg{constructor(h,x,A){this.tileID=h,this.bucketInstanceId=A,this.index=new i.c4(x.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const D=h.canonical.x*i.al,F=h.canonical.y*i.al;for(let z=0;zVe-Be);for(const Ve of Ce){const Be=this.crossTileIDs[Ve];if(this.keys[Ve]===oe&&!A.has(Be)){A.add(Be),ae.crossTileID=Be;break}}}}}class rc{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class jE{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(h){const x=Math.round((h-this.lng)/360);if(x!==0)for(const A in this.indexes){const D=this.indexes[A],F={};for(const z in D){const H=D[z];H.tileID=H.tileID.unwrapTo(H.tileID.wrap+x),F[H.tileID.key]=H}this.indexes[A]=F}this.lng=h}addBucket(h,x,A){if(this.indexes[h.overscaledZ]&&this.indexes[h.overscaledZ][h.key]){if(this.indexes[h.overscaledZ][h.key].bucketInstanceId===x.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(h.overscaledZ,this.indexes[h.overscaledZ][h.key])}for(let F=0;Fh.overscaledZ)for(const H in z){const Y=z[H];Y.tileID.isChildOf(h)&&Y.findMatches(x.symbolInstances,h,D)}else{const H=z[h.scaledTo(Number(F)).key];H&&H.findMatches(x.symbolInstances,h,D)}}for(let F=0;F{x[A]=!0});for(const A in this.layerIndexes)x[A]||delete this.layerIndexes[A]}}const Ef=771;class On{constructor(h,x,A,D){this.blendFunction=h,this.blendColor=x.toNonPremultipliedRenderColor(null),this.mask=A,this.blendEquation=D}}On.Replace=[1,0,1,0],On.disabled=new On(On.Replace,i.ao.transparent,[!1,!1,!1,!1]),On.unblended=new On(On.Replace,i.ao.transparent,[!0,!0,!0,!0]),On.alphaBlended=new On([1,Ef,1,Ef],i.ao.transparent,[!0,!0,!0,!0]),On.alphaBlendedNonPremultiplied=new On([770,Ef,770,Ef],i.ao.transparent,[!0,!0,!0,!0]),On.multiply=new On([774,0,774,0],i.ao.transparent,[!0,!0,!0,!0]),On.additive=new On([1,1,1,1],i.ao.transparent,[!0,!0,!0,!0]);class Lr{constructor(h,x,A){this.func=h,this.mask=x,this.range=A}}Lr.ReadOnly=!1,Lr.ReadWrite=!0,Lr.disabled=new Lr(519,Lr.ReadOnly,[0,1]);const pC=7680;class dn{constructor(h,x,A,D,F,z){this.test=h,this.ref=x,this.mask=A,this.fail=D,this.depthFail=F,this.pass=z}}dn.disabled=new dn({func:519,mask:0},0,0,pC,pC,pC);const q1=1029,fC=2305;class nn{constructor(h,x,A){this.enable=h,this.mode=x,this.frontFace=A}}function Pf(M,h){const x=i.ca(M,3);i.cc(M,h),i.cg(M,3,x)}function kE(M,h){const x=i.c7([]);return i.c8(x,x,-h),i.c9(x,x,-M),x}function gC(M,h){const x=[M[0],M[1],0],A=[h[0],h[1],0];if(i.ag(x)>=1e-15){const z=i.aw([],x);i.c5(A,z,i.bJ(A,z)),h[0]=A[0],h[1]=A[1]}const D=i.bI([],h,M);if(i.c6(D)<1e-15)return null;const F=Math.atan2(-D[1],D[0]);return kE(Math.atan2(Math.sqrt(M[0]*M[0]+M[1]*M[1]),-M[2]),F)}nn.disabled=new nn(!1,q1,fC),nn.backCCW=new nn(!0,q1,fC),nn.backCW=new nn(!0,q1,2304),nn.frontCW=new nn(!0,1028,2304),nn.frontCCW=new nn(!0,1028,fC);class Tu{constructor(h,x){this.position=h,this.orientation=x}get position(){return this._position}set position(h){if(h){const x=h instanceof i.ae?h:new i.ae(h[0],h[1],h[2]);this._renderWorldCopies&&(x.x=i.bT(x.x,0,1)),this._position=x}else this._position=null}lookAtPoint(h,x,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),H=[z.x-D.x,z.y-D.y,z.z-D.z];x||(x=[0,0,1]),x[2]=Math.abs(x[2]),this.orientation=gC(H,x)}setPitchBearing(h,x){this.orientation=kE(i.an(h),i.an(-x))}}class xC{constructor(h,x){this._transform=i.bA([]),this.orientation=x,this.position=h}get mercatorPosition(){const h=this.position;return new i.ae(h[0],h[1],h[2])}get position(){const h=i.ca(this._transform,3);return[h[0],h[1],h[2]]}set position(h){var x;h&&i.cg(this._transform,3,[(x=h)[0],x[1],x[2],1])}get orientation(){return this._orientation}set orientation(h){this._orientation=h||i.c7([]),h&&Pf(this._transform,this._orientation)}getPitchBearing(){const h=this.forward(),x=this.right();return{bearing:Math.atan2(-x[1],x[0]),pitch:Math.atan2(Math.sqrt(h[0]*h[0]+h[1]*h[1]),-h[2])}}setPitchBearing(h,x){this._orientation=kE(h,x),Pf(this._transform,this._orientation)}forward(){const h=i.ca(this._transform,2);return[-h[0],-h[1],-h[2]]}up(){const h=i.ca(this._transform,1);return[-h[0],-h[1],-h[2]]}right(){const h=i.ca(this._transform,0);return[h[0],h[1],h[2]]}getCameraToWorld(h,x){const A=new Float64Array(16);return i.bl(A,this.getWorldToCamera(h,x)),A}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(h,x,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]*=x,F}getWorldToCamera(h,x){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]*=x,A[9]*=x,A[10]*=x,A[11]*=x,A}getCameraToClipPerspective(h,x,A,D){const F=new Float64Array(16);return i.cd(F,h,x,A,D),F}getCameraToClipOrthographic(h,x,A,D,F,z){const H=new Float64Array(16);return i.ce(H,h,x,A,D,F,z),H}getDistanceToElevation(h,x=!1){const A=h===0?0:i.cf(h,x?i.a$(this.position[1]):this.position[1]),D=this.forward();return(A-this.position[2])/D[2]}clone(){return new xC([...this.position],[...this.orientation])}}const Dc={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class yC{constructor(h=0,x=0,A=0,D=0){if(isNaN(h)||h<0||isNaN(x)||x<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=x,this.left=A,this.right=D}interpolate(h,x,A){return x.top!=null&&h.top!=null&&(this.top=i.ak(h.top,x.top,A)),x.bottom!=null&&h.bottom!=null&&(this.bottom=i.ak(h.bottom,x.bottom,A)),x.left!=null&&h.left!=null&&(this.left=i.ak(h.left,x.left,A)),x.right!=null&&h.right!=null&&(this.right=i.ak(h.right,x.right,A)),this}getCenter(h,x){const A=i.aA((this.left+h-this.right)/2,0,h),D=i.aA((this.top+x-this.bottom)/2,0,x);return new i.P(A,D)}equals(h){return this.top===h.top&&this.bottom===h.bottom&&this.left===h.left&&this.right===h.right}clone(){return new yC(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Ip=15;class NE{constructor(h,x,A,D,F,z,H){this.tileSize=512,this._renderWorldCopies=F===void 0||F,this._minZoom=h||0,this._maxZoom=x||22,this._minPitch=A??0,this._maxPitch=D??60,this.setProjection(z),this.setMaxBounds(H),this.width=0,this.height=0,this._center=new i.aT(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new yC,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new xC,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 NE(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return h._elevation=this._elevation,h._centerAltitude=this._centerAltitude,h._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,h.tileSize=this.tileSize,h.mercatorFromTransition=this.mercatorFromTransition,h.width=this.width,h.height=this.height,h.cameraElevationReference=this.cameraElevationReference,h._center=this._center,h._setZoom(this.zoom),h._seaLevelZoom=this._seaLevelZoom,h.angle=this.angle,h._fov=this._fov,h._pitch=this._pitch,h._nearZ=this._nearZ,h._farZ=this._farZ,h._averageElevation=this._averageElevation,h._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,h._unmodified=this._unmodified,h._edgeInsets=this._edgeInsets.clone(),h._camera=this._camera.clone(),h._calcMatrices(),h.freezeTileCoverage=this.freezeTileCoverage,h.frustumCorners=this.frustumCorners,h._allowWorldUnderZoom=this._allowWorldUnderZoom,h}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||h===Number.NEGATIVE_INFINITY&&(!x||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const A=this._elevation;x||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,x=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],A=this.horizonLineFromTop();let D=0,F=0;for(let z=0;z{const Ve=i.cY(fe,ge,xe,Pe,Ce);Y.has(Ve)||(F.push(new i.aQ(ge,fe,xe,Pe,Ce)),Y.add(Ve))};for(let ge=0;gefe.canonical.z)continue;const xe=fe.canonical,Pe=fe.overscaledZ,Ce=fe.wrap,Ve=1<0,ut=xe.y+10,Mt=fe.wrap-(et?0:1),yt=fe.wrap+(Be?0:1),kt=et?xe.x-1:Ve-1,gt=Be?xe.x+1:0;if(z)A[0]<0?(ae(Pe,yt,xe.z,gt,xe.y),A[1]<0&&ut&&(ae(Pe,Ce,xe.z,xe.x,xe.y+1),ae(Pe,yt,xe.z,gt,xe.y+1)),A[1]>0&&st&&(ae(Pe,Ce,xe.z,xe.x,xe.y-1),ae(Pe,yt,xe.z,gt,xe.y-1))):A[0]>0?(ae(Pe,Mt,xe.z,kt,xe.y),A[1]<0&&ut&&(ae(Pe,Ce,xe.z,xe.x,xe.y+1),ae(Pe,Mt,xe.z,kt,xe.y+1)),A[1]>0&&st&&(ae(Pe,Ce,xe.z,xe.x,xe.y-1),ae(Pe,Mt,xe.z,kt,xe.y-1))):A[1]<0&&ut?ae(Pe,Ce,xe.z,xe.x,xe.y+1):st&&ae(Pe,Ce,xe.z,xe.x,xe.y-1);else{const mt=fe.visibleQuadrants;1&mt&&(ae(Pe,Mt,xe.z,kt,xe.y),st&&(ae(Pe,Ce,xe.z,xe.x,xe.y-1),ae(Pe,Mt,xe.z,kt,xe.y-1))),2&mt&&(ae(Pe,yt,xe.z,gt,xe.y),st&&(ae(Pe,Ce,xe.z,xe.x,xe.y-1),ae(Pe,yt,xe.z,gt,xe.y-1))),4&mt&&(ae(Pe,Mt,xe.z,kt,xe.y),ut&&(ae(Pe,Ce,xe.z,xe.x,xe.y+1),ae(Pe,Mt,xe.z,kt,xe.y+1))),8&mt&&(ae(Pe,yt,xe.z,gt,xe.y),ut&&(ae(Pe,Ce,xe.z,xe.x,xe.y+1),ae(Pe,yt,xe.z,gt,xe.y+1)))}}const oe=[];for(const ge of F)F.some(fe=>ge.isChildOf(fe))||oe.push(ge);if(F=oe.filter(ge=>!h.some(fe=>!!(ge.overscaledZ{const Be=Ve.canonical.x+.5-xe[0],et=Ve.canonical.y+.5-xe[1];return Be*Be+et*et{const kt=i.cY(ut,et,st,Mt,yt);F.has(kt)||(D.push(new i.aQ(et,ut,st,Mt,yt)),F.add(kt))},H=h.reduce((et,ut)=>Math.max(et,ut.overscaledZ),A),Y=1<{const st=Math.floor(et[0]),Mt=Math.floor(et[1]),yt=(et[0]-st)*i.al,kt=(et[1]-Mt)*i.al,gt=Math.floor(ut[0]),mt=Math.floor(ut[1]),Pt=(ut[0]-gt)*i.al,Ht=(ut[1]-mt)*i.al;for(let Ut=-1;Ut<=1;Ut++){const ts=st+Ut;if(!(ts<0||ts>=Y)){oe.x=yt-Ut*i.al,ge.x=Pt-(ts-gt)*i.al;for(let ns=-1;ns<=1;ns++){const fs=Mt+ns;oe.y=kt-ns*i.al,ge.y=Ht-(fs-mt)*i.al,i.cZ(oe,ge,ae)&&z(H,0,A,ts,fs)}}}},xe=x.points,Pe=xe[i.cv],Ce=xe[i.cw],Ve=this._projectToGround(Pe,xe[i.cx]),Be=this._projectToGround(Ce,xe[i.cy]);return fe(Pe,Ve),fe(Ce,Be),D}_projectToGround(h,x){return i.cz(i.cA(),h,x,h[2]/(h[2]-x[2]))}coveringTiles(h){let x=this.coveringZoomLevel(h);const A=x,D=this.elevation&&this.elevation.exaggeration(),F=D&&!h.isTerrainDEM,z=this.projection.name==="mercator";if(h.minzoom!==void 0&&xh.maxzoom&&(x=h.maxzoom);const H=this.locationCoordinate(this.center),Y=this.center.lat,ae=1<{const Jt=new i.ae(Ft.x+25e-6,Ft.y,Ft.z),Ls=new i.ae(Ft.x,Ft.y+25e-6,Ft.z),er=Ft.toLngLat(),pr=Jt.toLngLat(),Xs=Ls.toLngLat(),Vs=this.locationCoordinate(er),Cr=this.locationCoordinate(pr),kr=this.locationCoordinate(Xs),dr=Math.hypot(Cr.x-Vs.x,Cr.y-Vs.y),xr=Math.hypot(kr.x-Vs.x,kr.y-Vs.y);return Math.sqrt(dr*xr)*kt/25e-6},mt=Ft=>{const ls=Mt,Jt=yt;return{aabb:i.cF(this,ae,0,0,0,Ft,Jt,ls,this.projection),zoom:0,x:0,y:0,minZ:Jt,maxZ:ls,wrap:Ft,fullyVisible:!1}},Pt=[];let Ht=[];const Ut=x,ts=h.reparseOverscaled?A:x,ns=(Ve-this._centerAltitude)*Ce,fs=Ft=>{if(!this._elevation||!Ft.tileID||!z)return;const ls=this._elevation.getMinMaxForTile(Ft.tileID),Jt=Ft.aabb;ls?(Jt.min[2]=ls.min,Jt.max[2]=ls.max,Jt.center[2]=(Jt.min[2]+Jt.max[2])/2):(Ft.shouldSplit=Yt(Ft),Ft.shouldSplit||(Jt.min[2]=Jt.max[2]=Jt.center[2]=this._centerAltitude))},qs=(Ft,ls)=>{if(.707*ls{if(Ft.zoom=.9)return!0}else if(F&&(Ls=Ft.aabb.distanceZ(Be)*Ce),this.projection.isReprojectedInTileSpace&&A<=5){const xr=Math.pow(2,Ft.zoom),Vr=gt(new i.ae((Ft.x+.5)/xr,(Ft.y+.5)/xr));er=Vr>.85?1:Vr}if(!z&&!ge){const xr=Math.sqrt(ls*ls+Jt*Jt+Ls*Ls);let Vr=(1<0;){const Ft=Pt.pop(),ls=Ft.x,Jt=Ft.y;let Ls=Ft.fullyVisible;const er=()=>this.projection.name==="globe"&&(Ft.y===0||Ft.y===(1<>1),Cr={aabb:z?Ft.aabb.quadrant(pr):i.cF(this,ae,Ft.zoom+1,Xs,Vs,Ft.wrap,Ft.minZ,Ft.maxZ,this.projection),zoom:Ft.zoom+1,x:Xs,y:Vs,wrap:Ft.wrap,fullyVisible:Ls,tileID:void 0,shouldSplit:void 0,minZ:Ft.minZ,maxZ:Ft.maxZ};F&&!ge&&(Cr.tileID=new i.aQ(Ft.zoom+1===Ut?ts:Ft.zoom+1,Ft.wrap,Ft.zoom+1,Xs,Vs),fs(Cr)),Pt.push(Cr)}else{const pr=Ft.zoom===Ut?ts:Ft.zoom;if(h.minzoom&&h.minzoom>pr)continue;let Xs=0;if(!Ls){let dr=et?Ft.aabb.intersectsPrecise(xe):Ft.aabb.intersectsPreciseFlat(xe);if(dr===0&&er()){const xr=new i.cD(Ft.zoom,ls,Jt);dr=i.cE(this,ae,xr,!0).intersectsPrecise(xe)}if(dr===0)continue;if(h.calculateQuadrantVisibility)if(xe.containsPoint(Ft.aabb.center))Xs=15;else for(let xr=0;xr<4;xr++)Ft.aabb.quadrant(xr).intersects(xe)!==0&&(Xs|=1<{const Ls=[0,0,0,1],er=[i.al,i.al,0,1],pr=this.calculateFogTileMatrix(Jt.tileID.toUnwrapped());i.aC(Ls,Ls,pr),i.aC(er,er,pr);const Xs=i.cG([],Ls,er),Vs=i.cH([],Ls,er),Cr=i.c$(Xs,Vs);if(Cr===0)return!0;let kr=!1;const dr=this._elevation;if(dr&&Cr>Ft&&ls!==0){const xr=this.calculateProjMatrix(Jt.tileID.toUnwrapped());let Vr;h.isTerrainDEM||(Vr=dr.getMinMaxForTile(Jt.tileID)),Vr||(Vr={min:yt,max:Mt});const kn=i.cI(this.rotation),ga=[kn[0]*i.al,kn[1]*i.al,Vr.max];i.af(ga,ga,xr),kr=(1-ga[1])*this.height*.5Ft.distanceSq-ls.distanceSq).map(Ft=>Ft.tileID)}resize(h,x){this.width=h,this.height=x,this.pixelsToGLUnits=[2/h,-2/x],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(h){return Math.pow(2,h)}scaleZoom(h){return Math.log2(h)}project(h){const x=i.aA(h.lat,-i.cJ,i.cJ),A=this.projection.project(h.lng,x);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,x){let A,D;const F=this.centerPoint;if(this.projection.name==="globe"){const H=this.worldSize;A=(x.x-F.x)/H,D=(x.y-F.y)/H}else{const H=this.pointCoordinate(x),Y=this.pointCoordinate(F);A=H.x-Y.x,D=H.y-Y.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,x){return this.projection.locationPoint(this,h,x)}locationPoint3D(h,x){return this.projection.locationPoint(this,h,x,!0)}pointLocation(h){return this.coordinateLocation(this.pointCoordinate(h))}pointLocation3D(h,x){return this.coordinateLocation(this.pointCoordinate3D(h,x))}locationCoordinate(h,x){const A=x?i.cf(x,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,x){const A=x??this._centerAltitude,D=[h.x,h.y,0,1],F=[h.x,h.y,1,1];i.aC(D,D,this.pixelMatrixInverse),i.aC(F,F,this.pixelMatrixInverse);const z=F[3];i.cK(D,D,1/D[3]),i.cK(F,F,1/z);const H=D[2],Y=F[2];return{p0:D,p1:F,t:H===Y?0:(A-H)/(Y-H)}}screenPointToMercatorRay(h){const x=[h.x,h.y,0,1],A=[h.x,h.y,1,1];return i.aC(x,x,this.pixelMatrixInverse),i.aC(A,A,this.pixelMatrixInverse),i.cK(x,x,1/x[3]),i.cK(A,A,1/A[3]),x[2]=i.cf(x[2],this._center.lat)*this.worldSize,A[2]=i.cf(A[2],this._center.lat)*this.worldSize,i.cK(x,x,1/this.worldSize),i.cK(A,A,1/this.worldSize),new i.ax([x[0],x[1],x[2]],i.aw([],i.av([],A,x)))}rayIntersectionCoordinate(h){const{p0:x,p1:A,t:D}=h,F=i.cf(x[2],this._center.lat),z=i.cf(A[2],this._center.lat);return new i.ae(i.ak(x[0],A[0],D)/this.worldSize,i.ak(x[1],A[1],D)/this.worldSize,i.ak(F,z,D))}pointCoordinate(h,x=this._centerAltitude){return this.projection.pointCoordinate(this,h.x,h.y,x)}pointCoordinate3D(h,x){if(!this.elevation)return this.pointCoordinate(h,x);let 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,x);const z=.02*F,H=h.clone();for(let Y=0;Y<10&&F-D>z;Y++){H.y=i.ak(D,F,.66);const ae=this.projection.pointCoordinate3D(this,H.x,H.y);ae?(F=H.y,A=ae):D=H.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 x=this.pointCoordinate(h);return x.y>=0&&x.y<=1}_coordinatePoint(h,x){const A=x&&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:x}=this._edgeInsets,A=this.height-this._edgeInsets.bottom,D=this.width-this._edgeInsets.right,F=this.pointLocation3D(new i.P(x,h)),z=this.pointLocation3D(new i.P(D,h)),H=this.pointLocation3D(new i.P(D,A)),Y=this.pointLocation3D(new i.P(x,A));let ae=Math.min(F.lng,z.lng,H.lng,Y.lng),oe=Math.max(F.lng,z.lng,H.lng,Y.lng),ge=Math.min(F.lat,z.lat,H.lat,Y.lat),fe=Math.max(F.lat,z.lat,H.lat,Y.lat);const xe=Math.pow(2,-this.zoom)/16*270,Pe=this.projection.name==="globe"?1:4,Ce=(Ve,Be,et,ut,st)=>{const Mt=(Ve+et)/2,yt=(Be+ut)/2,kt=new i.P(Mt,yt),{lng:gt,lat:mt}=this.pointLocation3D(kt),Pt=Math.max(0,ae-gt,ge-mt,gt-oe,mt-fe);ae=Math.min(ae,gt),oe=Math.max(oe,gt),ge=Math.min(ge,mt),fe=Math.max(fe,mt),(stxe)&&(Ce(Ve,Be,Mt,yt,st+1),Ce(Mt,yt,et,ut,st+1))};if(Ce(x,h,D,h,1),Ce(D,h,D,A,1),Ce(D,A,x,A,1),Ce(x,A,x,h,1),this.projection.name==="globe"){const[Ve,Be]=i.cM(this);Ve?(fe=90,oe=180,ae=-180):Be&&(ge=-90,oe=180,ae=-180)}return new i.aI(new i.aT(ae,ge),new i.aT(oe,fe))}_getBoundsRectangular(h,x){const{top:A,left:D}=this._edgeInsets,F=this.height-this._edgeInsets.bottom,z=this.width-this._edgeInsets.right,H=new i.P(D,A),Y=new i.P(z,A),ae=new i.P(z,F),oe=new i.P(D,F);let ge=this.pointCoordinate(H,h),fe=this.pointCoordinate(Y,h);const xe=this.pointCoordinate(ae,x),Pe=this.pointCoordinate(oe,x),Ce=(Ve,Be)=>(Be.y-Ve.y)/(Be.x-Ve.x);return ge.y>1&&fe.y>=0?ge=new i.ae((1-Pe.y)/Ce(Pe,ge)+Pe.x,1):ge.y<0&&fe.y<=1&&(ge=new i.ae(-Pe.y/Ce(Pe,ge)+Pe.x,0)),fe.y>1&&ge.y>=0?fe=new i.ae((1-xe.y)/Ce(xe,fe)+xe.x,1):fe.y<0&&ge.y<=1&&(fe=new i.ae(-xe.y/Ce(xe,fe)+xe.x,0)),new i.aI().extend(this.coordinateLocation(ge)).extend(this.coordinateLocation(fe)).extend(this.coordinateLocation(Pe)).extend(this.coordinateLocation(xe))}_getBoundsRectangularTerrain(){const h=this.elevation;if(!h.visibleDemTiles.length||h.isUsingMockSource())return this._getBoundsRectangular(0,0);const x=h.visibleDemTiles.reduce((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(x.min*h.exaggeration(),x.max*h.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(h=!0){const x=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,A=this.height/2-x*(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.maxLngge&&(H=ge-ae),ge-oexe&&(z=xe-Y),xe-fe{for(let Yt=0;Yt<16;Yt++)ts[Yt]=i.ak(ns[Yt],fs[Yt],qs)})(H,H,Y,i.d0(this.pitch>=Ip?1:this.pitch/Ip))}else H=Y;const ae=i.cP([],Y,z);let oe=i.cP([],H,z);if(this.projection.isReprojectedInTileSpace){const mt=this.locationCoordinate(this.center),Pt=i.bA([]);i.br(Pt,Pt,[mt.x*this.worldSize,mt.y*this.worldSize,0]),i.aB(Pt,Pt,i.cQ(this)),i.br(Pt,Pt,[-mt.x*this.worldSize,-mt.y*this.worldSize,0]),i.aB(oe,oe,Pt),i.aB(ae,ae,Pt),this.inverseAdjustmentMatrix=i.cR(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=i.cS([],oe,[this.worldSize,this.worldSize,this.worldSize/F,1]),this.projMatrix=oe,this.invProjMatrix=i.bl(new Float64Array(16),this.projMatrix),x){const mt=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);mt[8]=2*-h.x/this.width,mt[9]=2*h.y/this.height,this.expandedFarZProjMatrix=i.cP([],mt,z)}else this.expandedFarZProjMatrix=this.projMatrix;const ge=i.bl([],H);this.frustumCorners=i.cT.fromInvProjectionMatrix(ge,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!x);const fe=new Float32Array(16);i.bA(fe),i.cS(fe,fe,[1,-1,1]),i.cU(fe,fe,this._pitch),i.bB(fe,fe,this.angle);const xe=i.cd(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=i.bz(xe);const Pe=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;xe[8]=2*-h.x/this.width,xe[9]=2*(h.y+Pe)/this.height,this.skyboxMatrix=i.aB(fe,xe,fe);const Ce=this.point,Ve=Ce.x,Be=Ce.y,et=this.width%2/2,ut=this.height%2/2,st=Math.cos(this.angle),Mt=Math.sin(this.angle),yt=Ve-Math.round(Ve)+st*et+Mt*ut,kt=Be-Math.round(Be)+st*ut+Mt*et,gt=new Float64Array(oe);if(i.br(gt,gt,[yt>.5?yt-1:yt,kt>.5?kt-1:kt,0]),this.alignedProjMatrix=gt,oe=i.bC(),i.cS(oe,oe,[this.width/2,-this.height/2,1]),i.br(oe,oe,[1,-1,0]),this.labelPlaneMatrix=oe,oe=i.bC(),i.cS(oe,oe,[1,-1,1]),i.br(oe,oe,[-1,-1,0]),i.cS(oe,oe,[2/this.width,2/this.height,1]),this.glCoordMatrix=oe,this.pixelMatrix=i.aB(new Float64Array(16),this.labelPlaneMatrix,ae),this._calcFogMatrices(),this._distanceTileDataCache={},oe=i.bl(new Float64Array(16),this.pixelMatrix),!oe)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=oe,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.cV(this);const mt=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.af(mt,mt,z),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=oe;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const h=this.cameraWorldSizeForFog,x=this.cameraPixelsPerMeter,A=this._camera.position,D=1/this.height/this._pixelsPerMercatorPixel,F=[h,h,x];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,x,D)}_computeCameraPosition(h){const x=(h=h||this.pixelsPerMeter)/this.pixelsPerMeter,A=this._camera.forward(),D=this.point,F=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*x-h/this.worldSize*this._centerAltitude;return[D.x/this.worldSize-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 x=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((x-A)/D,1)),this._camera.position=i.bH([],this._camera.position,h,F),this._updateStateFromCamera()}_updateStateFromCamera(){const h=this._camera.position,x=this._camera.forward(),{pitch: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)),H=Math.max((h[2]-F)/Math.cos(A),z),Y=this._zoomFromMercatorZ(H);i.bH(h,h,x,H),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(Y,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new i.ae(h[0],h[1],h[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(h){return Math.pow(2,h)*this.tileSize}_mercatorZfromZoom(h){return this.cameraToCenterDistance/this._worldSizeFromZoom(h)}_minimumHeightOverTerrain(){const h=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(h)}_zoomFromMercatorZ(h){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,h)*this.tileSize))}zoomFromMercatorZAdjusted(h){let x=0,A=i.cL,D=0,F=1/0;for(;A-x>1e-6&&A>x;){const z=x+.5*(A-x),H=this.tileSize*Math.pow(2,z),Y=this.getCameraToCenterDistance(this.projection,z,H),ae=this.scaleZoom(Y/(Math.max(0,h)*this.tileSize)),oe=Math.abs(z-ae);oeae||fe.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+i.cX(this.fovAboveCenter)>88||this.anyCornerOffEdge(new i.P(0,0),new i.P(this.width,this.height))}zoomDeltaToMovement(h,x){const A=i.ag(i.av([],this._camera.position,h)),D=this._zoomFromMercatorZ(A)+x;return A-this._mercatorZfromZoom(D)}getCameraPoint(){if(this.projection.name==="globe"){const h=function([x,A,D],F){const z=[x,A,D,1];i.aC(z,z,F);const H=z[3]=Math.max(z[3],1e-6);return z[0]/=H,z[1]/=H,z[2]/=H,z}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new i.P(h[0],h[1])}{const h=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.P(0,h))}}getCameraToCenterDistance(h,x=this.zoom,A=this.worldSize){const D=i.cO(h,x,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>=Ip?1:this.pitch/Ip))),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 fy=(M,h)=>{if(h>0&&M.terrain&&i.w("Cutoff is currently disabled on terrain"),h<=0||M.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const x=M.transform,A=Math.max(Math.abs(x._zoom-(M.minCutoffZoom-1)),1),D=x.isLODDisabled(!1)?i.ah(60,45,x.pitch):i.ah(30,15,x.pitch),F=x._farZ-x._nearZ,z=h*x.height,H=((1-(Y=D))*x.cameraToCenterDistance+Y*(x._farZ+z))*A;var Y;return{shouldRenderCutoff:D<1,uniformValues:{u_cutoff_params:[x._nearZ,x._farZ,(H-x._nearZ)/F,(H-z-x._nearZ)/F]}}},Hm=2048;class V2{constructor(h,x){this.aabb=h,this.lastCascade=x}}class pme{add(h,x){const A=this.receivers[h.key];A!==void 0?(A.aabb.min[0]=Math.min(A.aabb.min[0],x.min[0]),A.aabb.min[1]=Math.min(A.aabb.min[1],x.min[1]),A.aabb.min[2]=Math.min(A.aabb.min[2],x.min[2]),A.aabb.max[0]=Math.max(A.aabb.max[0],x.max[0]),A.aabb.max[1]=Math.max(A.aabb.max[1],x.max[1]),A.aabb.max[2]=Math.max(A.aabb.max[2],x.max[2])):this.receivers[h.key]=new V2(x,null)}clear(){this.receivers={}}get(h){return this.receivers[h.key]}computeRequiredCascades(h,x,A){const D=i.d9.fromPoints(h.points);let F=0;for(const z in this.receivers){const H=this.receivers[z];if(!H||!D.intersectsAabb(H.aabb))continue;H.aabb.min=D.closestPoint(H.aabb.min),H.aabb.max=D.closestPoint(H.aabb.max);const Y=H.aabb.getCorners();for(let ae=0;ae1||fe[1]<-1||fe[1]>1){oe=!1;break}}if(H.lastCascade=ae,F=Math.max(F,ae),oe)break}}return F+1}}class U1{constructor(h){this.painter=h,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new pme,this._depthMode=new Lr(h.context.gl.LEQUAL,Lr.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this.useNormalOffset=!1}destroy(){for(const h of this._cascades)h.texture.destroy(),h.framebuffer.destroy();this._cascades=[]}updateShadowParameters(h,x){const A=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!x||!x.properties)return;const D=x.properties.get("shadow-intensity");if(!x.shadowsEnabled()||D<=0||(this._shadowLayerCount=A.style.order.reduce((Pe,Ce)=>{const Ve=A.style._mergedLayers[Ce];return Pe+(Ve.hasShadowPass()&&!Ve.isHidden(h.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;const F=A.context,z=Hm,H=Hm;if(this._cascades.length===0||Hm!==this._cascades[0].texture.size[0]){this._cascades=[];for(let Pe=0;Pe<2;++Pe){const Ce=A._shadowMapDebug,Ve=F.gl,Be=F.createFramebuffer(z,H,Ce?1:0,"texture"),et=new i.T(F,{width:z,height:H,data:null},Ve.DEPTH_COMPONENT16);if(Be.depthAttachment.set(et.texture),Ce){const ut=new i.T(F,{width:z,height:H,data:null},Ve.RGBA8);Be.colorAttachment0.set(ut.texture)}this._cascades.push({framebuffer:Be,texture:et,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cB,scale:0})}}this.shadowDirection=W2(x);let Y=0;if(h.elevation){const Pe=h.elevation,Ce=[1e4,-1e4];Pe.visibleDemTiles.filter(Ve=>Ve.dem).forEach(Ve=>{const Be=Ve.dem.tree;Ce[0]=Math.min(Ce[0],Be.minimums[0]),Ce[1]=Math.max(Ce[1],Be.maximums[0])}),Ce[0]!==1e4&&(Y=(Ce[1]-Ce[0])*Pe.exaggeration())}const ae=1.5*h.cameraToCenterDistance,oe=3*ae,ge=new Float64Array(16);for(let Pe=0;Pe=0)return{};const F=function(Y,ae,oe){const ge=oe/(1<0&&(i.d8(F[1],F[1],[D[0]*z,0,0]),i.d8(F[2],F[2],[D[0]*z,0,0])),D[1]<0?(i.d8(F[0],F[0],[0,D[1]*z,0]),i.d8(F[1],F[1],[0,D[1]*z,0])):D[1]>0&&(i.d8(F[2],F[2],[0,D[1]*z,0]),i.d8(F[3],F[3],[0,D[1]*z,0]));const H={};return H.vertices=F,H.planes=[H2(F[1],F[0],F[4]),H2(F[2],F[1],F[5]),H2(F[3],F[2],F[6]),H2(F[0],F[3],F[7])],H}addShadowReceiver(h,x,A){this._receivers.add(h,i.d9.fromTileIdAndHeight(h,x,A))}getMaxCascadeForTile(h){const x=this._receivers.get(h);return x&&x.lastCascade?x.lastCascade:0}}function H2(M,h,x){const A=i.av([],x,h),D=i.av([],M,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 W2(M){const h=M.properties.get("direction"),x=i.d4(h.x,h.y,h.z);x[2]=i.aA(x[2],0,75);const A=i.d6([x[0],x[1],x[2]]);return i.d5(A.x,A.y,A.z)}function Kg(M,h,x){const A=h.properties.get("color-use-theme")==="none",D=h.properties.get("color"),F=h.properties.get("intensity"),z=h.properties.get("direction"),H=[z.x,z.y,z.z],Y=x.properties.get("color-use-theme")==="none",ae=x.properties.get("color"),oe=x.properties.get("intensity"),ge=Math.max(i.bJ([0,0,1],H),0),fe=[0,0,0];i.c5(fe,ae.toPremultipliedRenderColor(Y?null:M.getLut(h.scope)).toArray01Linear().slice(0,3),oe);const xe=[0,0,0];return i.c5(xe,D.toPremultipliedRenderColor(A?null:M.getLut(x.scope)).toArray01Linear().slice(0,3),ge*F),i.db([fe[0]>0?fe[0]/(fe[0]+xe[0]):0,fe[1]>0?fe[1]/(fe[1]+xe[1]):0,fe[2]>0?fe[2]/(fe[2]+xe[2]):0])}function gy(M,h,x,A,D,F){const z=M.zoom,H=M.scale,Y=M.worldSize,ae=1/Y,oe=M.aspect,ge=Math.sqrt(1+oe*oe)*Math.tan(.5*M.fovX),fe=ge*ge,xe=A-x,Pe=A+x;let Ce,Ve;fe>xe/Pe?(Ce=A,Ve=A*ge):(Ce=.5*Pe*(1+fe),Ve=.5*Math.sqrt(xe*xe+2*(A*A+x*x)*fe+Pe*Pe*fe*fe));const Be=M.projection.pixelsPerMeter(M.center.lat,Y),et=M._camera.getCameraToWorldMercator(),ut=[0,0,-Ce*ae];i.af(ut,ut,et);let st=Ve*ae;const Mt=M._edgeInsets;if(!(Mt.left===0&&Mt.top===0&&Mt.right===0&&Mt.bottom===0||Mt.left===Mt.right&&Mt.top===Mt.bottom)){const Ls=M._camera.getWorldToCamera(M.worldSize,M.projection.zAxisUnit==="meters"?Be:1),er=M._camera.getCameraToClipPerspective(M._fov,M.width/M.height,x,A);er[8]=2*-M.centerOffset.x/M.width,er[9]=2*M.centerOffset.y/M.height;const pr=new Float64Array(16);i.cP(pr,er,Ls);const Xs=new Float64Array(16);i.bl(Xs,pr);const Vs=i.cB.fromInvProjectionMatrix(Xs,Y,z,!0);for(const Cr of Vs.points){const kr=((yt=Cr)[0]/=H,yt[1]/=H,yt[2]=i.cf(yt[2],M._center.lat),yt);st=Math.max(st,i.c6(i.da([],ut,kr)))}}var yt;st*=D/(D-1);const kt=Math.acos(h[2]),gt=Math.atan2(-h[0],-h[1]),mt=new xC;mt.position=ut,mt.setPitchBearing(kt,gt);const Pt=mt.getWorldToCamera(Y,Be),Ht=st*Y,Ut=Math.min(M._mercatorZfromZoom(17)*Y*-2,-2*Ht),ts=mt.getCameraToClipOrthographic(-Ht,Ht,-Ht,Ht,Ut,(Ht+F*Be)/h[2]),ns=new Float64Array(16);i.aB(ns,ts,Pt);const fs=i.d5(Math.floor(1e6*ut[0])/1e6*Y,Math.floor(1e6*ut[1])/1e6*Y,0),qs=.5*D,Yt=[0,0,0];i.af(Yt,fs,ns),i.c5(Yt,Yt,qs);const Ft=[Math.floor(Yt[0]),Math.floor(Yt[1]),Math.floor(Yt[2])],ls=[0,0,0];i.av(ls,Yt,Ft),i.c5(ls,ls,-1/qs);const Jt=new Float64Array(16);return i.bA(Jt),i.br(Jt,Jt,ls),i.aB(ns,Jt,ns),[ns,Ht]}class fme extends i.E{constructor(h){super(),this.requestManager=h,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(h,x){return i.dc(this.requestManager.transformRequest(x,i.R.Model).url).then(A=>{if(!A)return;const D=i.dd(A),F=new i.de(h,x,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 ${x}: ${A.message}`)))})}load(h,x,A={forceReload:!1}){this.models[x]||(this.models[x]={});const D=Object.keys(h),F=[],z=[];for(const H of D){const Y=h[H];this.hasURLBeenRequested(Y)&&!A.forceReload||(this.modelByURL[Y]={modelId:H,scope:x},F.push(this.loadModel(H,Y)),z.push(H)),this.models[x][H]||(this.models[x][H]={model:null,numReferences:1})}this.numModelsLoading[x]=(this.numModelsLoading[x]||0)+z.length,Promise.allSettled(F).then(H=>{for(let Y=0;Y{this.fire(new i.y(new Error(`Could not load models: ${H.message}`)))})}isLoaded(){for(const h in this.numModelsLoading)if(this.numModelsLoading[h]>0)return!1;return!0}hasModel(h,x,A={exactIdMatch:!1}){return!!(A.exactIdMatch?this.getModel(h,x):this.getModelByURL(this.modelUris[x][h]))}getModel(h,x){return this.models[x]||(this.models[x]={}),this.models[x][h]?this.models[x][h].model:void 0}getModelByURL(h){if(!h)return null;const x=this.modelByURL[h];return x?this.models[x.scope][x.modelId].model:null}hasModelBeenAdded(h,x){return this.models[x]&&this.models[x][h]!==void 0}getModelURIs(h){return this.modelUris[h]||{}}addModel(h,x,A){this.models[A]||(this.models[A]={}),this.modelUris[A]||(this.modelUris[A]={});const D=this.requestManager.normalizeModelURL(x);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,x){this.models[x]||(this.models[x]={}),this.modelUris[x]||(this.modelUris[x]={});const A=this.modelUris[x];for(const D in h)A[D]=this.requestManager.normalizeModelURL(h[D])}reloadModels(h){this.load(this.modelUris[h],h,{forceReload:!0})}addModelsFromBucket(h,x){this.models[x]||(this.models[x]={}),this.modelUris[x]||(this.modelUris[x]={});const A={};for(const D of h)this.hasModel(D,x,{exactIdMatch:!0})||this.hasURLBeenRequested(D)?this.models[x][D].numReferences++:this.modelUris[x][D]&&!this.hasURLBeenRequested(D)?A[D]=this.modelUris[x][D]:!this.hasURLBeenRequested(D)&&i.df(D,!1)&&(this.modelUris[x][D]=this.requestManager.normalizeModelURL(D),A[D]=this.modelUris[x][D]);this.load(A,x)}hasURLBeenRequested(h){return this.modelByURL[h]!==void 0}removeModel(h,x,A=!1,D=!1){if(this.models[x]&&this.models[x][h]&&(this.models[x][h].numReferences--,this.models[x][h].numReferences===0||D)){const F=this.modelUris[x][h];A||delete this.modelUris[x][h],delete this.modelByURL[F];const z=this.models[x][h].model;if(!z)return;delete this.models[x][h],z.destroy()}}destroy(){for(const h of Object.keys(this.models))for(const x of Object.keys(this.models[h])){const A=this.models[h][x].model;delete this.models[h][x],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,x){this.models[x]||(this.models[x]={});for(const A in this.models[x])this.models[x][A].model&&this.models[x][A].model.upload(h.context)}}const SE=i.a6.colorTheme,gme=new i.a9({data:new i.aa(SE.data)});function aR(M){if(!M.metadata||!M.metadata.content_area)return;const h=i.o.devicePixelRatio,{left:x,top:A,width:D,height:F}=M.metadata.content_area,z=x*h,H=A*h;return[z,H,z+D*h,H+F*h]}function iR(M){if(M)return M.map(([h,x])=>[h*i.o.devicePixelRatio,x*i.o.devicePixelRatio])}class CE{constructor(h,x,A){this.id=h,this.scope=x,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 x=this.sourceCache.getVisibleCoordinates();if(x.length===0)return h;const A=this.sourceCache.getSource();if(!(A instanceof yd))return h;const D=x.map(z=>this.sourceCache.getTile(z)),F=A.getImages(D,Array.from(this.pendingRequests));for(const[z,H]of F)h.set(i.I.from({name:z,iconsetId:this.id}),H),this.pendingRequests.delete(z);for(const z of this.pendingRequests)this.missingRequests.add(z);return this.pendingRequests.clear(),h}}const xy=(M,h)=>Qe(M,h&&h.filter(x=>x.identifier!=="source.canvas")),oR=i.aH(Sa,["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"]),lR=i.aH(Sa,["setCenter","setZoom","setBearing","setPitch"]),vC=new Set(["background","sky","slot","custom"]),yy={version:8,layers:[],sources:{}},G2={duration:300,delay:0};class Wm extends i.E{constructor(h,x={}){super(),this.map=h,this.scope=x.scope||"",this.globalId=null,this.fragments=[],this.importDepth=x.importDepth||0,this.importsCache=x.importsCache||new Map,this.resolvedImports=x.resolvedImports||new Set,this.transition=Object.assign({},G2),this._buildingIndex=new R2(this),this.crossTileSymbolIndex=new Pp,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=x.styleChanges||new Se,this._hasDataDrivenEmissive=!1,this.dispatcher=x.dispatcher?x.dispatcher:new i.D(i.dh(),this),x.imageManager?this.imageManager=x.imageManager:(this.imageManager=new $e(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=x.glyphManager?x.glyphManager:new i.di(h._requestManager,x.localFontFamily?i.dj.all:x.localIdeographFontFamily?i.dj.ideographs:i.dj.none,x.localFontFamily||x.localIdeographFontFamily),x.modelManager?this.modelManager=x.modelManager:(this.modelManager=new fme(h._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=x.configOptions?x.configOptions:new Map,this._configDependentLayers=x.configDependentLayers?x.configDependentLayers:new Set,this._indoorDependentLayers=x.indoorDependentLayers?x.indoorDependentLayers:new Set,this._config=x.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:x.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=x.initialConfig,this.dispatcher.broadcast("setReferrer",i.dk());const A=this;this._rtlTextPluginCallback=Wm.registerForPluginStateChange(D=>{A.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(F,z)=>{if(i.dl(F),z&&z.every(H=>H))for(const H in A._sourceCaches){const Y=A._sourceCaches[H],ae=Y.getSource().type;ae!=="vector"&&ae!=="geojson"||Y.reload()}})}),this.on("data",D=>{if(D.dataType!=="source"||D.sourceDataType!=="metadata")return;const F=this.getOwnSource(D.sourceId);if(F&&F.vectorLayerIds)for(const z in this._layers){const H=this._layers[z];H.source===F.id&&this._validateLayer(H)}})}load(h){return h?(typeof h=="string"?this.loadURL(h):this.loadJSON(h),this):this}_getGlobalId(h){if(!h)return null;if(typeof h=="string"){if(i.h(h))return h;const x=i.dm(h);if(!x.startsWith("http"))try{return new URL(x,location.href).toString()}catch{return x}return x}return`json://${i.dn(JSON.stringify(h))}`}_diffStyle(h,x,A){this.globalId=this._getGlobalId(h);const D=(F,z)=>{try{z(null,this.setState(F,A))}catch(H){z(H,!1)}};if(typeof h=="string"){const F=this.map._requestManager.normalizeStyleURL(h),z=this.map._requestManager.transformRequest(F,i.R.Style);i.m(z,(H,Y)=>{H?this.fire(new i.y(H)):Y&&D(Y,x)})}else typeof h=="object"&&D(h,x)}loadURL(h,x={}){this.fire(new i.z("dataloading",{dataType:"style"}));const A=typeof x.validate=="boolean"?x.validate:!i.h(h);this.globalId=this._getGlobalId(h),h=this.map._requestManager.normalizeStyleURL(h,x.accessToken),this.resolvedImports.add(h);const D=this.importsCache.get(h);if(D)return this._load(D,A);const F=this.map._requestManager.transformRequest(h,i.R.Style);this._request=i.m(F,(z,H)=>{if(this._request=null,z)this.fire(new i.y(z));else if(H)return this.importsCache.set(h,H),this._load(H,A)})}loadJSON(h,x={}){this.fire(new i.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(h),this._request=i.o.frame(()=>{this._request=null,this._load(h,x.validate!==!1)})}loadEmpty(){this.fire(new i.z("dataloading",{dataType:"style"})),this._load(yy,!1)}_loadImports(h,x,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),H=new Promise(oe=>{z.once("style.import.load",oe),z.once("error",oe)}).then(()=>this.mergeAll());if(D.push(H),this.resolvedImports.has(F.url)){z.loadEmpty();continue}const Y=F.data||this.importsCache.get(F.url);Y?(z.loadJSON(Y,{validate:x}),this._isInternalStyle(Y)&&(z.globalId=null)):F.url?z.loadURL(F.url,{validate:x}):z.loadEmpty();const ae={style:z,id:F.id,config:F.config};if(A){const oe=this.fragments.findIndex(({id:ge})=>ge===A);this.fragments=this.fragments.slice(0,oe).concat(ae).concat(this.fragments.slice(oe))}else this.fragments.push(ae)}return Promise.allSettled(D)}getImportGlobalIds(h=this,x=new Set){for(const A of h.fragments)A.style.globalId&&x.add(A.style.globalId),this.getImportGlobalIds(A.style,x);return[...x.values()]}_createFragmentStyle(h){const x=this.scope?i.B(h.id,this.scope):h.id;let A;const D=this._initialConfig&&this._initialConfig[x];(h.config||D)&&(A=Object.assign({},h.config,D));const F=new Wm(this.map,{scope:x,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config: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,x){if(this._isInternalStyle(h)){const F=Object.assign({},yy,{imports:[{id:"basemap",data:h,url:""}]},h.center?{center:h.center}:{},h.bearing?{bearing:h.bearing}:{},h.pitch?{pitch:h.pitch}:{},h.zoom?{zoom:h.zoom}:{},h.light?{light:h.light}:{});return this._importedAsBasemap=!0,void this._load(F,x)}if(this.updateConfig(this._config,h.schema),x&&xy(this,Zt(h)))return;this._loaded=!0,this.stylesheet=i.dp(h);const A=()=>{for(const Y in h.sources)this.addSource(Y,h.sources[Y],{validate:!1,isInitialLoad:!0});if(h.iconsets)for(const Y in h.iconsets)this.addIconset(Y,h.iconsets[Y]);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=q0(this.stylesheet.layers);if(this._order=F.map(Y=>Y.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 Y=this.stylesheet.lights[0];this.light=new zt(Y.properties,Y.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new zt(this.stylesheet.light)),this._layers={};for(const Y of F){const ae=i.du(Y,this.scope,this._styleColorTheme.lut,this.options);ae.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(ae.fqid),ae.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(ae.fqid),this._hasAppearances=this._hasAppearances||ae.getAppearances().length!==0,ae.setEventedParent(this,{layer:{id:ae.id}}),this._layers[ae.id]=ae;const oe=this.getOwnLayerSourceCache(ae),ge=!!this.directionalLight&&this.directionalLight.shadowsEnabled();oe&&ae.canCastShadows()&&ge&&(oe.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const z=this.stylesheet.terrain;z&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(z,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new i.z("data",{dataType:"style"}));const H=this.isRootStyle();h.imports?this._loadImports(h.imports,x).then(()=>{this._reloadImports(),this.fire(new i.z(H?"style.load":"style.import.load"))}).catch(Y=>{this.fire(new i.y(new Error("Failed to load imports",Y))),this.fire(new i.z(H?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new i.z(H?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const D=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(D){const F=this._evaluateColorThemeData(D);this._loadColorTheme(F).then(()=>{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,x,A,D,F,z,H,Y,ae,oe;const ge={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(fe=>{if(fe.stylesheet){if(fe.light!=null&&(h=fe.light),fe.stylesheet.lights)for(const xe of fe.stylesheet.lights)xe.type==="ambient"&&fe.ambientLight!=null&&(x=fe.ambientLight),xe.type==="directional"&&fe.directionalLight!=null&&(A=fe.directionalLight);D=this._prioritizeTerrain(D,fe.terrain,fe.stylesheet.terrain),fe.stylesheet.fog&&fe.fog!=null&&(F=fe.fog),fe.stylesheet.snow&&fe.snow!=null&&(z=fe.snow),fe.stylesheet.rain&&fe.rain!=null&&(H=fe.rain),fe.stylesheet.camera!=null&&(oe=fe.stylesheet.camera),fe.stylesheet.projection!=null&&(Y=fe.stylesheet.projection),fe.stylesheet.transition!=null&&(ae=fe.stylesheet.transition),ge[fe.scope]=fe._styleColorTheme}}),this.light=h,this.ambientLight=x,this.directionalLight=A,this.fog=F,this.snow=z,this.rain=H,this._styleColorThemeForScope=ge,D===null?delete this.terrain:this.terrain=D,this.camera=oe||{"camera-projection":"perspective"},this.projection=Y||{name:"mercator"},this.transition=Object.assign({},G2,ae),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(h){const x=A=>{for(const D of A.fragments)x(D.style);h(A)};x(this)}_prioritizeTerrain(h,x,A){const D=h&&h.drapeRenderMode===0;return A===null?x&&x.drapeRenderMode===0?x:D?h:null:x!=null&&(!h||D||x&&x.drapeRenderMode===1)?x:h}mergeTerrain(){let h;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(x=>{h=this._prioritizeTerrain(h,x.terrain,x.stylesheet.terrain)}),h===null?delete this.terrain:this.terrain=h}mergeProjection(){let h;this.forEachFragmentStyle(x=>{x.stylesheet.projection!=null&&(h=x.stylesheet.projection)}),this.projection=h||{name:"mercator"}}mergeSources(){const h={},x={},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);x[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=x,this._mergedSymbolSourceCaches=A}mergeIndoor(){this.forEachFragmentStyle(h=>{if(h.stylesheet&&h.stylesheet.indoor)for(const x of Object.values(h.stylesheet.indoor)){const A=x,D=i.B(A.sourceId,h.scope);this._mergedIndoor[D]=new Set(A.sourceLayers||[])}})}mergeLayers(){const h={},x=[],A={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(z=>{for(const H of z._order){const Y=z._layers[H];if(Y.type==="slot"){const ae=i.dq(H);if(h[ae])continue;h[ae]=[]}Y.slot&&h[Y.slot]?h[Y.slot].push(Y):x.push(Y)}}),this._mergedOrder=[];let D=-1;const F=(z=[])=>{for(const H of z)if(H.type==="slot"){const Y=i.dq(H.id);h[Y]&&F(h[Y]),this._mergedSlots.push(Y)}else{const Y=i.B(H.id,H.scope);this._mergedOrder.push(Y),A[Y]=H,H.is3D(!!this.terrain)&&(this._has3DLayers=!0,D=this._mergedOrder.length-1),H.type==="circle"&&(this._hasCircleLayers=!0),H.type==="symbol"&&(this._hasSymbolLayers=!0),H.type==="clip"&&(this._clipLayerPresent=!0)}};if(F(x),this._has3DLayers){const z={};for(let H=0;Hz[H]-z[Y])}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(x,A,D,F){const z=Object.assign({},A);for(const Y of Object.keys(SE))z[Y]===void 0&&(z[Y]=SE[Y].default);const H=new i.a8(gme,x,new Map(D));return H.setTransitionOrValue(z,D),H.untransitioned().possiblyEvaluate(new i.ac(0,{worldview:void 0}))}(this.scope,h,this.options).get("data"):null}_loadColorTheme(h){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const x=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((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 H=i.I.from("mapbox-reserved-lut"),Y=new Image;Y.src=z,Y.onerror=()=>{this._styleColorTheme.lutLoading=!1,D(new Error("Failed to load image data"))},Y.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==x)return void A();this._styleColorTheme.lutLoading=!1;const{width:ae,height:oe,data:ge}=i.o.getImageData(Y);if(oe>32)return void D(new Error("The height of the image must be less than or equal to 32 pixels."));if(ae!==oe*oe)return void D(new Error("The width of the image must be equal to the height squared."));this.getImage(H)&&this.removeImage(H),this.addImage(H,{data:new i.q({width:ae,height:oe},ge),pixelRatio:1,sdf:!1,usvg:!1,version:0});const fe=this.imageManager.getImage(H,this.scope);fe?(this._styleColorTheme.lut={image:fe.data,data:h},A()):D(new Error("Missing LUT image."))}})}getLut(h){const x=this._styleColorThemeForScope[h];return x?x.lut:null}setProjection(h){h?this.stylesheet.projection=h:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(h){this._spriteRequest=function(x,A,D){let F,z,H;const Y=i.o.devicePixelRatio>1?"@2x":"";let ae=i.m(A.transformRequest(A.normalizeSpriteURL(x,Y,".json"),i.R.SpriteJSON),(fe,xe)=>{ae=null,H||(H=fe,F=xe,ge())}),oe=i.n(A.transformRequest(A.normalizeSpriteURL(x,Y,".png"),i.R.SpriteImage),(fe,xe)=>{oe=null,H||(H=fe,z=xe,ge())});function ge(){if(H)D(H);else if(F&&z){const fe=i.o.getImageData(z),xe={};for(const Pe in F){const{width:Ce,height:Ve,x:Be,y:et,sdf:ut,pixelRatio:st,stretchX:Mt,stretchY:yt,content:kt}=F[Pe],gt=new i.q({width:Ce,height:Ve});i.q.copy(fe,gt,{x:Be,y:et},{x:0,y:0},{width:Ce,height:Ve},null),xe[Pe]={data:gt,pixelRatio:st!==void 0?st:1,sdf:ut!==void 0&&ut,stretchX:Mt,stretchY:yt,content:kt,usvg:!1,version:0}}D(null,xe)}}return{cancel(){ae&&(ae.cancel(),ae=null),oe&&(oe.cancel(),oe=null)}}}(h,this.map._requestManager,(x,A)=>{if(this._spriteRequest=null,x)this.fire(new i.y(x));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,x){if(x.type==="sprite")return void this._loadSprite(x.url);const A=this.getOwnSourceCache(x.source);if(!A)return void this.fire(new i.y(new Error(`Source "${x.source}" as specified by iconset "${h}" does not exist and cannot be used as an iconset source`)));const D=A.getSource();if(D.type!=="raster-array")return void this.fire(new i.y(new Error(`Source "${x.source}" as specified by iconset "${h}" is not a "raster-array" source and cannot be used as an iconset source`)));D.partial=!1;const F=new CE(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 x=this.map._spriteFormat==="auto";var A,D;this._spriteRequest=(D=(F,z)=>{if(this._spriteRequest=null,F)x?this._loadSprite(h):this.fire(new i.y(F));else if(z){const H=new Map;for(const Y in z)H.set(i.I.from(Y),z[Y]);this.addImages(H)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new i.z("data",{dataType:"style"}))},i.bu((A=this.map._requestManager).transformRequest(A.normalizeIconsetURL(h),i.R.Iconset),(F,z)=>{if(F)return void D(F);const H={},Y=i.dg(new i.bt(z));for(const ae of Y.icons){const oe={version:1,pixelRatio:i.o.devicePixelRatio,content:aR(ae),stretchX:ae.metadata?iR(ae.metadata.stretch_x_areas):void 0,stretchY:ae.metadata?iR(ae.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:ae};H[ae.name]=oe}D(null,H)}))}_validateLayer(h){const x=this.getOwnSource(h.source);if(!x)return;const A=h.sourceLayer;A&&(x.type==="geojson"||x.vectorLayerIds&&x.vectorLayerIds.indexOf(A)===-1)&&this.fire(new i.y(new Error(`Source layer "${A}" does not exist on source "${x.id}" as specified by style layer "${h.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const h in this._sourceCaches)if(!this._sourceCaches[h].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(const{style:h}of this.fragments)if(!h.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((h,x)=>{const A=this.fragments[x];return A&&A.style&&(h.data=A.style.serialize()),h})}_serializeSources(){const h={};for(const x in this._sourceCaches){const A=this._sourceCaches[x].getSource();h[A.id]||(h[A.id]=A.serialize())}return h}_serializeLayers(h){const x=[];for(const A of h){const D=this._layers[A];D&&D.type!=="custom"&&x.push(D.serialize())}return x}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions()||this.hasFogTransition()||this.hasSnowTransition()||this.hasRainTransition())return!0;for(const h in this._sourceCaches)if(this._sourceCaches[h].hasTransition())return!0;for(const h in this._layers)if(this._layers[h].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(const h in this._mergedLayers){const x=this._mergedLayers[h];if(x._transitionablePaint&&x._transitionablePaint._values){const A=x._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 x=this.getOwnLayer(h);if(x)return x;this.fire(new i.y(new Error(`The layer '${h}' does not exist in the map's style.`)))}_checkSource(h){const x=this.getOwnSource(h);if(x)return x;this.fire(new i.y(new Error(`The source '${h}' does not exist in the map's style.`)))}precompilePrograms(h,x){const 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 H=h.getDefaultProgramParams(z,x.zoom,this._styleColorTheme.lut);H&&(A.style=this,this.fog&&(A._fogVisible=!0,H.overrideFog=!0,A.getOrCreateProgram(z,H)),A._fogVisible=!1,H.overrideFog=!1,A.getOrCreateProgram(z,H),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(H.overrideRtt=!0,A.getOrCreateProgram(z,H)))}}}update(h){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(h),this.directionalLight&&this.directionalLight.recalculate(h);const x=this.calculateLightsBrightness();h.brightness=x||0,x!==this._brightness&&(this._brightness=x,this.dispatcher.broadcast("setBrightness",x)),h.worldview!==this._worldview&&(this._worldview=h.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const A=this._changes.isDirty();let D=!1;if(this._changes.isDirty()){const H=this._changes.getLayerUpdatesByScope();for(const Y in H){const{updatedIds:ae,removedIds:oe}=H[Y];(ae||oe)&&(this._updateWorkerLayers(Y,ae,oe),D=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(h),this.light&&this.light.updateTransitions(h),this.ambientLight&&this.ambientLight.updateTransitions(h),this.directionalLight&&this.directionalLight.updateTransitions(h),this.fog&&this.fog.updateTransitions(h),this.snow&&this.snow.updateTransitions(h),this.rain&&this.rain.updateTransitions(h),this._changes.reset()}const F={};for(const H in this._mergedSourceCaches){const Y=this._mergedSourceCaches[H];F[H]=Y.used,Y.used=!1,Y.tileCoverLift=0}for(const H of this._mergedOrder){const Y=this._mergedLayers[H];if(Y.visibility!=="none"&&Y.recalculate(h,this._availableImages),!Y.isHidden(h.zoom)){const ae=this.getLayerSourceCache(Y);ae&&(ae.used=!0,ae.tileCoverLift=Math.max(ae.tileCoverLift,Y.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(Y,h)}):this.precompilePrograms(Y,h))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&D&&this.mergeLayers();const z=this.imageManager.getPendingImageProviders();for(const H of z)H.sourceCache.used=!0;for(const H in F){const Y=this._mergedSourceCaches[H];F[H]!==Y.used&&Y.getSource().fire(new i.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:Y.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 x of h){const A=x.resolvePendingRequests(),D=this.getFragmentStyle(x.scope);D&&D.addImages(A)}}_updateTilesForChangedImages(){const h={};for(const x in this._mergedSourceCaches){const A=this._mergedSourceCaches[x].getSource().scope;h[A]=h[A]||this._changes.getUpdatedImages(A),h[A].length!==0&&this._mergedSourceCaches[x].reloadTilesForDependencies(["icons","patterns"],h[A])}for(const x in h)this._changes.resetUpdatedImages(x)}_updateWorkerLayers(h,x,A){const D=this.getFragmentStyle(h);D&&this.dispatcher.broadcast("updateLayers",{layers:x?D._serializeLayers(x):[],scope:h,removedIds:A||[],options:D.options})}setState(h,x){if(this._checkLoaded(),xy(this,Zt(h)))return!1;(h=i.dp(h)).layers=q0(h.layers);const A=function(z,H){if(!z)return[{command:Sa.setStyle,args:[H]}];let Y=[];try{if(!i.by(z.version,H.version))return[{command:Sa.setStyle,args:[H]}];if(i.by(z.center,H.center)||Y.push({command:Sa.setCenter,args:[H.center]}),i.by(z.zoom,H.zoom)||Y.push({command:Sa.setZoom,args:[H.zoom]}),i.by(z.bearing,H.bearing)||Y.push({command:Sa.setBearing,args:[H.bearing]}),i.by(z.pitch,H.pitch)||Y.push({command:Sa.setPitch,args:[H.pitch]}),i.by(z.sprite,H.sprite)||Y.push({command:Sa.setSprite,args:[H.sprite]}),i.by(z.glyphs,H.glyphs)||Y.push({command:Sa.setGlyphs,args:[H.glyphs]}),i.by(z.imports,H.imports)||function(xe=[],Pe=[],Ce){Pe=Pe||[];const Ve=(xe=xe||[]).map(U0),Be=Pe.map(U0),et=xe.reduce(V0,{}),ut=Pe.reduce(V0,{}),st=Ve.slice();let Mt,yt,kt,gt;for(Mt=0,yt=0;Mt{xe.source&&ae[xe.source]?Y.push({command:Sa.removeLayer,args:[xe.id]}):ge.push(xe)});let fe=z.terrain;fe&&ae[fe.source]&&(Y.push({command:Sa.setTerrain,args:[void 0]}),fe=void 0),Y=Y.concat(oe),i.by(fe,H.terrain)||Y.push({command:Sa.setTerrain,args:[H.terrain]}),function(xe,Pe,Ce){Pe=Pe||[];const Ve=(xe=xe||[]).map(U0),Be=Pe.map(U0),et=xe.reduce(V0,{}),ut=Pe.reduce(V0,{}),st=Ve.slice(),Mt=Object.create(null);let yt,kt,gt,mt,Pt,Ht,Ut;for(yt=0,kt=0;yt!(z.command in lR));if(A.length===0)return!1;const D=A.filter(z=>!(z.command in oR));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))}),x&&Promise.all(F).then(x).catch(x),this.stylesheet=h,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(h){if(h.size===0)return this;for(const[x,A]of h.entries()){if(this.getImage(x))return this.fire(new i.y(new Error(`An image with the name "${x.name}" already exists.`)));this.imageManager.addImage(x,this.scope,A),this._changes.updateImage(x,this.scope)}return this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this}addImage(h,x){return this.getImage(h)?this.fire(new i.y(new Error(`An image with the name "${h.name}" already exists.`))):(this.imageManager.addImage(h,this.scope,x),this._changes.updateImage(h,this.scope),this._updateWorkerImages(),this.fire(new i.z("data",{dataType:"style"})),this)}updateImage(h,x,A=!1){this.imageManager.updateImage(h,this.scope,x),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,x,A={}){return this._checkLoaded(),this._validate(ve,`models.${h}`,x,null,A)||(this.modelManager.addModel(h,x,this.getActualScope()),this.fire(new i.z("data",{dataType:"style"}))),this}hasModel(h){return this.modelManager.hasModel(h,this.getActualScope())}removeModel(h){return this.hasModel(h)?(this.modelManager.removeModel(h,this.getActualScope(),!1,!0),this.fire(new i.z("data",{dataType:"style"})),this):this.fire(new i.y(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(h,x,A={}){if(this._checkLoaded(),this.getOwnSource(h)!==void 0)throw new Error(`There is already a source with ID "${h}".`);if(!x.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(x).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(x.type)>=0&&this._validate($r,`sources.${h}`,x,null,A))return;this.map&&this.map._collectResourceTiming&&(x.collectResourceTiming=!0);const D=Pl(h,x,this.dispatcher,this);D.scope=this.scope,D.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(D.id),source:D.serialize(),sourceId:D.id}));const F=z=>{const H=(z?"symbol:":"other:")+D.id,Y=i.B(H,this.scope),ae=this._sourceCaches[H]=new jl(Y,D,z);(z?this._symbolSourceCaches:this._otherSourceCaches)[D.id]=ae,ae.onAdd(this.map)};F(!1),x.type!=="vector"&&x.type!=="geojson"||F(!0),D.onAdd&&D.onAdd(this.map),A.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(h){this._checkLoaded();const x=this.getOwnSource(h);if(!x)throw new Error("There is no source with this ID");for(const D in this._layers)if(this._layers[D].source===h)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while layer "${D}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===h)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const D=Object.entries(this.stylesheet.iconsets).find(([F,z])=>z.type==="source"&&z.source===h);if(D)return this.fire(new i.y(new Error(`Source "${h}" cannot be removed while iconset "${D[0]}" is using it.`)))}const 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(),x.setEventedParent(null),x.onRemove&&x.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(h,x){this._checkLoaded(),this.getOwnSource(h).setData(x),this._changes.setDirty()}getOwnSource(h){const x=this.getOwnSourceCache(h);return x&&x.getSource()}getOwnSources(){const h=[];for(const x in this._otherSourceCaches){const A=this.getOwnSourceCache(x);A&&h.push(A.getSource())}return h}areTilesLoaded(){const h=this._mergedSourceCaches;for(const x in h){const A=h[x]._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 x=this._getTransitionParameters();for(const F of h){if(this._validate(an,"lights",F))return;switch(F.type){case"ambient":if(this.ambientLight){const z=this.ambientLight;z.set(F),z.updateTransitions(x)}else this.ambientLight=new Na(F,Qo||(Qo=new i.a9({color:new i.aa(i.a6.properties_light_ambient.color),"color-use-theme":new i.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new i.aa(i.a6.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const z=this.directionalLight;z.set(F),z.updateTransitions(x)}else this.directionalLight=new Na(F,Qa||(Qa=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(x,{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,x=this.ambientLight;if(!h||!x)return;const A=fe=>.2126*(fe[0]<=.03928?fe[0]/12.92:Math.pow((fe[0]+.055)/1.055,2.4))+.7152*(fe[1]<=.03928?fe[1]/12.92:Math.pow((fe[1]+.055)/1.055,2.4))+.0722*(fe[2]<=.03928?fe[2]/12.92:Math.pow((fe[2]+.055)/1.055,2.4)),D=h.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),F=h.properties.get("intensity"),z=h.properties.get("direction"),H=1-i.d4(z.x,z.y,z.z)[2]/90,Y=A(D)*F*H,ae=x.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),oe=x.properties.get("intensity"),ge=A(ae)*oe;return Number(((Y+ge)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const h=[];return this.directionalLight&&h.push(this.directionalLight.get()),this.ambientLight&&h.push(this.ambientLight.get()),h}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(h){if(h==null||h===""&&this.isRootStyle())return this;if(i.dr(h)){const x=i.ds(h),A=this.fragments.find(({id:F})=>F===x);if(!A)return;const D=i.dq(h);return A.style.getFragmentStyle(D)}{const x=this.fragments.find(({id:A})=>A===h);return x?x.style:void 0}}setFeaturesetSelectors(h){if(!h)return;const x={},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 Y=this.getOwnLayer(z.layer);if(!Y){i.w(`Layer is undefined for selector: ${z.layer}`);continue}const ae=A(Y.source,Y.sourceLayer);if(ae in x&&x[ae]!==z.featureNamespace){i.w(`"featureNamespace ${z.featureNamespace} of featureset ${D}'s selector is not associated to the same source, skip this selector`);continue}x[ae]=z.featureNamespace}let H;if(z.properties)for(const Y in z.properties){const ae=i.U(z.properties[Y]);ae.result==="success"&&(H=H||{},H[Y]=ae.value)}F.push({layerId:z.layer,namespace:z.featureNamespace,properties:H,uniqueFeatureID:z._uniqueFeatureID})}}}getFeaturesetDescriptors(h){const x=this.getFragmentStyle(h);if(!x||!x.stylesheet.featuresets)return[];const A=[];for(const D in x.stylesheet.featuresets)A.push({featuresetId:D,importId:x.scope?x.scope:void 0});return A}getFeaturesetLayers(h,x){const A=this.getFragmentStyle(x),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 H=A.getOwnLayer(z.layer);H&&F.push(H)}return F}getConfigProperty(h,x){const A=this.getFragmentStyle(h);if(!A)return null;const D=i.B(x,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,x){const A=i.B(h,x);return this._mergedIndoor[A]}setIndoorData(h,x){this.map.indoor.setIndoorData(x)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(h,x,A){const D=this.getFragmentStyle(h);if(!D)return;const F=D.stylesheet.schema;if(!F||!F[x])return;const z=i.U(A);if(z.result!=="success")return void xy(this,z.value);const H=z.value.expression,Y=i.B(x,D.scope),ae=D.options.get(Y);if(!ae)return;let oe;const{minValue:ge,maxValue:fe,stepValue:xe,type:Pe,values:Ce}=F[x],Ve=i.U(F[x].default);Ve.result==="success"&&(oe=Ve.value.expression),oe?(this.options.set(Y,Object.assign({},ae,{value:H,default:oe,minValue:ge,maxValue:fe,stepValue:xe,type:Pe,values:Ce})),this.updateConfigDependencies(x)):this.fire(new i.y(new Error(`No schema defined for the config option "${x}" in the "${h}" fragment.`)))}getConfig(h){const x=this.getFragmentStyle(h);if(!x)return null;const A=x.stylesheet.schema;if(!A)return null;const D={};for(const F in A){const z=i.B(F,x.scope),H=x.options.get(z),Y=H?H.value||H.default:null;D[F]=Y?Y.serialize():null}return D}setConfig(h,x){const A=this.getFragmentStyle(h);A&&(A.updateConfig(x,A.stylesheet.schema),this.updateConfigDependencies())}getSchema(h){const x=this.getFragmentStyle(h);return x?x.stylesheet.schema:null}setSchema(h,x){const A=this.getFragmentStyle(h);A&&(A.stylesheet.schema=x,A.updateConfig(A._config,x),this.updateConfigDependencies())}updateConfig(h,x){if(this._config=h,h||x)if(x)for(const A in x){let D,F;const z=i.U(x[A].default);if(z.result==="success"&&(D=z.value.expression),h&&h[A]!==void 0){const fe=i.U(h[A]);fe.result==="success"&&(F=fe.value.expression)}const{minValue:H,maxValue:Y,stepValue:ae,type:oe,values:ge}=x[A];if(D){const fe=i.B(A,this.scope);this.options.set(fe,{default:D,value:F,minValue:H,maxValue:Y,stepValue:ae,type:oe,values:ge})}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,x=()=>!0){for(const A of h){const D=this.getLayer(A);D&&x(D)&&(D.possiblyEvaluateVisibility(),this._updateLayer(D),this._changes.setDirty())}}updateConfigDependencies(h){this._updateLayers(this._configDependentLayers,x=>!h||x.expressionDependencies.configDependencies.has(h)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(x=>{const A=x._styleColorTheme.colorThemeOverride?x._styleColorTheme.colorThemeOverride:x._styleColorTheme.colorTheme;if(A){const D=x._evaluateColorThemeData(A);(!x._styleColorTheme.lut&&D!==""||x._styleColorTheme.lut&&D!==x._styleColorTheme.lut.data)&&x.setColorTheme(A)}}),this._changes.setDirty()}addLayer(h,x,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(xy(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(rl,`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 H=this._order.length;if(x){const ge=this._order.indexOf(x);if(ge===-1)return void this.fire(new i.y(new Error(`Layer with id "${x}" does not exist on this map.`)));F.slot===this._layers[x].slot?H=ge:i.w(`Layer with id "${x}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(H,0,D),this._layerOrderChanged=!0,this._layers[D]=F;const Y=this.getOwnLayerSourceCache(F),ae=!!this.directionalLight&&this.directionalLight.shadowsEnabled();Y&&F.canCastShadows()&&ae&&(Y.castsShadows=!0);const oe=this._changes.getRemovedLayer(F);if(oe&&F.source&&Y&&F.type!=="custom"){this._changes.discardLayerRemoval(F);const ge=i.B(F.source,F.scope);oe.type!==F.type?this._changes.updateSourceCache(ge,"clear"):(this._changes.updateSourceCache(ge,"reload"),Y.pause())}this._updateLayer(F),F.onAdd&&F.onAdd(this.map),F.scope=this.scope,this.mergeLayers()}moveLayer(h,x){this._checkLoaded();const A=this._checkLayer(h);if(!A||h===x)return;const D=this._order.indexOf(h);this._order.splice(D,1);let F=this._order.length;if(x){const z=this._order.indexOf(x);if(z===-1)return void this.fire(new i.y(new Error(`Layer with id "${x}" does not exist on this map.`)));A.slot===this._layers[x].slot?F=z:i.w(`Layer with id "${x}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(F,0,h),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(h){this._checkLoaded();const x=this._checkLayer(h);if(!x)return;x.setEventedParent(null);const A=this._order.indexOf(h);this._order.splice(A,1),delete this._layers[h],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(x.fqid),this._indoorDependentLayers.delete(x.fqid),this._changes.removeLayer(x);const D=this.getOwnLayerSourceCache(x);if(D&&D.castsShadows){let F=!1;for(const z in this._layers)if(this._layers[z].source===x.source&&this._layers[z].canCastShadows()){F=!0;break}D.castsShadows=F}x.onRemove&&x.onRemove(this.map),this.mergeLayers()}getOwnLayer(h){return this._layers[h]}hasLayer(h){return h in this._mergedLayers}hasLayerType(h){for(const x in this._layers)if(this._layers[x].type===h)return!0;return!1}setLayerZoomRange(h,x,A){this._checkLoaded();const D=this._checkLayer(h);D&&(D.minzoom===x&&D.maxzoom===A||(x!=null&&(D.minzoom=x),A!=null&&(D.maxzoom=A),this._updateLayer(D)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(h,x){this._checkLoaded();const A=this._checkLayer(h);A&&A.slot!==x&&(A.slot=x,this._updateLayer(A))}setFilter(h,x,A={}){this._checkLoaded();const D=this._checkLayer(h);if(D&&!i.by(D.filter,x))return x==null?(D.filter=void 0,void this._updateLayer(D)):void(this._validate(Ni,`layers.${D.id}.filter`,x,{layerType:D.type},A)||(D.filter=i.dp(x),this._updateLayer(D)))}getFilter(h){const x=this._checkLayer(h);if(x)return i.dp(x.filter)}setLayoutProperty(h,x,A,D={}){this._checkLoaded();const F=this._checkLayer(h);if(F&&!i.by(F.getLayoutProperty(x),A)){if(A!=null&&(!D||D.validate!==!1)&&xy(F,Vt.call(Zt,{key:`layers.${h}.layout.${x}`,layerType:F.type,objectKey:x,value:A,styleSpec:i.a6,style:{glyphs:!0,sprite:!0}})))return;F.setLayoutProperty(x,A),F.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F.fqid),F.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F.fqid),this._updateLayer(F)}}setLayerProperty(h,x,A,D={}){this._checkLoaded();const F=this._checkLayer(h);F&&(x==="appearances"?(F.setAppearances(A),this._changes.setDirty()):F.isPaintProperty(x)?this.setPaintProperty(h,x,A,D):this.setLayoutProperty(h,x,A,D))}getLayoutProperty(h,x){const A=this._checkLayer(h);if(A)return A.getLayoutProperty(x)}setPaintProperty(h,x,A,D={}){this._checkLoaded();const F=this._checkLayer(h);if(!F||i.by(F.getPaintProperty(x),A)||A!=null&&(!D||D.validate!==!1)&&xy(F,sc.call(Zt,{key:`layers.${h}.paint.${x}`,layerType:F.type,objectKey:x,value:A,styleSpec:i.a6})))return;const z=F.setPaintProperty(x,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,x){const A=this._checkLayer(h);if(A)return A.getPaintProperty(x)}setFeatureState(h,x){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:Y,importId:ae}=h.target,oe=this.getFragmentStyle(ae),ge=oe.getFeaturesetLayers(Y);for(const{source:fe,sourceLayer:xe}of ge)oe.setFeatureState({id:h.id,source:fe,sourceLayer:xe},x)}else if("layerId"in h.target){const{layerId:Y}=h.target,ae=this.getLayer(Y);this.setFeatureState({id:h.id,source:ae.source,sourceLayer:ae.sourceLayer},x)}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 H=this.getOwnSourceCaches(A);for(const Y of H)Y.setFeatureState(D,h.id,x)}removeFeatureState(h,x){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:Y,importId:ae}=h.target,oe=this.getFragmentStyle(ae),ge=oe.getFeaturesetLayers(Y);for(const{source:fe,sourceLayer:xe}of ge)oe.removeFeatureState({id:h.id,source:fe,sourceLayer:xe},x)}else if("layerId"in h.target){const{layerId:Y}=h.target,ae=this.getLayer(Y);this.removeFeatureState({id:h.id,source:ae.source,sourceLayer:ae.sourceLayer},x)}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(x&&typeof h.id!="string"&&typeof h.id!="number")return void this.fire(new i.y(new Error("A feature id is required to remove its specific state property.")));const H=this.getOwnSourceCaches(A);for(const Y of H)Y.removeFeatureState(z,h.id,x)}getFeatureState(h){if(this._checkLoaded(),"target"in h){let F;if("featuresetId"in h.target){const{featuresetId:z,importId:H}=h.target,Y=this.getFragmentStyle(H),ae=Y.getFeaturesetLayers(z);for(const{source:oe,sourceLayer:ge}of ae){const fe=Y.getFeatureState({id:h.id,source:oe,sourceLayer:ge});if(fe&&!F)F=fe;else if(!i.by(F,fe))return void this.fire(new i.y(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in h.target){const{layerId:z}=h.target,H=this.getLayer(z);F=this.getFeatureState({id:h.id,source:H.source,sourceLayer:H.sourceLayer})}return F}const x=h.source,A=h.sourceLayer,D=this._checkSource(x);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(x)[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(),x=h&&this.terrain&&this.terrain.scope===this.scope?h:this.stylesheet.terrain;return i.dv({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:x,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},A=>A!==void 0)}_updateFilteredLayers(h){for(const x of Object.values(this._mergedLayers))h(x)&&this._updateLayer(x)}_updateLayer(h){this._changes.updateLayer(h);const x=this.getLayerSourceCache(h),A=i.B(h.source,h.scope),D=this._changes.getUpdatedSourceCaches();h.source&&!D[A]&&x&&x.getSource().type!=="raster"&&(this._changes.updateSourceCache(A,"reload"),x.pause()),h.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(h){const x=H=>this._mergedLayers[H].is3D(!!this.terrain),A=this.order,D={},F=[];for(let H=A.length-1;H>=0;H--){const Y=A[H];if(x(Y)){D[Y]=H;for(const ae of h){const oe=ae[Y];if(oe)for(const ge of oe)F.push(ge)}}}F.sort((H,Y)=>Y.intersectionZ-H.intersectionZ);const z=[];for(let H=A.length-1;H>=0;H--){const Y=A[H];if(x(Y))for(let ae=F.length-1;ae>=0;ae--){const oe=F[ae].feature;if(oe.layer&&D[oe.layer.id]{if(vC.has(oe.type))return;const ge=this.getOwnLayerSourceCache(oe),fe=F[ge.id]=F[ge.id]||{sourceCache:ge,layers:{},has3DLayers:!1};oe.is3D(!!this.terrain)&&(fe.has3DLayers=!0),fe.layers[oe.fqid]=fe.layers[oe.fqid]||{styleLayer:oe,targets:[]},fe.layers[oe.fqid].targets.push({filter:D})};if(x&&x.layers){if(!Array.isArray(x.layers))return this.fire(new i.y(new Error("parameters.layers must be an Array."))),[];for(const oe of x.layers){const ge=this._layers[oe];if(!ge)return this.fire(new i.y(new Error(`The layer '${oe}' does not exist in the map's style and cannot be queried for features.`))),[];z(ge)}}else for(const oe in this._layers)z(this._layers[oe]);const H=this._queryRenderedFeatures(h,F,A),Y=this._flattenAndSortRenderedFeatures(H),ae=[];for(const oe of Y)i.dw(oe.layer.id)===this.scope&&ae.push(oe);return ae}queryRenderedFeatureset(h,x,A){let D;x&&!Array.isArray(x)&&x.filter&&(this._validate(Ni,"queryRenderedFeatures.filter",x.filter,null,x),D=i.b6(x.filter));const F="mock",z=[];if(x&&x.target)z.push(Object.assign({},x,{targetId:F,filter:D}));else{const oe=this.getFeaturesetDescriptors();for(const ge of oe)z.push({targetId:F,filter:D,target:ge});for(const{style:ge}of this.fragments){const fe=ge.getFeaturesetDescriptors();for(const xe of fe)z.push({targetId:F,filter:D,target:xe})}}const H=this.queryRenderedTargets(h,z,A),Y=[],ae=new Set;for(const oe of H)for(const ge of oe.variants[F])uy(ge,oe,ae)||Y.push(new i.dx(oe,ge));return Y}queryRenderedTargets(h,x,A){const D={},F=(H,Y,ae,oe)=>{const ge=D[Y.id]=D[Y.id]||{sourceCache:Y,layers:{},has3DLayers:!1};if(ge.layers[H.fqid]=ge.layers[H.fqid]||{styleLayer:H,targets:[]},H.is3D(!!this.terrain)&&(ge.has3DLayers=!0),!oe)return ae.uniqueFeatureID=!1,void ge.layers[H.fqid].targets.push(ae);ge.layers[H.fqid].targets.push(Object.assign({},ae,{namespace:oe.namespace,properties:oe.properties,uniqueFeatureID:oe.uniqueFeatureID}))};for(const H of x)if("featuresetId"in H.target){const{featuresetId:Y,importId:ae}=H.target,oe=this.getFragmentStyle(ae);if(!oe||!oe._featuresetSelectors)continue;const ge=oe._featuresetSelectors[Y];if(!ge){this.fire(new i.y(new Error(`The featureset '${Y}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const fe of ge){const xe=oe.getOwnLayer(fe.layerId);xe&&!vC.has(xe.type)&&F(xe,oe.getOwnLayerSourceCache(xe),H,fe)}}else if("layerId"in H.target){const{layerId:Y}=H.target,ae=this.getLayer(Y);if(!ae||vC.has(ae.type))continue;F(ae,this.getLayerSourceCache(ae),H)}const z=this._queryRenderedFeatures(h,D,A);return this._flattenAndSortRenderedFeatures(z)}_queryRenderedFeatures(h,x,A){const D=[],F=!!this.map._showQueryGeometry,z=ao.createFromScreenPoints(h,A);for(const H in x){const Y=D1(z,x[H],this._availableImages,A,F);Object.keys(Y).length&&D.push(Y)}if(this.placement)for(const H in x){if(!x[H].sourceCache._onlySymbols)continue;const Y=O1(z.screenGeometry,x[H],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(Y).length&&D.push(Y)}return D}querySourceFeatures(h,x){const A=x&&x.filter;A&&this._validate(Ni,"querySourceFeatures.filter",A,null,x);let D=[];const F=this.getOwnSourceCaches(h);for(const z of F)D=D.concat(R1(z,x));return D}addSourceType(h,x,A){return Wm.getSourceType(h)?A(new Error(`A source type called "${h}" already exists.`)):(Wm.setSourceType(h,x),x.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:h,url:x.workerSourceURL},A):A(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(h,x,A={}){this._checkLoaded();const D=this.light.getLight();let F=!1;for(const H in h)if(!i.by(h[H],D[H])){F=!0;break}if(!F)return;const z=this._getTransitionParameters();this.light.setLight(h,x,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,x=1){if(this._checkLoaded(),!h)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),x===0&&delete this.terrain,h===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let A=h;const D=!("source"in h)||h.source==null;if(x===1){if(this.disableElevatedTerrain)return;if("source"in A&&typeof A.source=="object"){const H="terrain-dem-src";this.addSource(H,A.source),A=i.dp(A),A=Object.assign(A,{source:H})}const F=Object.assign({},A),z={};if(this.terrain&&D){F.source=this.terrain.get().source;const H=this.terrain?this.getFragmentStyle(this.terrain.scope):null;H&&(z.style=H.serialize())}if(this._validate(Ha,"terrain",F,z))return}if(!this.terrain||this.terrain.scope!==this.scope&&!D||this.terrain&&x!==this.terrain.drapeRenderMode){if(!A)return;this._createTerrain(A,x),this.fire(new i.z("data",{dataType:"style"}))}else{const F=this.terrain,z=F.get();for(const H of Object.keys(i.a6.terrain))!A.hasOwnProperty(H)&&i.a6.terrain[H].default&&(A[H]=i.a6.terrain[H].default);for(const H in h)if(!i.by(h[H],z[H])){F.set(h,this.options),this.stylesheet.terrain=h;const Y=this._getTransitionParameters({duration:0});F.updateTransitions(Y),this.fire(new i.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(h){const x=this.fog=new jn(h,this.map.transform,this.scope,this.options);this.stylesheet.fog=x.get();const A=this._getTransitionParameters({duration:0});x.updateTransitions(A)}_createSnow(h){const x=this.snow=new nl(h,this.map.transform,this.scope,this.options);this.stylesheet.snow=x.get();const A=this._getTransitionParameters({duration:0});x.updateTransitions(A)}_createRain(h){const x=this.rain=new no(h,this.map.transform,this.scope,this.options);this.stylesheet.rain=x.get();const A=this._getTransitionParameters({duration:0});x.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 x=this.fog;if(!i.by(x.get(),h)){x.set(h,this.options),this.stylesheet.fog=x.get();const A=this._getTransitionParameters({duration:0});x.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 x=this.snow;if(!i.by(x.get(),h)){x.set(h,this.options),this.stylesheet.snow=x.get();const A=this._getTransitionParameters({duration:0});x.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 x=this.rain;if(!i.by(x.get(),h)){x.set(h,this.options),this.stylesheet.rain=x.get();const A=this._getTransitionParameters({duration:0});x.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()},x=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!x)return this._styleColorTheme.lut=null,void h();const A=this._evaluateColorThemeData(x);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,x){const A=this.getFragmentStyle(h);A&&(A._styleColorTheme.colorThemeOverride=x,A._reloadColorTheme())}_getTransitionParameters(h){return{now:i.o.now(),transition:Object.assign(this.transition,h)}}updateDrapeFirstLayers(){if(!this.terrain)return;const h=[],x=[];for(const A of this._mergedOrder)this.isLayerDraped(this._mergedLayers[A])?h.push(A):x.push(A);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...h),this._drapedFirstOrder.push(...x)}_createTerrain(h,x){const A=this.terrain=new $t(h,x,this.scope,this.options,this.map.getWorldview());x===1&&(this.stylesheet.terrain=h),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const D=this._getTransitionParameters({duration:0});A.updateTransitions(D)}_force3DLayerUpdate(){for(const h in this._layers){const x=this._layers[h];x.type==="fill-extrusion"&&this._updateLayer(x)}}_forceSymbolLayerUpdate(){for(const h in this._layers){const x=this._layers[h];x.type==="symbol"&&this._updateLayer(x)}}_validate(h,x,A,D,F={}){if(F&&F.validate===!1)return!1;const z=Object.assign({},this.serialize());return xy(this,h.call(Zt,Object.assign({key:x,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 x=this.getSourceCaches(h);for(const A of x)A.clearTiles()}clearSources(){for(const h in this._mergedSourceCaches)this._mergedSourceCaches[h].clearTiles()}clearLayers(){for(const h in this._mergedLayers){const x=this._mergedLayers[h];x._clear&&x._clear()}}reloadSource(h){const x=this.getSourceCaches(h);for(const A of x)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 x;this.directionalLight&&(x=W2(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],H=D.has(z._source.id);A.has(z._source.id)&&(z._source.reparseOverscaled=!1),z.update(h,void 0,void 0,x,H)}}_generateCollisionBoxes(){for(const h in this._sourceCaches){const x=this._sourceCaches[h];x.resume(),x.reload()}}_updatePlacement(h,x,A,D,F,z,H=!1){let Y=!1,ae=!1;const oe={},ge={};for(const Ce of this._mergedOrder){const Ve=this._mergedLayers[Ce];if(Ve.type!=="symbol")continue;const Be=i.B(Ve.source,Ve.scope);let et=oe[Be];if(!et){const st=this.getLayerSourceCache(Ve);if(!st)continue;const Mt=st.getRenderableIds(!0).map(yt=>st.getTileByID(yt));ge[Be]=Mt.slice(),et=oe[Be]=Mt.sort((yt,kt)=>kt.tileID.overscaledZ-yt.tileID.overscaledZ||(yt.tileID.isLessThan(kt.tileID)?-1:1))}const ut=this.crossTileSymbolIndex.addLayer(Ve,et,x.center.lng,x.projection);Y=Y||ut}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),H=H||this._layerOrderChanged,this._layerOrderChanged&&this.fire(new i.z("neworder"));const fe=!!(this.placement&&!x.equals(this.placement.transform)),xe=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!z||this.placement.lastReplacementSourceUpdateTime!==z.updateTime)),Pe=(fe||xe||Y||this.placement&&this.placement.isStale())&&D===0;if((H||!this.pauseablePlacement||Pe||D!==0&&this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),x.zoom))&&(this.pauseablePlacement=new vc(x,this._mergedOrder,H||D===0,A,D,F,this.placement,this.fog&&x.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,oe,ge,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.o.now()),ae=!0),Y&&this.pauseablePlacement.placement.setStale()),ae||Y){this._buildingIndex.onNewFrame(x.zoom);for(let Ce=0;CeF===h.id)!==-1)return void this.fire(new i.y(new Error(`Import with id '${h.id}' already exists in the map's style.`)));if(!x)return A.push(h),this._loadImports([h],!0);const D=A.findIndex(({id:F})=>F===x);return D===-1&&this.fire(new i.y(new Error(`Import with id "${x}" does not exist on this map.`))),this.stylesheet.imports=A.slice(0,D).concat(h).concat(A.slice(D)),this._loadImports([h],!0,x)}updateImport(h,x){this._checkLoaded();const A=this.stylesheet.imports||[],D=this.getImportIndex(h);return D===-1?this:typeof x=="string"?(this.setImportUrl(h,x),this):(x.url&&x.url!==A[D].url&&this.setImportUrl(h,x.url),i.by(x.config,A[D].config)||this.setImportConfig(h,x.config,x.data.schema),i.by(x.data,A[D].data)||this.setImportData(h,x.data),this)}moveImport(h,x){this._checkLoaded();let A=this.stylesheet.imports||[];const D=this.getImportIndex(h);if(D===-1)return this;const F=this.getImportIndex(x);if(F===-1)return this;const z=A[D],H=this.fragments[D];return A=A.filter(({id:Y})=>Y!==h),this.fragments=this.fragments.filter(({id:Y})=>Y!==h),this.stylesheet.imports=A.slice(0,F).concat(z).concat(A.slice(F)),this.fragments=this.fragments.slice(0,F).concat(H).concat(this.fragments.slice(F)),this.mergeLayers(),this}setImportUrl(h,x){this._checkLoaded();const A=this.stylesheet.imports||[],D=this.getImportIndex(h);if(D===-1)return this;A[D].url=x;const F=this.fragments[D];return F.style=this._createFragmentStyle(A[D]),F.style.on("style.import.load",()=>this.mergeAll()),F.style.loadURL(x),this}setImportData(h,x){this._checkLoaded();const A=this.getImportIndex(h),D=this.stylesheet.imports||[];return A===-1?this:x?(this.fragments[A].style.setState(x),this._reloadImports(),this):(delete D[A].data,this.setImportUrl(h,D[A].url))}setImportConfig(h,x,A){this._checkLoaded();const D=this.getImportIndex(h),F=this.stylesheet.imports||[];if(D===-1)return this;x?F[D].config=x:delete F[D].config;const z=this.fragments[D];A&&z.style.stylesheet&&(z.style.stylesheet.schema=A);const H=z.style.stylesheet&&z.style.stylesheet.schema;return z.config=x,z.style.updateConfig(x,H),this.updateConfigDependencies(),this}removeImport(h){this._checkLoaded();const x=this.stylesheet.imports||[],A=this.getImportIndex(h);A!==-1&&(x.splice(A,1),this.fragments[A].style._remove(),this.fragments.splice(A,1),this._reloadImports())}getImportIndex(h){const x=(this.stylesheet.imports||[]).findIndex(A=>A.id===h);return x===-1&&this.fire(new i.y(new Error(`Import '${h}' does not exist in the map's style and cannot be updated.`))),x}getLayer(h){return this._mergedLayers[h]}getSources(){const h=[];for(const x in this._mergedOtherSourceCaches){const A=this._mergedOtherSourceCaches[x];A&&h.push(A.getSource())}return h}getSource(h,x){const A=this.getSourceCache(h,x);return A&&A.getSource()}getLayerSource(h){const x=this.getLayerSourceCache(h);return x&&x.getSource()}getSourceCache(h,x){const A=i.B(h,x);return this._mergedOtherSourceCaches[A]}getLayerSourceCache(h){const x=i.B(h.source,h.scope);return h.type==="symbol"?this._mergedSymbolSourceCaches[x]:this._mergedOtherSourceCaches[x]}getSourceCaches(h){if(h==null)return Object.values(this._mergedSourceCaches);const x=[];return this._mergedOtherSourceCaches[h]&&x.push(this._mergedOtherSourceCaches[h]),this._mergedSymbolSourceCaches[h]&&x.push(this._mergedSymbolSourceCaches[h]),x}updateSourceCaches(){const h=this._changes.getUpdatedSourceCaches();for(const x in h){const A=h[x];A==="reload"?this.reloadSource(x):A==="clear"&&this.clearSource(x)}}updateLayers(h){const x=this._changes.getUpdatedPaintProperties();for(const A of x){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,x,A){this.imageManager.getImages(x.images,x.scope,A),this._updateTilesForChangedImages();const D=z=>{if(z){const H=x.images.map(Y=>i.I.toString(Y));z.setDependencies(x.tileID.key,x.type,H)}},F=i.B(x.source,x.scope);D(this._mergedOtherSourceCaches[F]),D(this._mergedSymbolSourceCaches[F]),x.images.some(z=>z.iconsetId)&&this.fire(new i.z("data",{dataType:"style"}))}rasterizeImages(h,x,A){this.imageManager.rasterizeImages(x,A)}getGlyphs(h,x,A){this.glyphManager.getGlyphs(x.stacks,A)}getResource(h,x,A){return i.dz(x,A)}getOwnSourceCache(h){return this._otherSourceCaches[h]}getOwnLayerSourceCache(h){return h.type==="symbol"?this._symbolSourceCaches[h.source]:this._otherSourceCaches[h.source]}getOwnSourceCaches(h){const x=[];return this._otherSourceCaches[h]&&x.push(this._otherSourceCaches[h]),this._symbolSourceCaches[h]&&x.push(this._symbolSourceCaches[h]),x}_isSourceCacheLoaded(h){const x=this.getOwnSourceCaches(h);return x.length===0?(this.fire(new i.y(new Error(`There is no source with ID '${h}'`))),!1):x.every(A=>A.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(h,x){if(!this._clipLayerPresent&&h.type!=="fill-extrusion"&&h.type!=="building")return!1;const A=h.type==="fill-extrusion"&&(h.sourceLayer==="building"||h.sourceLayer==="procedural_buildings"),D=h.type==="building";if(h.is3D(!!this.terrain)){if(A||D||x&&x.type==="batched-model"||h.type==="model")return!0}else if(h.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach(h=>{h.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Wm.getSourceType=function(M){return zm[M]},Wm.setSourceType=function(M,h){zm[M]=h},Wm.registerForPluginStateChange=i.dA;class cR extends i.E{constructor(h){super(),this._style=h,this._buildings={},this._activeFloors=new Set,this._activeFloorsVisible=!0,this._indoorState={selectedFloorId:null,lastActiveFloors:null,activeFloorsVisible:!0},i.aY(["_updateUI"],this)}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(h){h===this._selectedFloorId&&this._activeFloorsVisible||(this._selectedFloorId=h,this._activeFloorsVisible=!0,this._updateActiveFloors())}setActiveFloorsVisibility(h){this._activeFloorsVisible=h,this._updateActiveFloors(),this._updateIndoorSelector()}setIndoorData(h){for(const[x,A]of Object.entries(h.buildings))if(this._buildings[x])for(const D of A.floorIds)this._buildings[x].floors[D]||(this._buildings[x].floors[D]=A.floors[D]);else this._buildings[x]=A;for(const x of h.activeFloors)this._activeFloors.add(x);this._updateIndoorSelector()}getIndoorTileOptions(h,x){const A=this._style.getIndoorSourceLayers(h,x);return A&&this._indoorState?{sourceLayers:A,indoorState:this._indoorState}:null}_updateUI(h,x,A){const D=function(F,z,H,Y){let ae=null,oe=Number.MAX_SAFE_INTEGER;if(Y<16)return null;for(const[ge,fe]of Object.entries(F)){const xe=fe.center;if(xe){const Pe=z.distanceTo(i.aT.convert(xe));Pe({id:z,name:A.floors[z].name,zIndex:A.floors[z].zIndex})).sort((z,H)=>H.zIndex-z.zIndex);this.fire(new i.z("selector-update",{selectedFloorId:D,activeFloorsVisible:this._activeFloorsVisible,floors:F}))}_updateActiveFloors(){const h=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:h,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var V1=` #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`,H1=` #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;}`,ME=` #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`,_C="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;}",tm=` #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`,bC=`#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`,Qs=`#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`,TE=`#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`,wC=`#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;}`,jC=`#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`,AE=`#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 K2=/#include\s+"([^"]+)"/g,If=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,EE=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,K0=new Set(["ifdef","ifndef","elif","if","defined"]),Z0=new Set;_y(V1,Z0),_y(ME,Z0),_y(H1,Z0);const vy={"_prelude_fog.vertex.glsl":bC,"_prelude_terrain.vertex.glsl":tm,"_prelude_shadow.vertex.glsl":jC,"_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":Qs,"_prelude_shadow.fragment.glsl":AE,"_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":TE,"_prelude_raster_particle.glsl":wC},kC={};Ea("",tm),Ea(Qs,bC),Ea(AE,jC),Ea(TE,""),Ea(wC,"");const dR=Ea(H1,ME),NC=V1,xme=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",NC,dR.fragmentSource].join(` `),uR=["precision highp float;",NC,dR.vertexSource].join(` `);var PE={background:Ea(`#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:Ea(`#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:Ea(`#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:Ea(`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:Ea(`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:Ea(`#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:Ea("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:Ea(`#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:Ea(`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:Ea("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:Ea("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:Ea("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:Ea(`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:Ea(`#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:Ea(`#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:Ea(`#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:Ea(`#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:Ea(`#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:Ea(`#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:Ea(`#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:Ea(`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:Ea(`#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:Ea(`#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:Ea(`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:Ea(`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:Ea(`#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:Ea(`#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:Ea(`#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:Ea(`#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:Ea(`#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:Ea("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:Ea("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:Ea(`#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:Ea(`#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:Ea(`#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:Ea("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:Ea(`#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 }`,_C),skyboxGradient:Ea(`#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 }`,_C),skyboxCapture:Ea(` 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:Ea(`#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:Ea(`#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:Ea(`#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:Ea(`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:Ea(`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:Ea("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:Ea("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:Ea("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:Ea("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 _y(M,h){const x=M.split(` `);for(let A of x){if(A=A.trimStart(),A[0]!=="#"||!A.includes("if")||A.startsWith("#endif"))continue;const D=A.match(EE);if(D)for(const F of D)K0.has(F)||h.add(F)}}function Ea(M,h){const x=new Set,A=[],D=[];M=M.replace(K2,(z,H)=>(D.push(H),"")),h=h.replace(K2,(z,H)=>(A.push(H),""));let F=new Set(Z0);_y(M,F),_y(h,F);for(const z of[...A,...D])kC[z]||(kC[z]=new Set,_y(vy[z],kC[z])),F=new Set([...F,...kC[z]]);return{fragmentSource:M=M.replace(If,(z,H,Y,ae,oe)=>(x.add(oe),H==="define"?` #ifndef HAS_UNIFORM_u_${oe} in ${Y} ${ae} ${oe}; #else uniform ${Y} ${ae} u_${oe}; #endif `:H==="initialize"?` #ifdef HAS_UNIFORM_u_${oe} ${Y} ${ae} ${oe} = u_${oe}; #endif `:H==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${Y} ${ae} ${oe}; #endif `:H==="initialize-attribute"?"":void 0)),vertexSource:h=h.replace(If,(z,H,Y,ae,oe)=>{const ge=`MATERIAL_ATTRIBUTE_OFFSET_${oe}`,fe=ae==="float"?"vec2":ae,xe=`GET_ATTRIBUTE_${fe}(a_${oe}, materialInfo, ${ge})`,Pe=oe.match(/color/)?"color":fe;return H==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${Y} ${ae} a_${oe}; #endif `:x.has(oe)?H==="define"?` #ifndef HAS_UNIFORM_u_${oe} uniform lowp float u_${oe}_t; #if !defined(${ge}) in ${Y} ${fe} a_${oe}; #endif out ${Y} ${ae} ${oe}; #else uniform ${Y} ${ae} u_${oe}; #endif `:H==="initialize"?Pe==="vec4"?` #ifndef HAS_UNIFORM_u_${oe} ${oe} = a_${oe}; #else ${Y} ${ae} ${oe} = u_${oe}; #endif `:` #if !defined(HAS_UNIFORM_u_${oe}) #ifdef ${ge} ${oe} = unpack_mix_${Pe}(${xe}, u_${oe}_t); #else ${oe} = unpack_mix_${Pe}(a_${oe}, u_${oe}_t); #endif #else ${Y} ${ae} ${oe} = u_${oe}; #endif `:H==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${Y} ${ae} a_${oe}; out ${Y} ${ae} ${oe}; #endif `:H==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} ${oe} = a_${oe}; #endif `:void 0:H==="define"?` #ifndef HAS_UNIFORM_u_${oe} uniform lowp float u_${oe}_t; #if !defined(${ge}) in ${Y} ${fe} a_${oe}; #endif #else uniform ${Y} ${ae} u_${oe}; #endif `:H==="define-instanced"?Pe==="mat4"?` #ifdef INSTANCED_ARRAYS in vec4 a_${oe}0; in vec4 a_${oe}1; in vec4 a_${oe}2; in vec4 a_${oe}3; #else uniform ${Y} ${ae} u_${oe}; #endif `:` #ifdef INSTANCED_ARRAYS in ${Y} ${fe} a_${oe}; #else uniform ${Y} ${ae} u_${oe}; #endif `:H==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${oe} ${Y} ${ae} ${oe} = a_${oe}; #endif `:Pe==="vec4"?` #ifndef HAS_UNIFORM_u_${oe} #ifdef ${ge} ${Y} ${ae} ${oe} = ${xe}; #else ${Y} ${ae} ${oe} = a_${oe}; #endif #else ${Y} ${ae} ${oe} = u_${oe}; #endif `:` #ifndef HAS_UNIFORM_u_${oe} #ifdef ${ge} ${Y} ${ae} ${oe} = unpack_mix_${Pe}(${xe}, u_${oe}_t); #else ${Y} ${ae} ${oe} = unpack_mix_${Pe}(a_${oe}, u_${oe}_t); #endif #else ${Y} ${ae} ${oe} = u_${oe}; #endif `}),usedDefines:F,vertexIncludes:A,fragmentIncludes:D}}class yme{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(h,x,A,D,F,z,H,Y){this.context=h;let ae=this.boundPaintVertexBuffers.length!==D.length;for(let ge=0;!ae&&ge{const Mt=ut.paint.get("hillshade-shadow-color"),yt=ut.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",kt=ut.paint.get("hillshade-highlight-color"),gt=ut.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",mt=ut.paint.get("hillshade-accent-color"),Pt=ut.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Ht=ut.paint.get("hillshade-emissive-strength");let Ut=i.an(ut.paint.get("hillshade-illumination-direction"));if(ut.paint.get("hillshade-illumination-anchor")==="viewport")Ut-=Be.transform.angle;else if(Be.style&&Be.style.enable3dLights()&&Be.style.directionalLight){const ns=Be.style.directionalLight.properties.get("direction"),fs=i.d4(ns.x,ns.y,ns.z);Ut=i.an(fs[1])}const ts=!Be.options.moving;return{u_matrix:st||Be.transform.calculateProjMatrix(et.tileID.toUnwrapped(),ts),u_image:0,u_latrange:vme(0,et.tileID),u_light:[ut.paint.get("hillshade-exaggeration"),Ut],u_shadow:Mt.toPremultipliedRenderColor(yt?null:ut.lut),u_highlight:kt.toPremultipliedRenderColor(gt?null:ut.lut),u_emissive_strength:Ht,u_accent:mt.toPremultipliedRenderColor(Pt?null:ut.lut)}})(M,x,A,M.terrain?h.projMatrix:null);M.uploadCommonUniforms(H,fe,h.toUnwrapped());const{tileBoundsBuffer:Pe,tileBoundsIndexBuffer:Ce,tileBoundsSegments:Ve}=M.getTileBoundsBuffers(x);fe.draw(M,Y.TRIANGLES,D,F,z,nn.disabled,xe,A.id,Pe,Ce,Ve)}function IE(M,h,x){if(!h.needsDEMTextureUpload)return;const A=M.context,D=A.gl;A.pixelStoreUnpackPremultiplyAlpha.set(!1),h.demTexture=h.demTexture||M.getTileTexture(x.stride);const F=x.getPixels();h.demTexture?h.demTexture.update(F,{premultiply:!1}):h.demTexture=new i.T(A,F,D.R32F,{premultiply:!1}),h.needsDEMTextureUpload=!1}function bme(M,h,x){const A=M.context,D=A.gl;if(!h.dem)return;const F=h.dem;if(A.activeTexture.set(D.TEXTURE1),IE(M,h,F),!h.demTexture)return;h.demTexture.bind(D.NEAREST,D.CLAMP_TO_EDGE);const z=F.dim;A.activeTexture.set(D.TEXTURE0);let H=h.hillshadeFBO;if(!H){const fe=new i.T(A,{width:z,height:z,data:null},D.RGBA8);fe.bind(D.LINEAR,D.CLAMP_TO_EDGE),H=h.hillshadeFBO=A.createFramebuffer(z,z,1,"renderbuffer"),H.colorAttachment0.set(fe.texture)}A.bindFramebuffer.set(H.framebuffer),A.viewport.set([0,0,z,z]);const{tileBoundsBuffer:Y,tileBoundsIndexBuffer:ae,tileBoundsSegments:oe}=M.getMercatorTileBoundsBuffers(),ge=[];M.linearFloatFilteringSupported()&&ge.push("TERRAIN_DEM_FLOAT_FORMAT"),M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&ge.push("USE_MRT1"),M.getOrCreateProgram("hillshadePrepare",{defines:ge}).draw(M,D.TRIANGLES,Lr.disabled,dn.disabled,On.unblended,nn.disabled,((fe,xe)=>{const Pe=xe.stride,Ce=i.bC();return i.ce(Ce,0,i.al,-i.al,0,0,1),i.br(Ce,Ce,[0,-i.al,0]),{u_matrix:Ce,u_image:1,u_dimension:[Pe,Pe],u_zoom:fe.overscaledZ}})(h.tileID,F),x.id,Y,ae,oe),h.needsHillshadePrepare=!1}class lo{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 wme extends lo{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const x=this.current;(h.r!==x.r||h.g!==x.g||h.b!==x.b||h.a!==x.a||this.dirty)&&(this.gl.clearColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class hR extends lo{getDefault(){return 1}set(h){(h!==this.current||this.dirty)&&(this.gl.clearDepth(h),this.current=h,this.dirty=!1)}}class LE extends lo{getDefault(){return 0}set(h){(h!==this.current||this.dirty)&&(this.gl.clearStencil(h),this.current=h,this.dirty=!1)}}class SC extends lo{getDefault(){return[!0,!0,!0,!0]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||h[2]!==x[2]||h[3]!==x[3]||this.dirty)&&(this.gl.colorMask(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class DE extends lo{getDefault(){return!0}set(h){(h!==this.current||this.dirty)&&(this.gl.depthMask(h),this.current=h,this.dirty=!1)}}class Y0 extends lo{getDefault(){return 255}set(h){(h!==this.current||this.dirty)&&(this.gl.stencilMask(h),this.current=h,this.dirty=!1)}}class W1 extends lo{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(h){const x=this.current;(h.func!==x.func||h.ref!==x.ref||h.mask!==x.mask||this.dirty)&&(this.gl.stencilFunc(h.func,h.ref,h.mask),this.current=h,this.dirty=!1)}}class Z2 extends lo{getDefault(){const h=this.gl;return[h.KEEP,h.KEEP,h.KEEP]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||h[2]!==x[2]||this.dirty)&&(this.gl.stencilOp(h[0],h[1],h[2]),this.current=h,this.dirty=!1)}}class G1 extends lo{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;h?x.enable(x.STENCIL_TEST):x.disable(x.STENCIL_TEST),this.current=h,this.dirty=!1}}class mR extends lo{getDefault(){return[0,1]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||this.dirty)&&(this.gl.depthRange(h[0],h[1]),this.current=h,this.dirty=!1)}}class OE extends lo{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;h?x.enable(x.DEPTH_TEST):x.disable(x.DEPTH_TEST),this.current=h,this.dirty=!1}}class pR extends lo{getDefault(){return this.gl.LESS}set(h){(h!==this.current||this.dirty)&&(this.gl.depthFunc(h),this.current=h,this.dirty=!1)}}class K1 extends lo{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;h?x.enable(x.BLEND):x.disable(x.BLEND),this.current=h,this.dirty=!1}}class CC extends lo{getDefault(){const h=this.gl;return[h.ONE,h.ZERO,h.ONE,h.ZERO]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||h[2]!==x[2]||h[3]!==x[3]||this.dirty)&&(this.gl.blendFuncSeparate(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class MC extends lo{getDefault(){return i.ao.transparent.toNonPremultipliedRenderColor(null)}set(h){const x=this.current;(h.r!==x.r||h.g!==x.g||h.b!==x.b||h.a!==x.a||this.dirty)&&(this.gl.blendColor(h.r,h.g,h.b,h.a),this.current=h,this.dirty=!1)}}class RE extends lo{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 TC extends lo{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;h?x.enable(x.CULL_FACE):x.disable(x.CULL_FACE),this.current=h,this.dirty=!1}}class Y2 extends lo{getDefault(){return this.gl.BACK}set(h){(h!==this.current||this.dirty)&&(this.gl.cullFace(h),this.current=h,this.dirty=!1)}}class fR extends lo{getDefault(){return this.gl.CCW}set(h){(h!==this.current||this.dirty)&&(this.gl.frontFace(h),this.current=h,this.dirty=!1)}}let gR=class extends lo{getDefault(){return null}set(M){(M!==this.current||this.dirty)&&(this.gl.useProgram(M),this.current=M,this.dirty=!1)}};class xR extends lo{getDefault(){return this.gl.TEXTURE0}set(h){(h!==this.current||this.dirty)&&(this.gl.activeTexture(h),this.current=h,this.dirty=!1)}}class Z1 extends lo{getDefault(){const h=this.gl;return[0,0,h.drawingBufferWidth,h.drawingBufferHeight]}set(h){const x=this.current;(h[0]!==x[0]||h[1]!==x[1]||h[2]!==x[2]||h[3]!==x[3]||this.dirty)&&(this.gl.viewport(h[0],h[1],h[2],h[3]),this.current=h,this.dirty=!1)}}class yR extends lo{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.bindFramebuffer(x.FRAMEBUFFER,h),this.current=h,this.dirty=!1}}class jme extends lo{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.bindRenderbuffer(x.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class kme extends lo{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.bindTexture(x.TEXTURE_2D,h),this.current=h,this.dirty=!1}}class Nme extends lo{getDefault(){return null}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.bindBuffer(x.ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class FE extends lo{getDefault(){return null}set(h){const x=this.gl;x.bindBuffer(x.ELEMENT_ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class zE extends lo{getDefault(){return null}set(h){this.gl&&(h!==this.current||this.dirty)&&(this.gl.bindVertexArray(h),this.current=h,this.dirty=!1)}}class BE extends lo{getDefault(){return 4}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.pixelStorei(x.UNPACK_ALIGNMENT,h),this.current=h,this.dirty=!1}}class $E extends lo{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.pixelStorei(x.UNPACK_PREMULTIPLY_ALPHA_WEBGL,h),this.current=h,this.dirty=!1}}class vR extends lo{getDefault(){return!1}set(h){if(h===this.current&&!this.dirty)return;const x=this.gl;x.pixelStorei(x.UNPACK_FLIP_Y_WEBGL,h),this.current=h,this.dirty=!1}}class AC extends lo{constructor(h,x){super(h),this.context=h,this.parent=x}getDefault(){return null}}class EC extends AC{constructor(h,x,A=0){super(h,x),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 x=this.gl;x.framebufferTexture2D(x.FRAMEBUFFER,this.attachmentPoint,x.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class Y1 extends AC{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const x=this.gl;x.framebufferRenderbuffer(x.FRAMEBUFFER,this.attachment(),x.RENDERBUFFER,h),this.current=h,this.dirty=!1}}class X2 extends AC{attachment(){return this.gl.DEPTH_ATTACHMENT}set(h){if(h===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const x=this.gl;x.framebufferTexture2D(x.FRAMEBUFFER,this.attachment(),x.TEXTURE_2D,h,0),this.current=h,this.dirty=!1}}class _R extends Y1{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const sm=(M,h,x,A)=>({u_matrix:M,u_image0:0,u_image1:1,u_skirt_height:h,u_ground_shadow_factor:x,u_emissive_texture_available:A}),PC=(M,h,x,A,D,F,z,H,Y,ae,oe,ge,fe,xe,Pe,Ce,Ve)=>({u_proj_matrix:Float32Array.from(M),u_globe_matrix:h,u_normalize_matrix:Float32Array.from(A),u_merc_matrix:x,u_zoom_transition:D,u_merc_center:F,u_image0:0,u_image1:1,u_frustum_tl:z,u_frustum_tr:H,u_frustum_br:Y,u_frustum_bl:ae,u_globe_pos:oe,u_globe_radius:ge,u_viewport:fe,u_grid_matrix:Ve?Float32Array.from(Ve):new Float32Array(9),u_skirt_height:xe,u_far_z_cutoff:Pe,u_emissive_texture_available:Ce});function Q2(M,h){return M!=null&&h!=null&&!(!M.hasData()||!h.hasData())&&M.demTexture!=null&&h.demTexture!=null&&M.tileID.key!==h.tileID.key}const Zg=new class{constructor(){this.operations={}}newMorphing(M,h,x,A,D){if(M in this.operations){const F=this.operations[M];F.to.tileID.key!==x.tileID.key&&(F.queued=x)}else this.operations[M]={startTime:A,phase:0,duration:D,from:h,to:x,queued:null}}getMorphValuesForProxy(M){if(!(M in this.operations))return null;const h=this.operations[M];return{from:h.from,to:h.to,phase:h.phase}}update(M){for(const h in this.operations){const x=this.operations[h];for(x.phase=(M-x.startTime)/x.duration;x.phase>=1||!this._validOp(x);)if(!this._nextOp(x,M)){delete this.operations[h];break}}}_nextOp(M,h){return!!M.queued&&(M.from=M.to,M.to=M.queued,M.queued=null,M.phase=0,M.startTime=h,!0)}_validOp(M){return M.from.hasData()&&M.to.hasData()}},IC={0:null,1:"TERRAIN_VERTEX_MORPHING"};function LC(M,h,x){if(h===0)return 0;const A=h<1&&x===514?.25/h:1;return 6*Math.pow(1.5,22-M)*Math.max(h,1)*A}function qE(M,h){const x=1<({u_matrix:M});function ew(M,h,x,A,D){if(D>0){const F=i.o.now(),z=(F-M.timeAdded)/D,H=h?(F-h.timeAdded)/D:-1,Y=x.getSource(),ae=A.coveringZoomLevel({tileSize:Y.tileSize,roundZoom:Y.roundZoom}),oe=!h||Math.abs(h.tileID.overscaledZ-ae)>Math.abs(M.tileID.overscaledZ-ae),ge=oe&&M.refreshedUponExpiration?1:i.aA(oe?z:1-H,0,1);return h?{opacity:1,mix:1-ge,isFading:z<1}:{opacity:ge,mix:0,isFading:z<1}}return{opacity:1,mix:0,isFading:!1}}class DC extends jl{constructor(h){const x=Pl("mock-dem",{type:"raster-dem",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("mock-dem",x,!1),x.setEventedParent(this),this._sourceLoaded=!0}_loadTile(h,x){h.state="loaded",x(null)}}class UE extends jl{constructor(h){const x=Pl("proxy",{type:"geojson",maxzoom:h.transform.maxZoom},h.style.dispatcher,h.style);super("proxy",x,!1),x.setEventedParent(this),this.map=this.getSource().map=h,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(h,x,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 H=new $m(z,this._source.tileSize*z.overscaleFactor(),h.tileZoom,void 0,void 0,this._source.worldview);H.state="loaded",this._tiles[z.key]=H}return F},{});for(const F in this._tiles)F in D||(this.freeFBO(F),this._tiles[F].unloadVectorData(),delete this._tiles[F])}freeFBO(h){const x=this.proxyCachedFBO[h];if(x!==void 0){const A=Object.values(x);this.renderCachePool.push(...A),delete this.proxyCachedFBO[h]}}deallocRenderCache(){this.renderCache.forEach(h=>h.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class VE extends i.aQ{constructor(h,x,A){super(h.overscaledZ,h.wrap,h.canonical.z,h.canonical.x,h.canonical.y),this.proxyTileKey=x,this.projMatrix=A}}class HE extends i.bV{constructor(h,x){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=h,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[A,D,F]=function(Y){const ae=new i.bd,oe=new i.b0,ge=131;ae.reserve(17161),oe.reserve(33800);const fe=i.al/128,xe=i.al+fe/2,Pe=xe+fe;for(let Ve=-fe;Vexe||Ve<0||Ve>xe?24575:0,ut=i.aA(Math.round(Be),0,i.al),st=i.aA(Math.round(Ve),0,i.al);ae.emplaceBack(ut+et,st)}const Ce=(Ve,Be)=>{const et=Be*ge+Ve;oe.emplaceBack(et+1,et,et+ge),oe.emplaceBack(et+ge,et+ge+1,et+1)};for(let Ve=1;Ve<129;Ve++)for(let Be=1;Be<129;Be++)Ce(Be,Ve);return[0,129].forEach(Ve=>{for(let Be=0;Be<130;Be++)Ce(Be,Ve),Ce(Ve,Be)}),[ae,oe,32768]}(),z=h.context;this.gridBuffer=z.createVertexBuffer(A,i.bf.members),this.gridIndexBuffer=z.createIndexBuffer(D),this.gridSegments=i.bg.simpleSegment(0,0,A.length,D.length),this.gridNoSkirtSegments=i.bg.simpleSegment(0,0,A.length,F),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new UE(x.map),this.orthoMatrix=i.bC(),i.ce(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,i.al,0,i.al,0,1);const H=z.gl;this._overlapStencilMode=new dn({func:H.GEQUAL,mask:255},0,255,H.KEEP,H.KEEP,H.REPLACE),this._previousZoom=h.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=x,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new DC(x.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1}set style(h){h.on("data",this._onStyleDataEvent.bind(this)),this._style=h,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(h,x,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 H=h.terrain&&h.terrain.scope,Y=D.get("source"),ae=F?this._mockSourceCache:h.getSourceCache(Y,H);if(!ae)return void i.w(`Couldn't find terrain source "${Y}".`);if(this.sourceCache=ae,this._attenuationRange=h.terrain.getAttenuationRange(),this._exaggeration=z?this.calculateExaggeration(x):D.get("exaggeration"),!x.projection.requiresDraping&&z&&this._exaggeration===0)return void this._disable();this.enabled=!0;const oe=()=>{this.sourceCache.used&&i.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const ge=this.getScaledDemTileSize();this.sourceCache.update(x,ge,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,oe(),this._initializing=!0),oe(),x.updateElevation(!0,A),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(x),this._emptyDEMTextureDirty=!0,this._previousZoom=x.zoom}else this._disable()}calculateExaggeration(h){if(this._attenuationRange&&h.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(h.zoom);const x=this._previousCameraAltitude,A=h.getFreeCameraOptions().position.z/h.pixelsPerMeter*h.worldSize;this._previousCameraAltitude=A;const D=x!=null?A-x:Number.MAX_VALUE;if(Math.abs(D)<2)return this._exaggeration;const F=h.zoom,z=this._style.terrain;if(!this._previousUpdateTimestamp)return z.getExaggeration(F);let H=F-this._previousZoom;const Y=this._previousUpdateTimestamp;let ae=F;this._evaluationZoom!=null&&(ae=this._evaluationZoom,Math.abs(F-ae)>.5&&(H=.5*(F-ae+H)),H*D<0&&(ae+=H)),this._evaluationZoom=ae;const oe=z.getExaggeration(ae),ge=oe===z.getExaggeration(Math.max(0,ae-.1));if(ge&&Math.abs(oe-this._exaggeration)<.01)return oe;let fe=Math.min(.1,.00375*(this._updateTimestamp-Y));return(ge||oe<.1||Math.abs(H)<1e-4)&&(fe=Math.min(.2,4*fe)),i.ak(this._exaggeration,oe,fe)}resetTileLookupCache(h){this._findCoveringTileCache[h]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(h){h.dataType==="source"&&h.coord?this._clearRenderCacheForTile(h.sourceCacheId,h.coord):h.dataType==="style"&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const h in this._style._mergedSourceCaches)this._style._mergedSourceCaches[h].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(h=>h.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const h=2*this.proxySourceCache.getSource().tileSize;return[h,h]}set useVertexMorphing(h){this._useVertexMorphing=h}updateTileBinding(h){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const x=this.proxySourceCache,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=x.getIds().map(Y=>{const ae=x.getTileByID(Y).tileID;return ae.projMatrix=A.calculateProjMatrix(ae.toUnwrapped()),ae});(function(Y,ae){const oe=ae.transform.pointCoordinate(ae.transform.getCameraPoint()),ge=new i.P(oe.x,oe.y);Y.sort((fe,xe)=>{if(xe.overscaledZ-fe.overscaledZ)return xe.overscaledZ-fe.overscaledZ;const Pe=new i.P(fe.canonical.x+(1<{this.proxyToSource[Y.key]={}}),this.terrainTileForTile={};const z=this._style._mergedSourceCaches;for(const Y in z){const ae=z[Y];if(!ae.used||(ae!==this.sourceCache&&this.resetTileLookupCache(ae.id),this._setupProxiedCoordsForOrtho(ae,h[Y],F),ae.usedForTerrain))continue;const oe=h[Y];ae.getSource().reparseOverscaled&&this._assignTerrainTiles(oe)}this.proxiedCoords[x.id]=D.map(Y=>new VE(Y,Y.key,this.orthoMatrix)),this._assignTerrainTiles(D),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(F),this.renderingToTexture=!1;const H={};this._visibleDemTiles=[];for(const Y of this.proxyCoords){const ae=this.terrainTileForTile[Y.key];if(!ae)continue;const oe=ae.tileID.key;oe in H||(this._visibleDemTiles.push(ae),H[oe]=oe)}}_assignTerrainTiles(h){this._initializing||h.forEach(x=>{if(this.terrainTileForTile[x.key])return;const A=this._findTileCoveringTileID(x,this.sourceCache);A&&(this.terrainTileForTile[x.key]=A)})}_prepareDEMTextures(){const h=this.painter.context,x=h.gl;for(const A in this.terrainTileForTile){const D=this.terrainTileForTile[A],F=D.dem;!F||D.demTexture&&!D.needsDEMTextureUpload||(h.activeTexture.set(x.TEXTURE1),IE(this.painter,D,F))}}_prepareDemTileUniforms(h,x,A,D){if(!x||x.demTexture==null)return!1;const F=h.tileID.canonical,z=Math.pow(2,x.tileID.canonical.z-F.z),H=D||"";return A[`u_dem_tl${H}`]=[F.x*z%1,F.y*z%1],A[`u_dem_scale${H}`]=z,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let h=0;const x=this._visibleDemTiles.reduce((A,D)=>{if(!D.dem)return A;const F=D.dem.tree.minimums[0];return F>0&&h++,A+F},0);return h?x/h:0}_updateEmptyDEMTexture(){const h=this.painter.context,x=h.gl;h.activeTexture.set(x.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,x.R32F,{premultiply:!1}),F}setupElevationDraw(h,x,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 H=null,Y=null,ae=1;if(A&&A.morphing&&this._useVertexMorphing){const xe=A.morphing.srcDemTile,Pe=A.morphing.dstDemTile;ae=A.morphing.phase,xe&&Pe&&(this._prepareDemTileUniforms(h,xe,z,"_prev")&&(Y=xe),this._prepareDemTileUniforms(h,Pe,z)&&(H=Pe))}const oe=xe=>xe&&xe.demTexture&&this.painter.linearFloatFilteringSupported()?F.LINEAR:F.NEAREST;let ge=null;var fe;if(this.enabled?Y&&H?(ge=H.demTexture,D.activeTexture.set(F.TEXTURE4),Y.demTexture.bind(oe(Y),F.CLAMP_TO_EDGE),z.u_dem_lerp=ae):(H=this.terrainTileForTile[h.tileID.key],ge=this._prepareDemTileUniforms(h,H,z)?H.demTexture:this.emptyDEMTexture):ge=this.emptyDEMTexture,D.activeTexture.set(F.TEXTURE2),ge&&(z.u_dem_size=(fe=ge).size[0]===1?1:fe.size[0]-2,ge.bind(oe(H),F.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(A&&A.useDepthForOcclusion,x,z),A&&A.useMeterToDem&&H){const xe=(1<{if(Be===ns)return;const fs=[IC[ns],"PROJECTION_GLOBE_VIEW"];ut&&fs.push("CUSTOM_ANTIALIASING");const qs=ae.isTileAffectedByFog(ts);Ve=ae.getOrCreateProgram("globeRaster",{defines:fs,overrideFog:qs}),Be=ns},Mt=ae.colorModeForRenderPass(),yt=new Lr(Ce.LEQUAL,Lr.ReadWrite,ae.depthRangeFor3D);Zg.update(xe);const kt=i.dF(et),gt=[i.aF(et.center.lng),i.aJ(et.center.lat)],mt=ae.globeSharedBuffers,Pt=[et.width*i.o.devicePixelRatio,et.height*i.o.devicePixelRatio],Ht=Float32Array.from(et.globeMatrix),Ut={useDenormalizedUpVectorScale:!0};{const ts=ae.transform,ns=LC(ts.zoom,oe.exaggeration(),oe.sourceCache._source.tileSize);Be=-1;const fs=Ce.TRIANGLES;for(const qs of fe){const Yt=ge.getTile(qs),Ft=dn.disabled,ls=oe.prevTerrainTileForTile[qs.key],Jt=oe.terrainTileForTile[qs.key];Q2(ls,Jt)&&Zg.newMorphing(qs.key,ls,Jt,xe,250),X1(ae,Yt.emissiveTexture),Pe.activeTexture.set(Ce.TEXTURE0),Yt.texture&&Yt.texture.bind(Ce.LINEAR,Ce.CLAMP_TO_EDGE);const Ls=Zg.getMorphValuesForProxy(qs.key),er=Ls?1:0;Ls&&Object.assign(Ut,{morphing:{srcDemTile:Ls.from,dstDemTile:Ls.to,phase:i.dD(Ls.phase)}});const pr=i.dG(qs.canonical),Xs=i.dH(pr.getCenter().lat),Vs=i.dI(qs.canonical,pr,Xs,ts.worldSize/ts._pixelsPerMercatorPixel),Cr=i.bk(i.dJ(qs.canonical)),kr=ae.emissiveMode==="mrt-fallback"?1:0,dr=PC(ts.expandedFarZProjMatrix,Ht,kt,Cr,i.aj(ts.zoom),gt,ts.frustumCorners.TL,ts.frustumCorners.TR,ts.frustumCorners.BR,ts.frustumCorners.BL,ts.globeCenterInViewSpace,ts.globeRadius,Pt,ns,ts._farZ,kr,Vs);if(st(qs,er),Ve&&(oe.setupElevationDraw(Yt,Ve,Ut),ae.uploadCommonUniforms(Pe,Ve,qs.toUnwrapped()),mt)){const[xr,Vr,kn]=mt.getGridBuffers(Xs,ns!==0);Ve.draw(ae,fs,yt,Ft,Mt,nn.backCCW,dr,"globe_raster",xr,Vr,kn)}}}if(mt&&(ae.renderDefaultNorthPole||ae.renderDefaultSouthPole)){const ts=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];ut&&ts.push("CUSTOM_ANTIALIASING"),Ve=ae.getOrCreateProgram("globeRaster",{defines:ts});for(const ns of fe){const{x:fs,y:qs,z:Yt}=ns.canonical,Ft=qs===0,ls=qs===(1<xr.draw(ae,Ce.TRIANGLES,yt,dn.disabled,Mt,nn.disabled,PC(et.expandedFarZProjMatrix,Vs,Vs,Cr,0,gt,et.frustumCorners.TL,et.frustumCorners.TR,et.frustumCorners.BR,et.frustumCorners.BL,et.globeCenterInViewSpace,et.globeRadius,Pt,0,et._farZ,kr),"globe_pole_raster",Vr,er,pr);oe.setupElevationDraw(Xs,Ve,Ut),ae.uploadCommonUniforms(Pe,Ve,ns.toUnwrapped()),Ft&&ae.renderDefaultNorthPole&&dr(Ve,Jt),ls&&ae.renderDefaultSouthPole&&(Vs=i.cS(i.bC(),Vs,[1,-1,1]),dr(Ve,Ls))}}}})(D,F,z,H,Y);else{const ae=D.context,oe=ae.gl;let ge,fe;const xe=D.shadowRenderer,Pe=fy(D,D.longestCutoffRange),Ce=Mt=>{if(fe===Mt)return;const yt=[];yt.push(IC[Mt]),Pe.shouldRenderCutoff&&yt.push("RENDER_CUTOFF"),xe&&(yt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),xe.useNormalOffset&&yt.push("NORMAL_OFFSET")),ge=D.getOrCreateProgram("terrainRaster",{defines:yt}),fe=Mt},Ve=D.colorModeForRenderPass(),Be=new Lr(oe.LEQUAL,Lr.ReadWrite,D.depthRangeFor3D);Zg.update(Y);const et=D.transform,ut=LC(et.zoom,F.exaggeration(),F.sourceCache._source.tileSize);let st=[0,0,0];if(xe){const Mt=D.style.directionalLight,yt=D.style.ambientLight;Mt&&yt&&(st=Kg(D.style,Mt,yt))}{fe=-1;const Mt=oe.TRIANGLES,[yt,kt]=[F.gridIndexBuffer,F.gridSegments];for(const gt of H){const mt=z.getTile(gt),Pt=dn.disabled,Ht=F.prevTerrainTileForTile[gt.key],Ut=F.terrainTileForTile[gt.key];Q2(Ht,Ut)&&Zg.newMorphing(gt.key,Ht,Ut,Y,250),X1(D,mt.emissiveTexture),ae.activeTexture.set(oe.TEXTURE0),mt.texture&&mt.texture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE);const ts=Zg.getMorphValuesForProxy(gt.key),ns=ts?1:0;let fs;ts&&(fs={morphing:{srcDemTile:ts.from,dstDemTile:ts.to,phase:i.dD(ts.phase)}});const qs=D.emissiveMode==="mrt-fallback"?1:0,Yt=sm(gt.projMatrix,qE(gt.canonical,et.renderWorldCopies)?ut/10:ut,st,qs);if(Ce(ns),!ge)continue;F.setupElevationDraw(mt,ge,fs);const Ft=gt.toUnwrapped();xe&&xe.setupShadows(Ft,ge),D.uploadCommonUniforms(ae,ge,Ft,null,Pe),ge.draw(D,Mt,Be,Pt,Ve,nn.backCCW,Yt,"terrain_raster",F.gridBuffer,yt,kt)}}}}(x,this,this.proxySourceCache,h,this._updateTimestamp),this.renderingToTexture=!0,x.gpuTimingDeferredRenderEnd(),h.splice(0,h.length))}renderBatch(h){if(this._drapedRenderBatches.length===0)return h+1;this.renderingToTexture=!0;const x=this.painter,A=this.painter.context,D=this.proxySourceCache,F=this.proxiedCoords[D.id],z=this._drapedRenderBatches.shift(),H=x.style.order,Y=[];this._updateFBOs(x.emissiveMode==="mrt-fallback");let ae=0;for(const oe of F){const ge=D.getTileByID(oe.proxyTileKey),fe=D.proxyCachedFBO[oe.key]?D.proxyCachedFBO[oe.key][h]:void 0,xe=fe!==void 0?D.renderCache[fe]:this.pool[ae++],Pe=fe!==void 0;if(ge.texture=xe.tex,ge.emissiveTexture=xe.emissiveTex,Pe&&!xe.dirty){Y.push(ge.tileID);continue}A.bindFramebuffer.set(xe.fb.framebuffer);const Ce=A.gl;let Ve;Ce.drawBuffers(x.emissiveMode==="mrt-fallback"?[Ce.COLOR_ATTACHMENT0,Ce.COLOR_ATTACHMENT1]:[Ce.COLOR_ATTACHMENT0]),this.renderedToTile=!1,xe.dirty&&(A.clear({color:i.ao.transparent,stencil:0}),xe.dirty=!1);for(let Be=z.start;Be<=z.end;++Be){const et=x.style._mergedLayers[H[Be]];if(et.isHidden(x.transform.zoom))continue;const ut=x.style.getLayerSourceCache(et),st=ut?this.proxyToSource[oe.key][ut.id]:[oe];if(!st)continue;const Mt=st;A.viewport.set([0,0,xe.fb.width,xe.fb.height]),Ve!==(ut?ut.id:null)&&(this._setupStencil(xe,st,et,ut),Ve=ut?ut.id:null),x.renderLayer(x,ut,et,Mt)}if(Ce.drawBuffers([Ce.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const Be of this._pendingGroundEffectLayers){const et=x.style._mergedLayers[H[Be]];if(et.isHidden(x.transform.zoom))continue;const ut=x.style.getLayerSourceCache(et),st=ut?this.proxyToSource[oe.key][ut.id]:[oe];if(!st)continue;const Mt=st;A.viewport.set([0,0,xe.fb.width,xe.fb.height]),Ve!==(ut?ut.id:null)&&(this._setupStencil(xe,st,et,ut),Ve=ut?ut.id:null),x.renderLayer(x,ut,et,Mt)}this.renderedToTile?(xe.dirty=!0,Y.push(ge.tileID)):Pe||--ae,ae===5&&(ae=0,this.renderToBackBuffer(Y))}return this.renderToBackBuffer(Y),this.renderingToTexture=!1,A.bindFramebuffer.set(null),A.viewport.set([0,0,x.width,x.height]),z.end+1}postRender(){}isLayerOrderingCorrect(h){const x=h.order.length;let A=-1,D=x;for(let F=0;FA}getMinElevationBelowMSL(){let h=0;return this._visibleDemTiles.filter(x=>x.dem).forEach(x=>{h=Math.min(h,x.dem.tree.minimums[0])}),h===0?h:(h-30)*this._exaggeration}raycast(h,x,A){if(!this._visibleDemTiles)return null;const D=this._visibleDemTiles.filter(F=>F.dem).map(F=>{const z=F.tileID,H=1<(F.t!==null?F.t:Number.MAX_VALUE)-(z.t!==null?z.t:Number.MAX_VALUE));for(const F of D){if(F.t==null)return null;const z=F.tile.dem.tree.raycast(F.minx,F.miny,F.maxx,F.maxy,h,x,A);if(z!=null)return z}return null}_createFBO(){const h=this.painter.context,x=h.gl,A=this.drapeBufferSize;h.activeTexture.set(x.TEXTURE0);const D=new i.T(h,{width:A[0],height:A[1],data:null},x.RGBA8);D.bind(x.LINEAR,x.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},x.R8),z.bind(x.LINEAR,x.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&&x.texParameterf(x.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax),{fb:F,tex:D,emissiveTex:z,dirty:!1}}_updateFBOs(h){if(this._emissiveTexture!==h){for(const x of this.pool)this._updateFBO(x,h);for(const x of this.proxySourceCache.renderCache)this._updateFBO(x,h);this._emissiveTexture=h}}_updateFBO(h,x){const A=h.fb,D=this.painter.context,F=D.gl,z=this.drapeBufferSize;if(x){const H=new i.T(D,{width:z[0],height:z[1],data:null},F.R8);H.bind(F.LINEAR,F.CLAMP_TO_EDGE),h.emissiveTex=H,A.createColorAttachment(D,1),A.colorAttachment1.set(H.texture)}else h.emissiveTex=void 0,A.removeColorAttachment(D,1);h.dirty=!0}_initFBOPool(){for(;this.pool.length{const x=this._style._mergedLayers[h],A=x.isHidden(this.painter.transform.zoom);return x.type==="hillshade"||x.type==="custom"?!A&&x.shouldRedrape():!A&&x.hasTransition()})}_clearLineLayersFromRenderCache(){let h=!1;for(const A of this._style.getSources())if(A instanceof Cf){h=!0;break}if(!h)return;const x={};for(let A=0;AY>H.end)||i.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=A}_setupRenderCache(h){const x=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,x.renderCache.length>x.renderCachePool.length){const z=Object.values(x.proxyCachedFBO);x.proxyCachedFBO={};for(let H=0;H=0;z--){const H=A[z];if(x.getTileByID(H.key),x.proxyCachedFBO[H.key]!==void 0){const Y=h[H.key],ae=this.proxyToSource[H.key];let oe=0;for(const ge in ae){const fe=ae[ge],xe=Y[ge];if(!xe||xe.length!==fe.length||fe.some((Pe,Ce)=>Pe!==xe[Ce]||D[ge]&&D[ge].hasOwnProperty(Pe.key))){oe=-1;break}++oe}for(const ge in x.proxyCachedFBO[H.key])x.renderCache[x.proxyCachedFBO[H.key][ge]].dirty=oe<0||oe!==Object.values(Y).length}}const F=[...this._drapedRenderBatches];F.sort((z,H)=>H.end-H.start-(z.end-z.start));for(const z of F)for(const H of A){if(x.proxyCachedFBO[H.key])continue;let Y=x.renderCachePool.pop();Y===void 0&&x.renderCache.length<50&&(Y=x.renderCache.length,x.renderCache.push(this._createFBO())),Y!==void 0&&(x.proxyCachedFBO[H.key]={},x.proxyCachedFBO[H.key][z.start]=Y,x.renderCache[Y].dirty=!0)}this._tilesDirty={}}_setupStencil(h,x,A,D){if(!D||!this._sourceTilesOverlap[D.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const F=this.painter.context,z=F.gl;if(x.length<=1)return void(this._overlapStencilType=!1);let H;if(A.isTileClipped())H=x.length,this._overlapStencilMode.test={func:z.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(x[0].overscaledZ>x[x.length-1].overscaledZ))return void(this._overlapStencilType=!1);H=1,this._overlapStencilMode.test={func:z.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+H>255&&(F.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=H,this._overlapStencilMode.ref=this._stencilRef,A.isTileClipped()&&this._renderTileClippingMasks(x,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(h){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[h.key]),this._overlapStencilMode):dn.disabled}_renderTileClippingMasks(h,x){const A=this.painter,D=this.painter.context,F=D.gl;A._tileClippingMaskIDs={},D.setColorMode(On.disabled),D.setDepthMode(Lr.disabled);const z=A.getOrCreateProgram("clippingMask");for(const H of h){const Y=A._tileClippingMaskIDs[H.key]=--x;z.draw(A,F.TRIANGLES,Lr.disabled,new dn({func:F.ALWAYS,mask:0},Y,255,F.KEEP,F.KEEP,F.REPLACE),On.disabled,nn.disabled,J2(H.projMatrix),"$clipping",A.tileExtentBuffer,A.quadTriangleIndexBuffer,A.tileExtentSegments)}}pointCoordinate(h){const x=this.painter.transform;if(h.x<0||h.x>x.width||h.y<0||h.y>x.height)return null;const A=[h.x,h.y,1,1];i.aC(A,A,x.pixelMatrixInverse),i.cK(A,A,1/A[3]),A[0]/=x.worldSize,A[1]/=x.worldSize;const D=x._camera.position,F=i.cf(1,x.center.lat),z=[D[0],D[1],D[2]/F,0],H=i.da([],A.slice(0,3),z);i.aw(H,H);const Y=this.raycast(z,H,this._exaggeration);return Y!==null&&Y?(i.bH(z,z,H,Y),z[3]=z[2],z[2]*=F,z):null}_setupProxiedCoordsForOrtho(h,x,A){if(h.getSource()instanceof i.aU)return this._setupProxiedCoordsForImageSource(h,x,A);this._findCoveringTileCache[h.id]=this._findCoveringTileCache[h.id]||{};const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords;for(let Y=0;Yoe.overscaledZ-ae.overscaledZ)}_setupProxiedCoordsForImageSource(h,x,A){if(!h.getSource().loaded())return;const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords,z=h.getSource(),H=z.tileID;if(!H)return;const Y=new i.P(H.x,H.y)._div(1<(ge.min.x=Math.min(ge.min.x,fe.x-Y.x),ge.min.y=Math.min(ge.min.y,fe.y-Y.y),ge.max.x=Math.max(ge.max.x,fe.x-Y.x),ge.max.y=Math.max(ge.max.y,fe.y-Y.y),ge),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),oe=(ge,fe)=>{const xe=ge.wrap+ge.canonical.x/(1<Ve+ae.max.x||Pe+CeBe+ae.max.y};for(let ge=0;gez.key===x.tileID.key);if(F)return F}if(x.tileID.key!==h.key){const F=h.canonical.z-x.tileID.canonical.z;let z,H,Y;D=i.bC();const ae=x.tileID.wrap-h.wrap<0?(z=i.al>>F,H=z*((x.tileID.canonical.x<=ge){const fe=h.canonical.z-ge;x.getSource().reparseOverscaled?(H=Math.max(h.canonical.z+2,x.transform.tileZoom),z=new i.aQ(H,h.wrap,ge,h.canonical.x>>fe,h.canonical.y>>fe)):fe!==0&&(H=ge,z=new i.aQ(H,h.wrap,ge,h.canonical.x>>fe,h.canonical.y>>fe))}z.key!==h.key&&(ae.push(z.key),A=x.getTile(z))}const oe=ge=>{ae.forEach(fe=>{D[fe]=ge}),ae.length=0};for(H-=1;H>=Y&&(!A||!A.hasData());H--){A&&oe(A.tileID.key);const ge=z.calculateScaledKey(H);if(A=x.getTileByID(ge),A&&A.hasData())break;const fe=D[ge];if(fe===null)break;fe===void 0?ae.push(ge):A=x.getTileByID(fe)}return oe(A?A.tileID.key:null),A&&A.hasData()?A:null}findDEMTileFor(h){return this.enabled?this._findTileCoveringTileID(h,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(h,x){let A=this._tilesDirty[h];A||(A=this._tilesDirty[h]={}),A[x.key]=!0}}function Q1(M,h,x){const A=function(H,Y,ae){const oe=i.bJ(Y,H),ge=i.bJ(ae,[.2126,.7152,.0722]),fe=(Pe,Ce,Ve)=>(1-Ve)*Pe+Ve*Ce,xe=fe(1-.3*Math.min(ge,1),1,Math.min(oe+1,1));return fe(.92,1,Math.asin(i.aA(Y[2],-1,1))/Math.PI+.5)*xe}(M,[0,0,1],h),D=[0,0,0];i.c5(D,x.slice(0,3),A);const F=[0,0,0];i.c5(F,h.slice(0,3),M[2]);const z=[0,0,0];return i.d8(z,D,F),i.db(z)}const Sme=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Cme=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class bR{static cacheKey(h,x,A,D){const F=[x];D&&F.push(D.cacheKey);for(const z of A)h.usedDefines.has(z)&&F.push(z);return F.join("/")}constructor(h,x,A,D,F,z){const H=h.gl;this.program=H.createProgram(),this.configuration=D,this.name=x,this.fixedDefines=[...z];const Y=`#version 300 es ${(D?D.defines():[]).concat(z.map(Ce=>`#define ${Ce}`)).join(` `)}`,ae=[Y,xme];for(const Ce of A.fragmentIncludes)ae.push(vy[Ce]);ae.push(A.fragmentSource);const oe=ae.join(` `),ge=[Y,uR];for(const Ce of A.vertexIncludes)ge.push(vy[Ce]);this.forceManualRenderingForInstanceIDShaders=h.forceManualRenderingForInstanceIDShaders&&A.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&ge.push("uniform int u_instanceID;"),ge.push(A.vertexSource);let fe=ge.join(` `);this.forceManualRenderingForInstanceIDShaders&&(fe=fe.replaceAll("gl_InstanceID","u_instanceID"));const xe=H.createShader(H.FRAGMENT_SHADER);if(H.isContextLost())return void(this.failedToCreate=!0);H.shaderSource(xe,oe),H.compileShader(xe),H.attachShader(this.program,xe);const Pe=H.createShader(H.VERTEX_SHADER);H.isContextLost()?this.failedToCreate=!0:(H.shaderSource(Pe,fe),H.compileShader(Pe),H.attachShader(this.program,Pe),this.attributes={},H.linkProgram(this.program),H.deleteShader(Pe),H.deleteShader(xe),this.fixedUniforms=F(h),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=D?D.getUniforms(h):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(Ce=>({u_instanceID:new i.ch(Ce)}))(h)),(z.includes("TERRAIN")||x.includes("symbol")||x.includes("circle"))&&(this.terrainUniforms=(Ce=>({u_dem:new i.ch(Ce),u_dem_prev:new i.ch(Ce),u_dem_tl:new i.ck(Ce),u_dem_scale:new i.cj(Ce),u_dem_tl_prev:new i.ck(Ce),u_dem_scale_prev:new i.cj(Ce),u_dem_size:new i.cj(Ce),u_dem_lerp:new i.cj(Ce),u_exaggeration:new i.cj(Ce),u_depth:new i.ch(Ce),u_depth_size_inv:new i.ck(Ce),u_depth_range_unpack:new i.ck(Ce),u_occluder_half_size:new i.cj(Ce),u_occlusion_depth_offset:new i.cj(Ce),u_meter_to_dem:new i.cj(Ce),u_label_plane_matrix_inv:new i.cl(Ce)}))(h)),z.includes("GLOBE")&&(this.globeUniforms=(Ce=>({u_tile_tl_up:new i.ci(Ce),u_tile_tr_up:new i.ci(Ce),u_tile_br_up:new i.ci(Ce),u_tile_bl_up:new i.ci(Ce),u_tile_up_scale:new i.cj(Ce)}))(h)),z.includes("FOG")&&(this.fogUniforms=(Ce=>({u_fog_matrix:new i.cl(Ce),u_fog_range:new i.ck(Ce),u_fog_color:new i.d3(Ce),u_fog_horizon_blend:new i.cj(Ce),u_fog_vertical_limit:new i.ck(Ce),u_fog_temporal_offset:new i.cj(Ce),u_frustum_tl:new i.ci(Ce),u_frustum_tr:new i.ci(Ce),u_frustum_br:new i.ci(Ce),u_frustum_bl:new i.ci(Ce),u_globe_pos:new i.ci(Ce),u_globe_radius:new i.cj(Ce),u_globe_transition:new i.cj(Ce),u_is_globe:new i.ch(Ce),u_viewport:new i.ck(Ce)}))(h)),z.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(Ce=>({u_cutoff_params:new i.d3(Ce)}))(h)),z.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(Ce=>({u_lighting_ambient_color:new i.ci(Ce),u_lighting_directional_dir:new i.ci(Ce),u_lighting_directional_color:new i.ci(Ce),u_ground_radiance:new i.ci(Ce)}))(h)),z.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(Ce=>({u_light_matrix_0:new i.cl(Ce),u_light_matrix_1:new i.cl(Ce),u_fade_range:new i.ck(Ce),u_shadow_normal_offset:new i.ci(Ce),u_shadow_intensity:new i.cj(Ce),u_shadow_texel_size:new i.cj(Ce),u_shadow_map_resolution:new i.cj(Ce),u_shadow_direction:new i.ci(Ce),u_shadow_bias:new i.ci(Ce),u_shadowmap_0:new i.ch(Ce),u_shadowmap_1:new i.ch(Ce)}))(h)))}getAttributeLocation(h,x){let A=this.attributes[x];return A===void 0&&(A=this.attributes[x]=h.getAttribLocation(this.program,x)),A}setTerrainUniformValues(h,x){if(!this.terrainUniforms)return;const A=this.terrainUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)A[D]&&A[D].set(this.program,D,x[D])}}setGlobeUniformValues(h,x){if(!this.globeUniforms)return;const A=this.globeUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)A[D]&&A[D].set(this.program,D,x[D])}}setFogUniformValues(h,x){if(!this.fogUniforms)return;const A=this.fogUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)A[D].set(this.program,D,x[D])}}setCutoffUniformValues(h,x){if(!this.cutoffUniforms)return;const A=this.cutoffUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)A[D].set(this.program,D,x[D])}}setLightsUniformValues(h,x){if(!this.lightsUniforms)return;const A=this.lightsUniforms;if(!this.failedToCreate){h.program.set(this.program);for(const D in x)A[D].set(this.program,D,x[D])}}setShadowUniformValues(h,x){if(this.failedToCreate||!this.shadowUniforms)return;const A=this.shadowUniforms;h.program.set(this.program);for(const D in x)A[D].set(this.program,D,x[D])}_drawDebugWireframe(h,x,A,D,F,z,H,Y,ae,oe){const ge=h.options.wireframe;if(ge.terrain===!1&&ge.layers2D===!1&&ge.layers3D===!1)return;const fe=h.context;if(!(!(!ge.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!ge.layers2D||h._terrain&&h._terrain.renderingToTexture||!Sme.includes(this.name))||!(!ge.layers3D||!Cme.includes(this.name))))return;const xe=fe.gl,Pe=h.wireframeDebugCache.getLinesFromTrianglesBuffer(h.frameCounter,F,fe);if(!Pe)return;const Ce=[...this.fixedDefines,"DEBUG_WIREFRAME"],Ve=h.getOrCreateProgram(this.name,{config:this.configuration,defines:Ce});fe.program.set(Ve.program);const Be=(st,Mt,yt)=>{if(Mt[st]&&yt[st])for(const kt in Mt[st])yt[st][kt]&&yt[st][kt].set(yt.program,kt,Mt[st][kt].current)};ae&&ae.setUniforms(Ve.program,fe,Ve.binderUniforms,H,{zoom:Y}),Be("fixedUniforms",this,Ve),Be("terrainUniforms",this,Ve),Be("globeUniforms",this,Ve),Be("fogUniforms",this,Ve),Be("lightsUniforms",this,Ve),Be("shadowUniforms",this,Ve),Pe.bind(),fe.setColorMode(new On([xe.ONE,xe.ONE_MINUS_SRC_ALPHA,xe.ZERO,xe.ONE],i.ao.transparent,[!0,!0,!0,!1])),fe.setDepthMode(new Lr(x.func===xe.LESS?xe.LEQUAL:x.func,Lr.ReadOnly,x.range)),fe.setStencilMode(dn.disabled);const et=3*z.primitiveLength*2,ut=3*z.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const st=oe||1;for(let Mt=0;Mt1?xe.drawElementsInstanced(xe.LINES,et,xe.UNSIGNED_SHORT,ut,oe):xe.drawElements(xe.LINES,et,xe.UNSIGNED_SHORT,ut);F.bind(),fe.program.set(this.program),fe.setDepthMode(x),fe.setStencilMode(A),fe.setColorMode(D)}checkUniforms(h,x,A){if(this.fixedDefines.includes(x)){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 ${x} being defined`)}}draw(h,x,A,D,F,z,H,Y,ae,oe,ge,fe,xe,Pe,Ce,Ve){const Be=h.context,et=Be.gl;if(this.failedToCreate)return;Be.program.set(this.program),Be.setDepthMode(A),Be.setStencilMode(D),Be.setColorMode(F),Be.setCullFace(z);for(const[gt,mt]of this.fixedUniformsEntries)mt.set(this.program,gt,H[gt]);Pe&&Pe.setUniforms(this.program,Be,this.binderUniforms,fe,{zoom:xe});const ut={[et.POINTS]:1,[et.LINES]:2,[et.TRIANGLES]:3,[et.LINE_STRIP]:1}[x];this.checkUniforms(Y,"RENDER_SHADOWS",this.shadowUniforms);const st=Ce||[],Mt=Pe?Pe.getPaintVertexBuffers():[],yt=x===et.TRIANGLES&&oe,kt=Ve&&Ve>0?1:void 0;for(const gt of ge.get()){const mt=gt.vaos||(gt.vaos={});if((mt[Y]||(mt[Y]=new yme)).bind(Be,this,ae,Mt,oe,gt.vertexOffset,st,kt),this.forceManualRenderingForInstanceIDShaders){const Pt=Ve||1;for(let Ht=0;Ht1?et.drawElementsInstanced(x,gt.primitiveLength*ut,et.UNSIGNED_SHORT,gt.primitiveOffset*ut*2,Ve):oe?et.drawElements(x,gt.primitiveLength*ut,et.UNSIGNED_SHORT,gt.primitiveOffset*ut*2):et.drawArrays(x,gt.vertexOffset,gt.vertexLength);yt&&this._drawDebugWireframe(h,A,D,F,oe,gt,fe,xe,Pe,Ve)}}}function wR(M,h,x=0){const A=Math.pow(2,h.tileID.overscaledZ),D=h.tileSize*Math.pow(2,M.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,M.transform.tileZoom),u_pixel_coord_upper:[F>>16,z>>16],u_pixel_coord_lower:[65535&F,65535&z],u_pattern_transition:x}}const OC={terrain:0,flat:1},Mme=i.bC(),RC=(M,h,x,A,D,F,z,H,Y,ae,oe,ge,fe,xe,Pe,Ce,Ve,Be)=>{const et=h.style.light,ut=et.properties.get("position"),st=[ut.x,ut.y,ut.z],Mt=i.dO();et.properties.get("anchor")==="viewport"&&(i.dP(Mt,-h.transform.angle),i.dQ(st,st,Mt));const yt=et.properties.get("color").toPremultipliedRenderColor(null),kt=h.transform,gt={u_matrix:M,u_lightpos:st,u_lightintensity:et.properties.get("intensity"),u_lightcolor:[yt.r,yt.g,yt.b],u_vertical_gradient:+x,u_opacity:A,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Mme,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:OC[ae],u_base_type:OC[oe],u_ao:D,u_edge_radius:F,u_width_scale:z,u_flood_light_color:Pe,u_vertical_scale:Ce,u_flood_light_intensity:Ve,u_ground_shadow_factor:Be};return kt.projection.name==="globe"&&(gt.u_tile_id=[H.canonical.x,H.canonical.y,1<({u_matrix:M,u_edge_radius:h,u_width_scale:x,u_vertical_scale:A,u_height_type:OC[D],u_base_type:OC[F]}),jR=(M,h,x,A,D,F,z,H,Y,ae,oe,ge,fe,xe,Pe,Ce,Ve,Be)=>{const et=RC(M,h,x,A,D,F,z,H,ae,oe,ge,fe,xe,Pe,Ce,Ve,1,[0,0,0]),ut={u_height_factor:-Math.pow(2,H.overscaledZ)/Y.tileSize/8};return Object.assign(et,wR(h,Y,Be),ut)},J1=(M,h,x,A,D,F,z,H,Y,ae,oe)=>({u_matrix:h,u_opacity:x,u_ao_pass:A?1:0,u_meter_to_tile:D,u_ao:F,u_flood_light_intensity:z,u_flood_light_color:H,u_attenuation:Y,u_edge_radius:ae,u_fb:0,u_fb_size:oe,u_dynamic_offset:1}),GE=(M,h,x)=>({u_matrix:M,u_emissive_strength:h,u_ground_shadow_factor:x}),KE=(M,h,x,A,D,F=0)=>Object.assign(GE(M,h,D),wR(x,A,F)),kR=(M,h,x,A)=>({u_matrix:M,u_world:x,u_emissive_strength:h,u_ground_shadow_factor:A}),ZE=(M,h,x,A,D,F,z=0)=>Object.assign(KE(M,h,x,A,F,z),{u_world:D}),by=(M,h)=>({u_matrix:M,u_ground_shadow_factor:h}),X0=(M,h,x,A,D)=>({u_matrix:M,u_camera_pos:[h[0],h[1],h[2]],u_depth_bias:x,u_height_scale:A,u_reset_depth:D}),FC=(M,h,x,A,D,F,z,H,Y)=>({u_matrix:M,u_normal_matrix:h,u_opacity:x,u_faux_facade_ao_intensity:A,u_camera_pos:D,u_tile_to_meter:F,u_facade_emissive_chance:z,u_flood_light_color:H,u_flood_light_intensity:Y}),NR=M=>({u_matrix:M}),wy=M=>({u_matrix:M}),YE=(M,h,x,A,D,F,z,H)=>{const Y=i.al/F.tileSize;return{u_matrix:M,u_inv_rot_matrix:h,u_camera_to_center_distance:x.getCameraToCenterDistance(H),u_extrude_scale:[x.pixelsToGLUnits[0]/Y,x.pixelsToGLUnits[1]/Y],u_zoom_transition:A,u_tile_id:z,u_merc_center:D}},tw=(M,h,x=1)=>({u_matrix:M,u_color:h,u_overlay:0,u_overlay_scale:x}),SR=i.bC(),CR=(M,h,x,A,D,F,z)=>{const H=M.transform,Y=H.projection.name==="globe",ae=Y?i.dR(H.zoom,h.canonical)*H._pixelsPerMercatorPixel:i.ay(x,1,F),oe={u_matrix:h.projMatrix,u_extrude_scale:ae,u_intensity:z,u_inv_rot_matrix:SR,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(Y){oe.u_inv_rot_matrix=A,oe.u_merc_center=D,oe.u_tile_id=[h.canonical.x,h.canonical.y,1<({u_matrix:M,u_normalize_matrix:h,u_globe_matrix:x,u_merc_matrix:A,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:ae,u_fade_t:oe.mix,u_opacity:oe.opacity*ge.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:ge.paint.get("raster-brightness-min"),u_brightness_high:ge.paint.get("raster-brightness-max"),u_saturation_factor:i.dT(ge.paint.get("raster-saturation")),u_contrast_factor:i.dS(ge.paint.get("raster-contrast")),u_spin_weights:TR(ge.paint.get("raster-hue-rotate")),u_perspective_transform:fe,u_raster_elevation:xe,u_zoom_transition:z,u_merc_center:H,u_cutoff_params:Y,u_colorization_mix:zC(i.dU,Ce,Be),u_colorization_offset:BC(i.dU,Ve,Be),u_color_ramp:Pe,u_texture_offset:[ut/(et+2*ut),et/(et+2*ut)],u_texture_res:[et+2*ut,et+2*ut],u_emissive_strength:st});function TR(M){M*=Math.PI/180;const h=Math.sin(M),x=Math.cos(M);return[(2*x+1)/3,(-Math.sqrt(3)*h-x+1)/3,(Math.sqrt(3)*h-x+1)/3]}const Lf=.05,Tme=(M,h,x,A,D,F,z,H,Y,ae,oe,ge)=>({u_matrix:M,u_normalize_matrix:h,u_globe_matrix:x,u_merc_matrix:A,u_grid_matrix:D,u_tl_parent:F,u_scale_parent:ae,u_fade_t:oe.mix,u_opacity:oe.opacity,u_image0:0,u_image1:1,u_raster_elevation:ge,u_zoom_transition:z,u_merc_center:H,u_cutoff_params:Y}),Ame=(M,h,x,A,D,F,z,H,Y,ae)=>({u_particle_texture:M,u_particle_texture_side_len:h,u_tile_offset:x,u_velocity:A,u_color_ramp:F,u_velocity_res:D,u_max_speed:z,u_uv_offset:H,u_data_scale:[255*Y[0],255*Y[1]],u_data_offset:ae,u_particle_pos_scale:1.1,u_particle_pos_offset:[Lf,Lf]}),AR=(M,h,x,A,D,F,z,H,Y,ae)=>({u_particle_texture:M,u_particle_texture_side_len:h,u_velocity:x,u_velocity_res:A,u_max_speed:D,u_speed_factor:F,u_reset_rate:z,u_rand_seed:Math.random(),u_uv_offset:H,u_data_scale:[255*Y[0],255*Y[1]],u_data_offset:ae,u_particle_pos_scale:1.1,u_particle_pos_offset:[Lf,Lf]}),ER=i.bC(),$C=(M,h,x,A,D,F,z,H,Y,ae,oe,ge,fe,xe,Pe,Ce,Ve,Be,et,ut,st,Mt,yt,kt)=>{const gt=D.transform,mt={u_is_size_zoom_constant:+(M==="constant"||M==="source"),u_is_size_feature_constant:+(M==="constant"||M==="camera"),u_size_t:h?h.uSizeT:0,u_size:h?h.uSize:0,u_camera_to_center_distance:gt.getCameraToCenterDistance(et),u_rotate_symbol:+x,u_aspect_ratio:gt.width/gt.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:F,u_label_plane_matrix:z,u_coord_matrix:H,u_is_text:+ae,u_elevation_from_sea:Y?1:0,u_pitch_with_map:+A,u_texsize:oe,u_texsize_icon:ge,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:ER,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:ER,u_up_vector:[0,-1,0],u_color_adj_mat:Mt,u_icon_transition:yt||0,u_gamma_scale:A?D.transform.getCameraToCenterDistance(et)*Math.cos(D.terrain?0:D.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:kt||1,u_ground_shadow_factor:ut,u_inv_matrix:i.bl(i.bC(),z),u_normal_scale:st,u_lutTexture:Dc.LUT};return et.name==="globe"&&(mt.u_tile_id=[xe.canonical.x,xe.canonical.y,1<({u_matrix:M,u_emissive_strength:h,u_opacity:x,u_color:A}),jy=(M,h,x,A,D,F,z,H,Y)=>Object.assign(function(ae,oe,ge,fe,xe,Pe){const{width:Ce,height:Ve}=fe.imageManager.getPixelSize(oe),Be=Math.pow(2,Pe.tileID.overscaledZ),et=Pe.tileSize*Math.pow(2,fe.transform.tileZoom)/Be,ut=et*(Pe.tileID.canonical.x+Pe.tileID.wrap*Be),st=et*Pe.tileID.canonical.y;return{u_image:0,u_pattern_tl:ge.tl,u_pattern_br:ge.br,u_texsize:[Ce,Ve],u_pattern_size:ge.displaySize,u_pattern_units_to_pixels:xe?[fe.transform.width,-1*fe.transform.height]:[1/i.ay(Pe,1,fe.transform.tileZoom),1/i.ay(Pe,1,fe.transform.tileZoom)],u_pixel_coord_upper:[ut>>16,st>>16],u_pixel_coord_lower:[65535&ut,65535&st]}}(0,F,z,A,H,Y),{u_matrix:M,u_emissive_strength:h,u_opacity:x}),e_=new Float32Array(i.bA([])),Q0=(M,h,x,A,D,F,z,H,Y,ae,oe,ge,fe,xe=[0,0,0],Pe,Ce,Ve)=>{const Be=D.style.light,et=Be.properties.get("position"),ut=[-et.x,-et.y,et.z],st=i.dO();Be.properties.get("anchor")==="viewport"&&(i.dP(st,-D.transform.angle),i.dQ(ut,ut,st));const Mt=oe.alphaMode==="MASK",yt=Be.properties.get("color").toNonPremultipliedRenderColor(null),kt=fe.paint.get("model-ambient-occlusion-intensity"),gt=fe.paint.get("model-color").constantOr(i.ao.white).toNonPremultipliedRenderColor(null);return gt.a=fe.paint.get("model-color-mix-intensity").constantOr(0),Ve&&(gt.r=Ve[0],gt.g=Ve[1],gt.b=Ve[2],gt.a=Ve[3]),Ce&&(gt.r=Ce.color.r,gt.g=Ce.color.g,gt.b=Ce.color.b,gt.a=Ce.colorMix,ge=Ce.emissionStrength,F*=Ce.opacity),{u_matrix:M,u_lighting_matrix:h,u_normal_matrix:x,u_node_matrix:A||e_,u_lightpos:ut,u_lightintensity:Be.properties.get("intensity"),u_lightcolor:[yt.r,yt.g,yt.b],u_camera_pos:xe,u_opacity:F,u_baseTextureIsAlpha:0,u_alphaMask:+Mt,u_alphaCutoff:oe.alphaCutoff,u_baseColorFactor:z.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:H.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:Y,u_roughnessFactor:ae,u_baseColorTexture:Dc.BaseColor,u_metallicRoughnessTexture:Dc.MetallicRoughness,u_normalTexture:Dc.Normal,u_occlusionTexture:Dc.Occlusion,u_emissionTexture:Dc.Emission,u_lutTexture:Dc.LUT,u_color_mix:gt.toArray01(),u_aoIntensity:kt,u_emissive_strength:ge,u_occlusionTextureTransform:Pe||[0,0,0,0]}},XE=(M,h=e_,x=e_)=>({u_matrix:M,u_instance:h,u_node_matrix:x}),qC={fillExtrusion:M=>({u_matrix:new i.cl(M),u_lightpos:new i.ci(M),u_lightintensity:new i.cj(M),u_lightcolor:new i.ci(M),u_vertical_gradient:new i.cj(M),u_opacity:new i.cj(M),u_edge_radius:new i.cj(M),u_width_scale:new i.cj(M),u_ao:new i.ck(M),u_height_type:new i.ch(M),u_base_type:new i.ch(M),u_tile_id:new i.ci(M),u_zoom_transition:new i.cj(M),u_inv_rot_matrix:new i.cl(M),u_merc_center:new i.ck(M),u_up_dir:new i.ci(M),u_height_lift:new i.cj(M),u_flood_light_color:new i.ci(M),u_vertical_scale:new i.cj(M),u_flood_light_intensity:new i.cj(M),u_ground_shadow_factor:new i.ci(M)}),fillExtrusionDepth:M=>({u_matrix:new i.cl(M),u_edge_radius:new i.cj(M),u_width_scale:new i.cj(M),u_vertical_scale:new i.cj(M),u_height_type:new i.ch(M),u_base_type:new i.ch(M)}),fillExtrusionPattern:M=>({u_matrix:new i.cl(M),u_lightpos:new i.ci(M),u_lightintensity:new i.cj(M),u_lightcolor:new i.ci(M),u_vertical_gradient:new i.cj(M),u_height_factor:new i.cj(M),u_edge_radius:new i.cj(M),u_width_scale:new i.cj(M),u_ao:new i.ck(M),u_height_type:new i.ch(M),u_base_type:new i.ch(M),u_tile_id:new i.ci(M),u_zoom_transition:new i.cj(M),u_inv_rot_matrix:new i.cl(M),u_merc_center:new i.ck(M),u_up_dir:new i.ci(M),u_height_lift:new i.cj(M),u_image:new i.ch(M),u_texsize:new i.ck(M),u_pixel_coord_upper:new i.ck(M),u_pixel_coord_lower:new i.ck(M),u_tile_units_to_pixels:new i.cj(M),u_opacity:new i.cj(M),u_pattern_transition:new i.cj(M)}),fillExtrusionGroundEffect:M=>({u_matrix:new i.cl(M),u_opacity:new i.cj(M),u_ao_pass:new i.cj(M),u_meter_to_tile:new i.cj(M),u_ao:new i.ck(M),u_flood_light_intensity:new i.cj(M),u_flood_light_color:new i.ci(M),u_attenuation:new i.cj(M),u_edge_radius:new i.cj(M),u_fb:new i.ch(M),u_fb_size:new i.cj(M),u_dynamic_offset:new i.cj(M)}),fill:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_ground_shadow_factor:new i.ci(M)}),fillPattern:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_image:new i.ch(M),u_texsize:new i.ck(M),u_pixel_coord_upper:new i.ck(M),u_pixel_coord_lower:new i.ck(M),u_tile_units_to_pixels:new i.cj(M),u_ground_shadow_factor:new i.ci(M),u_pattern_transition:new i.cj(M)}),fillOutline:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_world:new i.ck(M),u_ground_shadow_factor:new i.ci(M)}),fillOutlinePattern:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_world:new i.ck(M),u_image:new i.ch(M),u_texsize:new i.ck(M),u_pixel_coord_upper:new i.ck(M),u_pixel_coord_lower:new i.ck(M),u_tile_units_to_pixels:new i.cj(M),u_ground_shadow_factor:new i.ci(M),u_pattern_transition:new i.cj(M)}),building:M=>({u_matrix:new i.cl(M),u_normal_matrix:new i.cl(M),u_opacity:new i.cj(M),u_faux_facade_ao_intensity:new i.cj(M),u_camera_pos:new i.ci(M),u_tile_to_meter:new i.cj(M),u_facade_emissive_chance:new i.cj(M),u_flood_light_color:new i.ci(M),u_flood_light_intensity:new i.cj(M)}),buildingBloom:M=>({u_matrix:new i.cl(M)}),buildingDepth:M=>({u_matrix:new i.cl(M)}),elevatedStructuresDepth:M=>({u_matrix:new i.cl(M),u_depth_bias:new i.cj(M)}),elevatedStructures:M=>({u_matrix:new i.cl(M),u_ground_shadow_factor:new i.ci(M)}),elevatedStructuresDepthReconstruct:M=>({u_matrix:new i.cl(M),u_camera_pos:new i.ci(M),u_depth_bias:new i.cj(M),u_height_scale:new i.cj(M),u_reset_depth:new i.cj(M)}),circle:i.dY,collisionBox:M=>({u_matrix:new i.cl(M),u_inv_rot_matrix:new i.cl(M),u_camera_to_center_distance:new i.cj(M),u_extrude_scale:new i.ck(M),u_zoom_transition:new i.cj(M),u_merc_center:new i.ck(M),u_tile_id:new i.ci(M)}),collisionCircle:M=>({u_matrix:new i.cl(M),u_inv_matrix:new i.cl(M),u_camera_to_center_distance:new i.cj(M),u_viewport_size:new i.ck(M)}),debug:M=>({u_color:new i.dB(M),u_matrix:new i.cl(M),u_overlay:new i.ch(M),u_overlay_scale:new i.cj(M)}),clippingMask:M=>({u_matrix:new i.cl(M)}),heatmap:M=>({u_extrude_scale:new i.cj(M),u_intensity:new i.cj(M),u_matrix:new i.cl(M),u_inv_rot_matrix:new i.cl(M),u_merc_center:new i.ck(M),u_tile_id:new i.ci(M),u_zoom_transition:new i.cj(M),u_up_dir:new i.ci(M)}),heatmapTexture:M=>({u_image:new i.ch(M),u_color_ramp:new i.ch(M),u_opacity:new i.cj(M)}),hillshade:M=>({u_matrix:new i.cl(M),u_image:new i.ch(M),u_latrange:new i.ck(M),u_light:new i.ck(M),u_shadow:new i.dB(M),u_highlight:new i.dB(M),u_emissive_strength:new i.cj(M),u_accent:new i.dB(M)}),hillshadePrepare:M=>({u_matrix:new i.cl(M),u_image:new i.ch(M),u_dimension:new i.ck(M),u_zoom:new i.cj(M)}),line:i.dX,linePattern:i.dW,raster:M=>({u_matrix:new i.cl(M),u_normalize_matrix:new i.cl(M),u_globe_matrix:new i.cl(M),u_merc_matrix:new i.cl(M),u_grid_matrix:new i.dC(M),u_tl_parent:new i.ck(M),u_scale_parent:new i.cj(M),u_fade_t:new i.cj(M),u_opacity:new i.cj(M),u_image0:new i.ch(M),u_image1:new i.ch(M),u_brightness_low:new i.cj(M),u_brightness_high:new i.cj(M),u_saturation_factor:new i.cj(M),u_contrast_factor:new i.cj(M),u_spin_weights:new i.ci(M),u_perspective_transform:new i.ck(M),u_raster_elevation:new i.cj(M),u_zoom_transition:new i.cj(M),u_merc_center:new i.ck(M),u_cutoff_params:new i.d3(M),u_colorization_mix:new i.d3(M),u_colorization_offset:new i.cj(M),u_color_ramp:new i.ch(M),u_texture_offset:new i.ck(M),u_texture_res:new i.ck(M),u_emissive_strength:new i.cj(M)}),rasterParticle:M=>({u_matrix:new i.cl(M),u_normalize_matrix:new i.cl(M),u_globe_matrix:new i.cl(M),u_merc_matrix:new i.cl(M),u_grid_matrix:new i.dC(M),u_tl_parent:new i.ck(M),u_scale_parent:new i.cj(M),u_fade_t:new i.cj(M),u_opacity:new i.cj(M),u_image0:new i.ch(M),u_image1:new i.ch(M),u_raster_elevation:new i.cj(M),u_zoom_transition:new i.cj(M),u_merc_center:new i.ck(M),u_cutoff_params:new i.d3(M)}),rasterParticleTexture:M=>({u_texture:new i.ch(M),u_opacity:new i.cj(M)}),rasterParticleDraw:M=>({u_particle_texture:new i.ch(M),u_particle_texture_side_len:new i.cj(M),u_tile_offset:new i.ck(M),u_velocity:new i.ch(M),u_color_ramp:new i.ch(M),u_velocity_res:new i.ck(M),u_max_speed:new i.cj(M),u_uv_offset:new i.ck(M),u_data_scale:new i.ck(M),u_data_offset:new i.cj(M),u_particle_pos_scale:new i.cj(M),u_particle_pos_offset:new i.ck(M)}),rasterParticleUpdate:M=>({u_particle_texture:new i.ch(M),u_particle_texture_side_len:new i.cj(M),u_velocity:new i.ch(M),u_velocity_res:new i.ck(M),u_max_speed:new i.cj(M),u_speed_factor:new i.cj(M),u_reset_rate:new i.cj(M),u_rand_seed:new i.cj(M),u_uv_offset:new i.ck(M),u_data_scale:new i.ck(M),u_data_offset:new i.cj(M),u_particle_pos_scale:new i.cj(M),u_particle_pos_offset:new i.ck(M)}),symbol:M=>({u_is_size_zoom_constant:new i.ch(M),u_is_size_feature_constant:new i.ch(M),u_size_t:new i.cj(M),u_size:new i.cj(M),u_camera_to_center_distance:new i.cj(M),u_rotate_symbol:new i.ch(M),u_aspect_ratio:new i.cj(M),u_fade_change:new i.cj(M),u_matrix:new i.cl(M),u_label_plane_matrix:new i.cl(M),u_coord_matrix:new i.cl(M),u_is_text:new i.ch(M),u_elevation_from_sea:new i.ch(M),u_pitch_with_map:new i.ch(M),u_texsize:new i.ck(M),u_texsize_icon:new i.ck(M),u_texture:new i.ch(M),u_texture_icon:new i.ch(M),u_gamma_scale:new i.cj(M),u_device_pixel_ratio:new i.cj(M),u_tile_id:new i.ci(M),u_zoom_transition:new i.cj(M),u_inv_rot_matrix:new i.cl(M),u_merc_center:new i.ck(M),u_camera_forward:new i.ci(M),u_tile_matrix:new i.cl(M),u_up_vector:new i.ci(M),u_ecef_origin:new i.ci(M),u_is_halo:new i.ch(M),u_icon_transition:new i.cj(M),u_color_adj_mat:new i.cl(M),u_scale_factor:new i.cj(M),u_ground_shadow_factor:new i.ci(M),u_inv_matrix:new i.cl(M),u_normal_scale:new i.cj(M),u_lutTexture:new i.ch(M)}),background:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_opacity:new i.cj(M),u_color:new i.dB(M)}),backgroundPattern:M=>({u_matrix:new i.cl(M),u_emissive_strength:new i.cj(M),u_opacity:new i.cj(M),u_image:new i.ch(M),u_pattern_tl:new i.ck(M),u_pattern_br:new i.ck(M),u_texsize:new i.ck(M),u_pattern_size:new i.ck(M),u_pixel_coord_upper:new i.ck(M),u_pixel_coord_lower:new i.ck(M),u_pattern_units_to_pixels:new i.ck(M)}),terrainRaster:M=>({u_matrix:new i.cl(M),u_image0:new i.ch(M),u_image1:new i.ch(M),u_skirt_height:new i.cj(M),u_ground_shadow_factor:new i.ci(M),u_emissive_texture_available:new i.cj(M)}),skybox:M=>({u_matrix:new i.cl(M),u_sun_direction:new i.ci(M),u_cubemap:new i.ch(M),u_opacity:new i.cj(M),u_temporal_offset:new i.cj(M)}),skyboxGradient:M=>({u_matrix:new i.cl(M),u_color_ramp:new i.ch(M),u_center_direction:new i.ci(M),u_radius:new i.cj(M),u_opacity:new i.cj(M),u_temporal_offset:new i.cj(M)}),skyboxCapture:M=>({u_matrix_3f:new i.dC(M),u_sun_direction:new i.ci(M),u_sun_intensity:new i.cj(M),u_color_tint_r:new i.d3(M),u_color_tint_m:new i.d3(M),u_luminance:new i.cj(M)}),globeRaster:M=>({u_proj_matrix:new i.cl(M),u_globe_matrix:new i.cl(M),u_normalize_matrix:new i.cl(M),u_merc_matrix:new i.cl(M),u_zoom_transition:new i.cj(M),u_merc_center:new i.ck(M),u_image0:new i.ch(M),u_image1:new i.ch(M),u_grid_matrix:new i.dC(M),u_skirt_height:new i.cj(M),u_far_z_cutoff:new i.cj(M),u_frustum_tl:new i.ci(M),u_frustum_tr:new i.ci(M),u_frustum_br:new i.ci(M),u_frustum_bl:new i.ci(M),u_globe_pos:new i.ci(M),u_globe_radius:new i.cj(M),u_viewport:new i.ck(M),u_emissive_texture_available:new i.cj(M)}),globeAtmosphere:M=>({u_frustum_tl:new i.ci(M),u_frustum_tr:new i.ci(M),u_frustum_br:new i.ci(M),u_frustum_bl:new i.ci(M),u_horizon:new i.cj(M),u_transition:new i.cj(M),u_fadeout_range:new i.cj(M),u_atmosphere_fog_color:new i.d3(M),u_high_color:new i.d3(M),u_space_color:new i.d3(M),u_temporal_offset:new i.cj(M),u_horizon_angle:new i.cj(M)}),model:M=>({u_matrix:new i.cl(M),u_lighting_matrix:new i.cl(M),u_normal_matrix:new i.cl(M),u_node_matrix:new i.cl(M),u_lightpos:new i.ci(M),u_lightintensity:new i.cj(M),u_lightcolor:new i.ci(M),u_camera_pos:new i.ci(M),u_opacity:new i.cj(M),u_baseColorFactor:new i.d3(M),u_emissiveFactor:new i.d3(M),u_metallicFactor:new i.cj(M),u_roughnessFactor:new i.cj(M),u_baseTextureIsAlpha:new i.ch(M),u_alphaMask:new i.ch(M),u_alphaCutoff:new i.cj(M),u_baseColorTexture:new i.ch(M),u_metallicRoughnessTexture:new i.ch(M),u_normalTexture:new i.ch(M),u_occlusionTexture:new i.ch(M),u_emissionTexture:new i.ch(M),u_lutTexture:new i.ch(M),u_color_mix:new i.d3(M),u_aoIntensity:new i.cj(M),u_emissive_strength:new i.cj(M),u_occlusionTextureTransform:new i.d3(M)}),modelDepth:M=>({u_matrix:new i.cl(M),u_instance:new i.cl(M),u_node_matrix:new i.cl(M)}),groundShadow:M=>({u_matrix:new i.cl(M),u_ground_shadow_factor:new i.ci(M)}),stars:M=>({u_matrix:new i.cl(M),u_up:new i.ci(M),u_right:new i.ci(M),u_intensity_multiplier:new i.cj(M)}),snowParticle:M=>({u_modelview:new i.cl(M),u_projection:new i.cl(M),u_time:new i.cj(M),u_cam_pos:new i.ci(M),u_velocityConeAperture:new i.cj(M),u_velocity:new i.cj(M),u_horizontalOscillationRadius:new i.cj(M),u_horizontalOscillationRate:new i.cj(M),u_boxSize:new i.cj(M),u_billboardSize:new i.cj(M),u_simpleShapeParameters:new i.ck(M),u_screenSize:new i.ck(M),u_thinningCenterPos:new i.ck(M),u_thinningShape:new i.ci(M),u_thinningAffectedRatio:new i.cj(M),u_thinningParticleOffset:new i.cj(M),u_particleColor:new i.d3(M),u_direction:new i.ci(M)}),rainParticle:M=>({u_modelview:new i.cl(M),u_projection:new i.cl(M),u_time:new i.cj(M),u_cam_pos:new i.ci(M),u_texScreen:new i.ch(M),u_velocityConeAperture:new i.cj(M),u_velocity:new i.cj(M),u_boxSize:new i.cj(M),u_rainDropletSize:new i.ck(M),u_distortionStrength:new i.cj(M),u_rainDirection:new i.ci(M),u_color:new i.d3(M),u_screenSize:new i.ck(M),u_thinningCenterPos:new i.ck(M),u_thinningShape:new i.ci(M),u_thinningAffectedRatio:new i.cj(M),u_thinningParticleOffset:new i.cj(M),u_shapeDirectionalPower:new i.cj(M),u_shapeNormalPower:new i.cj(M),u_mode:new i.cj(M)}),vignette:M=>({u_vignetteShape:new i.ci(M),u_vignetteColor:new i.d3(M)}),occlusion:M=>({u_matrix:new i.cl(M),u_anchorPos:new i.ci(M),u_screenSizePx:new i.ck(M),u_occluderSizePx:new i.ck(M),u_color:new i.d3(M)})};class Lp{constructor(h,x,A,D){this.id=Lp.uniqueIdxCounter,Lp.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,x.arrayBuffer,this.dynamicDraw?F.DYNAMIC_DRAW:F.STATIC_DRAW),this.dynamicDraw||D||x.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(h){this.id=Lp.uniqueIdxCounter,Lp.uniqueIdxCounter++;const x=this.context.gl;this.context.unbindVAO(),this.bind(),x.bufferSubData(x.ELEMENT_ARRAY_BUFFER,0,h.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Lp.uniqueIdxCounter=0;const QE={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class PR{constructor(h,x,A,D,F,z){this.length=x.length,this.attributes=A,this.itemSize=x.bytesPerElement,this.dynamicDraw=D,this.instanceCount=z,this.context=h;const H=h.gl;this.buffer=H.createBuffer(),h.bindVertexBuffer.set(this.buffer),H.bufferData(H.ARRAY_BUFFER,x.arrayBuffer,this.dynamicDraw?H.DYNAMIC_DRAW:H.STATIC_DRAW),this.dynamicDraw||F||x.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(h){const x=this.context.gl;this.bind(),x.bufferSubData(x.ARRAY_BUFFER,0,h.arrayBuffer)}enableAttributes(h,x){for(let A=0;A0&&h.vertexAttribDivisor(F,A)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class IR{constructor(h,x,A,D,F){this.context=h,this.width=x,this.height=A;const z=this.framebuffer=h.gl.createFramebuffer();D>0&&(this.colorAttachment0=new EC(h,z,0)),D>1&&(this.colorAttachment1=new EC(h,z,1)),F&&(this.depthAttachmentType=F,this.depthAttachment=F==="renderbuffer"?new Y1(h,z):new X2(h,z))}createColorAttachment(h,x){x===0?this.colorAttachment0=new EC(h,this.framebuffer,0):x===1&&(this.colorAttachment1=new EC(h,this.framebuffer,1))}removeColorAttachment(h,x){const A=this.context.gl;let D;x===0?(D=this.colorAttachment0.get(),this.colorAttachment0=void 0):x===1&&(D=this.colorAttachment1.get(),this.colorAttachment1=void 0),D&&A.deleteTexture(D)}destroy(){const h=this.context.gl;if(this.colorAttachment0){const x=this.colorAttachment0.get();x&&h.deleteTexture(x)}if(this.colorAttachment1){const x=this.colorAttachment1.get();x&&h.deleteTexture(x)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const x=this.depthAttachment.get();x&&h.deleteRenderbuffer(x)}else{const x=this.depthAttachment.get();x&&h.deleteTexture(x)}h.deleteFramebuffer(this.framebuffer)}}class t_{constructor(h,x){this.gl=h,this.clearColor=new wme(this),this.clearDepth=new hR(this),this.clearStencil=new LE(this),this.colorMask=new SC(this),this.depthMask=new DE(this),this.stencilMask=new Y0(this),this.stencilFunc=new W1(this),this.stencilOp=new Z2(this),this.stencilTest=new G1(this),this.depthRange=new mR(this),this.depthTest=new OE(this),this.depthFunc=new pR(this),this.blend=new K1(this),this.blendFunc=new CC(this),this.blendColor=new MC(this),this.blendEquation=new RE(this),this.cullFace=new TC(this),this.cullFaceSide=new Y2(this),this.frontFace=new fR(this),this.program=new gR(this),this.activeTexture=new xR(this),this.viewport=new Z1(this),this.bindFramebuffer=new yR(this),this.bindRenderbuffer=new jme(this),this.bindTexture=new kme(this),this.bindVertexBuffer=new Nme(this),this.bindElementBuffer=new FE(this),this.bindVertexArrayOES=new zE(this),this.pixelStoreUnpack=new BE(this),this.pixelStoreUnpackPremultiplyAlpha=new $E(this),this.pixelStoreUnpackFlipY=new vR(this),this.options=x?Object.assign({},x):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=h.getExtension("EXT_texture_filter_anisotropic")||h.getExtension("MOZ_EXT_texture_filter_anisotropic")||h.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=h.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=h.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=h.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=h.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=x&&!!x.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.indexOf("PowerVR")!==-1,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=h.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=h.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=h.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=h.getParameter(h.MAX_TEXTURE_SIZE),this.extBlendFuncExtended=h.getExtension("WEBGL_blend_func_extended")}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(h,x,A){return new Lp(this,h,x,A)}createVertexBuffer(h,x,A,D,F){return new PR(this,h,x,A,D,F)}createRenderbuffer(h,x,A){const D=this.gl,F=D.createRenderbuffer();return this.bindRenderbuffer.set(F),D.renderbufferStorage(D.RENDERBUFFER,h,x,A),this.bindRenderbuffer.set(null),F}createFramebuffer(h,x,A,D){return new IR(this,h,x,A,D)}clear({color:h,depth:x,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])),x!==void 0&&(z|=F.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(x),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,On.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 J0;function _r(M,h,x,A,D,F,z){const H=M.context,Y=H.gl,ae=M.transform,oe=[i.aF(ae.center.lng),i.aJ(ae.center.lat)],ge=x.layout.get("symbol-placement"),fe=x.layout.get("text-variable-anchor"),xe=x.layout.get("icon-rotation-alignment")==="map",Pe=x.layout.get("text-rotation-alignment")==="map",Ce=ge!=="point",Ve=[];let Be=0,et=0;for(let mt=0;mt0){const dr=i.bC(),xr=Xs;i.cP(dr,Ut.placementInvProjMatrix,ae.glCoordMatrix),i.cP(dr,dr,Ut.placementViewportMatrix),Ve.push({circleArray:Cr,circleOffset:et,transform:xr,invTransform:dr,projection:Ut.getProjection()}),Be+=Cr.length/4,et=Be}if(!Vs)continue;M.terrain&&M.terrain.setupElevationDraw(Ht,pr);const kr=Ls?[Pt.canonical.x,Pt.canonical.y,1<=0&&(xe[ut.associatedIconIndex]={x:Ut,y:ts,z:ns,angle:ls})}else Ep(yt,ge)}if(ae){fe.clear();const et=M.icon.placedSymbolArray;for(let ut=0;ut{let Pa=[0,0,0];if(oi){const zn=M.style.directionalLight,Zi=M.style.ambientLight;zn&&Zi&&(Pa=Kg(M.style,zn,Zi))}return Pa},Wa=oi=>{mt.depthOcclusionForSymbolsAndCircles&&(x.hasOcclusionOpacityProperties||M.terrain)&&(oi.push("DEPTH_D24"),oi.push("DEPTH_OCCLUSION"))},_n=oi=>{x.lut&&!yt&&(x.lut.texture||(x.lut.texture=new i.d$(M.context,x.lut.image,[x.lut.image.height,x.lut.image.height,x.lut.image.height],kt.gl.RGBA8)),kt.activeTexture.set(kt.gl.TEXTURE0+Dc.LUT),x.lut.texture&&x.lut.texture.bind(kt.gl.LINEAR,kt.gl.CLAMP_TO_EDGE),oi.push("APPLY_LUT_ON_GPU"))},ii=()=>{const oi=Pt&&x.layout.get("symbol-placement")!=="point",Pa=[];Wa(Pa),_n(Pa);const zn=oi||kn,Zi=Vs.elevationType==="road",Fo=M.shadowRenderer,yo=Zi&&Ut&&!!Fo&&Fo.enabled,Ai=Er(yo),Pu=Zi&&Ut&&!M.terrain?Yt:qs,bd=x.paint.get("icon-image-cross-fade");M.terrainRenderModeElevated()&&Ut&&Pa.push("PITCH_WITH_MAP_TERRAIN"),Cr&&(Pa.push("PROJECTION_GLOBE_VIEW"),zn&&Pa.push("PROJECTED_POS_ON_VIEWPORT")),bd>0&&Vs.hasAnySecondaryIcon&&Pa.push("ICON_TRANSITION"),!Vs.icon.zOffsetVertexBuffer||Zi&&M.terrain||Pa.push("Z_OFFSET"),Be===0&&et===0&&ut===0&&st===1||Pa.push("COLOR_ADJUSTMENT"),Vs.sdfIcons&&Pa.push("RENDER_SDF"),yo&&Pa.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Zi&&Ut&&!M.terrain&&Vs.icon.orientationVertexBuffer&&Pa.push("ELEVATED_ROADS");const Dl=Vs.icon.programConfigurations.get(x.id),Rd=M.getOrCreateProgram("symbol",{config:Dl,defines:Pa}),Fd=Xs.imageAtlasTexture?Xs.imageAtlasTexture.size:[0,0],Qc=Vs.iconSizeData,am=i.bK(Qc,mt.zoom),Ym=Ut||!mt.isOrthographic,ah=Ys(dr,Xs.tileID.canonical,Ut,Pt,mt,Vs.getProjection(),xr),To=cn(dr,Xs.tileID.canonical,Ut,Pt,mt,Vs.getProjection(),xr),Wo=M.translatePosMatrix(To,Xs,H,ae,!0),Ei=M.translatePosMatrix(dr,Xs,H,ae),al=zn?rw:ah,jo=Pt&&!Ut&&!oi;let vo=er;!Jt&&!mt.mercatorFromTransition||Pt||(vo=Yg(mt));const Xm=Cr?vo:er,gw=x.getColorAdjustmentMatrix(Be,et,ut,st),Rp=$C(Qc.kind,am,jo,Ut,M,Ei,al,Wo,Mt,!1,Fd,[0,0],0,pr,kr,Ft,ga,Xm,Vs.getProjection(),Ai,Ja,gw,bd,null),xw=Xs.imageAtlasTexture?Xs.imageAtlasTexture:null,d_=x.layout.get("icon-size").constantOr(0)!==1||Vs.iconsNeedLinear,zf=Vs.sdfIcons||M.options.rotating||M.options.zooming||d_||Ym?gt.LINEAR:gt.NEAREST,ax=Vs.sdfIcons&&x.paint.get("icon-halo-width").constantOr(1)!==0,u_=M.terrain&&Ut&&oi?i.bl(i.bC(),ah):rw;if(oi&&Vs.icon){const Ty=i.bV.getAtTileOffsetFunc(pr,mt.center.lat,mt.worldSize,Vs.getProjection()),ix=ln(dr,Xs.tileID.canonical,Ut,Pt,mt,Vs.getProjection(),xr),Fp=x.layout.get("icon-size-scale-range"),ox=i.aA(M.scaleFactor,Fp[0],Fp[1]);Hg(Vs,dr,M,!1,ix,To,Ut,Ce,Ty,pr,ox)}return{program:Rd,buffers:Vs.icon,uniformValues:Rp,atlasTexture:xw,atlasTextureIcon:null,atlasInterpolation:zf,atlasInterpolationIcon:null,isSDF:Vs.sdfIcons,hasHalo:ax,depthMode:Pu,tile:Xs,renderWithShadows:yo,labelPlaneMatrixInv:u_}},wi=()=>{const oi=Ht&&x.layout.get("symbol-placement")!=="point",Pa=[],zn=oi||ls||kn,Zi=Vs.elevationType==="road",Fo=M.shadowRenderer,yo=Zi&&ts&&!!Fo&&Fo.enabled,Ai=Er(yo),Pu=Zi&&ts&&!M.terrain?Yt:qs;M.terrainRenderModeElevated()&&ts&&Pa.push("PITCH_WITH_MAP_TERRAIN"),Cr&&(Pa.push("PROJECTION_GLOBE_VIEW"),zn&&Pa.push("PROJECTED_POS_ON_VIEWPORT")),!Vs.text.zOffsetVertexBuffer||Zi&&M.terrain||Pa.push("Z_OFFSET"),Vs.iconsInText&&Pa.push("RENDER_TEXT_AND_SYMBOL"),Pa.push("RENDER_SDF"),yo&&Pa.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Zi&&ts&&!M.terrain&&Vs.text.orientationVertexBuffer&&Pa.push("ELEVATED_ROADS"),Wa(Pa);const bd=Vs.text.programConfigurations.get(x.id),Dl=M.getOrCreateProgram("symbol",{config:bd,defines:Pa});let Rd,Fd=[0,0],Qc=null;const am=Vs.textSizeData;Vs.iconsInText&&(Fd=Xs.imageAtlasTexture?Xs.imageAtlasTexture.size:[0,0],Qc=Xs.imageAtlasTexture?Xs.imageAtlasTexture:null,Rd=ts||!mt.isOrthographic||M.options.rotating||M.options.zooming||am.kind==="composite"||am.kind==="camera"?gt.LINEAR:gt.NEAREST);const Ym=Xs.glyphAtlasTexture?Xs.glyphAtlasTexture.size:[0,0],ah=x.layout.get("text-size-scale-range"),To=i.aA(M.scaleFactor,ah[0],ah[1]),Wo=i.bK(am,mt.zoom,To),Ei=Ys(dr,Xs.tileID.canonical,ts,Ht,mt,Vs.getProjection(),xr),al=cn(dr,Xs.tileID.canonical,ts,Ht,mt,Vs.getProjection(),xr),jo=M.translatePosMatrix(al,Xs,Y,oe,!0),vo=M.translatePosMatrix(dr,Xs,Y,oe),Xm=zn?rw:Ei,gw=Ht&&!ts&&!oi;let Rp=er;!Jt&&!mt.mercatorFromTransition||Ht||(Rp=Yg(mt));const xw=$C(am.kind,Wo,gw,ts,M,vo,Xm,jo,Mt,!0,Ym,Fd,0,pr,kr,Ft,ga,Cr?Rp:er,Vs.getProjection(),Ai,Ja,null,null,To),d_=Xs.glyphAtlasTexture?Xs.glyphAtlasTexture:null,zf=gt.LINEAR,ax=x.paint.get("text-halo-width").constantOr(1)!==0,u_=M.terrain&&ts&&oi?i.bl(i.bC(),Ei):rw;if(oi&&Vs.text){const Ty=i.bV.getAtTileOffsetFunc(pr,mt.center.lat,mt.worldSize,Vs.getProjection()),ix=ln(dr,Xs.tileID.canonical,ts,Ht,mt,Vs.getProjection(),xr);Hg(Vs,dr,M,!0,ix,al,ts,Ve,Ty,pr,To)}return{program:Dl,buffers:Vs.text,uniformValues:xw,atlasTexture:d_,atlasTextureIcon:Qc,atlasInterpolation:zf,atlasInterpolationIcon:Rd,isSDF:!0,hasHalo:ax,depthMode:Pu,tile:Xs,renderWithShadows:yo,labelPlaneMatrixInv:u_}},pi=Vs.icon.segments.get().length,Ua=Vs.text.segments.get().length,Fn=pi&&!z.onlyText?ii():null,si=Ua&&!z.onlyIcons?wi():null,wo=x.paint.get("icon-opacity").constantOr(1),eo=x.paint.get("text-opacity").constantOr(1);if(ns&&Vs.canOverlap){fs=!0;const oi=wo&&!z.onlyText?Vs.icon.segments.get():[],Pa=eo&&!z.onlyIcons?Vs.text.segments.get():[];for(const zn of oi)Ls.push({segments:new i.bg([zn]),sortKey:zn.sortKey,state:Fn});for(const zn of Pa)Ls.push({segments:new i.bg([zn]),sortKey:zn.sortKey,state:si})}else z.onlyText||Ls.push({segments:wo?Vs.icon.segments:new i.bg([]),sortKey:0,state:Fn}),z.onlyIcons||Ls.push({segments:eo?Vs.text.segments:new i.bg([]),sortKey:0,state:si})}fs&&Ls.sort((pr,Xs)=>pr.sortKey-Xs.sortKey);for(const pr of Ls){const Xs=pr.state;if(Xs)if(M.terrain?M.terrain.setupElevationDraw(Xs.tile,Xs.program,{useDepthForOcclusion:mt.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Xs.labelPlaneMatrixInv}):M.setupDepthForOcclusion(mt.depthOcclusionForSymbolsAndCircles,Xs.program),kt.activeTexture.set(gt.TEXTURE0),Xs.atlasTexture&&Xs.atlasTexture.bind(Xs.atlasInterpolation,gt.CLAMP_TO_EDGE,!0),Xs.atlasTextureIcon&&(kt.activeTexture.set(gt.TEXTURE1),Xs.atlasTextureIcon&&Xs.atlasTextureIcon.bind(Xs.atlasInterpolationIcon,gt.CLAMP_TO_EDGE,!0)),Xs.renderWithShadows&&M.shadowRenderer.setupShadows(Xs.tile.tileID.toUnwrapped(),Xs.program,"vector-tile"),M.uploadCommonLightUniforms(M.context,Xs.program),Xs.hasHalo){const Vs=Xs.uniformValues;Vs.u_is_halo=1,JE(Xs.buffers,pr.segments,x,M,Xs.program,Xs.depthMode,D,F,Vs,2),Vs.u_is_halo=0}else{if(Xs.isSDF){const Vs=Xs.uniformValues;Xs.hasHalo&&(Vs.u_is_halo=1,JE(Xs.buffers,pr.segments,x,M,Xs.program,Xs.depthMode,D,F,Vs,1)),Vs.u_is_halo=0}JE(Xs.buffers,pr.segments,x,M,Xs.program,Xs.depthMode,D,F,Xs.uniformValues,1)}}}function JE(M,h,x,A,D,F,z,H,Y,ae){const oe=[M.dynamicLayoutVertexBuffer,M.opacityVertexBuffer,M.iconTransitioningVertexBuffer,M.globeExtVertexBuffer,M.zOffsetVertexBuffer,M.orientationVertexBuffer];D.draw(A,A.context.gl.TRIANGLES,F,z,H,nn.disabled,Y,x.id,M.layoutVertexBuffer,M.indexBuffer,h,x.paint,A.transform.zoom,M.programConfigurations.get(x.id),oe,ae)}function LR(M,h){const x=1<=Ip?1:xe.pitch/Ip))),2*Pe}(M.transform),ae=M.transform.getFreeCameraOptions().position,oe="elevatedStructuresDepthReconstruct",ge=M.getOrCreateProgram(oe,{defines:["DEPTH_RECONSTRUCTION"]}),fe=M.getOrCreateProgram(oe);for(const xe of A){const Pe=h.getTile(xe),Ce=Pe.getBucket(x);if(!Ce)continue;const Ve=Ce.elevatedStructures;if(!Ve)continue;const Be=Ce.elevationBufferData.heightRange,et=LR(xe.toUnwrapped(),ae),ut=M.translatePosMatrix(xe.projMatrix,Pe,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor"));let st,Mt,yt,kt;if(D==="initialize"){if(!Be||Be.min>=1||Ve.depthSegments.segments[0].primitiveLength===0)continue;st=X0(ut,et,Y,1,0),Mt=z,yt=Ve.depthSegments,kt=ge}else if(D==="reset"){if(!Be||Be.min>=0||Ve.maskSegments.segments[0].primitiveLength===0)continue;st=X0(ut,et,0,0,1),Mt=H,yt=Ve.maskSegments,kt=ge}else if(D==="geometry"){if(Ve.depthSegments.segments[0].primitiveLength===0)continue;st=X0(ut,et,Y,1,0),Mt=z,yt=Ve.depthSegments,kt=fe}kt.draw(M,F.TRIANGLES,Mt,dn.disabled,On.disabled,nn.disabled,st,x.id,Ve.vertexBuffer,Ve.indexBuffer,yt,x.paint,M.transform.zoom)}}function VC(M,h,x,A){const{painter:D,sourceCache:F,layer:z,coords:H,colorMode:Y,elevationType:ae,terrainEnabled:oe,pass:ge}=M,fe=D.context.gl,xe=z.paint.get("fill-pattern"),Pe=z.paint.get("fill-pattern-cross-fade"),Ce=xe.constantOr(null);let Ve=ae;ae!=="road"||h&&!oe||(Ve="none");const Be=Ve==="road",et=M.painter.shadowRenderer,ut=Be&&!!et&&et.enabled,st=new Lr(D.context.gl.LEQUAL,Lr.ReadOnly,D.depthRangeFor3D);let Mt=[0,0,0];if(ut){const mt=D.style.directionalLight,Pt=D.style.ambientLight;mt&&Pt&&(Mt=Kg(D.style,mt,Pt))}const yt=xe&&xe.constantOr(1),kt=D.terrain&&D.terrain.renderingToTexture,gt=(mt,Pt)=>{let Ht,Ut,ts,ns,fs;Pt?(Ht=yt&&!z.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",ts=fe.LINES):(Ht=yt?"fillPattern":"fill",ts=fe.TRIANGLES);for(const qs of H){const Yt=F.getTile(qs);if(yt&&!Yt.patternsLoaded())continue;const Ft=Yt.getBucket(z);if(!Ft)continue;const ls=h?Ft.elevationBufferData:Ft.bufferData;if(ls.isEmpty())continue;D.prepareDrawTile();const Jt=ls.programConfigurations.get(z.id),Ls=D.isTileAffectedByFog(qs),er=[],pr=[];Be&&(er.push("ELEVATED_ROADS"),pr.push(ls.elevatedLayoutVertexBuffer)),ut&&er.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),kt&&x&&er.push("USE_MRT1"),yt&&(D.context.activeTexture.set(fe.TEXTURE0),Yt.imageAtlasTexture&&Yt.imageAtlasTexture.bind(fe.LINEAR,fe.CLAMP_TO_EDGE),Jt.updatePaintBuffers());let Xs=!1;if(Ce&&Yt.imageAtlas){const xr=Yt.imageAtlas,Vr=i.e3.from(Ce),kn=Vr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),ga=Vr.getSecondary(),Ja=xr.patternPositions.get(kn),Er=ga?xr.patternPositions.get(ga.scaleSelf(i.o.devicePixelRatio).toString()):null;Xs=!!Ja&&!!Er,Ja&&Jt.setConstantPatternPositions(Ja,Er)}Pe>0&&(Xs||Jt.getPatternTransitionVertexBuffer("fill-pattern"))&&er.push("FILL_PATTERN_TRANSITION");const Vs=D.getOrCreateProgram(Ht,{config:Jt,overrideFog:Ls,defines:er}),Cr=D.translatePosMatrix(qs.projMatrix,Yt,z.paint.get("fill-translate"),z.paint.get("fill-translate-anchor"));ut&&et.setupShadows(Yt.tileID.toUnwrapped(),Vs,"vector-tile");const kr=z.paint.get("fill-emissive-strength");if(Pt){ns=ls.lineIndexBuffer,fs=ls.lineSegments;const xr=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[fe.drawingBufferWidth,fe.drawingBufferHeight];Ut=Ht==="fillOutlinePattern"&&yt?ZE(Cr,kr,D,Yt,xr,Mt,Pe):kR(Cr,kr,xr,Mt)}else ns=ls.indexBuffer,fs=ls.triangleSegments,Ut=yt?KE(Cr,kr,D,Yt,Mt,Pe):GE(Cr,kr,Mt);D.uploadCommonUniforms(D.context,Vs,qs.toUnwrapped());let dr=mt;(ae==="road"&&!oe||ae==="offset")&&(dr=st),Vs.draw(D,ts,dr,A||D.stencilModeForClipping(qs),Y,nn.disabled,Ut,z.id,ls.layoutVertexBuffer,ns,fs,z.paint,D.transform.zoom,Jt,pr)}};D.renderPass===ge&>(D.depthModeForSublayer(1,D.renderPass==="opaque"?Lr.ReadWrite:Lr.ReadOnly),!1),Ve==="none"&&D.renderPass==="translucent"&&z.paint.get("fill-antialias")&>(D.depthModeForSublayer(z.getPaintProperty("fill-outline-color")?2:0,Lr.ReadOnly),!0)}function HC(M,h,x,A,D,F,z,H){x.resetLayerRenderingStats(M);const Y=M.context,ae=Y.gl,oe=M.transform,ge=x.paint.get("fill-extrusion-pattern"),fe=x.paint.get("fill-extrusion-pattern-cross-fade"),xe=ge.constantOr(null),Pe=ge.constantOr(1),Ce=x.paint.get("fill-extrusion-opacity"),Ve=M.style.enable3dLights(),Be=x.paint.get(Ve&&!Pe?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),et=[x.paint.get("fill-extrusion-ambient-occlusion-intensity"),Be],ut=x.layout.get("fill-extrusion-edge-radius"),st=ut>0&&!x.paint.get("fill-extrusion-rounded-roof"),Mt=st?0:ut,yt=oe.projection.name==="globe"?i.eb():0,kt=oe.projection.name==="globe",gt=kt?i.aj(oe.zoom):0,mt=[i.aF(oe.center.lng),i.aJ(oe.center.lat)],Pt=x.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Ht=x.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Pt?null:x.lut).toArray01().slice(0,3),Ut=x.paint.get("fill-extrusion-flood-light-intensity"),ts=x.paint.get("fill-extrusion-vertical-scale"),ns=x.paint.get("fill-extrusion-line-width").constantOr(1)!==0,fs=x.paint.get("fill-extrusion-height-alignment"),qs=x.paint.get("fill-extrusion-base-alignment"),Yt=fy(M,x.paint.get("fill-extrusion-cutoff-fade-range")),Ft=[];let ls;kt&&Ft.push("PROJECTION_GLOBE_VIEW"),et[0]>0&&Ft.push("FAUX_AO"),st&&Ft.push("ZERO_ROOF_RADIUS"),H&&Ft.push("HAS_CENTROID"),Ut>0&&Ft.push("FLOOD_LIGHT"),Yt.shouldRenderCutoff&&Ft.push("RENDER_CUTOFF"),ns&&Ft.push("RENDER_WALL_MODE");const Jt=M.renderPass==="shadow",Ls=M.shadowRenderer,er=Jt&&!!Ls,pr=Jt?nn.disabled:nn.backCCW;M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0);let Xs=[0,0,0];if(Ls){const kr=M.style.directionalLight,dr=M.style.ambientLight;kr&&dr&&(Xs=Kg(M.style,kr,dr)),Jt||(Ft.push("RENDER_SHADOWS","DEPTH_TEXTURE"),Ls.useNormalOffset&&Ft.push("NORMAL_OFFSET")),ls=Ft.concat(["SHADOWS_SINGLE_CASCADE"])}const Vs=er?"fillExtrusionDepth":Pe?"fillExtrusionPattern":"fillExtrusion",Cr=x.getLayerRenderingStats();for(const kr of A){const dr=h.getTile(kr),xr=dr.getBucket(x);if(!xr||xr.projection.name!==oe.projection.name)continue;let Vr=!1;Ls&&(Vr=Ls.getMaxCascadeForTile(kr.toUnwrapped())===0);const kn=M.isTileAffectedByFog(kr),ga=xr.programConfigurations.get(x.id);let Ja=!1;if(xe&&dr.imageAtlas){const Ua=dr.imageAtlas,Fn=i.e3.from(xe),si=Fn.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),wo=Fn.getSecondary(),eo=Ua.patternPositions.get(si),oi=wo?Ua.patternPositions.get(wo.scaleSelf(i.o.devicePixelRatio).toString()):null;Ja=!!eo&&!!oi,eo&&ga.setConstantPatternPositions(eo,oi)}fe>0&&(Ja||ga.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Ft.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Er=M.getOrCreateProgram(Vs,{config:ga,defines:Vr?ls:Ft,overrideFog:kn});if(M.terrain&&M.terrain.setupElevationDraw(dr,Er,{useMeterToDem:!0}),!xr.centroidVertexBuffer){const Ua=Er.getAttributeLocation(ae,"a_centroid_pos");Ua!==-1&&ae.vertexAttrib2f(Ua,0,0)}!Jt&&Ls&&Ls.setupShadows(dr.tileID.toUnwrapped(),Er,"vector-tile"),Pe&&(M.context.activeTexture.set(ae.TEXTURE0),dr.imageAtlasTexture&&dr.imageAtlasTexture.bind(ae.LINEAR,ae.CLAMP_TO_EDGE),ga.updatePaintBuffers());const Wa=x.paint.get("fill-extrusion-vertical-gradient"),_n=1/xr.tileToMeter;let ii;if(Jt&&Ls){if(Qg(dr.tileID,xr.maxHeight,M))continue;const Ua=Ls.calculateShadowPassMatrixFromTile(dr.tileID.toUnwrapped());ii=WE(Ua,Mt,_n,ts,fs,qs)}else{const Ua=M.translatePosMatrix(kr.expandedProjMatrix,dr,x.paint.get("fill-extrusion-translate"),x.paint.get("fill-extrusion-translate-anchor")),Fn=oe.projection.createInversionMatrix(oe,kr.canonical);ii=Pe?jR(Ua,M,Wa,Ce,et,Mt,_n,kr,dr,yt,fs,qs,gt,mt,Fn,Ht,ts,fe):RC(Ua,M,Wa,Ce,et,Mt,_n,kr,yt,fs,qs,gt,mt,Fn,Ht,ts,Ut,Xs)}M.uploadCommonUniforms(Y,Er,kr.toUnwrapped(),null,Yt);let wi=xr.segments;if(oe.projection.name==="mercator"&&!Jt&&(wi=xr.getVisibleSegments(dr.tileID,M.terrain,M.transform.getFrustum(0)),!wi.get().length))continue;if(Cr)if(Jt)for(const Ua of wi.get())Cr.numRenderedVerticesInShadowPass+=Ua.primitiveLength;else for(const Ua of wi.get())Cr.numRenderedVerticesInTransparentPass+=Ua.primitiveLength;const pi=[];(M.terrain||H)&&pi.push(xr.centroidVertexBuffer),kt&&pi.push(xr.layoutVertexExtBuffer),ns&&pi.push(xr.wallVertexBuffer),Er.draw(M,Y.gl.TRIANGLES,D,F,z,pr,ii,x.id,xr.layoutVertexBuffer,xr.indexBuffer,wi,x.paint,M.transform.zoom,ga,pi)}M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!1)}class eP{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function Xg(M,h,x,A,D,F,z,H,Y,ae,oe,ge,fe,xe,Pe,Ce,Ve,Be,et,ut){const st=h.context,Mt=st.gl,yt=h.transform,kt=h.transform.zoom,gt=[],mt=M.translate,Pt=M.translateAnchor,Ht=M.edgeRadius,Ut=fy(h,M.cutoffFadeRange);oe==="clear"?(gt.push("CLEAR_SUBPASS"),ut&&(gt.push("CLEAR_FROM_TEXTURE"),st.activeTexture.set(Mt.TEXTURE0),ut.bind(Mt.LINEAR,Mt.CLAMP_TO_EDGE))):oe==="sdf"?gt.push("SDF_SUBPASS"):oe==="emissive"&&(gt.push("USE_MRT1"),st.activeTexture.set(Mt.TEXTURE0),ut.bind(Mt.LINEAR,Mt.CLAMP_TO_EDGE)),Be&>.push("HAS_CENTROID"),Ut.shouldRenderCutoff&>.push("RENDER_CUTOFF");const ts=(ns,fs,qs,Yt,Ft)=>{let ls=gt;fs.groundRadiusBuffer!=null&&(ls=gt.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const Jt=fs.programConfigurations.get(A.id),Ls=h.isTileAffectedByFog(ns),er=h.getOrCreateProgram("fillExtrusionGroundEffect",{config:Jt,defines:ls,overrideFog:Ls}),pr=J1(h,Yt,ge,ae,Ft,[fe,xe*Ft],Pe,Ce,Ve,kt>=17?0:Ht*Ft,ut?ut.size[0]:0),Xs=[];Be&&Xs.push(fs.hiddenByLandmarkVertexBuffer),fs.groundRadiusBuffer!=null&&Xs.push(fs.groundRadiusBuffer),h.uploadCommonUniforms(st,er,ns.toUnwrapped(),null,Ut),er.draw(h,st.gl.TRIANGLES,F,z,H,Y,pr,A.id,fs.vertexBuffer,fs.indexBuffer,qs,A.paint,kt,Jt,Xs)};for(const ns of D){const fs=x.getTile(ns),qs=fs.getBucket(A);if(!qs||qs.projection.name!==yt.projection.name||!qs.groundEffect||qs.groundEffect&&!qs.groundEffect.hasData())continue;const Yt=qs.groundEffect,Ft=1/qs.tileToMeter;{const ls=h.translatePosMatrix(ns.projMatrix,fs,mt,Pt),Jt=Yt.getDefaultSegment();ts(ns,Yt,Jt,ls,Ft)}if(et)for(let ls=0;ls<4;ls++){const Jt=i.e9[ls](ns),Ls=x.getTile(Jt);if(!Ls)continue;const er=Ls.getBucket(A);if(!er||er.projection.name!==yt.projection.name||!er.groundEffect||er.groundEffect&&!er.groundEffect.hasData())continue;const pr=er.groundEffect;let Xs,Vs;ls===0?(Xs=[-i.al,0,0],Vs=1):ls===1?(Xs=[i.al,0,0],Vs=0):ls===2?(Xs=[0,-i.al,0],Vs=3):(Xs=[0,i.al,0],Vs=2);const Cr=pr.regionSegments[Vs];if(!Cr)continue;const kr=new Float32Array(16);i.br(kr,ns.projMatrix,Xs),ts(ns,pr,Cr,h.translatePosMatrix(kr,fs,mt,Pt),Ft)}}}function Eme(M,h,x,A,D,F,z){A.centroidVertexArray.length===0&&A.createCentroidsBuffer();const H=F?F.findDEMTileFor(x):null;if(!(H&&H.dem||z))return;F&&H&&H.dem&&A.selfDEMTileTimestamp!==H.dem._timestamp&&(A.borderDoneWithNeighborZ=[-1,-1,-1,-1],A.selfDEMTileTimestamp=H.dem._timestamp);const Y=Be=>new i.P(Math.ceil((Be+i.ed)*i.ee),0),ae=Be=>{const et=h.getSource().minzoom,ut=Mt=>{const yt=h.getTileByID(Mt);if(yt&&yt.hasData())return yt.getBucket(D)},st=[0,-1,1];for(const Mt of st){if(Be.overscaledZ+Mt(oe[0]=Math.min(Be.min.y,et.min.y),oe[1]=Math.max(Be.max.y,et.max.y),oe[2]=i.al-et.min.x>Be.max.x?et.min.x-i.al:Be.max.x,oe),fe=(Be,et)=>(oe[0]=Math.min(Be.min.x,et.min.x),oe[1]=Math.max(Be.max.x,et.max.x),oe[2]=i.al-et.min.y>Be.max.y?et.min.y-i.al:Be.max.y,oe),xe=[(Be,et)=>ge(Be,et),(Be,et)=>ge(et,Be),(Be,et)=>fe(Be,et),(Be,et)=>fe(et,Be)],Pe=(Be,et,ut,st,Mt,yt,kt)=>{if(!F)return 0;const gt=[[yt?ut:Be,yt?Be:ut,0],[yt?ut:et,yt?et:ut,0]],mt=kt<0?i.al+kt:kt,Pt=[yt?mt:(Be+et)/2,yt?(Be+et)/2:mt,0];return ut===0&&kt<0||ut!==0&&kt>0?F.getForTilePoints(Mt,[Pt],!0,st):gt.push(Pt),F.getForTilePoints(x,gt,!0,H),Math.max(gt[0][2],gt[1][2],Pt[2])/F.exaggeration()};for(let Be=0;Be<4;Be++){const et=A.borderFeatureIndices[Be];if(et.length===0)continue;const ut=i.e9[Be](x),st=ae(ut);if(!(st&&st instanceof i.ea))continue;const Mt=F?F.findDEMTileFor(ut):null;if(!(Mt&&Mt.dem||z)||(F&&Mt&&Mt.dem&&A.borderDEMTileTimestamp[Be]!==Mt.dem._timestamp&&(A.borderDoneWithNeighborZ[Be]=-1,A.borderDEMTileTimestamp[Be]=Mt.dem._timestamp),A.borderDoneWithNeighborZ[Be]===st.canonical.z))continue;st.centroidVertexArray.length===0&&st.createCentroidsBuffer();const yt=(Be<2?1:5)-Be,kt=st.borderDoneWithNeighborZ[yt]!==A.canonical.z,gt=st.borderFeatureIndices[yt];let mt=0;if(A.canonical.z!==st.canonical.z){for(const Pt of et)A.showCentroid(A.featuresOnBorder[Pt]);if(kt)for(const Pt of gt)st.showCentroid(st.featuresOnBorder[Pt]);A.borderDoneWithNeighborZ[Be]=st.canonical.z,st.borderDoneWithNeighborZ[yt]=A.canonical.z}for(const Pt of et){const Ht=A.featuresOnBorder[Pt],Ut=A.centroidData[Ht.centroidDataIndex],ts=Ht.borders[Be];let ns;for(;mtts[0]+3||fs[0]>ts[0]-3)break;st.showCentroid(ns),mt++}if(ns&&mtts[1]-3)&&(qs++,++mt!==gt.length);)ns=st.featuresOnBorder[gt[mt]];ns=st.featuresOnBorder[gt[fs]];let Yt=!1;if(qs>=1){const Jt=ns.borders[yt];Math.abs(ts[0]-Jt[0])<3&&Math.abs(ts[1]-Jt[1])<3&&(qs=1,Yt=!0,mt=fs+1)}else if(qs===0){A.showCentroid(Ht);continue}const Ft=st.centroidData[ns.centroidDataIndex];z&&Yt&&(((Ce=Ut).flags|(Ve=Ft).flags)&i.ec?(Ce.flags|=i.ec,Ve.flags|=i.ec):(Ce.flags&=~i.ec,Ve.flags&=~i.ec));const ls=Ht.intersectsCount()>1||ns.intersectsCount()>1;if(qs>1)mt=fs,Ut.centroidXY=Ft.centroidXY=new i.P(0,0);else if(Mt&&Mt.dem&&!ls){const Jt=xe[Be](Ut,Ft),Ls=Be%2?i.al-1:0,er=Pe(Jt[0],Math.min(i.al-1,Jt[1]),Ls,Mt,ut,Be<2,Jt[2]);Ut.centroidXY=Ft.centroidXY=Y(er)}else ls?Ut.centroidXY=Ft.centroidXY=new i.P(0,0):(Ut.centroidXY=A.encodeBorderCentroid(Ht),Ft.centroidXY=st.encodeBorderCentroid(ns));A.writeCentroidToBuffer(Ut),st.writeCentroidToBuffer(Ft)}else A.showCentroid(Ht)}A.borderDoneWithNeighborZ[Be]=st.canonical.z,st.borderDoneWithNeighborZ[yt]=A.canonical.z}var Ce,Ve;(A.needsCentroidUpdate||!A.centroidVertexBuffer&&A.centroidVertexArray.length!==0)&&A.uploadCentroid(M)}const kh=[1,0,0],tP=[0,1,0],Au=[0,0,1];function Qg(M,h,x){const A=x.transform,D=x.shadowRenderer;if(!D)return!0;const F=M.toUnwrapped(),z=A.tileSize*D._cascades[x.currentShadowCascade].scale;let H=h;if(A.elevation){const Ce=A.elevation.getMinMaxForTile(M);Ce&&(H+=Ce.max)}const Y=[...D.shadowDirection];Y[2]=-Y[2];const ae=D.computeSimplifiedTileShadowVolume(F,H,z,Y);if(!ae)return!1;const oe=[kh,tP,Au,Y,[Y[0],0,Y[2]],[0,Y[1],Y[2]]],ge=A.projection.name==="globe",fe=A.scaleZoom(z),xe=i.cB.fromInvProjectionMatrix(A.invProjMatrix,A.worldSize,fe,!ge),Pe=D.getCurrentCascadeFrustum();return xe.intersectsPrecise(ae.vertices,ae.planes,oe)===0||Pe.intersectsPrecise(ae.vertices,ae.planes,oe)===0}function aw(M){const{painter:h,source:x,layer:A,coords:D}=M;let F=M.defines;const z=h.context,H=h.renderPass==="shadow",Y=h.renderPass==="light-beam",ae=h.shadowRenderer,oe=i.ef(h.transform.center.lat,h.transform.zoom),ge=fy(h,A.paint.get("building-cutoff-fade-range"));ge.shouldRenderCutoff&&(F=F.concat("RENDER_CUTOFF")),M.floodLightIntensity>0&&(F=F.concat("FLOOD_LIGHT"));for(const fe of D){const xe=x.getTile(fe),Pe=xe.getBucket(A);if(!Pe)continue;ae&&ae.getMaxCascadeForTile(fe.toUnwrapped())===0&&(F=F.concat("SHADOWS_SINGLE_CASCADE"));const Ce=Pe.programConfigurations.get(A.id);let Ve,Be,et,ut=h.translatePosMatrix(fe.expandedProjMatrix,xe,[0,0],"map");if(ut=i.cS(i.bC(),ut,[1,1,M.verticalScale]),H&&ae){if(Qg(xe.tileID,Pe.maxHeight*oe,h))continue;let Mt=ae.calculateShadowPassMatrixFromTile(xe.tileID.toUnwrapped());Mt=i.cS(i.bC(),Mt,[1,1,M.verticalScale]),et=wy(Mt),Ve=Be=h.getOrCreateProgram("buildingDepth",{config:Ce,defines:F,overrideFog:!1})}else if(Y)Ve=Be=h.getOrCreateProgram("buildingBloom",{config:Ce,defines:F,overrideFog:!1}),et=NR(ut);else{const Mt=h.transform.calculatePosMatrix(fe.toUnwrapped(),h.transform.worldSize);i.cS(Mt,Mt,[1,1,M.verticalScale]);const yt=i.bC();i.cS(yt,Mt,[1,-1,1/oe]),i.bl(yt,yt),i.eg(yt,yt);const kt=h.transform.getFreeCameraOptions().position,gt=1<{if(Y){const kt=Mt.entranceBloom;yt.draw(h,z.gl.TRIANGLES,M.depthMode,dn.disabled,M.blendMode,nn.disabled,et,A.id,kt.layoutVertexBuffer,kt.indexBuffer,kt.segmentsBucket,A.paint,h.transform.zoom,Ce,[kt.layoutAttenuationBuffer,kt.layoutColorBuffer])}else{const kt=Mt.segmentsBucket;let gt=[Mt.layoutNormalBuffer,Mt.layoutCentroidBuffer,Mt.layoutColorBuffer,Mt.layoutFloodLightDataBuffer];Mt.layoutFacadePaintBuffer&&(gt=gt.concat([Mt.layoutFacadeDataBuffer,Mt.layoutFacadeVerticalRangeBuffer,Mt.layoutFacadePaintBuffer])),yt.draw(h,z.gl.TRIANGLES,M.depthMode,dn.disabled,M.blendMode,H?nn.disabled:nn.backCW,et,A.id,Mt.layoutVertexBuffer,Mt.indexBuffer,kt,A.paint,h.transform.zoom,Ce,gt)}};h.uploadCommonUniforms(z,Be,fe.toUnwrapped(),null,ge),Pe.buildingWithoutFacade&&st(Pe.buildingWithoutFacade,Be),Pe.buildingWithFacade&&(Ve!==Be&&h.uploadCommonUniforms(z,Ve,fe.toUnwrapped(),null,ge),st(Pe.buildingWithFacade,Ve))}}function WC(M,h,x,A,D,F,z,H,Y,ae,oe,ge,fe){const xe=M.context.gl,Pe=M.depthModeForSublayer(1,Lr.ReadOnly,xe.LEQUAL,!0),Ce=.1*(1-(Ve=oe))+3*Ve;var Ve;const Be=M._showOverdrawInspector,et=ge,ut=new eP;Be||Xg(ut,M,h,x,A,Pe,new dn({func:xe.ALWAYS,mask:255},255,255,xe.KEEP,xe.KEEP,xe.REPLACE),new On([xe.ONE,xe.ONE,xe.ONE,xe.ONE],i.ao.transparent,[!1,!1,!1,!0],xe.MIN),nn.disabled,D,"sdf",F,z,H,Y,ae,Ce,et,!1);{const st=Be?dn.disabled:new dn({func:xe.EQUAL,mask:255},255,255,xe.KEEP,xe.DECR,xe.DECR),Mt=Be?M.colorModeForRenderPass():new On([xe.ONE_MINUS_DST_ALPHA,xe.DST_ALPHA,xe.ONE,xe.ONE],i.ao.transparent,[!0,!0,!0,!0]);Xg(ut,M,h,x,A,Pe,st,Mt,nn.disabled,D,"color",F,z,H,Y,ae,Ce,et,!1)}}function GC(M){return[M[0]*i.eh,M[1]*i.eh,M[2]*i.eh,0]}function iw(M,h,x,A,D,F,z,H,Y){const ae=A.getSource(),oe=x.globeSharedBuffers;if(!oe)return;let ge,fe,xe;if(h&&(ge=A.getTile(h)),ae instanceof i.aU?(fe=ae.texture,xe=i.dK(0,0,x.transform)):ge&&h&&(fe=ge.texture,xe=i.dK(h.canonical.z,h.canonical.x,x.transform)),!fe||!xe)return;M||(xe=i.cS(i.bC(),xe,[1,-1,1]));const Pe=x.context,Ce=Pe.gl,Ve=D.paint.get("raster-resampling")==="nearest"?Ce.NEAREST:Ce.LINEAR,Be=x.colorModeForDrapableLayerRenderPass(F),et=z.defines;et.push("GLOBE_POLES");const ut=new Lr(Ce.LEQUAL,Lr.ReadWrite,x.depthRangeFor3D),st=Float32Array.from(x.transform.expandedFarZProjMatrix),Mt=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0))));x.terrain&&x.terrain.prepareDrawTile(),Pe.activeTexture.set(Ce.TEXTURE0),fe.bind(Ve,Ce.CLAMP_TO_EDGE),Pe.activeTexture.set(Ce.TEXTURE1),fe.bind(Ve,Ce.CLAMP_TO_EDGE),"useMipmap"in fe&&Pe.extTextureFilterAnisotropic&&x.transform.pitch>20&&Ce.texParameterf(Ce.TEXTURE_2D,Pe.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,Pe.extTextureFilterAnisotropicMax);const[yt,kt,gt,mt]=h?oe.getPoleBuffers(h.canonical.z,!1):oe.getPoleBuffers(0,!0),Pt=D.paint.get("raster-elevation");let Ht;M?(Ht=yt,x.renderDefaultNorthPole=Pt!==0):(Ht=kt,x.renderDefaultSouthPole=Pt!==0);const Ut=GC(z.mix),ts=((fs,qs,Yt,Ft,ls,Jt,Ls,er,pr,Xs,Vs,Cr,kr)=>MR(fs,qs,Yt,new Float32Array(16),new Float32Array(9),[0,0],Ft,[0,0],[0,0,0,0],1,{opacity:1,mix:0},Jt,[0,0],er,2,Xs,Vs,Cr,1,0,kr))(st,Mt,xe,i.aj(x.transform.zoom),0,D,0,Pt,0,Ut,z.offset,z.range,F),ns=x.getOrCreateProgram("raster",{defines:et});x.uploadCommonUniforms(Pe,ns,null),ns.draw(x,Ce.TRIANGLES,ut,Y,Be,H,ts,D.id,Ht,gt,mt)}function DR(M){const h=M._nearZ,x=M.projection.farthestPixelDistance(M),A=x-h,D=.2*M.height,F=h+D;return[h,x,(F-D-h)/A,(F-h)/A]}function Jg(M,h,x,A){if(M)return h instanceof yd&&M instanceof _d?h.getTextureDescriptor(M,x,!0):{texture:M.texture,mix:GC(A.mix),offset:A.offset,buffer:0,tileSize:1}}var Hi=i.ei([{name:"a_index",type:"Int16",components:1}]);class KC{constructor(h,x,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(x,D),this.lastInvalidatedAt=0}updateParticleTexture(h,x){if(this.particleTextureDimension===x.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const A=this.context.gl,D=x.width*x.height;this.particleTexture0=new i.T(this.context,x,A.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new i.T(this.context,x,A.RGBA8,{premultiply:!1,useMipmap:!1});const F=new i.ej;F.reserve(D);for(let z=0;z0){const Ut=i.bj(x.canonical,Y),ts=i.el(Ut);fe=i.aB(new Float32Array(16),Y.globeMatrix,ts),i.aB(fe,Y.projMatrix,fe)}const xe=i.bC();xe[12]+=2*D/(i.o.devicePixelRatio*Y.width),xe[13]+=2*F/(i.o.devicePixelRatio*Y.height),i.aB(fe,xe,fe);const Pe=M.getOrCreateProgram("debug",{defines:ge}),Ce=h.getTileByID(x.key);M.terrain&&M.terrain.setupElevationDraw(Ce,Pe);const Ve=Lr.disabled,Be=dn.disabled,et=M.colorModeForRenderPass(),ut="$debug";H.activeTexture.set(ae.TEXTURE0),M.emptyTexture.bind(ae.LINEAR,ae.CLAMP_TO_EDGE),oe?Ce._makeGlobeTileDebugBuffers(M.context,Y):Ce._makeDebugTileBoundsBuffers(M.context,Y.projection);const st=Ce._tileDebugBuffer||M.debugBuffer,Mt=Ce._tileDebugIndexBuffer||M.debugIndexBuffer,yt=Ce._tileDebugSegments||M.debugSegments;if(Pe.draw(M,ae.LINE_STRIP,Ve,Be,et,nn.disabled,tw(fe,A.toPremultipliedRenderColor(null)),ut,st,Mt,yt,null,null,null,[Ce._globeTileDebugBorderBuffer]),z){const Ut=Ce.latestRawTileData,ts=Math.floor((Ut&&Ut.byteLength||0)/1024);let ns=x.canonical.toString();x.overscaledZ!==x.canonical.z&&(ns+=` => ${x.overscaledZ}`),ns+=` ${Ce.state}`,ns+=` ${ts}kb`,function(fs,qs){fs.initDebugOverlayCanvas();const Yt=fs.debugOverlayCanvas,Ft=fs.context.gl,ls=fs.debugOverlayCanvas.getContext("2d");ls.clearRect(0,0,Yt.width,Yt.height),ls.shadowColor="white",ls.shadowBlur=2,ls.lineWidth=1.5,ls.strokeStyle="white",ls.textBaseline="top",ls.font="bold 36px Open Sans, sans-serif",ls.fillText(qs,5,5),ls.strokeText(qs,5,5),fs.debugOverlayTexture.update(Yt),fs.debugOverlayTexture.bind(Ft.LINEAR,Ft.CLAMP_TO_EDGE)}(M,ns)}const kt=h.getTile(x).tileSize,gt=512/Math.min(kt,512)*(x.overscaledZ/Y.zoom)*.5,mt=Ce._tileDebugTextBuffer||M.debugBuffer,Pt=Ce._tileDebugTextIndexBuffer||M.quadTriangleIndexBuffer,Ht=Ce._tileDebugTextSegments||M.debugSegments;Pe.draw(M,ae.TRIANGLES,Ve,Be,On.alphaBlended,nn.disabled,tw(fe,i.ao.transparent.toPremultipliedRenderColor(null),gt),ut,mt,Pt,Ht,null,null,null,[Ce._globeTileDebugTextBuffer])}function sv(M,h,x,A){Gt(M,0,h+x/2,M.transform.width,x,A)}function Mo(M,h,x,A){Gt(M,h-x/2,0,x,M.transform.height,A)}function Gt(M,h,x,A,D,F){const z=M.context,H=z.gl;H.enable(H.SCISSOR_TEST),H.scissor(h*i.o.devicePixelRatio,x*i.o.devicePixelRatio,A*i.o.devicePixelRatio,D*i.o.devicePixelRatio),z.clear({color:F}),H.disable(H.SCISSOR_TEST)}const BR=i.ei([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:ZC}=BR;function Df(M,h,x,A){M.emplaceBack(h,x,A)}class YC{constructor(h){this.vertexArray=new i.em,this.indices=new i.b0,Df(this.vertexArray,-1,-1,1),Df(this.vertexArray,1,-1,1),Df(this.vertexArray,-1,1,1),Df(this.vertexArray,1,1,1),Df(this.vertexArray,-1,-1,-1),Df(this.vertexArray,1,-1,-1),Df(this.vertexArray,-1,1,-1),Df(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,ZC),this.indexBuffer=h.createIndexBuffer(this.indices),this.segment=i.bg.simpleSegment(0,0,36,12)}}function rv(M,h,x,A,D,F){const z=M.context.gl,H=h.paint.get("sky-atmosphere-color"),Y=h.paint.get("sky-atmosphere-halo-color"),ae=h.paint.get("sky-atmosphere-sun-intensity"),oe=((ge,fe,xe,Pe,Ce)=>({u_matrix_3f:ge,u_sun_direction:fe,u_sun_intensity:xe,u_color_tint_r:[Pe.r,Pe.g,Pe.b,Pe.a],u_color_tint_m:[Ce.r,Ce.g,Ce.b,Ce.a],u_luminance:5e-5}))(i.eo(i.dO(),A),D,ae,H.toPremultipliedRenderColor(null),Y.toPremultipliedRenderColor(null));z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+F,h.skyboxTexture,0),x.draw(M,z.TRIANGLES,Lr.disabled,dn.disabled,On.unblended,nn.frontCW,oe,"skyboxCapture",h.skyboxGeometry.vertexBuffer,h.skyboxGeometry.indexBuffer,h.skyboxGeometry.segment)}const $R=i.ei([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class s_{constructor(h){const x=new i.ep;x.emplaceBack(-1,1,1,0,0),x.emplaceBack(1,1,1,1,0),x.emplaceBack(1,-1,1,1,1),x.emplaceBack(-1,-1,1,0,1);const A=new i.b0;A.emplaceBack(0,1,2),A.emplaceBack(2,3,0),this.vertexBuffer=h.createVertexBuffer(x,$R.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 Pme=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 Ime{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class qR{constructor(h){this.colorModeAlphaBlendedWriteRGB=new On([1,Ef,1,Ef],i.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new On([1,0,1,0],i.ao.transparent,[!1,!1,!1,!0]),this.params=new Ime,this.updateNeeded=!0}update(h){const x=h.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new s_(x);const A=this.params.sizeRange,D=this.params.intensityRange,F=function(oe){const ge=i.eq(30),fe=[];for(let xe=0;xe{const gt=F.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];kt&>.push("ALPHA_PASS");const mt=h.getOrCreateProgram("globeAtmosphere",{defines:gt}),Pt=((Ut,ts,ns,fs,qs,Yt,Ft,ls,Jt,Ls,er,pr)=>({u_frustum_tl:Ut,u_frustum_tr:ts,u_frustum_br:ns,u_frustum_bl:fs,u_horizon:qs,u_transition:Yt,u_fadeout_range:Ft,u_atmosphere_fog_color:ls.toArray01(),u_high_color:Jt.toArray01(),u_space_color:Ls.toArray01(),u_temporal_offset:er,u_horizon_angle:pr}))(F.frustumCorners.TL,F.frustumCorners.TR,F.frustumCorners.BR,F.frustumCorners.BL,F.frustumCorners.horizon,H,Ve,oe,fe,Pe,et,Mt);h.uploadCommonUniforms(A,mt);const Ht=this.atmosphereBuffer;Ht&&mt.draw(h,D.TRIANGLES,z,dn.disabled,kt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,nn.backCW,Pt,kt?"atmosphere_glow_alpha":"atmosphere_glow",Ht.vertexBuffer,Ht.indexBuffer,Ht.segments)};yt(!1),yt(!0)}drawStars(h,x){const A=i.aA(x.properties.get("star-intensity"),0,1);if(A===0)return;const D=h.context,F=D.gl,z=h.transform,H=h.getOrCreateProgram("stars"),Y=i.c7([]);i.c9(Y,Y,-z._pitch),i.c8(Y,Y,-z.angle),i.c9(Y,Y,i.an(z._center.lat)),i.et(Y,Y,-i.an(z._center.lng));const ae=i.cc(new Float32Array(16),Y),oe=i.aB([],z.starsProjMatrix,ae),ge=i.eo([],ae),fe=i.eu([],ge),xe=[0,1,0];i.dQ(xe,xe,fe),i.c5(xe,xe,this.params.sizeMultiplier);const Pe=[1,0,0];i.dQ(Pe,Pe,fe),i.c5(Pe,Pe,this.params.sizeMultiplier);const Ce=(Ve=xe,Be=Pe,et=A,{u_matrix:Float32Array.from(oe),u_up:Ve,u_right:Be,u_intensity_multiplier:et});var Ve,Be,et;h.uploadCommonUniforms(D,H),this.starsVx&&this.starsIdx&&H.draw(h,F.TRIANGLES,Lr.disabled,dn.disabled,this.colorModeAlphaBlendedWriteRGB,nn.disabled,Ce,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class XC{constructor(){this.visibleTiles=[]}updateBorders(h,x){const A=[],D=[],F=h._getRenderableCoordinates(!1,!0);for(const Y of F){const ae=h.getTile(Y);if(!ae.hasData())continue;const oe=ae.getBucket(x);oe&&(oe.isEmpty()||(A.push(Y.key),D.push({bucket:oe,tileID:Y.canonical})))}let z=A.length!==this.visibleTiles.length;if(!z){A.sort();for(let Y=0;YY.tileID.z-ae.tileID.z||Y.tileID.x-ae.tileID.x||Y.tileID.y-ae.tileID.y);for(const Y of D){const ae=new Array,oe=new Array,ge=Y.bucket;for(const fe of ge.featuresOnBorder)H.has(fe.featureId)?oe.push(fe.footprintIndex):(H.add(fe.featureId),ae.push(fe.footprintIndex));ge.updateFootprintHiddenFlags(ae,i.ev,!1),ge.updateFootprintHiddenFlags(oe,i.ev,!0)}}}function QC(M,h){const x=[...M],A=h.cameraWorldSizeForFog/h.worldSize,D=i.bA([]);return i.cS(D,D,[A,A,1]),i.aB(x,D,x),i.aB(x,h.worldToFogMatrix,x),x}function JC(M,h,x,A,D){const F=x.material,z=A.context,{baseColorTexture:H,metallicRoughnessTexture:Y}=F.pbrMetallicRoughness,{normalTexture:ae,occlusionTexture:oe,emissionTexture:ge}=F;function fe(Pe,Ce,Ve){if(Pe&&(M.push(Ce),z.activeTexture.set(z.gl.TEXTURE0+Ve),Pe.gfxTexture)){const{minFilter:Be,magFilter:et,wrapS:ut,wrapT:st}=Pe.sampler;Pe.gfxTexture.bindExtraParam(Be,et,ut,st)}}fe(H,"HAS_TEXTURE_u_baseColorTexture",Dc.BaseColor),fe(Y,"HAS_TEXTURE_u_metallicRoughnessTexture",Dc.MetallicRoughness),fe(ae,"HAS_TEXTURE_u_normalTexture",Dc.Normal),fe(oe,"HAS_TEXTURE_u_occlusionTexture",Dc.Occlusion),fe(ge,"HAS_TEXTURE_u_emissionTexture",Dc.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+Dc.LUT),D.texture&&D.texture.bind(z.gl.LINEAR,z.gl.CLAMP_TO_EDGE),M.push("APPLY_LUT_ON_GPU")),x.texcoordBuffer&&(M.push("HAS_ATTRIBUTE_a_uv_2f"),h.push(x.texcoordBuffer)),x.colorBuffer&&(M.push(x.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),h.push(x.colorBuffer)),x.normalBuffer&&(M.push("HAS_ATTRIBUTE_a_normal_3f"),h.push(x.normalBuffer)),x.pbrBuffer&&(M.push("HAS_ATTRIBUTE_a_pbr"),M.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),h.push(x.pbrBuffer)),F.alphaMode!=="OPAQUE"&&F.alphaMode!=="MASK"||M.push("UNPREMULT_TEXTURE_IN_SHADER"),F.defined||M.push("DIFFUSE_SHADED");const xe=A.shadowRenderer;xe&&(M.push("RENDER_SHADOWS","DEPTH_TEXTURE"),xe.useNormalOffset&&M.push("NORMAL_OFFSET"))}function e3(M,h,x,A,D,F){const z=M.modelOpacity,H=h.context,Y=new Lr(h.context.gl.LEQUAL,M.isLightMesh?Lr.ReadOnly:Lr.ReadWrite,h.depthRangeFor3D),ae=h.transform,oe=M.mesh,ge=oe.material,fe=ge.pbrMetallicRoughness,xe=h.style.fog;let Pe;Pe=h.transform.projection.zAxisUnit==="pixels"?[...M.nodeModelMatrix]:i.aB([],A.zScaleMatrix,M.nodeModelMatrix),i.aB(Pe,A.negCameraPosMatrix,Pe);const Ce=i.bl([],Pe);i.eg(Ce,Ce);const Ve=x.paint.get("model-color-use-theme").constantOr("default")==="none",Be=x.paint.get("model-emissive-strength").constantOr(0),et=Q0(new Float32Array(M.worldViewProjection),new Float32Array(Pe),new Float32Array(Ce),null,h,z,fe.baseColorFactor,ge.emissiveFactor,fe.metallicFactor,fe.roughnessFactor,ge,Be,x,void 0,void 0,M.materialOverride,M.modelColor),ut={defines:[]},st=[],Mt=h.shadowRenderer;Mt&&(Mt.useNormalOffset=!1),JC(ut.defines,st,oe,h,Ve?null:x.lut);let yt=null;if(xe){const mt=QC(M.nodeModelMatrix,h.transform);if(yt=new Float32Array(mt),ae.projection.name!=="globe"){const Pt=oe.aabb.min,Ht=oe.aabb.max,[Ut,ts]=xe.getOpacityForBounds(mt,Pt[0],Pt[1],Ht[0],Ht[1]);ut.overrideFog=Ut>=gs||ts>=gs}}const kt=fy(h,x.paint.get("model-cutoff-fade-range"));kt.shouldRenderCutoff&&ut.defines.push("RENDER_CUTOFF");const gt=h.getOrCreateProgram("model",ut);h.uploadCommonUniforms(H,gt,null,yt,kt),h.renderPass!=="shadow"&&Mt&&Mt.setupShadowsFromMatrix(M.nodeModelMatrix,gt),gt.draw(h,H.gl.TRIANGLES,Y,D,F,oe.material.doubleSided?nn.disabled:nn.backCCW,et,x.id,oe.vertexBuffer,oe.indexBuffer,oe.segments,x.paint,h.transform.zoom,void 0,st)}function ow(M,h){return M.style._importedAsBasemap?"basemap":h.scope}function nv(M,h,x,A,D,F,z,H,Y,ae){const oe=M.transform,ge=!!h.isGeometryBloom&&h.isGeometryBloom;if(ge&&M.renderPass==="shadow")return;const fe=oe.projection.name==="globe"?i.eD(x,oe):[...x];i.aB(fe,fe,h.globalMatrix);const xe=i.aB([],A,fe);if(h.meshes)for(const Pe of h.meshes){const Ce=H.get(Pe.material.name);if(Ce&&Ce.opacity<=0)continue;if(Pe.material.alphaMode!=="BLEND"){z.push({mesh:Pe,depth:0,modelIndex:D,worldViewProjection:xe,nodeModelMatrix:fe,isLightMesh:ge,materialOverride:Ce,modelOpacity:Y,modelColor:ae});continue}const Ve=i.af([],Pe.centroid,xe);!oe.isOrthographic&&Ve[2]<=0||F.push({mesh:Pe,depth:Ve[2],modelIndex:D,worldViewProjection:xe,nodeModelMatrix:fe,isLightMesh:ge,materialOverride:Ce,modelOpacity:Y,modelColor:ae})}if(h.children)for(const Pe of h.children)nv(M,Pe,x,A,D,F,z,H,Y,ae)}function Dp(M,h,x,A){const D=x.shadowRenderer;if(!D)return;const F=D.getShadowPassDepthMode(),z=D.getShadowPassColorMode(),H=D.calculateShadowPassMatrixFromMatrix(h),Y=XE(H);x.getOrCreateProgram("modelDepth",{defines:x._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(x,x.context.gl.TRIANGLES,F,dn.disabled,z,nn.disabled,Y,A.id,M.vertexBuffer,M.indexBuffer,M.segments,A.paint,x.transform.zoom,void 0,void 0)}function UR(M,h,x,A,D,F){for(const z of D){const H=Object.assign({},A);H.part=z;const Y={type:"Unknown",id:h,properties:H},ae={orientation:M.paint.get("model-rotation").evaluate(Y,x)};F.set(z,ae)}}function VR(M,h,x,A,D,F){for(const z of D){const H=Object.assign({},A);H.part=z;const Y={type:"Unknown",id:h,properties:H},ae={color:M.paint.get("model-color").evaluate(Y,x),colorMix:M.paint.get("model-color-mix-intensity").evaluate(Y,x),opacity:M.paint.get("model-opacity").evaluate(Y,x),emissionStrength:M.paint.get("model-emissive-strength").evaluate(Y,x)};F.set(z,ae)}}function HR(M,h,x,A,D){let F=!1;for(const H of A)H.modelOpacity!==1&&(e3(H,M,h,D[H.modelIndex],dn.disabled,On.disabled),F=!0);for(const H of A)e3(H,M,h,D[H.modelIndex],H.modelOpacity!==1?M.stencilModeFor3D():dn.disabled,M.colorModeForRenderPass());F&&M.resetStencilClippingMasks();const z=On.additive;for(const H of x)e3(H,M,h,D[H.modelIndex],dn.disabled,H.isLightMesh?z:M.colorModeForRenderPass())}function WR(M,h,x){const A=h.updateZoomBasedPaintProperties(),D=function(F,z,H){let Y,ae,oe,ge=F.terrain?F.terrain.exaggeration():0;if(F.terrain&&ge>0){const fe=F.terrain,xe=fe.findDEMTileFor(H);xe&&xe.dem?Y=i.eF.create(fe,H,xe):ge=0}if(ge===0&&(z.terrainElevationMin=0,z.terrainElevationMax=0),ge===z.validForExaggeration&&(ge===0||Y&&Y._demTile&&Y._demTile.tileID===z.validForDEMTile.id&&Y._dem._timestamp===z.validForDEMTile.timestamp))return!1;for(const fe in z.instancesPerModel){const xe=z.instancesPerModel[fe];for(let Pe=0;Peae&&(ae=xe.max)}const oe=i.aA(A.x,F,z)-A.x,ge=i.aA(A.y,H,Y)-A.y,fe=i.cf(ae,h.center.lat)-A.z;return h._zoomFromMercatorZ(Math.sqrt(oe*oe+ge*ge+fe*fe))}function GR(M,h,x,A,D,F,z){const H=M.context,Y=M.renderPass==="shadow",ae=M.shadowRenderer,oe=Y&&ae?ae.getShadowPassDepthMode():new Lr(H.gl.LEQUAL,Lr.ReadWrite,M.depthRangeFor3D),ge=M.isTileAffectedByFog(F),fe=M.transform.projection.name==="globe";if(x.meshes)for(const xe of x.meshes){const Pe=fe?[]:["MODEL_POSITION_ON_GPU"],Ce=[];let Ve,Be,et;const ut=!fe&&A.instancedDataArray.length>20;ut&&Pe.push("INSTANCED_ARRAYS");const st=fy(M,h.paint.get("model-cutoff-fade-range"));if(st.shouldRenderCutoff&&Pe.push("RENDER_CUTOFF"),Y&&ae)Ve=M.getOrCreateProgram("modelDepth",{defines:Pe}),Be=XE(z.shadowTileMatrix,z.shadowTileMatrix,Float32Array.from(x.globalMatrix)),et=ae.getShadowPassColorMode();else{JC(Pe,Ce,xe,M,h.paint.get("model-color-use-theme").constantOr("default")==="none"?null:h.lut),Ve=M.getOrCreateProgram("model",{defines:Pe,overrideFog:ge});const yt=xe.material,kt=yt.pbrMetallicRoughness,gt=h.paint.get("model-opacity").constantOr(1),mt=h.paint.get("model-emissive-strength").constantOr(0);Be=Q0(F.expandedProjMatrix,Float32Array.from(x.globalMatrix),new Float32Array(16),null,M,gt,kt.baseColorFactor,yt.emissiveFactor,kt.metallicFactor,kt.roughnessFactor,yt,mt,h,D),ae&&(z.shadowUniformsInitialized?Ve.setShadowUniformValues(H,ae.getShadowUniformValues()):(ae.setupShadows(F.toUnwrapped(),Ve,"model-tile"),z.shadowUniformsInitialized=!0)),et=st.shouldRenderCutoff||gt<1||yt.alphaMode!=="OPAQUE"?On.alphaBlended:On.unblended}M.uploadCommonUniforms(H,Ve,F.toUnwrapped(),null,st);const Mt=xe.material.doubleSided?nn.disabled:nn.backCCW;if(ut)Ce.push(A.instancedDataBuffer),Ve.draw(M,H.gl.TRIANGLES,oe,dn.disabled,et,Mt,Be,h.id,xe.vertexBuffer,xe.indexBuffer,xe.segments,h.paint,M.transform.zoom,void 0,Ce,A.instancedDataArray.length);else{const yt=Y?"u_instance":"u_normal_matrix";for(let kt=0;ktY[1]?z:Y,F[0]=x.max[0],z=i.aC(i.eG(),F,D),H=z[1]Y[1]?z:Y,F[1]=x.min[1],z=i.aC(i.eG(),F,D),H=z[1]Y[1]?z:Y;const ae=i.aA(A[0],0,1),oe=100*h.pixelsPerMeter*i.aA(A[1],0,1),ge=i.aA(A[2],0,1),fe=i.eH(i.eG(),H,Y,ae),xe=Math.tan(.5*h.fovX),Pe=-fe[2]*xe;if(oe===0)return fe[1]<-Math.abs(Pe)?ge:1;const Ce=(-Math.abs(Pe)-fe[1])/oe,Ve=(et,ut,st)=>(1-st)*et+st*ut,Be=i.aA(Ve(1,ge,Ce),ge,1);return Ve(1,Be,i.aA((h.pitch-20)/20,0,1))}class KR{}class Ny{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(h,x,A){{const ge=this._storage.get(x.id);if(ge)return ge.lastUsedFrameIdx=h,ge.buf}const D=A.gl,F=D.getBufferParameter(D.ELEMENT_ARRAY_BUFFER,D.BUFFER_SIZE),z=new ArrayBuffer(F),H=new Int16Array(z);D.getBufferSubData(D.ELEMENT_ARRAY_BUFFER,0,new Int16Array(z));const Y=new i.eJ;for(let ge=0;ge30&&(A.buf.destroy(),this._storage.delete(x))}destroy(){for(const[h,x]of this._storage)x.buf.destroy(),this._storage.delete(h)}}class r_{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const n_=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 ex{constructor(h){this.revealStart=11,this.revealRange=2}}const rP=i.ei([{type:"Float32",name:"a_pos_2f",components:2}]);class nP{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(h,x){const A=h.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const z=new i.eK,H=new i.b0;z.emplaceBack(-1,-1),z.emplaceBack(1,-1),z.emplaceBack(1,1),z.emplaceBack(-1,1),H.emplaceBack(0,1,2),H.emplaceBack(0,2,3),this.vignetteVx=h.context.createVertexBuffer(z,rP.members),this.vignetteIdx=h.context.createIndexBuffer(H)}const D=i.bg.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){h.uploadCommonUniforms(h.context,A);const z={u_vignetteShape:(F={vignetteShape:[x.start,x.range,Math.pow(10,x.fadePower)],vignetteColor:[x.color.r,x.color.g,x.color.b,x.color.a*x.strength]}).vignetteShape,u_vignetteColor:F.vignetteColor};A.draw(h,h.context.gl.TRIANGLES,Lr.disabled,dn.disabled,On.alphaBlended,nn.disabled,z,"vignette",this.vignetteVx,this.vignetteIdx,D)}var F}}class aP{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(h,x){const A=h.getFreeCameraOptions().position,D=A.toAltitude(),F=A.toLngLat(),z=i.an(F.lng),H=i.an(F.lat),Y=h.pixelsPerMeter/x,ae=z*i.eM,oe=i.eM*Math.log(Math.tan(Math.PI/4+H/2));if(this._offsetXPrev===void 0)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const ge=-this._offsetYPrev+oe,fe=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+ae)*Y,this._accumulatedOffsetY+=ge*Y,this._accumulatedElevation+=fe*Y,this._offsetXPrev=ae,this._offsetYPrev=oe,this._elevationPrev=D}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function t3(M,h){return[-(M[0]-Math.floor(M[0]/h)*h),-(M[1]-Math.floor(M[1]/h)*h),-(M[2]-Math.floor(M[2]/h)*h)]}function rm(M){const h=i.eq(1323123451230),x=[];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 x=h.context;if(!this.particlesVx){const A=rm(this.particlesCount),D=new i.eN,F=new i.b0;let z=0;const H=i.eq(1323123451230);for(let Y=0;YA)return;const D=rh(0,1,x.revealStart,x.revealStart+x.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 H=structuredClone(this._vignetteParams);H.strength*=D,F.overrideStyleParameters||(F.intensity=h.style.rain.state.density,F.timeFactor=h.style.rain.state.intensity,F.color=structuredClone(h.style.rain.state.color),z=structuredClone(h.style.rain.state.direction),F.screenThinning.intensity=h.style.rain.state.centerThinning,F.dropletSizeX=h.style.rain.state.dropletSize[0],F.dropletSizeYScale=h.style.rain.state.dropletSize[1]/h.style.rain.state.dropletSize[0],F.distortionStrength=100*h.style.rain.state.distortionStrength,H.strength=1,H.color=structuredClone(h.style.rain.state.vignetteColor));const Y=this.updateOnRender(h,F.timeFactor),ae=h.context,oe=ae.gl,ge=h.transform;this.screenTexture&&this.screenTexture.size[0]===h.width&&this.screenTexture.size[1]===h.height||(this.screenTexture=new i.T(ae,{width:h.width,height:h.height,data:null},oe.RGBA8)),F.distortionStrength>0&&(ae.activeTexture.set(oe.TEXTURE0),this.screenTexture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE),oe.copyTexSubImage2D(oe.TEXTURE_2D,0,0,0,0,0,h.width,h.height));const fe=h.getOrCreateProgram("rainParticle");h.uploadCommonUniforms(ae,fe),ae.activeTexture.set(oe.TEXTURE0),this.screenTexture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE);const xe=[F.color.r,F.color.g,F.color.b,F.color.a],Pe=(Ce,Ve)=>{const Be=t3(this._movement.getPosition(),Ce),et=F.dropletSizeX,ut=F.dropletSizeX*F.dropletSizeYScale,st=h.width/2,Mt=h.height/2,yt=rh(0,F.screenThinning.start,0,1,F.screenThinning.intensity),kt=rh(.001,F.screenThinning.range,0,1,F.screenThinning.intensity),gt=rh(0,F.screenThinning.particleOffset,0,1,F.screenThinning.intensity),mt=(Pt={modelview:Y.modelviewMatrix,projection:Y.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Be,velocityConeAperture:F.velocityConeAperture,velocity:F.velocity,boxSize:Ce,rainDropletSize:[et,ut],distortionStrength:F.distortionStrength,rainDirection:z,color:xe,screenSize:[ge.width,ge.height],thinningCenterPos:[st,Mt],thinningShape:[yt,kt,Math.pow(10,F.screenThinning.fadePower)],thinningAffectedRatio:F.screenThinning.affectedRatio,thinningParticleOffset:gt,shapeDirectionalPower:F.shapeDirPower,shapeNormalPower:F.shapeNormalPower,mode:Ve?0:1},{u_modelview:Float32Array.from(Pt.modelview),u_projection:Float32Array.from(Pt.projection),u_time:Pt.time,u_cam_pos:Pt.camPos,u_texScreen:0,u_velocityConeAperture:Pt.velocityConeAperture,u_velocity:Pt.velocity,u_boxSize:Pt.boxSize,u_rainDropletSize:Pt.rainDropletSize,u_distortionStrength:Pt.distortionStrength,u_rainDirection:Pt.rainDirection,u_color:Pt.color,u_screenSize:Pt.screenSize,u_thinningCenterPos:Pt.thinningCenterPos,u_thinningShape:Pt.thinningShape,u_thinningAffectedRatio:Pt.thinningAffectedRatio,u_thinningParticleOffset:Pt.thinningParticleOffset,u_shapeDirectionalPower:Pt.shapeDirectionalPower,u_shapeNormalPower:Pt.shapeNormalPower,u_mode:Pt.mode});var Pt;const Ht=Math.round(F.intensity*this.particlesCount),Ut=i.bg.simpleSegment(0,0,4*Ht,2*Ht);fe.draw(h,oe.TRIANGLES,Lr.disabled,dn.disabled,On.alphaBlended,nn.disabled,mt,"rain_particles",this.particlesVx,this.particlesIdx,Ut)};F.distortionStrength>0&&Pe(F.boxSize,!0),Pe(F.boxSize,!1),this._vignette.draw(h,H)}}const iP=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 oP extends av{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 ex("Precipitation > Snow"),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3}update(h){const x=h.context;if(!this.particlesVx){const A=rm(this.particlesCount),D=new i.eO,F=new i.b0;let z=0;const H=i.eq(1323123451230);for(let Y=0;Yz)return;const H=rh(0,1,F.revealStart,F.revealStart+F.revealRange,z);D.strength*=H,x.overrideStyleParameters||(x.intensity=h.style.snow.state.density,x.timeFactor=h.style.snow.state.intensity,x.color=structuredClone(h.style.snow.state.color),A=structuredClone(h.style.snow.state.direction),x.screenThinning.intensity=h.style.snow.state.centerThinning,x.billboardSize=2.79*h.style.snow.state.flakeSize,D.strength=1,D.color=structuredClone(h.style.snow.state.vignetteColor));const Y=this.updateOnRender(h,x.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const ae=h.context,oe=ae.gl,ge=h.transform,fe=h.getOrCreateProgram("snowParticle");h.uploadCommonUniforms(ae,fe),((xe,Pe,Ce)=>{const Ve=t3(this._movement.getPosition(),xe),Be=ge.width/2,et=ge.height/2,ut=rh(0,Ce.screenThinning.start,0,1,Ce.screenThinning.intensity),st=rh(.001,Ce.screenThinning.range,0,1,Ce.screenThinning.intensity),Mt=rh(0,Ce.screenThinning.particleOffset,0,1,Ce.screenThinning.intensity),yt=(kt={modelview:Y.modelviewMatrix,projection:Y.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Ve,velocityConeAperture:Ce.velocityConeAperture,velocity:Ce.velocity,horizontalOscillationRadius:Ce.horizontalOscillationRadius,horizontalOscillationRate:Ce.horizontalOscillationRate,boxSize:xe,billboardSize:1*Ce.billboardSize,simpleShapeParameters:[Ce.shapeFadeStart,Ce.shapeFadePower],screenSize:[ge.width,ge.height],thinningCenterPos:[Be,et],thinningShape:[ut,st,Math.pow(10,Ce.screenThinning.fadePower)],thinningAffectedRatio:Ce.screenThinning.affectedRatio,thinningParticleOffset:Mt,color:[Ce.color.r,Ce.color.g,Ce.color.b,Ce.color.a],direction:A},{u_modelview:Float32Array.from(kt.modelview),u_projection:Float32Array.from(kt.projection),u_time:kt.time,u_cam_pos:kt.camPos,u_velocityConeAperture:kt.velocityConeAperture,u_velocity:kt.velocity,u_horizontalOscillationRadius:kt.horizontalOscillationRadius,u_horizontalOscillationRate:kt.horizontalOscillationRate,u_boxSize:kt.boxSize,u_billboardSize:kt.billboardSize,u_simpleShapeParameters:kt.simpleShapeParameters,u_screenSize:kt.screenSize,u_thinningCenterPos:kt.thinningCenterPos,u_thinningShape:kt.thinningShape,u_thinningAffectedRatio:kt.thinningAffectedRatio,u_thinningParticleOffset:kt.thinningParticleOffset,u_particleColor:kt.color,u_direction:kt.direction});var kt;const gt=Math.round(Ce.intensity*this.particlesCount),mt=i.bg.simpleSegment(0,0,4*gt,2*gt);this.particlesVx&&this.particlesIdx&&fe.draw(h,oe.TRIANGLES,Lr.disabled,dn.disabled,On.alphaBlended,nn.disabled,yt,"snow_particles",this.particlesVx,this.particlesIdx,mt)})(x.boxSize,0,x),this._vignette.draw(h,D)}}const Sy={symbol:function(M,h,x,A,D){if(M.renderPass!=="translucent")return;const F=dn.disabled,z=M.colorModeForRenderPass(),H=x.layout.get("text-variable-anchor"),Y=x.layout.get("text-size-scale-range"),ae=i.aA(M.scaleFactor,Y[0],Y[1]);H&&function(fe,xe,Pe,Ce,Ve,Be,et,ut){const st=xe.transform,Mt=Ve==="map",yt=Be==="map";for(const kt of fe){const gt=Ce.getTile(kt),mt=gt.getBucket(Pe);if(!mt||!mt.text||!mt.text.segments.get().length)continue;const Pt=i.bK(mt.textSizeData,st.zoom,ut),Ht=qm(kt,mt.getProjection(),st),Ut=st.calculatePixelsToTileUnitsMatrix(gt),ts=Ys(Ht,gt.tileID.canonical,yt,Mt,st,mt.getProjection(),Ut),ns=mt.hasIconTextFit()&&mt.hasIconData();Pt&&Yr(mt,Mt,yt,et,st,ts,kt,Math.pow(2,st.zoom-gt.tileID.overscaledZ),Pt,ns)}}(A,M,x,h,x.layout.get("text-rotation-alignment"),x.layout.get("text-pitch-alignment"),D,ae);const oe=x.paint.get("icon-opacity").constantOr(1)!==0,ge=x.paint.get("text-opacity").constantOr(1)!==0;x.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(oe||ge)?nw(M,h,x,A,F,z):(oe&&nw(M,h,x,A,F,z,{onlyIcons:!0}),ge&&nw(M,h,x,A,F,z,{onlyText:!0})),h.map.showCollisionBoxes&&(_r(M,h,x,A,x.paint.get("text-translate"),x.paint.get("text-translate-anchor"),!0),_r(M,h,x,A,x.paint.get("icon-translate"),x.paint.get("icon-translate-anchor"),!1))},circle:function(M,h,x,A){if(M.renderPass!=="translucent")return;const D=x.paint.get("circle-opacity"),F=x.paint.get("circle-stroke-width"),z=x.paint.get("circle-stroke-opacity"),H=x.layout.get("circle-sort-key").constantOr(1)!==void 0,Y=x.paint.get("circle-emissive-strength");if(D.constantOr(1)===0&&(F.constantOr(1)===0||z.constantOr(1)===0))return;const ae=M.context,oe=ae.gl,ge=M.transform,fe=!(!M.terrain||!M.terrain.enabled),xe=x.layout.get("circle-elevation-reference"),Pe=M.depthModeForSublayer(0,Lr.ReadOnly),Ce=new Lr(M.context.gl.LEQUAL,Lr.ReadOnly,M.depthRangeFor3D),Ve=xe==="none"||fe?Pe:Ce,Be=dn.disabled,et=M.colorModeForDrapableLayerRenderPass(Y),ut=ge.projection.name==="globe",st=[i.aF(ge.center.lng),i.aJ(ge.center.lat)],Mt=[];for(let kt=0;ktkt.sortKey-gt.sortKey);const yt={useDepthForOcclusion:ge.depthOcclusionForSymbolsAndCircles};for(const kt of Mt){const{programConfiguration:gt,program:mt,layoutVertexBuffer:Pt,dynamicBuffers:Ht,indexBuffer:Ut,uniformValues:ts,tile:ns}=kt.state,fs=kt.segments;M.terrain&&M.terrain.setupElevationDraw(ns,mt,yt),M.uploadCommonUniforms(ae,mt,ns.tileID.toUnwrapped()),mt.draw(M,oe.TRIANGLES,Ve,Be,et,nn.disabled,ts,x.id,Pt,Ut,fs,x.paint,ge.zoom,gt,Ht)}},heatmap:function(M,h,x,A){if(x.paint.get("heatmap-opacity")!==0)if(M.renderPass==="offscreen"){const D=M.context,F=D.gl,z=dn.disabled,H=new On([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!0,!0,!0,!0]);(function(xe,Pe,Ce,Ve){const Be=xe.gl,et=Pe.width*Ve,ut=Pe.height*Ve;xe.activeTexture.set(Be.TEXTURE1),xe.viewport.set([0,0,et,ut]);let st=Ce.heatmapFbo;if(!st||st&&(st.width!==et||st.height!==ut)){st&&st.destroy();const Mt=Be.createTexture();Be.bindTexture(Be.TEXTURE_2D,Mt),Be.texParameteri(Be.TEXTURE_2D,Be.TEXTURE_WRAP_S,Be.CLAMP_TO_EDGE),Be.texParameteri(Be.TEXTURE_2D,Be.TEXTURE_WRAP_T,Be.CLAMP_TO_EDGE),Be.texParameteri(Be.TEXTURE_2D,Be.TEXTURE_MIN_FILTER,Be.LINEAR),Be.texParameteri(Be.TEXTURE_2D,Be.TEXTURE_MAG_FILTER,Be.LINEAR),st=Ce.heatmapFbo=xe.createFramebuffer(et,ut,1,null),function(yt,kt,gt,mt,Pt,Ht){const Ut=yt.gl;Ut.texImage2D(Ut.TEXTURE_2D,0,yt.extRenderToTextureHalfFloat?Ut.RGBA16F:Ut.RGBA,Pt,Ht,0,Ut.RGBA,yt.extRenderToTextureHalfFloat?Ut.HALF_FLOAT:Ut.UNSIGNED_BYTE,null),mt.colorAttachment0.set(gt)}(xe,0,Mt,st,et,ut)}else Be.bindTexture(Be.TEXTURE_2D,st.colorAttachment0.get()),xe.bindFramebuffer.set(st.framebuffer)})(D,M,x,M.transform.projection.name==="globe"?.5:.25),D.clear({color:i.ao.transparent});const Y=M.transform,ae=Y.projection.name==="globe",oe=ae?["PROJECTION_GLOBE_VIEW"]:[],ge=ae?nn.frontCCW:nn.disabled,fe=[i.aF(Y.center.lng),i.aJ(Y.center.lat)];for(let xe=0;xe({u_image:0,u_color_ramp:1,u_opacity:ge.paint.get("heatmap-opacity")}))(0,F),F.id,D.viewportBuffer,D.quadTriangleIndexBuffer,D.viewportSegments,F.paint,D.transform.zoom)}(M,x))},line:function(M,h,x,A){if(M.renderPass!=="translucent")return;const D=x.paint.get("line-opacity"),F=x.paint.get("line-width");if(D.constantOr(1)===0||F.constantOr(1)===0)return;const z=x.paint.get("line-emissive-strength").isConstant(),H=x.paint.get("line-emissive-strength").constantOr(0),Y=x.paint.get("line-occlusion-opacity"),ae=x.layout.get("line-elevation-reference"),oe=x.layout.get("line-width-unit")==="meters",ge=ae==="sea",fe=!(!M.terrain||!M.terrain.enabled),xe=M.context,Pe=xe.gl;if(x.hasElevatedBuckets&&M.transform.projection.name==="globe")return;const Ce=x.layout.get("line-cross-slope"),Ve=Ce!==void 0,Be=Ce<1,et=M.colorModeForDrapableLayerRenderPass(z?H:null),ut=M.terrain&&M.terrain.renderingToTexture,st=ut?1:i.o.devicePixelRatio,Mt=x.paint.get("line-dasharray"),yt=Mt.constantOr(1),kt=x.layout.get("line-cap"),gt=Mt.constantOr(null),mt=kt.constantOr(null),Pt=x.paint.get("line-pattern"),Ht=Pt.constantOr(1),Ut=x.paint.get("line-pattern-cross-fade"),ts=Pt.constantOr(null),ns=x.paint.get("line-opacity").constantOr(1);let fs=!Ht&&ns!==1||M.depthOcclusion&&Y>0&&Y<1;const qs=x.paint.get("line-gradient"),Yt=Ht?"linePattern":"line",Ft=i.e2(x);let ls;if(ut&&M.terrain&&M.terrain.clipOrMaskOverlapStencilType()&&(fs=!1),Y!==0&&M.depthOcclusion){const pr=x.paint._values["line-opacity"];pr&&pr.value&&pr.value.kind==="constant"?ls=pr.value:i.w(`Occlusion opacity for layer ${x.id} is supported only when line-opacity isn't data-driven.`)}F.value.kind!=="constant"&&F.value.isLineProgressConstant===!1&&Ft.push("VARIABLE_LINE_WIDTH"),ut&&(M.emissiveMode!=="dual-source-blending"||z?M.emissiveMode==="mrt-fallback"&&Ft.push("USE_MRT1"):Ft.push("DUAL_SOURCE_BLENDING"));const Jt=(pr,Xs,Vs,Cr,kr,dr)=>{for(const xr of pr){const Vr=h.getTile(xr);if(Ht&&!Vr.patternsLoaded())continue;const kn=Vr.getBucket(x);if(!kn||kn.elevationType!=="none"&&!kr||kn.elevationType==="none"&&kr)continue;M.prepareDrawTile();const ga=[...Xs],Ja=M.shadowRenderer,Er=kn.elevationType==="road"&&!!Ja&&Ja.enabled;let Wa=[0,0,0];if(Er){const zn=M.style.directionalLight,Zi=M.style.ambientLight;zn&&Zi&&(Wa=Kg(M.style,zn,Zi)),ga.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const _n=kn.programConfigurations.get(x.id);let ii=!1;if(ts&&Vr.imageAtlas){const zn=i.e3.from(ts),Zi=zn.getPrimary().scaleSelf(st).toString(),Fo=Vr.imageAtlas.patternPositions.get(Zi),yo=zn.getSecondary(),Ai=yo?Vr.imageAtlas.patternPositions.get(yo.scaleSelf(st).toString()):null;ii=!!Fo&&!!Ai,Fo&&_n.setConstantPatternPositions(Fo,Ai)}Ut>0&&(ii||_n.getPatternTransitionVertexBuffer("line-pattern"))&&ga.push("LINE_PATTERN_TRANSITION");const wi=M.isTileAffectedByFog(xr),pi=M.getOrCreateProgram(Yt,{config:_n,defines:ga,overrideFog:wi});if(!Ht&>&&mt&&Vr.lineAtlas){const zn=Vr.lineAtlas.getDash(gt,mt);zn&&_n.setConstantPatternPositions(zn)}Er&&Ja.setupShadows(Vr.tileID.toUnwrapped(),pi,"vector-tile");let[Ua,Fn]=x.paint.get("line-trim-offset");(mt==="round"||mt==="square")&&Ua!==Fn&&(Ua===0&&(Ua-=1),Fn===1&&(Fn+=1));const si=ut?xr.projMatrix:null,wo=oe?1/kn.tileToMeter/i.ay(Vr,1,M.transform.zoom):1,eo=oe?1/kn.tileToMeter/i.ay(Vr,1,Math.floor(M.transform.zoom)):1,oi=Ht?i.e4(M,Vr,x,si,st,wo,eo,[Ua,Fn],Wa,Ut):i.e5(M,Vr,x,si,kn.lineClipsArray.length,st,wo,eo,[Ua,Fn],Wa);if(qs){const zn=kn.gradients[x.id];let Zi=zn.texture;if(x.gradientVersion!==zn.version){let Fo=256;if(x.stepInterpolant){const yo=h.getSource().maxzoom,Ai=xr.canonical.z===yo?Math.ceil(1<{ls!=null&&(ls.value=ns*Y),pi.draw(M,Pe.TRIANGLES,Vs,zn,et,nn.disabled,oi,x.id,kn.layoutVertexBuffer,kn.indexBuffer,kn.segments,x.paint,M.transform.zoom,_n,[kn.layoutVertexBuffer2,kn.patternVertexBuffer,kn.zOffsetVertexBuffer]),ls!=null&&(ls.value=ns)};if(fs&&!kr){const zn=M.stencilModeForClipping(xr).ref;zn===0&&ut&&xe.clear({stencil:0});const Zi={func:Pe.EQUAL,mask:255};oi.u_alpha_discard_threshold=.8,Pa(new dn(Zi,zn,255,Pe.KEEP,Pe.KEEP,Pe.INVERT)),oi.u_alpha_discard_threshold=0,Pa(new dn(Zi,zn,255,Pe.KEEP,Pe.KEEP,Pe.KEEP))}else oi.u_alpha_discard_threshold=fs&&kr&&dr?.8:0,Pa(kr?Cr:M.stencilModeForClipping(xr))}};let Ls=M.depthModeForSublayer(0,Lr.ReadOnly);const er=new Lr(M.depthOcclusion?Pe.GREATER:Pe.LEQUAL,Lr.ReadOnly,M.depthRangeFor3D);if(x.hasNonElevatedBuckets){const pr=!ut&&M.terrain;Y!==0&&pr?i.w(`Occlusion opacity for layer ${x.id} is supported on terrain only if the layer has line-z-offset enabled.`):pr?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${x.id}.`):Jt(A,Ft,Ls,dn.disabled,!1,!0)}if(x.hasElevatedBuckets){ae==="hd-road-markup"?fe||(Ls=er,Ft.push("ELEVATED_ROADS")):(Ft.push("ELEVATED"),Ls=er,Ve&&Ft.push(Be?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),ge&&Ft.push("ELEVATION_REFERENCE_SEA"));const pr=fs?M.stencilModeFor3D():dn.disabled;M.forceTerrainMode=!0,Jt(A,Ft,Ls,pr,!0,!0),fs&&Jt(A,Ft,Ls,pr,!0,!1),M.forceTerrainMode=!1}fs&&(M.resetStencilClippingMasks(),ut&&xe.clear({stencil:0})),Y===0||M.depthOcclusion||ut||M.layersWithOcclusionOpacity.push(M.currentLayer)},fill:function(M,h,x,A){const D=x.paint.get("fill-color"),F=x.paint.get("fill-opacity");if(F.constantOr(1)===0)return;const z=x.paint.get("fill-emissive-strength"),H=M.colorModeForDrapableLayerRenderPass(z),Y=x.paint.get("fill-pattern"),ae=M.opaquePassEnabledForLayer()&&!Y.constantOr(1)&&D.constantOr(i.ao.transparent).a===1&&F.constantOr(0)===1?"opaque":"translucent";let oe="none";x.layout.get("fill-elevation-reference")!=="none"?oe="road":x.paint.get("fill-z-offset").constantOr(1)!==0&&(oe="offset");const ge=!(!M.terrain||!M.terrain.enabled),fe={painter:M,sourceCache:h,layer:x,coords:A,colorMode:H,elevationType:oe,terrainEnabled:ge,pass:ae};if(M.renderPass==="shadow")return void(M.shadowRenderer&&oe==="road"&&!ge&&function(Pe){const{painter:Ce,sourceCache:Ve,layer:Be,coords:et}=Pe,ut=Ce.context.gl,st=Pe.painter.shadowRenderer;for(const Mt of et){const yt=Ve.getTile(Mt),kt=yt.getBucket(Be);if(!kt)continue;const gt=kt.elevatedStructures;if(!gt||!gt.shadowCasterSegments||gt.shadowCasterSegments.segments[0].primitiveLength===0)continue;Ce.prepareDrawTile();const mt=kt.bufferData.programConfigurations.get(Be.id),Pt=Ce.isTileAffectedByFog(Mt),Ht=Ce.getOrCreateProgram("elevatedStructuresDepth",{config:mt,overrideFog:Pt}),Ut=st.calculateShadowPassMatrixFromTile(yt.tileID.toUnwrapped());Ce.uploadCommonUniforms(Ce.context,Ht,Mt.toUnwrapped());const ts={u_matrix:Ut,u_depth_bias:0};Ht.draw(Ce,ut.TRIANGLES,st.getShadowPassDepthMode(),dn.disabled,st.getShadowPassColorMode(),nn.disabled,ts,Be.id,gt.vertexBuffer,gt.indexBuffer,gt.shadowCasterSegments,Be.paint,Ce.transform.zoom,mt)}}(fe));const xe=M.emissiveMode==="mrt-fallback";if(oe!=="offset"){if(VC(fe,!1,xe),oe==="road"){const Pe=!ge&&M.renderPass==="translucent";Pe&&UC(M,h,x,A,"geometry"),VC(fe,!0,xe,dn.disabled),Pe&&function(Ce){const{painter:Ve,sourceCache:Be,layer:et,coords:ut,colorMode:st}=Ce,Mt=Ve.context.gl,yt=Ce.painter.shadowRenderer,kt=!!yt&&yt.enabled,gt=new Lr(Ve.context.gl.LEQUAL,Lr.ReadOnly,Ve.depthRangeFor3D);let mt=[0,0,0];if(kt){const Ht=Ve.style.directionalLight,Ut=Ve.style.ambientLight;Ht&&Ut&&(mt=Kg(Ve.style,Ht,Ut))}const Pt=Ht=>{for(const Ut of ut){const ts=Be.getTile(Ut),ns=ts.getBucket(et);if(!ns)continue;const fs=ns.elevatedStructures;if(!fs)continue;let qs,Yt;if(Ht?(qs=fs.renderableBridgeSegments,Yt=fs.bridgeProgramConfigurations.get(et.id)):(qs=fs.renderableTunnelSegments,Yt=fs.tunnelProgramConfigurations.get(et.id)),!qs||qs.segments[0].primitiveLength===0)continue;Yt.updatePaintBuffers(),Ve.prepareDrawTile();const Ft=Ve.isTileAffectedByFog(Ut),ls=[];kt&&ls.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const Jt=Ve.getOrCreateProgram("elevatedStructures",{config:Yt,overrideFog:Ft,defines:ls}),Ls=Ve.translatePosMatrix(Ut.projMatrix,ts,et.paint.get("fill-translate"),et.paint.get("fill-translate-anchor"));kt&&yt.setupShadows(ts.tileID.toUnwrapped(),Jt,"vector-tile");const er=by(Ls,mt);Ve.uploadCommonUniforms(Ve.context,Jt,Ut.toUnwrapped()),Jt.draw(Ve,Mt.TRIANGLES,gt,dn.disabled,st,nn.backCCW,er,et.id,fs.vertexBuffer,fs.indexBuffer,qs,et.paint,Ve.transform.zoom,Yt,[fs.vertexBufferNormal])}};Pt(!0),Pt(!1)}(fe)}}else VC(fe,!1,xe,M.stencilModeFor3D())},"fill-extrusion":function(M,h,x,A){const D=x.paint.get("fill-extrusion-opacity"),F=M.context,z=F.gl,H=M.terrain,Y=H&&H.renderingToTexture;if(D===0)return;const ae=M.emissiveMode==="mrt-fallback",oe=M.conflationActive&&M.style.isLayerClipped(x,h.getSource()),ge=M.style.order.indexOf(x.fqid);if(oe&&function(fe,xe,Pe,Ce,Ve){for(const Be of Ce){const et=xe.getTile(Be).getBucket(Pe);et&&(et.updateReplacement(Be,fe.replacementSource,Ve),et.uploadCentroid(fe.context))}}(M,h,x,A,ge),H||oe)for(const fe of A){const xe=h.getTile(fe).getBucket(x);xe&&Eme(M.context,h,fe,xe,x,H,oe)}if(M.renderPass==="shadow"&&M.shadowRenderer){const fe=M.shadowRenderer;if(H&&D<.65&&x._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.ad)return;const xe=fe.getShadowPassDepthMode(),Pe=fe.getShadowPassColorMode();HC(M,h,x,A,xe,dn.disabled,Pe,oe)}else if(M.renderPass==="translucent"){const fe=!x.paint.get("fill-extrusion-pattern").constantOr(1),xe=x.paint.get("fill-extrusion-color").constantOr(i.ao.white);if(!Y&&xe.a!==0){const Pe=new Lr(M.context.gl.LEQUAL,Lr.ReadWrite,M.depthRangeFor3D);D===1&&fe?HC(M,h,x,A,Pe,dn.disabled,On.unblended,oe):(HC(M,h,x,A,Pe,dn.disabled,On.disabled,oe),HC(M,h,x,A,Pe,M.stencilModeFor3D(),M.colorModeForRenderPass(),oe),M.resetStencilClippingMasks())}if(M.style.enable3dLights()&&fe&&(!H&&M.transform.projection.name!=="globe"||Y)){const Pe=x.paint.get("fill-extrusion-opacity"),Ce=x.paint.get("fill-extrusion-ambient-occlusion-intensity"),Ve=x.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Be=x.paint.get("fill-extrusion-flood-light-intensity"),et=x.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",ut=x.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(et?null:x.lut).toArray01().slice(0,3),st=Ce>0&&Ve>0,Mt=Be>0,yt=(mt,Pt,Ht)=>(1-Ht)*mt+Ht*Pt,kt=new eP;kt.translate=x.paint.get("fill-extrusion-translate"),kt.translateAnchor=x.paint.get("fill-extrusion-translate-anchor"),kt.edgeRadius=x.layout.get("fill-extrusion-edge-radius"),kt.cutoffFadeRange=x.paint.get("fill-extrusion-cutoff-fade-range");const gt=mt=>{const Pt=M.depthModeForSublayer(1,Lr.ReadOnly,z.LEQUAL,!0),Ht=x.paint.get(mt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Ut=yt(.1,3,Ht),ts=M._showOverdrawInspector;if(!ts){const ns=new dn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),fs=new On([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);Xg(kt,M,h,x,A,Pt,ns,fs,nn.disabled,mt,"sdf",Pe,Ce,Ve,Be,ut,Ut,oe,!1)}{const ns=ts?dn.disabled:new dn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),fs=ts?M.colorModeForRenderPass():new On([z.ONE_MINUS_DST_ALPHA,z.DST_ALPHA,z.ONE,z.ONE],i.ao.transparent,[!0,!0,!0,!0]);Xg(kt,M,h,x,A,Pt,ns,fs,nn.disabled,mt,"color",Pe,Ce,Ve,Be,ut,Ut,oe,!1)}};if(Y){const mt=()=>{const Ht=H.drapeBufferSize[0],Ut=H.drapeBufferSize[1];let ts=H.framebufferCopyTexture;return ts&&(!ts||ts.size[0]===Ht&&ts.size[1]===Ut)||(ts&&ts.destroy(),ts=H.framebufferCopyTexture=new i.T(F,new i.q({width:Ht,height:Ut}),z.RGBA8)),ts.bind(z.LINEAR,z.CLAMP_TO_EDGE),z.copyTexSubImage2D(z.TEXTURE_2D,0,0,0,0,0,Ht,Ut),ts},Pt=(Ht,Ut,ts)=>{const ns=M.depthModeForSublayer(1,Lr.ReadOnly,z.LEQUAL,!1),fs=x.paint.get(Ht?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),qs=yt(.1,3,fs);{const Yt=new On([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0]);Xg(kt,M,h,x,A,ns,dn.disabled,Yt,nn.disabled,Ht,"clear",Pe,Ce,Ve,Be,ut,qs,oe,Ut)}{const Yt=new dn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),Ft=new On([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);Xg(kt,M,h,x,A,ns,Yt,Ft,nn.disabled,Ht,"sdf",Pe,Ce,Ve,Be,ut,qs,oe,Ut)}ae&&!Ht&&(ts=mt());{const Yt=Ht?z.ZERO:z.ONE_MINUS_DST_ALPHA,Ft=new dn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),ls=new On([Yt,z.DST_ALPHA,z.ONE_MINUS_DST_ALPHA,z.ZERO],i.ao.transparent,[!0,!0,!0,!0]);Xg(kt,M,h,x,A,ns,Ft,ls,nn.disabled,Ht,"color",Pe,Ce,Ve,Be,ut,qs,oe,Ut)}if(!ae||Ht){const Yt=new On([z.ONE,z.ONE,z.ONE,Ht?z.ZERO:z.ONE],i.ao.transparent,[!1,!1,!1,!0],Ht?z.FUNC_ADD:z.MAX);Xg(kt,M,h,x,A,ns,dn.disabled,Yt,nn.disabled,Ht,"clear",Pe,Ce,Ve,Be,ut,qs,oe,Ut,ts)}else{z.drawBuffers([z.NONE,z.COLOR_ATTACHMENT1]);const Yt=new dn({func:z.EQUAL,mask:255},254,255,z.KEEP,z.DECR,z.DECR),Ft=new On([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!0,!1,!1,!1],z.MAX);Xg(kt,M,h,x,A,ns,Yt,Ft,nn.disabled,Ht,"emissive",Pe,Ce,Ve,Be,ut,qs,oe,Ut,ts),z.drawBuffers([z.COLOR_ATTACHMENT0])}};if(st||Mt){let Ht;M.prepareDrawTile(),ae&&!st||(Ht=mt()),st&&Pt(!0,!1,Ht),Mt&&Pt(!1,!0,Ht)}}else st&>(!0),Mt&>(!1),(st||Mt)&&M.resetStencilClippingMasks()}}},building:function(M,h,x,A){M.currentLayer0&&F>0,ae=!0;const oe=x.paint.get("building-vertical-scale");if(oe<=0)return;M.shadowRenderer||(ae=!1);const ge=M.conflationActive&&M.style.isLayerClipped(x,h.getSource()),fe=M.style.order.indexOf(x.fqid);if(function(xe,Pe,Ce,Ve,Be,et){for(const ut of et){const st=Pe.getTile(ut).getBucket(Ce);st&&(Be&&st.updateReplacement(ut,xe.replacementSource,Ve),st.uploadUpdatedIndexBuffer(xe.context))}}(M,h,x,fe,ge,A),function(xe,Pe,Ce,Ve){for(const Be of Ve){const et=Pe.getTile(Be).getBucket(Ce);et&&et.needsEvaluation()&&et.uploadUpdatedColorBuffer(xe.context)}}(M,h,x,A),x.resetLayerRenderingStats(M),M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!0),M.renderPass==="shadow"&&M.shadowRenderer){const xe=M.shadowRenderer,Pe=[],Ce=xe.getShadowPassDepthMode();aw({painter:M,source:h,layer:x,coords:A,defines:Pe,blendMode:xe.getShadowPassColorMode(),depthMode:Ce,opacity:H,verticalScale:oe,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(M.renderPass==="translucent"){let xe=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];ae&&(xe=xe.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),M.shadowRenderer&&M.shadowRenderer.useNormalOffset&&(xe=xe.concat("NORMAL_OFFSET"));const Pe=x.paint.get("building-facade-emissive-chance"),Ce=x.paint.get("building-ambient-occlusion-intensity"),Ve=x.paint.get("building-flood-light-intensity"),Be=x.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",et=x.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(Be?null:x.lut).toArray01().slice(0,3),ut=x.paint.get("building-flood-light-ground-attenuation"),st=Ve>0,Mt=new Lr(M.context.gl.LEQUAL,Lr.ReadWrite,M.depthRangeFor3D);H<1&&aw({painter:M,source:h,layer:x,coords:A,defines:xe,blendMode:On.disabled,depthMode:Mt,opacity:H,verticalScale:oe,facadeEmissiveChance:Pe,facadeAOIntensity:Ce,floodLightIntensity:Ve,floodLightColor:et,depthOnly:!0});const yt=M.colorModeForRenderPass();aw({painter:M,source:h,layer:x,coords:A,defines:xe,blendMode:yt,depthMode:Mt,opacity:H,verticalScale:oe,facadeEmissiveChance:Pe,facadeAOIntensity:Ce,floodLightIntensity:Ve,floodLightColor:et}),Y&&WC(M,h,x,A,!0,H,D,F,Ve,et,z,ge),st&&WC(M,h,x,A,!1,H,D,F,Ve,et,ut,ge)}else if(M.renderPass==="light-beam"){const xe=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],Pe=new Lr(M.context.gl.LEQUAL,Lr.ReadOnly,M.depthRangeFor3D);aw({painter:M,source:h,layer:x,coords:A,defines:xe,blendMode:On.alphaBlended,depthMode:Pe,opacity:H,verticalScale:oe,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}M.shadowRenderer&&(M.shadowRenderer.useNormalOffset=!1),M.resetStencilClippingMasks()},hillshade:function(M,h,x,A){if(M.renderPass!=="offscreen"&&M.renderPass!=="translucent"||M.style.disableElevatedTerrain)return;const D=M.context,F=M.terrain&&M.terrain.renderingToTexture,[z,H]=M.renderPass!=="translucent"||F?[{},A]:M.stencilConfigForOverlap(A);for(const Y of H){const ae=h.getTile(Y);if(ae.needsHillshadePrepare&&M.renderPass==="offscreen")bme(M,ae,x);else if(M.renderPass==="translucent"){const oe=M.depthModeForSublayer(0,Lr.ReadOnly),ge=x.paint.get("hillshade-emissive-strength"),fe=M.colorModeForDrapableLayerRenderPass(ge),xe=F&&M.terrain?M.terrain.stencilModeForRTTOverlap(Y):z[Y.overscaledZ];_me(M,Y,ae,x,oe,xe,fe)}}D.viewport.set([0,0,M.width,M.height]),M.resetStencilClippingMasks()},raster:function(M,h,x,A,D,F){if(M.renderPass!=="translucent"||x.paint.get("raster-opacity")===0)return;const z=M.transform.projection.name==="globe",H=x.paint.get("raster-elevation")!==0,Y=H&&z;if(M.renderElevatedRasterBackface&&!Y)return;const ae=M.context,oe=ae.gl,ge=h.getSource(),fe=function(yt,kt,gt,mt,Pt){const Ht=kt.paint.get("raster-color"),Ut=yt.type==="raster-array",ts=[],ns=kt.paint.get("raster-resampling"),fs=kt.paint.get("raster-color-mix");let qs=kt.paint.get("raster-color-range");const Yt=[fs[0],fs[1],fs[2],0],Ft=fs[3];let ls=ns==="nearest"?mt.NEAREST:mt.LINEAR;if(Ut&&(ts.push("RASTER_ARRAY"),Ht||ts.push("RASTER_COLOR"),ns==="linear"&&ts.push("RASTER_ARRAY_LINEAR"),ls=mt.NEAREST,!qs&&yt.rasterLayers)){const Jt=yt.rasterLayers.find(({id:Ls})=>Ls===kt.sourceLayer);Jt&&Jt.fields&&Jt.fields.range&&(qs=Jt.fields.range)}if(qs=qs||[0,1],Ht){ts.push("RASTER_COLOR"),gt.activeTexture.set(mt.TEXTURE2),kt.updateColorRamp(qs);let Jt=kt.colorRampTexture;Jt||(Jt=kt.colorRampTexture=new i.T(gt,kt.colorRamp,mt.RGBA8)),Jt.bind(mt.LINEAR,mt.CLAMP_TO_EDGE)}return Pt&&ts.push("USE_MRT1"),{mix:Yt,range:qs,offset:Ft,defines:ts,resampling:ls}}(ge,x,ae,oe,M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback");if(ge instanceof i.aU&&!A.length&&!z)return;const xe=x.paint.get("raster-emissive-strength"),Pe=M.colorModeForDrapableLayerRenderPass(xe),Ce=M.terrain&&M.terrain.renderingToTexture,Ve=!M.options.moving,Be=x.paint.get("raster-resampling")==="nearest"?oe.NEAREST:oe.LINEAR;if(ge instanceof i.aU&&!A.length&&(ge.onNorthPole||ge.onSouthPole)){const yt=H?M.stencilModeFor3D():dn.disabled;return void iw(!!ge.onNorthPole,null,M,h,x,xe,fe,nn.disabled,yt)}if(!A.length)return;const[et,ut]=ge instanceof i.aU||Ce?[{},A]:M.stencilConfigForOverlap(A),st=ut[ut.length-1].overscaledZ;Y&&fe.defines.push("PROJECTION_GLOBE_VIEW"),H&&fe.defines.push("RENDER_CUTOFF");const Mt=(yt,kt,gt)=>{for(const mt of yt){const Pt=mt.toUnwrapped(),Ht=h.getTile(mt);if(Ce&&(!Ht||!Ht.hasData()))continue;ae.activeTexture.set(oe.TEXTURE0);const Ut=Jg(Ht,ge,x,fe);if(!Ut||!Ut.texture)continue;const{texture:ts,mix:ns,offset:fs,tileSize:qs,buffer:Yt}=Ut;let Ft,ls;Ce?(Ft=Lr.disabled,ls=mt.projMatrix):H?(Ft=new Lr(oe.LEQUAL,Lr.ReadWrite,M.depthRangeFor3D),ls=z?Float32Array.from(M.transform.expandedFarZProjMatrix):M.transform.calculateProjMatrix(Pt,Ve)):(Ft=M.depthModeForSublayer(mt.overscaledZ-st,x.paint.get("raster-opacity")===1?Lr.ReadWrite:Lr.ReadOnly,oe.LESS),ls=M.transform.calculateProjMatrix(Pt,Ve));const Jt=M.terrain&&Ce?M.terrain.stencilModeForRTTOverlap(mt):et[mt.overscaledZ],Ls=F?0:x.paint.get("raster-fade-duration");Ht.registerFadeDuration(Ls);const er=h.findLoadedParent(mt,0),pr=ew(Ht,er,h,M.transform,Ls);let Xs,Vs;!pr.isFading&&Ht.refreshedUponExpiration&&(Ht.refreshedUponExpiration=!1),M.terrain&&M.terrain.prepareDrawTile(),ae.activeTexture.set(oe.TEXTURE0),ts.bind(Be,oe.CLAMP_TO_EDGE),ae.activeTexture.set(oe.TEXTURE1),er?(er.texture&&er.texture.bind(Be,oe.CLAMP_TO_EDGE),Xs=Math.pow(2,er.tileID.overscaledZ-Ht.tileID.overscaledZ),Vs=[Ht.tileID.canonical.x*Xs%1,Ht.tileID.canonical.y*Xs%1]):ts.bind(Be,oe.CLAMP_TO_EDGE),"useMipmap"in ts&&ae.extTextureFilterAnisotropic&&M.transform.pitch>20&&oe.texParameterf(oe.TEXTURE_2D,ae.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,ae.extTextureFilterAnisotropicMax);const Cr=M.transform;let kr;const dr=H?DR(Cr):[0,0,0,0];let xr,Vr,kn,ga,Ja,Er=0;if(Y&&ge instanceof i.aU&&ge.coordinates.length>3)xr=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0)))),Vr=Float32Array.from(Cr.globeMatrix),kn=Float32Array.from(i.dF(Cr)),ga=[i.aF(Cr.center.lng),i.aJ(Cr.center.lat)],kr=ge.elevatedGlobePerspectiveTransform,Ja=ge.elevatedGlobeGridMatrix||new Float32Array(9);else if(Y){const wi=i.dG(mt.canonical);Er=i.dH(wi.getCenter().lat),xr=Float32Array.from(i.bk(i.dJ(mt.canonical))),Vr=Float32Array.from(Cr.globeMatrix),kn=Float32Array.from(i.dF(Cr)),ga=[i.aF(Cr.center.lng),i.aJ(Cr.center.lat)],kr=[0,0],Ja=Float32Array.from(i.dI(mt.canonical,wi,Er,Cr.worldSize/Cr._pixelsPerMercatorPixel))}else kr=ge instanceof i.aU?ge.perspectiveTransform:[0,0],xr=new Float32Array(16),Vr=new Float32Array(9),kn=new Float32Array(16),ga=[0,0],Ja=new Float32Array(9);const Wa=MR(ls,xr,Vr,kn,Ja,Vs||[0,0],i.aj(M.transform.zoom),ga,dr,Xs||1,pr,x,kr,H?x.paint.get("raster-elevation"):0,2,ns,fs,fe.range,qs,Yt,xe),_n=M.isTileAffectedByFog(mt),ii=M.getOrCreateProgram("raster",{defines:fe.defines,overrideFog:_n});if(M.uploadCommonUniforms(ae,ii,Pt),ge instanceof i.aU){const wi=ge.elevatedGlobeVertexBuffer,pi=ge.elevatedGlobeIndexBuffer;if(Ce||!z)ge.boundsBuffer&&ge.boundsSegments&&ii.draw(M,oe.TRIANGLES,Ft,dn.disabled,Pe,nn.disabled,Wa,x.id,ge.boundsBuffer,M.quadTriangleIndexBuffer,ge.boundsSegments);else if(wi&&pi){const Ua=Cr.zoom<=i.c_?ge.elevatedGlobeSegments:ge.getSegmentsForLongitude(Cr.center.lng);Ua&&ii.draw(M,oe.TRIANGLES,Ft,dn.disabled,Pe,kt,Wa,x.id,wi,pi,Ua)}}else if(Y){Ft=new Lr(oe.LEQUAL,Lr.ReadOnly,M.depthRangeFor3D);const wi=M.globeSharedBuffers;if(wi){const[pi,Ua,Fn]=wi.getGridBuffers(Er,!1);ii.draw(M,oe.TRIANGLES,Ft,gt||Jt,M.colorModeForRenderPass(),kt,Wa,x.id,pi,Ua,Fn)}}else{const{tileBoundsBuffer:wi,tileBoundsIndexBuffer:pi,tileBoundsSegments:Ua}=M.getTileBoundsBuffers(Ht);ii.draw(M,oe.TRIANGLES,Ft,Jt,Pe,nn.disabled,Wa,x.id,wi,pi,Ua)}}if(!(ge instanceof i.aU)&&Y)for(const mt of yt){const Pt=mt.canonical.y===(1<>>16,2654435769),((mt=Math.imul(mt^mt>>>16,2654435769))>>>0)/4294967296},gt=1/1.1;for(let mt=0;mti.e9[Jt](ts));Yt.push(ts);const Ft=ts.canonical.x,ls=ts.canonical.y;for(const Jt of Yt){const Ls=st.getTile(Pt?Jt.wrapped():Jt);if(!Ls)continue;const er=Ls.rasterParticleState;if(!er)continue;const pr=Jt.canonical.x+(1<kt.tileID)),xe&&(ae.activeTexture.set(oe.TEXTURE0),M.imageManager.bind(M.context,x.scope));const yt=[];if(M.terrain&&M.terrain.renderingToTexture&&M.emissiveMode==="mrt-fallback"&&yt.push("USE_MRT1"),Y){const kt=M.getOrCreateProgram(ut,{overrideFog:!1,overrideRtt:!0,defines:yt}),gt=new Float32Array(i.bA([])),mt=new i.aQ(0,0,0,0,0),Pt=xe?jy(gt,H,z,M,0,x.scope,Pe,Y,{tileID:mt,tileSize:fe}):sw(gt,H,z,D.toPremultipliedRenderColor(F?null:x.lut));kt.draw(M,oe.TRIANGLES,Be,Ve,et,nn.disabled,Pt,x.id,M.viewportBuffer,M.quadTriangleIndexBuffer,M.viewportSegments)}else for(const kt of Mt){const gt=M.isTileAffectedByFog(kt),mt=M.getOrCreateProgram(ut,{overrideFog:gt,defines:yt}),Pt=kt.toUnwrapped(),Ht=A?kt.projMatrix:M.transform.calculateProjMatrix(Pt);M.prepareDrawTile();const Ut=h?h.getTile(kt):st?st[kt.key]:new $m(kt,fe,ge.zoom,M),ts=xe?jy(Ht,H,z,M,0,x.scope,Pe,Y,{tileID:kt,tileSize:fe}):sw(Ht,H,z,D.toPremultipliedRenderColor(F?null:x.lut));M.uploadCommonUniforms(ae,mt,Pt);const{tileBoundsBuffer:ns,tileBoundsIndexBuffer:fs,tileBoundsSegments:qs}=M.getTileBoundsBuffers(Ut);mt.draw(M,oe.TRIANGLES,Be,Ve,et,nn.disabled,ts,x.id,ns,fs,qs)}},sky:function(M,h,x){const A=M._atmosphere?i.aj(M.transform.zoom):1,D=x.paint.get("sky-opacity")*A;if(D===0)return;const F=M.context,z=x.paint.get("sky-type"),H=new Lr(F.gl.LEQUAL,Lr.ReadOnly,[0,1]),Y=M.frameCounter/1e3%1;z==="atmosphere"?M.renderPass==="offscreen"?x.needsSkyboxCapture(M)&&(function(ae,oe,ge,fe){const xe=ae.context,Pe=xe.gl;let Ce=oe.skyboxFbo;if(!Ce){Ce=oe.skyboxFbo=xe.createFramebuffer(32,32,1,null),oe.skyboxGeometry=new YC(xe),oe.skyboxTexture=xe.gl.createTexture(),Pe.bindTexture(Pe.TEXTURE_CUBE_MAP,oe.skyboxTexture),Pe.texParameteri(Pe.TEXTURE_CUBE_MAP,Pe.TEXTURE_WRAP_S,Pe.CLAMP_TO_EDGE),Pe.texParameteri(Pe.TEXTURE_CUBE_MAP,Pe.TEXTURE_WRAP_T,Pe.CLAMP_TO_EDGE),Pe.texParameteri(Pe.TEXTURE_CUBE_MAP,Pe.TEXTURE_MIN_FILTER,Pe.LINEAR),Pe.texParameteri(Pe.TEXTURE_CUBE_MAP,Pe.TEXTURE_MAG_FILTER,Pe.LINEAR);for(let ut=0;ut<6;++ut)Pe.texImage2D(Pe.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,Pe.RGBA,32,32,0,Pe.RGBA,Pe.UNSIGNED_BYTE,null)}xe.bindFramebuffer.set(Ce.framebuffer),xe.viewport.set([0,0,32,32]);const Ve=oe.getCenter(ae,!0),Be=ae.getOrCreateProgram("skyboxCapture"),et=new Float64Array(16);i.bA(et),i.en(et,et,.5*-Math.PI),rv(ae,oe,Be,et,Ve,0),i.bA(et),i.en(et,et,.5*Math.PI),rv(ae,oe,Be,et,Ve,1),i.bA(et),i.cU(et,et,.5*-Math.PI),rv(ae,oe,Be,et,Ve,2),i.bA(et),i.cU(et,et,.5*Math.PI),rv(ae,oe,Be,et,Ve,3),i.bA(et),rv(ae,oe,Be,et,Ve,4),i.bA(et),i.en(et,et,Math.PI),rv(ae,oe,Be,et,Ve,5),xe.viewport.set([0,0,ae.width,ae.height])}(M,x),x.markSkyboxValid(M)):M.renderPass==="sky"&&function(ae,oe,ge,fe,xe){const Pe=ae.context,Ce=Pe.gl,Ve=ae.transform,Be=ae.getOrCreateProgram("skybox");Pe.activeTexture.set(Ce.TEXTURE0),Ce.bindTexture(Ce.TEXTURE_CUBE_MAP,oe.skyboxTexture);const et=((ut,st,Mt,yt,kt)=>({u_matrix:ut,u_sun_direction:st,u_cubemap:0,u_opacity:yt,u_temporal_offset:kt}))(Ve.skyboxMatrix,oe.getCenter(ae,!1),0,fe,xe);ae.uploadCommonUniforms(Pe,Be),Be.draw(ae,Ce.TRIANGLES,ge,dn.disabled,ae.colorModeForRenderPass(),nn.backCW,et,"skybox",oe.skyboxGeometry.vertexBuffer,oe.skyboxGeometry.indexBuffer,oe.skyboxGeometry.segment)}(M,x,H,D,Y):z==="gradient"&&M.renderPass==="sky"&&function(ae,oe,ge,fe,xe){const Pe=ae.context,Ce=Pe.gl,Ve=ae.transform,Be=ae.getOrCreateProgram("skyboxGradient");oe.skyboxGeometry||(oe.skyboxGeometry=new YC(Pe)),Pe.activeTexture.set(Ce.TEXTURE0);let et=oe.colorRampTexture;et||(et=oe.colorRampTexture=new i.T(Pe,oe.colorRamp,Ce.RGBA8)),et.bind(Ce.LINEAR,Ce.CLAMP_TO_EDGE);const ut=((st,Mt,yt,kt,gt)=>({u_matrix:st,u_color_ramp:0,u_center_direction:Mt,u_radius:i.an(yt),u_opacity:kt,u_temporal_offset:gt}))(Ve.skyboxMatrix,oe.getCenter(ae,!1),oe.paint.get("sky-gradient-radius"),fe,xe);ae.uploadCommonUniforms(Pe,Be),Be.draw(ae,Ce.TRIANGLES,ge,dn.disabled,ae.colorModeForRenderPass(),nn.backCW,ut,"skyboxGradient",oe.skyboxGeometry.vertexBuffer,oe.skyboxGeometry.indexBuffer,oe.skyboxGeometry.segment)}(M,x,H,D,Y)},custom:function(M,h,x,A){const D=M.context,F=x.implementation;if(!M.transform.projection.unsupportedLayers||!M.transform.projection.unsupportedLayers.includes("custom")||M.terrain&&(M.terrain.renderingToTexture||M.renderPass==="offscreen")&&x.isDraped(h)){if(M.renderPass==="offscreen"){const z=F.prerender;if(z){if(M.setCustomLayerDefaults(),D.setColorMode(M.colorModeForRenderPass()),M.transform.projection.name==="globe"){const H=M.transform.pointMerc;z.call(F,D.gl,M.transform.customLayerMatrix(),M.transform.getProjection(),M.transform.globeToMercatorMatrix(),i.aj(M.transform.zoom),[H.x,H.y],M.transform.pixelsPerMeterRatio)}else z.call(F,D.gl,M.transform.customLayerMatrix());D.setDirty(),M.setBaseState()}}else if(M.renderPass==="translucent"){if(M.terrain&&M.terrain.renderingToTexture){const H=F.renderToTile;if(H){const Y=A[0].canonical,ae={x:Y.x+A[0].wrap*(F.wrapTileId?0:1<{ae&&(ae.useNormalOffset=!0,oe||(ae.enabled=!0))},fe=h.getSource();if(M.renderPass==="light-beam"&&fe.type!=="batched-model")return;if(fe.type==="vector"||fe.type==="geojson")return function(st,Mt,yt,kt,gt){const mt=st.transform,Pt=mt.projection.name==="globe",Ht=mt.getFreeCameraOptions().position;if(!st.modelManager)return;const Ut=st.modelManager;yt.modelManager=Ut;const ts=st.shadowRenderer;if(!yt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const ns=yt._unevaluatedLayout._values["model-id"],fs=Object.assign({},yt.layout.get("model-id").parameters),qs=st.style.order.indexOf(yt.fqid),Yt=yt.paint.get("model-opacity").constantOr(1);for(const Ft of kt){const ls=Mt.getTile(Ft).getBucket(yt);if(!ls||ls.projection.name!==mt.projection.name)continue;const Jt=ls.getModelUris();if(Jt&&!ls.modelsRequested&&(Ut.addModelsFromBucket(Jt,gt),ls.modelsRequested=!0),Pt)fs.zoom=Ft.overscaledZ;else{const dr=Eu(Ft,mt);fs.zoom=dr}const Ls=ns.possiblyEvaluate(fs);if(WR(st,ls,Ft),Of.shadowUniformsInitialized=!1,Of.useSingleShadowCascade=!!ts&&ts.getMaxCascadeForTile(Ft.toUnwrapped())===0,st.renderPass==="shadow"&&ts){if(st.currentShadowCascade===1&&ls.isInsideFirstShadowMapFrustum)continue;const dr=mt.calculatePosMatrix(Ft.toUnwrapped(),mt.worldSize);if(Of.tileMatrix.set(dr),Of.shadowTileMatrix=Float32Array.from(ts.calculateShadowPassMatrixFromMatrix(dr)),Of.aabb.min=[0,0,0],Of.aabb.max[0]=Of.aabb.max[1]=i.al,Of.aabb.max[2]=0,Lme(ls,Of,st,yt.scope))continue}const er=1<0&&st.style.isLayerClipped(yt,Mt.getSource())&&ls.updateReplacement(Ft,st.replacementSource,qs,yt.scope)&&(ls.uploaded=!1,ls.upload(st.context));let Xs=0;const Vs=new Array,Cr=new Array,kr=new Array;for(let dr in ls.instancesPerModel){const xr=ls.instancesPerModel[dr];xr.features.length>0&&!Pt&&(dr=Ls.evaluate(xr.features[0].feature,{}));const Vr=Ut.getModel(dr,gt);if(Vr||Ut.hasURLBeenRequested(dr)||ls.modelUris.includes(dr)||(ls.modelUris.push(dr),ls.modelsRequested=!1),Vr&&Vr.uploaded)if(Pt){const kn=i.c5([],[Ht.x,Ht.y,Ht.z],st.transform.worldSize);i.ew(kn,kn);for(let ga=0;ga0&&Wa.elevationUpdate(dr.terrain,ga,Er,Vr.source),Wa.needsReEvaluation(dr,Ja,Vr)&&Wa.evaluate(Vr))}})(st,Mt,yt,kt),function(){let dr,xr,Vr;Vs?(dr=kt.length-1,xr=-1,Vr=-1):(dr=0,xr=kt.length,Vr=1);const kn=new Float64Array(16),ga=i.cA(),Ja=new i.P(0,0);for(let Er=dr;Er!==xr;Er+=Vr){const Wa=kt[Er],_n=Mt.getTile(Wa).getBucket(yt);if(!_n||!_n.uploaded)continue;let ii=!1;Ht&&(ii=Ht.getMaxCascadeForTile(Wa.toUnwrapped())===0);const wi=mt.calculatePosMatrix(Wa.toUnwrapped(),mt.worldSize),pi=_n.modelTraits;!er&&Vs&&(i.bl(kn,wi),i.af(ga,ts,kn),Ja.x=ga[0],Ja.y=ga[1]);const Ua=[];_n.setFilter(yt.filter);for(const Fn of _n.getNodesInfo()){if(Fn.hiddenByReplacement||!Fn.node.meshes)continue;const si=Fn.node;let wo=0;st.terrain&&si.elevation&&(wo=si.elevation*st.terrain.exaggeration());const eo=(()=>{const Rd=Fn.aabb;return Ls.min=[...Rd.min],Ls.max=[...Rd.max],Ls.min[2]+=wo,Ls.max[2]+=wo,i.af(Ls.min,Ls.min,wi),i.af(Ls.max,Ls.max,wi),Ls})(),oi=Fn.evaluatedScale;if(oi[0]<=1&&oi[1]<=1&&oi[2]<=1&&eo.intersects(pr)===0)continue;if(!er&&Vs){const Rd=.16666666666666666;Fn.cameraCollisionOpacity=ts[0]>eo.min[0]&&ts[0]eo.min[1]&&ts[1]!Vs||Fn.opacity===1&&si.opacity===1?Fn.depthsi.depth?-1:1);for(const Fn of Ua){const si=Fn.nodeInfo,wo=si.node;let eo=i.aB([],Yt,Fn.tileModelMatrix);i.aB(eo,fs,eo);const oi=i.bl([],eo);i.eg(oi,oi),i.cS(oi,oi,lw),eo=i.aB(eo,eo,wo.globalMatrix);const Pa=st.renderPass==="light-beam",zn=yt.paint.get("model-color-use-theme").constantOr("default")==="none",Zi=pi&i.eI.HasMapboxMeshFeatures,Fo=Zi?0:si.evaluatedRMEA[0][2];for(let yo=0;yo=gs||vo>=gs}}const Qc=Ai.material;let am;Qc.occlusionTexture&&Qc.occlusionTexture.offsetScale&&(am=Qc.occlusionTexture.offsetScale,Dl.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const Ym=st.getOrCreateProgram("model",Dl);!er&&Ht&&Ht.setupShadowsFromMatrix(Fn.tileModelMatrix,Ym,Ht.useNormalOffset),st.uploadCommonUniforms(gt,Ym,null,Fd);const ah=Qc.pbrMetallicRoughness;ah.metallicFactor=.9,ah.roughnessFactor=.5;const To=Q0(new Float32Array(bd),new Float32Array(eo),new Float32Array(oi),new Float32Array(wo.globalMatrix),st,Fn.opacity,ah.baseColorFactor,Qc.emissiveFactor,ah.metallicFactor,ah.roughnessFactor,Qc,Fo,yt,[0,0,0],am);!Pu&&(si.hasTranslucentParts||Fn.opacity<1)&&Ym.draw(st,gt.gl.TRIANGLES,ls,dn.disabled,On.disabled,nn.backCCW,To,yt.id,Ai.vertexBuffer,Ai.indexBuffer,Ai.segments,yt.paint,st.transform.zoom,void 0,Rd),Ym.draw(st,gt.gl.TRIANGLES,Pu?Jt:ls,dn.disabled,Pu||Fn.opacity<1||si.hasTranslucentParts?On.alphaBlended:On.unblended,nn.backCCW,To,yt.id,Ai.vertexBuffer,Ai.indexBuffer,Ai.segments,yt.paint,st.transform.zoom,void 0,Rd)}}}}()}(M,h,x,A),void ge();if(fe.type!=="model")return;const xe=fe.getModels(),Pe=[],Ce=M.transform.getFreeCameraOptions().position,Ve=i.c5([],[Ce.x,Ce.y,Ce.z],M.transform.worldSize);i.ew(Ve,Ve);const Be=[],et=[];let ut=0;for(const st of xe){const Mt=h.getFeatureState("",st.id),yt={type:"Unknown",id:st.id,properties:st.featureProperties},kt=x.paint.get("model-rotation").evaluate(yt,Mt),gt=x.paint.get("model-scale").evaluate(yt,Mt),mt=x.paint.get("model-translation").evaluate(yt,Mt),Pt=x.paint.get("model-opacity").evaluate(yt,Mt);UR(x,st.id,Mt,st.featureProperties,st.nodeOverrideNames,st.nodeOverrides),VR(x,st.id,Mt,st.featureProperties,st.materialOverrideNames,st.materialOverrides),st.nodeOverrides.size>0&&st.computeBoundsAndApplyParent(),st.computeModelMatrix(M,kt,gt,mt,H,z,!1);const Ht=i.bA([]),Ut=i.ef(st.position.lat,M.transform.zoom),ts=i.bq([],[1,1,1/Ut]);i.br(Ht,Ht,Ve),Pe.push({zScaleMatrix:ts,negCameraPosMatrix:Ht});for(const ns of st.nodes)nv(M,ns,st.matrix,M.transform.expandedFarZProjMatrix,ut,Be,et,st.materialOverrides,Pt);ut++}if(Be.sort((st,Mt)=>Mt.depth-st.depth),M.renderPass!=="shadow")HR(M,x,Be,et,Pe),ge();else{for(const st of et)Dp(st.mesh,st.nodeModelMatrix,M,x);for(const st of Be)Dp(st.mesh,st.nodeModelMatrix,M,x);ge()}}},r3={line:function(M,h,x){if(M.hasElevatedBuckets=!1,M.hasNonElevatedBuckets=!1,M._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||M._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(h){const A=h.getVisibleCoordinates();for(const D of A){const F=h.getTile(D).getBucket(M);if(F&&(F.elevationType!=="none"?M.hasElevatedBuckets=!0:M.hasNonElevatedBuckets=!0,M.hasElevatedBuckets&&M.hasNonElevatedBuckets))break}}}else M.hasNonElevatedBuckets=!0},model:function(M,h,x){const A=h.getSource();if(!A.loaded())return;if(A.type==="vector"||A.type==="geojson")return void(x.modelManager&&x.modelManager.upload(x,ow(x,M)));if(A.type==="batched-model"||A.type!=="model")return;const D=A.getModels();for(const F of D)F.upload(x.context)},raster:function(M,h,x){const A=h.getSource();if(!(A instanceof yd&&A.loaded()))return;const D=M.sourceLayer||A.rasterLayerIds&&A.rasterLayerIds[0];if(!D)return;const F=M.paint.get("raster-array-band")||A.getInitialBand(D);if(F==null)return;const z=h.getIds().map(H=>h.getTileByID(H));for(const H of z)H.updateNeeded(M.id,F)&&A.prepareTile(H,D,M.id,F)},"raster-particle":function(M,h,x){const A=h.getSource();if(!(A instanceof yd&&A.loaded()))return;const D=M.sourceLayer||A.rasterLayerIds&&A.rasterLayerIds[0];if(!D)return;const F=M.paint.get("raster-particle-array-band")||A.getInitialBand(D);if(F==null)return;const z=h.getIds().map(H=>h.getTileByID(H));for(const H of z)H.updateNeeded(M.id,F)&&A.prepareTile(H,D,M.id,F)}},nm={fill:UC},n3={fill:function(M,h,x,A){if(!x.layout||x.layout.get("fill-elevation-reference")==="none"||x.paint.get("fill-opacity").constantOr(1)===0)return;const D=M.context.gl,F=new Lr(D.LEQUAL,Lr.ReadOnly,M.depthRangeFor3D),z=new dn({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),H=M.transform.getFreeCameraOptions().position,Y=M.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const ae of A){const oe=h.getTile(ae),ge=oe.getBucket(x);if(!ge)continue;const fe=ge.elevatedStructures;if(!fe||fe.depthSegments.segments[0].primitiveLength===0)continue;const xe=LR(ae.toUnwrapped(),H),Pe=M.translatePosMatrix(ae.projMatrix,oe,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor")),Ce=X0(Pe,xe,0,1,0);Y.draw(M,D.TRIANGLES,F,z,On.disabled,nn.disabled,Ce,x.id,fe.vertexBuffer,fe.indexBuffer,fe.depthSegments,x.paint,M.transform.zoom)}}};class a3{constructor(h,x,A,D,F){this.context=new t_(h,x),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 Y of z)this._debugParams.enabledLayers[Y]=!0;for(const Y of z);this.occlusionParams=new r_,this.setup(),this.numSublayers=jl.maxUnderzooming+jl.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 U1(this),this._wireframeDebugCache=new Ny,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const H=new i.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new i.T(this.context,H,h.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=D,this.worldview=F,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(h,x){const A=!!h&&!!h.terrain&&this.transform.projection.supportsTerrain;if(!(A||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new HE(this,h));const D=this._terrain;this.transform.elevation=A?D:null,D.update(h,this.transform,x),this.transform.elevation&&!D.enabled&&(this.transform.elevation=null)}_updateFog(h){const x=h.fog;if(!x||this.transform.projection.name==="globe"||x.getOpacity(this.transform.pitch)<1||x.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[A,D]=x.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 HE(this,this.style)),this._forceTerrainMode=h}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(h,x){if(this.width=h*i.o.devicePixelRatio,this.height=x*i.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const A of this.style.order)this.style._mergedLayers[A].resize()}setup(){const h=this.context,x=new i.bd;x.emplaceBack(0,0),x.emplaceBack(i.al,0),x.emplaceBack(0,i.al),x.emplaceBack(i.al,i.al),this.tileExtentBuffer=h.createVertexBuffer(x,i.bf.members),this.tileExtentSegments=i.bg.simpleSegment(0,0,4,2);const 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 H=new i.be;for(const ae of[0,1,3,2,0])H.emplaceBack(ae);this.debugIndexBuffer=h.createIndexBuffer(H),this.emptyTexture=new i.T(h,new i.q({width:1,height:1},Uint8Array.of(0,0,0,0)),h.gl.RGBA8),this.identityMat=i.bC();const Y=this.context.gl;this.stencilClearMode=new dn({func:Y.ALWAYS,mask:0},0,255,Y.ZERO,Y.ZERO,Y.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,Lr.disabled,this.stencilClearMode,On.disabled,nn.disabled,J2(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(h,x,A){if(!x||this.currentStencilSource===x.id||!h.isTileClipped()||!A||A.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let H=!1;for(const Y of A)if(this._tileClippingMaskIDs[Y.key]===void 0){H=!0;break}if(!H)return}this.currentStencilSource=x.id;const D=this.context,F=D.gl;this.nextStencilID+A.length>256&&this.clearStencil(),D.setColorMode(On.disabled),D.setDepthMode(Lr.disabled);const z=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const H of A){const Y=x.getTile(H),ae=this._tileClippingMaskIDs[H.key]=this.nextStencilID++,{tileBoundsBuffer:oe,tileBoundsIndexBuffer:ge,tileBoundsSegments:fe}=this.getTileBoundsBuffers(Y);z.draw(this,F.TRIANGLES,Lr.disabled,new dn({func:F.ALWAYS,mask:0},ae,255,F.KEEP,F.KEEP,F.REPLACE),On.disabled,nn.disabled,J2(H.projMatrix),"$clipping",oe,ge,fe)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const h=this.nextStencilID++,x=this.context.gl;return new dn({func:x.NOTEQUAL,mask:255},h,255,x.KEEP,x.KEEP,x.REPLACE)}stencilModeForClipping(h){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(h);const x=this.context.gl;return new dn({func:x.EQUAL,mask:255},this._tileClippingMaskIDs[h.key],0,x.KEEP,x.KEEP,x.REPLACE)}stencilConfigForOverlap(h){const x=this.context.gl,A=h.sort((z,H)=>H.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 H=0;Hthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((h,x)=>h+x/this._fpsHistory.length,0))}render(h,x){const 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=x;const D=this.style._mergedLayers,F=!(!this.terrain||!this.terrain.enabled),z=()=>this.style._getOrder(F).filter(Yt=>{const Ft=D[Yt];return!(Ft.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[Ft.type]});let H=z(),Y=!1,ae=!1,oe=null,ge=0,fe=!1;for(const Yt of H){const Ft=D[Yt];Ft.visibility!=="none"&&(Ft.type==="circle"?Y=!0:Ft.type==="building"?(oe=Ft,++ge):Ft.type==="symbol"&&(Ft.hasOcclusionOpacityProperties?ae=!0:Y=!0))}this.updateEmissiveMode();let xe=H.map(Yt=>D[Yt]);const Pe=this.style._mergedSourceCaches;this.imageManager=h.imageManager,this.modelManager=h.modelManager,this.symbolFadeChange=h.placement.symbolFadeChange(i.o.now()),this.imageManager.beginFrame();for(const Yt in Pe){const Ft=Pe[Yt];Ft.used&&(Ft.prepare(this.context),Ft.getSource().usedInConflation&&++ge)}let Ce=!1;for(const Yt of xe)Yt.isHidden(this.transform.zoom)||(Yt.type==="clip"&&(Ce=!0),this.prepareLayer(Yt));const Ve={},Be={},et={},ut={},st={};for(const Yt in Pe){const Ft=Pe[Yt];Ve[Yt]=Ft.getVisibleCoordinates(),Be[Yt]=Ve[Yt].slice().reverse(),et[Yt]=Ft.getVisibleCoordinates(!0).reverse(),ut[Yt]=Ft.getShadowCasterCoordinates(),st[Yt]=Ft.sortCoordinatesByDistance(Ve[Yt])}const Mt=Yt=>{const Ft=this.style.getLayerSourceCache(Yt);return Ft&&Ft.used?Ft.getSource():null};if(ge||Ce||this._clippingActiveLastFrame){const Yt=[],Ft=[];let ls=0;for(const Jt of xe)this.isSourceForClippingOrConflation(Jt,Mt(Jt))&&(Yt.push(Jt),Ft.push(ls)),ls++;if(Yt&&(Ce||Yt.length>1)||this._clippingActiveLastFrame){Ce=!1;const Jt=[];for(let Ls=0;Ls0){const Jt=Mt(Ft);Jt&&(this.minCutoffZoom=Math.max(Jt.minzoom,this.minCutoffZoom)),Ft.minzoom&&(this.minCutoffZoom=Math.max(Ft.minzoom,this.minCutoffZoom))}Ft.is3D(F)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Yt),this._lastOcclusionLayer=Yt)}const yt=this.style&&this.style.fog;yt?(this._fogVisible=yt.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=yt.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(et),this.opaquePassCutoff=0,H=z(),xe=H.map(Yt=>D[Yt]));const kt=this._shadowRenderer;if(kt){kt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Yt in Pe)for(const Ft of Ve[Yt]){let ls={min:0,max:0};this.terrain&&(ls=this.terrain.getMinMaxForTile(Ft)||ls),kt.addShadowReceiver(Ft.toUnwrapped(),ls.min,ls.max)}}this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new i.eR(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new qR(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const gt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),mt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(gt&&!this._snow&&(this._snow=new oP(this)),!gt&&this._snow&&(this._snow.destroy(),delete this._snow),mt&&!this._rain&&(this._rain=new s3(this)),!mt&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),oe){this.buildingTileBorderManager||(this.buildingTileBorderManager=new XC);const Yt=this.style.getLayerSourceCache(oe);this.buildingTileBorderManager.updateBorders(Yt,oe)}if(!lt.has(this.context.gl))return;this.renderPass="offscreen";for(const Yt of xe){const Ft=h.getLayerSourceCache(Yt);if(!Yt.hasOffscreenPass()||Yt.isHidden(this.transform.zoom))continue;const ls=Ft?Be[Ft.id]:void 0;(Yt.type==="custom"||Yt.type==="raster"||Yt.type==="raster-particle"||Yt.isSky()||ls&&ls.length)&&this.renderLayer(this,Ft,Yt,ls)}this.depthRangeFor3D=[0,1-(xe.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,ut)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const Pt=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Ht=(()=>{if(x.showOverdrawInspector)return i.ao.black;const Yt=this.style.fog;if(Yt&&this.transform.projection.supportsFog){const Ft=this.style.getLut(Yt.scope);if(!Pt){const ls=Yt.properties.get("color-use-theme")==="none",Jt=Yt.properties.get("color").toNonPremultipliedRenderColor(ls?null:Ft).toArray01();return new i.ao(...Jt)}if(Pt){const ls=Yt.properties.get("space-color-use-theme")==="none",Jt=Yt.properties.get("space-color").toNonPremultipliedRenderColor(ls?null:Ft).toArray01();return new i.ao(...Jt)}}return i.ao.transparent})();if(this.context.clear({color:Ht,depth:1}),this.clearStencil(),this._showOverdrawInspector=x.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Pt&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=H.length-1;this.currentLayer>=0;this.currentLayer--){const Yt=xe[this.currentLayer],Ft=h.getLayerSourceCache(Yt);if(Yt.isSky())continue;const ls=Ft?(Yt.is3D(F)?st:Be)[Ft.id]:void 0;this._renderTileClippingMasks(Yt,Ft,ls),this.renderLayer(this,Ft,Yt,ls)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&Pt&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||i.aj(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer0&&Yt.hasShadowPass()&&--ts==0){{this.clearStencil(),this.resetStencilClippingMasks();const ls=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const ls=this.currentLayer;this.depthOcclusion=!0;for(const Jt of this.layersWithOcclusionOpacity){this.currentLayer=Jt;const Ls=xe[this.currentLayer],er=h.getLayerSourceCache(Ls),pr=er?Be[er.id]:void 0;this.terrain||this._renderTileClippingMasks(Ls,er,er?Ve[er.id]:void 0),this.renderLayer(this,er,Ls,pr)}this.depthOcclusion=!1,this.currentLayer=ls,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let Yt=null;xe.forEach(Ft=>{const ls=h.getLayerSourceCache(Ft);ls&&!Ft.isHidden(this.transform.zoom)&&ls.getVisibleCoordinates().length&&(!Yt||Yt.getSource().maxzoom0?x.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(h,x,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||x!==void 0&&!x||F.push("FOG","FOG_DITHERING"),D&&F.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&F.push("OVERDRAW_INSPECTOR"),F}getOrCreateProgram(h,x){this.cache=this.cache||{};const A=x&&x.defines||[],D=x&&x.config,F=this.currentGlobalDefines(h,x&&x.overrideFog,x&&x.overrideRtt).concat(A),z=bR.cacheKey(PE[h],h,F,D);return this.cache[z]||(this.cache[z]=new bR(this.context,h,PE[h],D,qC[h],F)),this.cache[z]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const h=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(h.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new i.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(h,x){if(this.style.enable3dLights()){const A=this.style.directionalLight,D=this.style.ambientLight;if(A&&D){const F=((z,H,Y)=>{const ae=z.properties.get("direction"),oe=z.properties.get("color-use-theme")==="none",ge=z.properties.get("color").toNonPremultipliedRenderColor(oe?null:Y.getLut(z.scope)).toArray01(),fe=z.properties.get("intensity"),xe=H.properties.get("color-use-theme")==="none",Pe=H.properties.get("color").toNonPremultipliedRenderColor(xe?null:Y.getLut(H.scope)).toArray01(),Ce=H.properties.get("intensity"),Ve=[ae.x,ae.y,ae.z],Be=i.dN(Pe,Ce),et=i.dN(ge,fe);return{u_lighting_ambient_color:Be,u_lighting_directional_dir:Ve,u_lighting_directional_color:et,u_ground_radiance:Q1(Ve,et,Be)}})(A,D,this.style);x.setLightsUniformValues(h,F)}}}uploadCommonUniforms(h,x,A,D,F){if(this.uploadCommonLightUniforms(h,x),this.terrain&&this.terrain.renderingToTexture)return;const z=this.style.fog;if(z){const H=z.getOpacity(this.transform.pitch),Y=((ae,oe,ge,fe,xe,Pe,Ce,Ve,Be,et,ut,st)=>{const Mt=ae.transform,yt=oe.properties.get("color-use-theme")==="none",kt=oe.properties.get("color").toNonPremultipliedRenderColor(yt?null:ae.style.getLut(oe.scope)).toArray01();kt[3]=fe;const gt=ae.frameCounter/1e3%1,[mt,Pt]=oe.properties.get("vertical-range");return{u_fog_matrix:ge?Mt.calculateFogTileMatrix(ge):st||ae.identityMat,u_fog_range:oe.getFovAdjustedRange(Mt._fov),u_fog_color:kt,u_fog_horizon_blend:oe.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(mt,Pt),Pt],u_fog_temporal_offset:gt,u_frustum_tl:xe,u_frustum_tr:Pe,u_frustum_br:Ce,u_frustum_bl:Ve,u_globe_pos:Be,u_globe_radius:et,u_viewport:ut,u_globe_transition:i.aj(Mt.zoom),u_is_globe:+(Mt.projection.name==="globe")}})(this,z,A,H,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*i.o.devicePixelRatio,this.transform.height*i.o.devicePixelRatio],D);x.setFogUniformValues(h,Y)}F&&x.setCutoffUniformValues(h,F.uniformValues)}setTileLoadedFlag(h){this.tileLoaded=h}saveCanvasCopy(){const h=this.canvasCopy();h&&(this.frameCopies.push(h),this.tileLoaded=!1)}canvasCopy(){const h=this.context.gl,x=h.createTexture();return h.bindTexture(h.TEXTURE_2D,x),h.copyTexImage2D(h.TEXTURE_2D,0,h.RGBA,0,0,h.drawingBufferWidth,h.drawingBufferHeight,0),x}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const h=this.style&&this.style.fog;return!!h&&h.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const h=this._backgroundTiles,x=this._backgroundTiles={},A=this.transform.coveringTiles({tileSize:512});for(const D of A)x[D.key]=h[D.key]||new $m(D,512,this.transform.tileZoom,this,void 0,this.worldview);return x}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(h,x){return!(!h.is3D(!(!this.terrain||!this.terrain.enabled))||h.type!=="clip"&&h.type!=="building"&&(h.minzoom&&h.minzoom>this.transform.zoom||(this.style._clipLayerPresent||h.sourceLayer!=="building"&&h.sourceLayer!=="procedural_buildings")&&(!x||x.type!=="batched-model")))}isTileAffectedByFog(h){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let x=this._cachedTileFogOpacities[h.key];return x||(this._cachedTileFogOpacities[h.key]=x=this.style.fog.getOpacityForTile(h)),x[0]>=gs||x[1]>=gs}setupDepthForOcclusion(h,x,A){const D=this.context,F=D.gl,z=!!A;var H;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/((H=this.depthRangeFor3D)[1]-H[0]),-1-2*H[0]/(H[1]-H[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||x.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 i3(M,h){let x=!1,A=null;const D=()=>{A=null,x&&(M(),A=setTimeout(D,h),x=!1)};return()=>(x=!0,A||D(),A)}class lP{constructor(h){this._hashName=h&&encodeURIComponent(h),i.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=i3(this._updateHashUnthrottled.bind(this),300)}addTo(h){return this._map=h,window.addEventListener("hashchange",this._onHashChange,!1),h.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const h=this._map;if(!h)return"";const x=Il(h);if(this._hashName){const A=this._hashName;let D=!1;const F=location.hash.slice(1).split("&").map(z=>{const H=z.split("=")[0];return H===A?(D=!0,`${H}=${x}`):z}).filter(z=>z);return D||F.push(`${A}=${x}`),`#${F.join("&")}`}return`#${x}`}_getCurrentHash(){const h=location.hash.replace("#","");if(this._hashName){let x;return h.split("&").map(A=>A.split("=")).forEach(A=>{A[0]===this._hashName&&(x=A)}),(x&&x[1]||"").split("/")}return h.split("/")}_onHashChange(){const h=this._map;if(!h)return!1;const x=this._getCurrentHash();if(x.length>=3&&!x.some(A=>isNaN(Number(A)))){const A=h.dragRotate.isEnabled()&&h.touchZoomRotate.isEnabled()?+(x[3]||0):h.getBearing();return h.jumpTo({center:[+x[2],+x[1]],zoom:+x[0],bearing:A,pitch:+(x[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function Il(M,h){const x=M.getCenter(),A=Math.round(100*M.getZoom())/100,D=Math.ceil((A*Math.LN2+Math.log(512/360/.5))/Math.LN10),F=Math.pow(10,D),z=Math.round(x.lng*F)/F,H=Math.round(x.lat*F)/F,Y=M.getBearing(),ae=M.getPitch();let oe=h?`/${z}/${H}/${A}`:`${A}/${H}/${z}`;return(Y||ae)&&(oe+="/"+Math.round(10*Y)/10),ae&&(oe+=`/${Math.round(ae)}`),oe}const a_={linearity:.3,easing:i.eT(0,0,.3,1)},cP=Object.assign({deceleration:2500,maxSpeed:1400},a_),dP=Object.assign({deceleration:20,maxSpeed:1400},a_),iv=Object.assign({deceleration:1e3,maxSpeed:360},a_),uP=Object.assign({deceleration:1e3,maxSpeed:90},a_);class hP{constructor(h){this._map=h,this.clear()}clear(){this._inertiaBuffer=[]}record(h){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.o.now(),settings:h})}_drainInertiaBuffer(){const h=this._inertiaBuffer,x=i.o.now();for(;h.length>0&&x-h[0].time>160;)h.shift()}_onMoveEnd(h){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const x={zoom:0,bearing:0,pitch:0,pan:new i.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:F}of this._inertiaBuffer)x.zoom+=F.zoomDelta||0,x.bearing+=F.bearingDelta||0,x.pitch+=F.pitchDelta||0,F.panDelta&&x.pan._add(F.panDelta),F.around&&(x.around=F.around),F.pinchAround&&(x.pinchAround=F.pinchAround);const A=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,D={};if(x.pan.mag()){const F=Rf(x.pan.mag(),A,Object.assign({},cP,h||{}));D.offset=x.pan.mult(F.amount/x.pan.mag()),D.center=this._map.transform.center,i_(D,F)}if(x.zoom){const F=Rf(x.zoom,A,dP);D.zoom=this._map.transform.zoom+F.amount,i_(D,F)}if(x.bearing){const F=Rf(x.bearing,A,iv);D.bearing=this._map.transform.bearing+i.aA(F.amount,-179,179),i_(D,F)}if(x.pitch){const F=Rf(x.pitch,A,uP);D.pitch=this._map.transform.pitch+F.amount,i_(D,F)}if(D.zoom||D.bearing){const F=x.pinchAround===void 0?x.around:x.pinchAround;D.around=F?this._map.unproject(F):this._map.getCenter()}return this.clear(),D.noMoveStart=!0,D}}function i_(M,h){(!M.duration||M.durationx.unproject(Y)),H=F.reduce((Y,ae,oe,ge)=>Y.add(ae.div(ge.length)),new i.P(0,0));super(h,{points:F,point:H,lngLats:z,lngLat:x.unproject(H),originalEvent:A}),this._defaultPrevented=!1}}class mP extends i.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(h,x){super("wheel",{originalEvent:x}),this._defaultPrevented=!1}}class o3{constructor(h,x){this._map=h,this._clickTolerance=x.clickTolerance}reset(){this._mousedownPos=void 0}wheel(h){return this._firePreventable(new mP(this._map,h))}mousedown(h,x){return this._mousedownPos=x,this._firePreventable(new nh(h.type,this._map,h))}mouseup(h){this._map.fire(new nh(h.type,this._map,h))}preclick(h){const x=new MouseEvent("preclick",h);this._map.fire(new nh(x.type,this._map,x))}click(h,x){this._mousedownPos&&this._mousedownPos.dist(x)>=this._clickTolerance||(this.preclick(h),this._map.fire(new nh(h.type,this._map,h)))}dblclick(h){return this._firePreventable(new nh(h.type,this._map,h))}mouseover(h){this._map.fire(new nh(h.type,this._map,h))}mouseout(h){this._map.fire(new nh(h.type,this._map,h))}touchstart(h){return this._firePreventable(new Cy(h.type,this._map,h))}touchmove(h){this._map.fire(new Cy(h.type,this._map,h))}touchend(h){this._map.fire(new Cy(h.type,this._map,h))}touchcancel(h){this._map.fire(new Cy(h.type,this._map,h))}_firePreventable(h){if(this._map.fire(h),h.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class pP{constructor(h){this._map=h}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(h){this._map.fire(new nh(h.type,this._map,h))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new nh("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(h){this._delayContextMenu?this._contextMenuEvent=h:this._map.fire(new nh(h.type,this._map,h)),this._map.listens("contextmenu")&&h.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class l3{constructor(h,x){this._map=h,this._el=h.getCanvasContainer(),this._container=h.getContainer(),this._clickTolerance=x.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(h,x){this.isEnabled()&&h.shiftKey&&h.button===0&&(I(),this._startPos=this._lastPos=x,this._active=!0)}mousemoveWindow(h,x){if(!this._active)return;const A=x,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,${Y}px)`,this._box.style.width=H-z+"px",this._box.style.height=ae-Y+"px")})}mouseupWindow(h,x){if(!this._active)return;const A=this._startPos,D=x;if(A&&h.button===0){if(this.reset(),$(),A.x!==D.x||A.y!==D.y)return this._map.fire(new i.z("boxzoomend",{originalEvent:h})),{cameraAnimation:F=>F.fitScreenCoordinates(A,D,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",h)}}keydown(h){this._active&&h.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",h))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),L(),delete this._startPos,delete this._lastPos}_fireEvent(h,x){return this._map.fire(new i.z(h,{originalEvent:x}))}}function c3(M,h){const x={};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)}(x),this.touches=c3(A,x)))}touchmove(h,x,A){if(this.aborted||!this.centroid)return;const D=c3(A,x);for(const F in this.touches){const z=D[F];(!z||z.dist(this.touches[F])>30)&&(this.aborted=!0)}}touchend(h,x,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 d3{constructor(h){this.singleTap=new ZR(h),this.numTaps=h.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(h,x,A){this.singleTap.touchstart(h,x,A)}touchmove(h,x,A){this.singleTap.touchmove(h,x,A)}touchend(h,x,A){const D=this.singleTap.touchend(h,x,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 YR{constructor(){this._zoomIn=new d3({numTouches:1,numTaps:2}),this._zoomOut=new d3({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(h,x,A){this._zoomIn.touchstart(h,x,A),this._zoomOut.touchstart(h,x,A)}touchmove(h,x,A){this._zoomIn.touchmove(h,x,A),this._zoomOut.touchmove(h,x,A)}touchend(h,x,A){const D=this._zoomIn.touchend(h,x,A),F=this._zoomOut.touchend(h,x,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 XR={0:1,2:2},fP={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class u3{constructor(h){this.reset(),this._clickTolerance=h.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(h,x){return!1}_move(h,x){return{}}mousedown(h,x){if(this._lastPoint)return;const A=V(h);this._correctButton(h,A)&&(this._lastPoint=x,this._eventButton=A)}mousemoveWindow(h,x){const A=this._lastPoint;if(A){if(h.preventDefault(),this._eventButton!=null&&function(D,F){const z=XR[F];return D.buttons===void 0||(D.buttons&z)!==z}(h,this._eventButton))this.reset();else if(this._moved||!(x.dist(A)0&&(this._active=!0);const D=c3(A,x),F=new i.P(0,0),z=new i.P(0,0);let H=0;for(const ae in D){const oe=D[ae],ge=this._touches[ae];ge&&(F._add(oe),z._add(oe.sub(ge)),H++,D[ae]=oe)}if(this._touches=D,H{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class h3{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(h){}_move(h,x,A){return{}}touchstart(h,x,A){this._firstTwoTouches||A.length<2||(this._firstTwoTouches=[A[0].identifier,A[1].identifier],this._start([x[0],x[1]]))}touchmove(h,x,A){const D=this._firstTwoTouches;if(!D)return;h.preventDefault();const[F,z]=D,H=cw(A,x,F),Y=cw(A,x,z);if(!H||!Y)return;const ae=this._aroundCenter?null:H.add(Y).div(2);return this._move([H,Y],ae,h)}touchend(h,x,A){if(!this._firstTwoTouches)return;const[D,F]=this._firstTwoTouches,z=cw(A,x,D),H=cw(A,x,F);z&&H||(this._active&&$(),this.reset())}touchcancel(){this.reset()}enable(h){this._enabled=!0,this._aroundCenter=!!h&&h.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function cw(M,h,x){for(let A=0;AMath.abs(M.x)}class Ome extends h3{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,m3(h[0].sub(h[1]))&&(this._valid=!1)}_move(h,x,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,x,A){if(this._valid!==void 0)return this._valid;const D=h.mag()>=2,F=x.mag()>=2;if(!D&&!F)return;if(!D||!F)return this._firstMove==null&&(this._firstMove=A),A-this._firstMove<100&&void 0;const z=h.y>0==x.y>0;return m3(h)&&m3(x)&&z}}const Rme={panStep:100,bearingStep:15,pitchStep:10};class Fme{constructor(){const h=Rme;this._panStep=h.panStep,this._bearingStep=h.bearingStep,this._pitchStep=h.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(h){if(h.altKey||h.ctrlKey||h.metaKey)return;let x=0,A=0,D=0,F=0,z=0;switch(h.keyCode){case 61:case 107:case 171:case 187:x=1;break;case 189:case 109:case 173:x=-1;break;case 37:h.shiftKey?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:H=>{const Y=H.getZoom();H.easeTo({duration:300,easeId:"keyboardHandler",easing:dw,zoom:x?Math.round(Y)+x*(h.shiftKey?2:1):Y,bearing:H.getBearing()+A*this._bearingStep,pitch:H.getPitch()+D*this._pitchStep,offset:[-F*this._panStep,-z*this._panStep],center:H.getCenter()},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function dw(M){return M*(2-M)}const yP=4.000244140625,vP=1/450;class p3{constructor(h,x){this._map=h,this._el=h.getCanvasContainer(),this._handler=x,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=vP,i.aY(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(h){this._defaultZoomRate=h}setWheelZoomRate(h){this._wheelZoomRate=h}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(h){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!h&&h.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(h){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(h.ctrlKey||h.metaKey||this.isZooming()||i.eU()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let x=h.deltaMode===WheelEvent.DOM_DELTA_LINE?40*h.deltaY:h.deltaY;const A=i.o.now(),D=A-(this._lastWheelEventTime||0);this._lastWheelEventTime=A,x!==0&&x%yP==0?this._type="wheel":x!==0&&Math.abs(x)<4?this._type="trackpad":D>400?(this._type=null,this._lastValue=x,this._timeout=window.setTimeout(this._onTimeout,40,h)):this._type||(this._type=Math.abs(D*x)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,x+=this._lastValue)),h.shiftKey&&x&&(x/=4),this._type&&(this._lastWheelEvent=h,this._delta-=x,this._active||this._start(h)),h.preventDefault()}_onTimeout(h){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(h)}_start(h){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const x=q(this._el,h);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:x,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const h=this._map.transform;this._type==="wheel"&&h.projection.wrap&&(h._center.lng>=180||h._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const x=()=>h._terrainEnabled()&&this._aroundCoord?h.computeZoomRelativeTo(this._aroundCoord):h.zoom;if(this._delta!==0){const ae=this._type==="wheel"&&Math.abs(this._delta)>yP?this._wheelZoomRate:this._defaultZoomRate;let oe=2/(1+Math.exp(-Math.abs(this._delta*ae)));this._delta<0&&oe!==0&&(oe=1/oe);const ge=x(),fe=Math.pow(2,ge),xe=typeof this._targetZoom=="number"?h.zoomScale(this._targetZoom):fe;this._targetZoom=Math.min(h.maxZoom,Math.max(h.minZoom,h.scaleZoom(xe*oe))),this._type==="wheel"&&(this._startZoom=ge,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const A=typeof this._targetZoom=="number"?this._targetZoom:x(),D=this._startZoom,F=this._easing;let z,H=!1;if(this._type==="wheel"&&D&&F){const ae=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),oe=F(ae);z=i.ak(D,A,oe),ae<1?this._frameId||(this._frameId=!0):H=!0}else z=A,H=!0;this._active=!0,H&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let Y=z-x();return Y*this._lastDelta<0&&(Y=0),{noInertia:!0,needsRenderFrame:!H,zoomDelta:Y,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(h){let x=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,H=Math.sqrt(.0729-z*z);x=i.eT(z,H,.25,1)}return this._prevEase={start:i.o.now(),duration:h,easing:x},x}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=w("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class tx{constructor(h,x){this._clickZoom=h,this._tapZoom=x}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class f3{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(h,x){return h.preventDefault(),{cameraAnimation:A=>{A.easeTo({duration:300,zoom:A.getZoom()+(h.shiftKey?-1:1),around:A.unproject(x)},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ll{constructor(){this._tap=new d3({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(h,x,A){this._swipePoint||(this._tapTime&&h.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?A.length>0&&(this._swipePoint=x[0],this._swipeTouch=A[0].identifier):this._tap.touchstart(h,x,A))}touchmove(h,x,A){if(this._tapTime){if(this._swipePoint){if(A[0].identifier!==this._swipeTouch)return;const D=x[0],F=D.y-this._swipePoint.y;return this._swipePoint=D,h.preventDefault(),this._active=!0,{zoomDelta:F/128}}}else this._tap.touchmove(h,x,A)}touchend(h,x,A){this._tapTime?this._swipePoint&&A.length===0&&this.reset():this._tap.touchend(h,x,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 Ff{constructor(h,x,A){this._el=h,this._mousePan=x,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 uw{constructor(h,x,A){this._pitchWithRotate=h.pitchWithRotate,this._mouseRotate=x,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 g3{constructor(h,x,A,D){this._el=h,this._touchZoom=x,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 hw=M=>M.zoom||M.drag||M.pitch||M.rotate;class zme extends i.z{}class mw{constructor(){this.constants=[1,1,.01],this.radius=0}setup(h,x){const A=i.av([],x,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 x=i.c5([],h,this.radius);if(x[2]>0){const A=i.c5([],[0,0,1],i.bJ(x,[0,0,1])),D=i.c5([],i.aw([],[x[0],x[1],0]),this.radius),F=i.d8([],x,i.c5([],i.av([],i.d8([],D,A),x),2));x[0]=F[0],x[1]=F[1]}return x}}function x3(M){return M.panDelta&&M.panDelta.mag()||M.zoomDelta||M.bearingDelta||M.pitchDelta}class Bme{constructor(h,x){this._map=h,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new hP(h),this._bearingSnap=x.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new mw,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(x),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 H=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(F,H,z)}}destroy(){for(const[h,x,A]of this._listeners){const D=h===document?this.handleWindowEvent:this.handleEvent;h.removeEventListener(x,D,A)}}_addDefaultHandlers(h){const x=this._map,A=x.getCanvasContainer();this._add("mapEvent",new o3(x,h));const D=x.boxZoom=new l3(x,h);this._add("boxZoom",D);const F=new YR,z=new f3;x.doubleClickZoom=new tx(z,F),this._add("tapZoom",F),this._add("clickZoom",z);const H=new Ll;this._add("tapDragZoom",H);const Y=x.touchPitch=new Ome(x);this._add("touchPitch",Y);const ae=new gP(h),oe=new xP(h);x.dragRotate=new uw(h,ae,oe),this._add("mouseRotate",ae,["mousePitch"]),this._add("mousePitch",oe,["mouseRotate"]);const ge=new QR(h),fe=new JR(x,h);x.dragPan=new Ff(A,ge,fe),this._add("mousePan",ge),this._add("touchPan",fe,["touchZoom","touchRotate"]);const xe=new xo,Pe=new Dme;x.touchZoomRotate=new g3(A,Pe,xe,H),this._add("touchRotate",xe,["touchPan","touchZoom"]),this._add("touchZoom",Pe,["touchPan","touchRotate"]),this._add("blockableMapEvent",new pP(x));const Ce=x.scrollZoom=new p3(x,this);this._add("scrollZoom",Ce,["mousePan"]);const Ve=x.keyboard=new Fme;this._add("keyboard",Ve);for(const Be of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])h.interactive&&h[Be]&&x[Be].enable(h[Be])}_add(h,x,A){this._handlers.push({handlerName:h,handler:x,allowed:A}),this._handlersById[h]=x}stop(h){if(!this._updatingCamera){for(const{handler:x}of this._handlers)x.reset();this._inertia.clear(),this._fireEvents({},{},h),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:h}of this._handlers)if(h.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!hw(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(h,x,A){for(const D in h)if(D!==A&&(!x||x.indexOf(D)<0))return!0;return!1}handleWindowEvent(h){this.handleEvent(h,`${h.type}Window`)}_getMapTouches(h){const x=[];for(const A of h)this._el.contains(A.target)&&x.push(A);return x}handleEvent(h,x){this._updatingCamera=!0;const A=h.type==="renderFrame",D=A?void 0:h,F={needsRenderFrame:!1},z={},H={},Y=h.touches?this._getMapTouches(h.touches):void 0,ae=Y?U(this._el,Y):A?void 0:q(this._el,h);for(const{handlerName:fe,handler:xe,allowed:Pe}of this._handlers){if(!xe.isEnabled())continue;let Ce;this._blockedByActive(H,Pe,fe)?xe.reset():xe[x||h.type]&&(Ce=xe[x||h.type](h,ae,Y),this.mergeHandlerResult(F,z,Ce,fe,D),Ce&&Ce.needsRenderFrame&&this._triggerRenderFrame()),(Ce||xe.isActive())&&(H[fe]=xe)}const oe={};for(const fe in this._previousActiveHandlers)H[fe]||(oe[fe]=D);this._previousActiveHandlers=H,(Object.keys(oe).length||x3(F))&&(this._changes.push([F,z,oe]),this._triggerRenderFrame()),(Object.keys(H).length||x3(F))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:ge}=F;ge&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],ge(this._map))}mergeHandlerResult(h,x,A,D,F){if(!A)return;Object.assign(h,A);const z={handlerName:D,originalEvent:A.originalEvent||F};A.zoomDelta!==void 0&&(x.zoom=z),A.panDelta!==void 0&&(x.drag=z),A.pitchDelta!==void 0&&(x.pitch=z),A.bearingDelta!==void 0&&(x.rotate=z)}_applyChanges(){const h={},x={},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(x,F),Object.assign(A,z);this._updateMapTransform(h,x,A),this._changes=[]}_updateMapTransform(h,x,A){const D=this._map,F=D.transform,z=et=>[et.x,et.y,et.z];if((et=>{const ut=this._eventsInProgress.drag;return ut&&!this._handlersById[ut.handlerName].isActive()})()&&!x3(h)){const et=F.zoom;F.cameraElevationReference="sea",this._originalZoom!=null&&F._orthographicProjectionAtLowPitch&&F.projection.name!=="globe"&&F.pitch===0?(F.cameraElevationReference="ground",F.zoom=this._originalZoom):(F.recenterOnTerrain(),F.cameraElevationReference="ground"),et!==F.zoom&&this._map._update(!0)}if(F._isCameraConstrained&&D._stop(!0),!x3(h))return void this._fireEvents(x,A,!0);let{panDelta:H,zoomDelta:Y,bearingDelta:ae,pitchDelta:oe,around:ge,aroundCoord:fe,pinchAround:xe}=h;F._isCameraConstrained&&(Y>0&&(Y=0),F._isCameraConstrained=!1),xe!==void 0&&(ge=xe),(Y||(et=>x[et]&&!this._eventsInProgress[et])("drag"))&&ge&&(this._dragOrigin=z(F.pointCoordinate3D(ge)),this._originalZoom=F.zoom,this._trackingEllipsoid.setup(F._camera.position,this._dragOrigin)),F.cameraElevationReference="sea",D._stop(!0),ge=ge||D.transform.centerPoint,ae&&(F.bearing+=ae),oe&&(F.pitch+=oe),F._updateCameraState();const Pe=[0,0,0];if(H)if(F.projection.name==="mercator"){const et=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(ge).dir),ut=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(ge.sub(H)).dir);Pe[0]=ut[0]-et[0],Pe[1]=ut[1]-et[1]}else{const et=F.pointCoordinate(ge);if(F.projection.name==="globe"){H=H.rotate(-F.angle);const ut=F._pixelsPerMercatorPixel/F.worldSize;Pe[0]=-H.x*i.eW(i.a$(et.y))*ut,Pe[1]=-H.y*i.eW(F.center.lat)*ut}else{const ut=F.pointCoordinate(ge.sub(H));et&&ut&&(Pe[0]=ut.x-et.x,Pe[1]=ut.y-et.y)}}const Ce=F.zoom,Ve=[0,0,0];if(Y){const et=z(fe||F.pointCoordinate3D(ge)),ut={dir:i.aw([],i.av([],et,F._camera.position))};if(ut.dir[2]<0){const st=F.zoomDeltaToMovement(et,Y);i.c5(Ve,ut.dir,st)}}const Be=i.d8(Pe,Pe,Ve);F._translateCameraConstrained(Be),Y&&Math.abs(F.zoom-Ce)>1e-4&&F.recenterOnTerrain(),F.cameraElevationReference="ground",this._map._update(),h.noInertia||this._inertia.record(h),this._fireEvents(x,A,!0)}_fireEvents(h,x,A){const D=hw(this._eventsInProgress),F=hw(h),z={};for(const oe in h){const{originalEvent:ge}=h[oe];this._eventsInProgress[oe]||(z[`${oe}start`]=ge),this._eventsInProgress[oe]=h[oe]}!D&&F&&this._fireEvent("movestart",F.originalEvent);for(const oe in z)this._fireEvent(oe,z[oe]);F&&this._fireEvent("move",F.originalEvent);for(const oe in h){const{originalEvent:ge}=h[oe];this._fireEvent(oe,ge)}const H={};let Y;for(const oe in this._eventsInProgress){const{handlerName:ge,originalEvent:fe}=this._eventsInProgress[oe];this._handlersById[ge].isActive()||(delete this._eventsInProgress[oe],Y=x[ge]||fe,H[`${oe}end`]=Y)}for(const oe in H)this._fireEvent(oe,H[oe]);const ae=hw(this._eventsInProgress);if(A&&(D||F)&&!ae){this._updatingCamera=!0;const oe=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),ge=fe=>fe!==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 y3="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class _P extends i.E{constructor(h,x){super(),this._moving=!1,this._zooming=!1,this.transform=h,this._bearingSnap=x.bearingSnap,this._respectPrefersReducedMotion=x.respectPrefersReducedMotion!==!1,i.aY(["_renderFrameCallback"],this)}getCenter(){return new i.aT(this.transform.center.lng,this.transform.center.lat)}setCenter(h,x){return this.jumpTo({center:h},x)}panBy(h,x,A){return h=i.P.convert(h).mult(-1),this.panTo(this.transform.center,Object.assign({offset:h},x),A)}panTo(h,x,A){return this.easeTo(Object.assign({center:h},x),A)}getZoom(){return this.transform.zoom}setZoom(h,x){return this.jumpTo({zoom:h},x),this}zoomTo(h,x,A){return this.easeTo(Object.assign({zoom:h},x),A)}zoomIn(h,x){return this.zoomTo(this.getZoom()+1,h,x),this}zoomOut(h,x){return this.zoomTo(this.getZoom()-1,h,x),this}getBearing(){return this.transform.bearing}setBearing(h,x){return this.jumpTo({bearing:h},x),this}getPadding(){return this.transform.padding}setPadding(h,x){return this.jumpTo({padding:h},x),this}rotateTo(h,x,A){return this.easeTo(Object.assign({bearing:h},x),A)}resetNorth(h,x){return this.rotateTo(0,Object.assign({duration:1e3},h),x),this}resetNorthPitch(h,x){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},h),x),this}snapToNorth(h,x){return Math.abs(this.getBearing())h.aspect?A/(2*Math.tan(.5*h.fovX)*h.aspect):D/(2*Math.tan(.5*h.fovY)*h.aspect)}_cameraForBoundsOnGlobe(h,x,A,D,F,z){const H=h.clone(),Y=this._extendCameraOptions(z);H.bearing=D,H.pitch=F;const ae=i.aT.convert(x),oe=i.aT.convert(A),ge=.5*(ae.lat+oe.lat),fe=.5*(ae.lng+oe.lng),xe=i.eZ(ge,fe),Pe=i.aw([],xe),Ce=i.aw([],i.bI([],Pe,[0,1,0])),Ve=i.bI([],Ce,Pe),Be=[Ce[0],Ce[1],Ce[2],0,Ve[0],Ve[1],Ve[2],0,Pe[0],Pe[1],Pe[2],0,0,0,0,1],et=[xe,i.eZ(ae.lat,ae.lng),i.eZ(oe.lat,ae.lng),i.eZ(oe.lat,oe.lng),i.eZ(ae.lat,oe.lng),i.eZ(ge,ae.lng),i.eZ(ge,oe.lng),i.eZ(ae.lat,fe),i.eZ(oe.lat,fe)];let ut=i.d9.fromPoints(et.map(Jt=>[i.bJ(Ce,Jt),i.bJ(Ve,Jt),i.bJ(Pe,Jt)]));const st=i.af([],ut.center,Be);i.e_(st)===0&&i.e$(st,0,0,1),i.aw(st,st),i.c5(st,st,i.aD),H.center=i.f0(st);const Mt=H.getWorldToCameraMatrix(),yt=i.bl(new Float64Array(16),Mt);ut=i.d9.applyTransform(ut,i.aB([],Mt,Be));const kt=this._extendAABB(ut,H,Y,D);if(!kt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");ut=kt,i.af(st,st,Mt);const gt=.5*(ut.max[2]-ut.min[2]),mt=this._minimumAABBFrustumDistance(H,ut),Pt=i.c5([],[0,0,1],gt),Ht=i.d8(Pt,st,Pt),Ut=mt+(H.pitch===0?0:i.bG(st,Ht)),ts=H.globeCenterInViewSpace,ns=i.av([],st,[ts[0],ts[1],ts[2]]);i.aw(ns,ns),i.c5(ns,ns,Ut);const fs=i.d8([],st,ns);i.af(fs,fs,yt);const qs=i.eM/i.aD,Yt=i.ag(fs),Ft=i.cf(Math.max(Yt*qs-i.eM,Number.EPSILON),0),ls=Math.min(H.zoomFromMercatorZAdjusted(Ft),Y.maxZoom);return ls>.5*(i.c_+i.cL)?(H.setProjection({name:"mercator"}),H.zoom=ls,this._cameraForBounds(H,x,A,D,F,z)):{center:H.center,zoom:ls,bearing:D,pitch:F}}_extendAABB(h,x,A,D){const F=.5*((A.padding.left||0)+(A.padding.right||0)),z=.5*((A.padding.top||0)+(A.padding.bottom||0)),H=z,Y=F,ae=F,oe=z,ge=x.width-(Y+ae),fe=x.height-(H+oe),xe=i.av([],h.max,h.min),Pe=Math.min(ge/xe[0],fe/xe[1]),Ce=Math.min(x.scaleZoom(x.scale*Pe),A.maxZoom);if(isNaN(Ce))return null;const Ve=x.scale/x.zoomScale(Ce),Be=new i.d9([h.min[0]-Y*Ve,h.min[1]-oe*Ve,h.min[2]],[h.max[0]+ae*Ve,h.max[1]+H*Ve,h.max[2]]),et=(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 Be.center[0]-=et.x*Ve,Be.center[1]+=et.y*Ve,Be}queryTerrainElevation(h,x){const A=this.transform.elevation;return A?(x=Object.assign({},{exaggerated:!0},x),A.getAtPoint(i.ae.fromLngLat(h),null,x.exaggerated)):null}_cameraForBounds(h,x,A,D,F,z){if(h.projection.name==="globe")return this._cameraForBoundsOnGlobe(h,x,A,D,F,z);const H=h.clone(),Y=this._extendCameraOptions(z);H.bearing=D,H.pitch=F;const ae=i.aT.convert(x),oe=i.aT.convert(A),ge=new i.aT(ae.lng,oe.lat),fe=new i.aT(oe.lng,ae.lat),xe=H.project(ae),Pe=H.project(oe),Ce=this.queryTerrainElevation(ae),Ve=this.queryTerrainElevation(oe),Be=this.queryTerrainElevation(ge),et=this.queryTerrainElevation(fe),ut=[[xe.x,xe.y,Math.min(Ce||0,Ve||0,Be||0,et||0)],[Pe.x,Pe.y,Math.max(Ce||0,Ve||0,Be||0,et||0)]];let st=i.d9.fromPoints(ut);const Mt=H.getWorldToCameraMatrix(),yt=i.bl(new Float64Array(16),Mt);st=i.d9.applyTransform(st,Mt);const kt=this._extendAABB(st,H,Y,D);if(!kt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");st=kt;const gt=.5*i.av([],st.max,st.min)[2],mt=this._minimumAABBFrustumDistance(H,st),Pt=[0,0,1,0];i.aC(Pt,Pt,Mt),i.f1(Pt,Pt);const Ht=i.c5([],Pt,mt+gt),Ut=i.d8([],st.center,Ht);i.af(st.center,st.center,yt),i.af(Ut,Ut,yt);const ts=H.unproject(new i.P(st.center[0],st.center[1])),ns=i.f2(H.projection,ts),fs=Math.pow(2,ns),qs=Math.min(H._zoomFromMercatorZ(Ut[2]*H.pixelsPerMeter*fs/H.worldSize),Y.maxZoom);return H.mercatorFromTransition&&qs<.5*(i.c_+i.cL)?(H.setProjection({name:"globe"}),H.zoom=qs,this._cameraForBounds(H,x,A,D,F,z)):{center:ts,zoom:qs,bearing:D,pitch:F}}fitBounds(h,x,A){const D=this.cameraForBounds(h,x);return this._fitInternal(D,x,A)}fitScreenCoordinates(h,x,A,D,F){const z=i.P.convert(h),H=i.P.convert(x),Y=new i.P(Math.min(z.x,H.x),Math.min(z.y,H.y)),ae=new i.P(Math.max(z.x,H.x),Math.max(z.y,H.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(z,H))return this;const oe=this.transform.pointLocation3D(Y),ge=this.transform.pointLocation3D(ae),fe=this.transform.pointLocation3D(new i.P(Y.x,ae.y)),xe=this.transform.pointLocation3D(new i.P(ae.x,Y.y)),Pe=[Math.min(oe.lng,ge.lng,fe.lng,xe.lng),Math.min(oe.lat,ge.lat,fe.lat,xe.lat)],Ce=[Math.max(oe.lng,ge.lng,fe.lng,xe.lng),Math.max(oe.lat,ge.lat,fe.lat,xe.lat)],Ve=D&&D.pitch?D.pitch:this.getPitch(),Be=this._cameraForBounds(this.transform,Pe,Ce,A,Ve,D);return this._fitInternal(Be,D,F)}_fitInternal(h,x,A){return h?(x=Object.assign(h,x)).linear?this.easeTo(x,A):this.flyTo(x,A):this}jumpTo(h,x){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 H=typeof h.padding=="number"?this._extendPadding(h.padding):h.padding;if(h.padding!=null&&!A.isPaddingEqual(H))if(h.retainPadding===!1){const Y=A.clone();Y.padding=H,A.setLocationAtPoint(A.center,Y.centerPoint)}else A.padding=H;return h.preloadOnly?(this._preloadTiles(A),this):(this.fire(new i.z("movestart",x)).fire(new i.z("move",x)),D&&this.fire(new i.z("zoomstart",x)).fire(new i.z("zoom",x)).fire(new i.z("zoomend",x)),F&&this.fire(new i.z("rotatestart",x)).fire(new i.z("rotate",x)).fire(new i.z("rotateend",x)),z&&this.fire(new i.z("pitchstart",x)).fire(new i.z("pitch",x)).fire(new i.z("pitchend",x)),this.fire(new i.z("moveend",x)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||i.w(y3),this.transform.getFreeCameraOptions()}setFreeCameraOptions(h,x){const A=this.transform;if(!A.projection.supportsFreeCamera)return i.w(y3),this;this.stop();const D=A.zoom,F=A.pitch,z=A.bearing;A.setFreeCameraOptions(h);const H=D!==A.zoom,Y=F!==A.pitch,ae=z!==A.bearing;return this.fire(new i.z("movestart",x)).fire(new i.z("move",x)),H&&this.fire(new i.z("zoomstart",x)).fire(new i.z("zoom",x)).fire(new i.z("zoomend",x)),ae&&this.fire(new i.z("rotatestart",x)).fire(new i.z("rotate",x)).fire(new i.z("rotateend",x)),Y&&this.fire(new i.z("pitchstart",x)).fire(new i.z("pitch",x)).fire(new i.z("pitchend",x)),this.fire(new i.z("moveend",x)),this}easeTo(h,x){this._stop(!1,h.easeId),((h=Object.assign({offset:[0,0],duration:500,easing:i.eV},h)).animate===!1||this._prefersReducedMotion(h))&&(h.duration=0);const A=this.transform,D=this.getZoom(),F=this.getBearing(),z=this.getPitch(),H=this.getPadding(),Y="zoom"in h?+h.zoom:D,ae="bearing"in h?this._normalizeBearing(h.bearing,F):F,oe="pitch"in h?+h.pitch:z,ge=this._extendPadding(h.padding),fe=i.P.convert(h.offset);let xe,Pe,Ce;if(A.projection.name==="globe"){const Pt=i.ae.fromLngLat(A.center),Ht=fe.rotate(-A.angle);Pt.x+=Ht.x/A.worldSize,Pt.y+=Ht.y/A.worldSize;const Ut=Pt.toLngLat(),ts=i.aT.convert(h.center||Ut);this._normalizeCenter(ts),xe=A.centerPoint.add(Ht),Pe=new i.P(Pt.x,Pt.y).mult(A.worldSize),Ce=new i.P(i.aF(ts.lng),i.aJ(ts.lat)).mult(A.worldSize).sub(Pe)}else{xe=A.centerPoint.add(fe);const Pt=A.pointLocation(xe),Ht=i.aT.convert(h.center||Pt);this._normalizeCenter(Ht),Pe=A.project(Pt),Ce=A.project(Ht).sub(Pe)}const Ve=A.zoomScale(Y-D);let Be,et;h.around&&(Be=i.aT.convert(h.around),et=A.locationPoint(Be));const ut=this._zooming||Y!==D,st=this._rotating||F!==ae,Mt=this._pitching||oe!==z,yt=!A.isPaddingEqual(ge),kt=h.retainPadding===!1?A.clone():A,gt=Pt=>Ht=>{if(ut&&(Pt.zoom=i.ak(D,Y,Ht)),st&&(Pt.bearing=i.ak(F,ae,Ht)),Mt&&(Pt.pitch=i.ak(z,oe,Ht)),yt&&(kt.interpolatePadding(H,ge,Ht),xe=kt.centerPoint.add(fe)),Be)Pt.setLocationAtPoint(Be,et);else{const Ut=Pt.zoomScale(Pt.zoom-D),ts=Y>D?Math.min(2,Ve):Math.max(.5,Ve),ns=Math.pow(ts,1-Ht),fs=Pt.unproject(Pe.add(Ce.mult(Ht*ns)).mult(Ut));Pt.setLocationAtPoint(Pt.renderWorldCopies?fs.wrap():fs,xe)}return h.preloadOnly||this._fireMoveEvents(x),Pt};if(h.preloadOnly){const Pt=this._emulate(gt,h.duration,A);return this._preloadTiles(Pt),this}const mt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=ut,this._rotating=st,this._pitching=Mt,this._padding=yt,this._easeId=h.easeId,this._prepareEase(x,h.noMoveStart,mt),this._ease(gt(A),Pt=>{A.cameraElevationReference==="sea"&&A.recenterOnTerrain(),this._afterEase(x,Pt)},h),this}_prepareEase(h,x,A={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),x||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,x){if(this._easeId&&x&&this._easeId===x)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,x){if(this._prefersReducedMotion(h)){const Jt=i.aH(h,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(Jt,x)}this.stop(),h=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:i.eV},h);const A=this.transform,D=this.getZoom(),F=this.getBearing(),z=this.getPitch(),H=this.getPadding(),Y="zoom"in h?i.aA(+h.zoom,A.minZoom,A.maxZoom):D,ae="bearing"in h?this._normalizeBearing(h.bearing,F):F,oe="pitch"in h?+h.pitch:z,ge=this._extendPadding(h.padding),fe=A.zoomScale(Y-D),xe=i.P.convert(h.offset);let Pe=A.centerPoint.add(xe);const Ce=A.pointLocation(Pe),Ve=i.aT.convert(h.center||Ce);this._normalizeCenter(Ve);const Be=A.project(Ce),et=A.project(Ve).sub(Be);let ut=h.curve;const st=Math.max(A.width,A.height),Mt=st/fe,yt=et.mag();if("minZoom"in h){const Jt=i.aA(Math.min(h.minZoom,D,Y),A.minZoom,A.maxZoom),Ls=st/A.zoomScale(Jt-D);ut=Math.sqrt(Ls/yt*2)}const kt=ut*ut;function gt(Jt){const Ls=(Mt*Mt-st*st+(Jt?-1:1)*kt*kt*yt*yt)/(2*(Jt?Mt:st)*kt*yt);return Math.log(Math.sqrt(Ls*Ls+1)-Ls)}function mt(Jt){return(Math.exp(Jt)-Math.exp(-Jt))/2}function Pt(Jt){return(Math.exp(Jt)+Math.exp(-Jt))/2}const Ht=gt(0);let Ut=function(Jt){return Pt(Ht)/Pt(Ht+ut*Jt)},ts=function(Jt){return st*((Pt(Ht)*(mt(Ls=Ht+ut*Jt)/Pt(Ls))-mt(Ht))/kt)/yt;var Ls},ns=(gt(1)-Ht)/ut;if(Math.abs(yt)<1e-6||!isFinite(ns)){if(Math.abs(st-Mt)<1e-6)return this.easeTo(h,x);const Jt=Mth.maxDuration&&(h.duration=0);const fs=F!==ae,qs=oe!==z,Yt=!A.isPaddingEqual(ge),Ft=h.retainPadding===!1?A.clone():A,ls=Jt=>Ls=>{const er=Ls*ns,pr=1/Ut(er);Jt.zoom=Ls===1?Y:D+Jt.scaleZoom(pr),fs&&(Jt.bearing=i.ak(F,ae,Ls)),qs&&(Jt.pitch=i.ak(z,oe,Ls)),Yt&&(Ft.interpolatePadding(H,ge,Ls),Pe=Ft.centerPoint.add(xe));const Xs=Ls===1?Ve:Jt.unproject(Be.add(et.mult(ts(er))).mult(pr));return Jt.setLocationAtPoint(Jt.renderWorldCopies?Xs.wrap():Xs,Pe),Jt._updateCameraOnTerrain(),h.preloadOnly||this._fireMoveEvents(x),Jt};if(h.preloadOnly){const Jt=this._emulate(ls,h.duration,A);return this._preloadTiles(Jt),this}return this._zooming=!0,this._rotating=fs,this._pitching=qs,this._padding=Yt,this._prepareEase(x,!1),this._ease(ls(A),()=>this._afterEase(x),h),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(h){}_cancelRenderFrame(h){}_stop(h,x){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const A=this._onEaseEnd;this._onEaseEnd=void 0,A.call(this,x)}if(!h){const A=this.handlers;A&&A.stop(!1)}return this}_ease(h,x,A){A.animate===!1||A.duration===0?(h(1),x()):(this._easeStart=i.o.now(),this._easeOptions=A,this._onEaseFrame=h,this._onEaseEnd=x,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const h=Math.min((i.o.now()-this._easeStart)/this._easeOptions.duration,1),x=this._onEaseFrame;x&&x(this._easeOptions.easing(h)),h<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(h,x){h=i.bT(h,-180,180);const A=Math.abs(h-x);return Math.abs(h-360-x)180?-360:A<-180?360:0}_prefersReducedMotion(h){return this._respectPrefersReducedMotion&&i.o.prefersReducedMotion&&!(h&&h.essential)}_emulate(h,x,A){const D=Math.ceil(15*x/1e3),F=[],z=h(A.clone());for(let H=0;H<=D;H++){const Y=z(H/D);F.push(Y.clone())}return F}_preloadTiles(h,x){}}class pw{constructor(h={}){this.options=h,i.aY(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(h){const x=this.options&&this.options.compact,A=h._getUIString("AttributionControl.ToggleAttribution");this._map=h,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=w("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",A);const D=w("span","mapboxgl-ctrl-icon",this._compactButton);return D.setAttribute("aria-hidden","true"),D.setAttribute("title",A),this._innerContainer=w("div","mapboxgl-ctrl-attrib-inner",this._container),x&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),x===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let h=this._editLink;h||(h=this._editLink=this._container.querySelector(".mapbox-improve-map"));const x=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||i.e.ACCESS_TOKEN}];if(h){const A=x.reduce((D,F,z)=>(F.value&&(D+=`${F.key}=${F.value}${zD.length-F.length),h=h.filter((D,F)=>{for(let z=F+1;z=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?h=[...this.options.customAttribution,...h]:h.unshift(this.options.customAttribution));const A=h.map(D=>function(F){const z=new DOMParser().parseFromString(F,"text/html");return Array.from(z.body.querySelectorAll("*")).forEach(H=>{const Y=H.textContent||"";if(H.tagName!=="A")return void H.replaceWith(z.createTextNode(Y));const ae=H.getAttribute("href");if(!ae||!/^(https?:|mailto:)/i.test(ae))return void H.replaceWith(z.createTextNode(Y));const oe=z.createElement("a");oe.href=ae,oe.textContent=Y,oe.rel="noopener nofollow";const ge=H.getAttribute("class");ge&&(oe.className=ge),H.replaceWith(oe)}),z.body.innerHTML}(D)).join(" | ");A!==this._attribHTML&&(this._attribHTML=A,h.length?(this._innerContainer.innerHTML=A,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class fw{constructor(){i.aY(["_updateLogo","_updateCompact"],this)}onAdd(h){this._map=h,this._container=w("div","mapboxgl-ctrl");const x=w("a","mapboxgl-ctrl-logo");return x.target="_blank",x.rel="noopener nofollow",x.href="https://www.mapbox.com/",x.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),x.setAttribute("rel","noopener nofollow"),this._container.appendChild(x),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(h){h&&h.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const h=this._map.style._sourceCaches;if(Object.entries(h).length===0)return!0;for(const x in h){const A=h[x].getSource();if(A.hasOwnProperty("mapbox_logo")&&!A.mapbox_logo)return!1}return!0}_updateCompact(){const h=this._container.children;if(h.length){const x=h[0];this._map.getCanvasContainer().offsetWidth<250?x.classList.add("mapboxgl-compact"):x.classList.remove("mapboxgl-compact")}}}class o_{constructor(){i.aY(["_onIndoorUpdate"],this)}onAdd(h){return this._map=h,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",x=>this._onIndoorUpdate(x)),this._container}_createButton(h,x){const A=w("button",h,this._container);return A.type="button",A.addEventListener("click",x),A}_createSeparator(){return w("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(h,x){this._map&&(h.setAttribute("aria-label",x),h.textContent=x)}onRemove(){this._container&&this._container.remove(),this._map&&this._map.indoor&&(this._map.indoor.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"right"}_onIndoorUpdate(h){if(!h||!h.floors)return this._model=h,void(this._container.style.display="none");const x=this._model;this._model=h,this._container.style.display="inline-block",this._container.style.borderRadius="8px",x&&Array.from(this._container.children).forEach(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 x=this._map;this._model&&x&&x._setIndoorActiveFloorsVisibility(!this._model.activeFloorsVisible)});w("span","mapboxgl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&h.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(h),this._createSeparator()}_updateBuildingsButtonState(){const h=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");h&&this._model&&(this._model.activeFloorsVisible?h.classList.remove("mapboxgl-ctrl-level-button-selected"):h.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(h,x){for(let A=0;A{this._map._selectIndoorFloor(D.id)});this._setButtonTitle(F,D.zIndex.toString()),this._model&&D.id===this._model.selectedFloorId&&x&&F.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(F),A=this._endTime)return this._end;const x=i.dD((h-this._startTime)/(this._endTime-this._startTime));return this._start*(1-x)+this._end*x}isEasing(h){return h>=this._startTime&&h<=this._endTime}jumpTo(h){this._startTime=-1/0,this._endTime=-1/0,this._start=h,this._end=h}easeTo(h,x,A){this._start=this.getValue(x),this._end=h,this._startTime=x,this._endTime=x+A}}const nx={"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 My extends i.z{constructor(h,x,A,D){const{point:F,lngLat:z,originalEvent:H,target:Y}=h;super(h.type,{point:F,lngLat:z,originalEvent:H,target:Y}),this.preventDefault=()=>{h.preventDefault()},this.id=x,this.interaction=A,this.feature=D}}class Op{constructor(h){this.map=h,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}add(h,x){if(this.typeById.has(h))throw new Error(`Interaction id "${h}" already exists.`);const A=x.filter;let D=x.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,x)):F.size===0&&this.map.on(D,this.handleType),F.size===0&&this.interactionsByType.set(D,F),F.set(h,x),this.typeById.set(h,D)}get(h){const x=this.typeById.get(h);if(!x)return;const A=this.interactionsByType.get(x);return A?A.get(h):void 0}remove(h){const x=this.typeById.get(h);if(!x)return;this.typeById.delete(h),this.filters.delete(h);const A=this.interactionsByType.get(x);A&&(A.delete(h),x==="mouseenter"||x==="mouseleave"?(this.delegatedInteractions.delete(h),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):A.size===0&&this.map.off(x,this.handleType))}queryTargets(h,x){const A=[];for(const[D,F]of x)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 x=this.queryTargets(h.point,Array.from(this.delegatedInteractions).reverse());x.length&&(h.type="mouseenter",this.handleType(h,x));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 x=Array.from(this.hoveredFeatures.values()).map(({feature:A})=>A);x.length&&(h.type="mouseleave",this.handleType(h,x)),this.hoveredFeatures.clear()}handleType(h,x){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=!!x;x=x||this.queryTargets(h.point,D);let z=!1;const H=new Set;for(const Y of x){for(const[ae,oe]of D){if(!oe.target)continue;const ge=Y.variants?Y.variants[ae]:null;if(ge){for(const fe of ge){if(uy(fe,Y,H,ae))continue;const xe=new i.dx(Y,fe),Pe=qg(fe,Y,ae);F&&xe.id!==void 0&&(xe.state=this.map.getFeatureState(xe));const Ce=A?this.prevHoveredFeatures.get(Pe):null,Ve=new My(h,ae,oe,xe),Be=Ce?Ce.stop:oe.handler(Ve);if(A&&this.hoveredFeatures.set(Pe,{feature:Y,stop:Be}),Be!==!1){z=!0;break}}if(z)break}}if(z)break}if(!z)for(const[Y,ae]of D){const{handler:oe,target:ge}=ae;if(!ge&&oe(new My(h,Y,ae,null))!==!1)break}}}function $me(M,h){if(Array.isArray(M)&&Array.isArray(h)){const x=new Set(M),A=new Set(h);return x.size===A.size&&M.every(D=>A.has(D))}return i.by(M,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"},Ume={showCompass:!0,showZoom:!0,visualizePitch:!1};class Vme{constructor(h,x,A=!1){this._clickTolerance=10,this.element=x,this.mouseRotate=new gP({clickTolerance:h.dragRotate._mouseRotate._clickTolerance}),this.map=h,A&&(this.mousePitch=new xP({clickTolerance:h.dragRotate._mousePitch._clickTolerance})),i.aY(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),x.addEventListener("mousedown",this.mousedown),x.addEventListener("touchstart",this.touchstart,{passive:!1}),x.addEventListener("touchmove",this.touchmove),x.addEventListener("touchend",this.touchend),x.addEventListener("touchcancel",this.reset)}down(h,x){this.mouseRotate.mousedown(h,x),this.mousePitch&&this.mousePitch.mousedown(h,x),I()}move(h,x){const A=this.map,D=this.mouseRotate.mousemoveWindow(h,x),F=D&&D.bearingDelta;if(F&&A.setBearing(A.getBearing()+F),this.mousePitch){const z=this.mousePitch.mousemoveWindow(h,x),H=z&&z.pitchDelta;H&&A.setPitch(A.getPitch()+H)}}off(){const h=this.element;h.removeEventListener("mousedown",this.mousedown),h.removeEventListener("touchstart",this.touchstart),h.removeEventListener("touchmove",this.touchmove),h.removeEventListener("touchend",this.touchend),h.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){L(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(h){this.down(Object.assign({},h,{ctrlKey:!0,preventDefault:()=>h.preventDefault()}),q(this.element,h)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(h){this.move(h,q(this.element,h))}mouseup(h){this.mouseRotate.mouseupWindow(h),this.mousePitch&&this.mousePitch.mouseupWindow(h),this.offTemp()}touchstart(h){h.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=U(this.element,h.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>h.preventDefault()},this._startPos))}touchmove(h){h.targetTouches.length!==1?this.reset():(this._lastPos=U(this.element,h.targetTouches)[0],this.move({preventDefault:()=>h.preventDefault()},this._lastPos))}touchend(h){h.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)x.width||h.y>x.height;x.locationPoint3D(A).distSqr(h)180;){const A=x.locationPoint3D(M);if(A.x>=0&&A.y>=0&&A.x<=x.width&&A.y<=x.height)break;M.lng>x.center.lng?M.lng-=360:M.lng+=360}return M}const Od={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%)"},Gm={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class v3 extends i.E{constructor(h,x){super(),(h instanceof HTMLElement||x)&&(h=Object.assign({element:h},x)),i.aY(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:A="center",color:D="#3FB1CE",scale:F=1,draggable:z=!1,clickTolerance:H=0,rotation:Y=Gm.rotation,rotationAlignment:ae=Gm.rotationAlignment,pitchAlignment:oe=Gm.pitchAlignment,occludedOpacity:ge=Gm.occludedOpacity,altitude:fe=Gm.altitude}=h||{};this._anchor=A,this._color=D,this._scale=F,this._draggable=z,this._clickTolerance=H,this._rotation=Y,this._rotationAlignment=ae,this._pitchAlignment=oe,this._occludedOpacity=ge,this._altitude=fe,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),h&&h.element?(this._element=h.element,this._offset=i.P.convert(h&&h.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=i.P.convert(h&&h.offset||[0,-14])),this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",Ce=>{Ce.preventDefault()}),this._element.addEventListener("mousedown",Ce=>{Ce.preventDefault()});const xe=this._element.classList;for(const Ce in Od)xe.remove(`mapboxgl-marker-anchor-${Ce}`);xe.add(`mapboxgl-marker-anchor-${this._anchor}`);const Pe=h&&h.className?h.className.trim().split(/\s+/):[];xe.add(...Pe),this._popup=null}_createDefaultMarker(){const h=w("div"),x=j("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},h);if(this._altitude===0){const A=j("radialGradient",{id:"shadowGradient"},j("defs",{},x));j("stop",{offset:"10%","stop-opacity":.4},A),j("stop",{offset:"100%","stop-opacity":.05},A),j("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},x)}return j("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},x),j("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},x),j("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},x),h}addTo(h){return h===this._map||(this.remove(),this._map=h,h.getCanvasContainer().appendChild(this._element),h.on("move",this._updateMoving),h.on("moveend",this._update),h.on("remove",this._clearFadeTimer),h._addMarker(this),this.setDraggable(this._draggable),this._update(),h.on("click",this._onMapClick)),this}remove(){const h=this._map;return h&&(h.off("click",this._onMapClick),h.off("move",this._updateMoving),h.off("moveend",this._update),h.off("mousedown",this._addDragHandler),h.off("touchstart",this._addDragHandler),h.off("mouseup",this._onUp),h.off("touchend",this._onUp),h.off("mousemove",this._onMove),h.off("touchmove",this._onMove),h.off("remove",this._clearFadeTimer),h._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=i.aT.convert(h),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(h){return h===this._altitude||(this._defaultMarker&&(this._altitude===0&&h!==0||this._altitude!==0&&h===0)&&(this._element=this._createDefaultMarker()),this._altitude=h||Gm.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(h){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),h){if(!("offset"in h.options)){const D=Math.sqrt(Math.pow(13.5,2)/2);h.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[D,-1*(38.1-13.5+D)],"bottom-right":[-D,-1*(38.1-13.5+D)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=h,h._marker=this,h._altitude=this._altitude,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(h){const x=h.code,A=h.charCode||h.keyCode;x!=="Space"&&x!=="Enter"&&A!==32&&A!==13||this.togglePopup()}_onMapClick(h){const x=h.originalEvent.target,A=this._element;this._popup&&(x===A||A.contains(x))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const h=this._popup;return h?(h.isOpen()?(h.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(h.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const h=this._map,x=this._pos;if(!h||!x)return!1;const A=h.unproject(x,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 x=this._pos;if(!x||x.x<0||x.x>h.transform.width||x.y<0||x.y>h.transform.height)return void this._clearFadeTimer();const A=h.unproject(x,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 x=this._offset.mult(this._scale);this._element.style.transform=` translate(${h.x}px,${h.y}px) ${Od[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${x.x}px,${x.y}px) `}_calculateXYTransform(){const h=this._pos,x=this._map,A=this.getPitchAlignment();if(!x||!h||A!=="map")return"";if(!x._showingGlobe()){const Y=x.getPitch();return Y?`rotateX(${Y}deg)`:""}const D=i.cX(i.f6(x.transform,this._lngLat)),F=h.sub(i.f7(x.transform)),z=Math.abs(F.x)+Math.abs(F.y);if(z===0)return"";const H=D/z;return`rotateX(${-F.y*H}deg) rotateY(${F.x*H}deg)`}_calculateZTransform(){const h=this._pos,x=this._map;if(!x||!h)return"";let A=0;const D=this.getRotationAlignment();if(D==="map")if(x._showingGlobe()){const F=x.project(new i.aT(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),z=x.project(new i.aT(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(F);A=i.cX(Math.atan2(z.y,z.x))-90}else A=-x.getBearing();else if(D==="horizon"){const F=i.ah(4,6,x.getZoom()),z=i.f7(x.transform);z.y+=F*x.transform.height;const H=h.sub(z),Y=i.cX(Math.atan2(H.y,H.x));A=(Y>90?Y-270:Y+90)*(1-F)}return A+=this._rotation,A?`rotateZ(${A}deg)`:""}_update(h){cancelAnimationFrame(this._updateFrameId);const x=this._map;x&&(x.transform.renderWorldCopies&&(this._lngLat=bP(this._lngLat,this._pos,x.transform)),this._pos=x.project(this._lngLat,this._altitude),h===!0?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),x._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(x._showingGlobe()||x.getTerrain()||x.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(h){return this._offset=i.P.convert(h),this._update(),this}addClassName(h){return this._element.classList.add(h),this}removeClassName(h){return this._element.classList.remove(h),this}toggleClassName(h){return this._element.classList.toggle(h)}_onMove(h){const x=this._map;if(!x)return;const A=this._pointerdownPos,D=this._positionDelta;if(A&&D){if(!this._isDragging){const F=this._clickTolerance||x._clickTolerance;if(h.point.dist(A)M.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(M.minPitch!=null&&M.maxPitch!=null&&M.minPitch>M.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(M.minPitch!=null&&M.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(M.maxPitch!=null&&M.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(M.antialias&&i.f3(window)&&(M.antialias=!1,i.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new NE(M.minZoom,M.maxZoom,M.minPitch,M.maxPitch,M.renderWorldCopies,null,null),M),this._repaint=!!M.repaint,this._interactive=M.interactive,this._minTileCacheSize=M.minTileCacheSize,this._maxTileCacheSize=M.maxTileCacheSize,this._failIfMajorPerformanceCaveat=M.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=M.preserveDrawingBuffer,this._antialias=M.antialias,this._trackResize=M.trackResize,this._bearingSnap=M.bearingSnap,this._refreshExpiredTiles=M.refreshExpiredTiles,this._fadeDuration=M.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=M.crossSourceCollisions,this._collectResourceTiming=M.collectResourceTiming,this._language=this._parseLanguage(M.language),this._worldview=M.worldview,this._renderTaskQueue=new sx,this._domRenderTaskQueue=new sx,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.b2(),this._locale=Object.assign({},nx,M.locale),this._clickTolerance=M.clickTolerance,this._cooperativeGestures=M.cooperativeGestures,this._performanceMetricsCollection=M.performanceMetricsCollection,this._tessellationStep=M.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=M.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new rx(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=M.scaleFactor,this._requestManager=new Q(M.transformRequest,M.accessToken,M.testMode),this._silenceAuthErrors=!!M.testMode,this._contextCreateOptions=M.contextCreateOptions?Object.assign({},M.contextCreateOptions):{},typeof M.container=="string"){const x=document.getElementById(M.container);if(!x)throw new Error(`Container '${M.container.toString()}' not found.`);this._container=x}else{if(!(M.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=M.container}if(this._container.childNodes.length>0&&i.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),M.maxBounds&&this.setMaxBounds(M.maxBounds),this._spriteFormat=M.spriteFormat,i.aY(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new Bme(this,M),this._localFontFamily=M.localFontFamily,this._localIdeographFontFamily=M.localIdeographFontFamily,(M.style||!M.testMode)&&this.setStyle(M.style||i.e.DEFAULT_STYLE,{config:M.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),M.projection&&this.setProjection(M.projection),M.hash&&(this._hash=new lP(typeof M.hash=="string"&&M.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){h.center==null&&h.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:M.center,zoom:M.zoom,bearing:M.bearing,pitch:M.pitch});const x=M.bounds;x&&(this.resize(),this.fitBounds(x,Object.assign({},M.fitBoundsOptions,{duration:0})))}this.resize(),M.attributionControl&&this.addControl(new pw({customAttribution:M.customAttribution})),this._logoControl=new fw,this.addControl(this._logoControl,M.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent(),this._setupIndoor()}),this.on("data",x=>{this._update(x.dataType==="style"),this.fire(new i.z(`${x.dataType}data`,x))}),this.on("dataloading",x=>{this.fire(new i.z(`${x.dataType}dataloading`,x))}),this._interactions=new Op(this)}_getMapId(){return this._mapId}addControl(M,h){if(h===void 0&&(h=M.getDefaultPosition?M.getDefaultPosition():"top-right"),!M||!M.onAdd)return this.fire(new i.y(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const x=M.onAdd(this);this._controls.push(M);const A=this._controlPositions[h];return h.indexOf("bottom")!==-1?A.insertBefore(x,A.firstChild):A.appendChild(x),this}removeControl(M){if(!M||!M.onRemove)return this.fire(new i.y(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const h=this._controls.indexOf(M);return h>-1&&this._controls.splice(h,1),M.onRemove(this),this}hasControl(M){return this._controls.indexOf(M)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(M){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const h=!this._moving;return h&&this.fire(new i.z("movestart",M)).fire(new i.z("move",M)),this.fire(new i.z("resize",M)),h&&this.fire(new i.z("moveend",M)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(M){return this.transform.setMaxBounds(i.aI.convert(M)),this._update()}setMinZoom(M){if((M=M??-2)>=-2&&M<=this.transform.maxZoom)return this.transform.minZoom=M,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=M,this._update(),this.getZoom()>M?this.setZoom(M):this.fire(new i.z("zoomstart")).fire(new i.z("zoom")).fire(new i.z("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(M){if((M=M??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(M>=0&&M<=this.transform.maxPitch)return this.transform.minPitch=M,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(M>=this.transform.minPitch)return this.transform.maxPitch=M,this._update(),this.getPitch()>M?this.setPitch(M):this.fire(new i.z("pitchstart")).fire(new i.z("pitch")).fire(new i.z("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(M){return this._scaleFactor=M,this.painter.scaleFactor=M,this._scaleFactorChanged=!0,this.style._updateFilteredLayers(h=>h.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(M){return this.transform.renderWorldCopies=M,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(M){return M==="auto"?navigator.language:Array.isArray(M)?M.length===0?void 0:M.map(h=>h==="auto"?navigator.language:h):M}setLanguage(M){const h=this._parseLanguage(M);if(!this.style||h===this._language)return this;this._language=h,this.style.reloadSources();for(const x of this._controls)x._setLanguage&&x._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(M){return this.style&&M!==this._worldview?(this._worldview=M,this._styleDirty=!0,this.style.reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(M){return this._lazyInitEmptyStyle(),M?typeof M=="string"&&(M={name:M}):M=null,this._useExplicitProjection=!!M,this._prioritizeAndUpdateProjection(M,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const M=this.transform,h=M.projection.name;let x;h==="globe"&&M.zoom>=i.cL?(M.setMercatorFromTransition(),x=!0):h==="mercator"&&M.zoom=i.cL?this.transform.setMercatorFromTransition():this.transform.setProjection(M),this.style.applyProjectionUpdate();const A=this.transform.getProjection().name==="mercator"&&x!==this.transform.mercatorFromTransition;return(h||A)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(M,h){return this.transform.locationPoint3D(i.aT.convert(M),h)}unproject(M,h){return this.transform.pointLocation3D(i.P.convert(M),h)}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(M,h,x){const A=D=>{let F=[];if(Array.isArray(h)){const z=h.filter(H=>this.getLayer(H));F=z.length?this.queryRenderedFeatures(D,{layers:z}):[]}else F=this.queryRenderedFeatures(D,{target:h});return F};if(M==="mouseenter"||M==="mouseover"){let D=!1;return{listener:x,targets:h,delegates:{mousemove:z=>{const H=A(z.point);H.length?D||(D=!0,x.call(this,new nh(M,this,z.originalEvent,{features:H}))):D=!1},mouseout:()=>{D=!1}}}}if(M==="mouseleave"||M==="mouseout"){let D=!1;return{listener:x,targets:h,delegates:{mousemove:H=>{A(H.point).length?D=!0:D&&(D=!1,x.call(this,new nh(M,this,H.originalEvent)))},mouseout:H=>{D&&(D=!1,x.call(this,new nh(M,this,H.originalEvent)))}}}}{const D=F=>{const z=A(F.point);z.length&&(F.features=z,x.call(this,F),delete F.features)};return{listener:x,targets:h,delegates:{[M]:D}}}}on(M,h,x){if(typeof h=="function"||x===void 0)return super.on(M,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._createDelegatedListener(M,h,x);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[M]=this._delegatedListeners[M]||[],this._delegatedListeners[M].push(A);for(const D in A.delegates)this.on(D,A.delegates[D]);return this}once(M,h,x){if(typeof h=="function"||x===void 0)return super.once(M,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._createDelegatedListener(M,h,x);for(const D in A.delegates)this.once(D,A.delegates[D]);return this}off(M,h,x){if(typeof h=="function"||x===void 0)return super.off(M,h);if(typeof h=="string"&&(h=[h]),!this._areTargetsValid(h))return this;const A=this._delegatedListeners?this._delegatedListeners[M]:void 0;return A&&(D=>{for(let F=0;F{if(x){const D=typeof x=="string"?x:x instanceof Error?x.message:x.error;i.w(`Unable to perform style diff: ${D}. Rebuilding the style from scratch.`),this._updateStyle(M,h)}else A&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=h.localIdeographFontFamily,this._localFontFamily=h.localFontFamily,this._updateStyle(M,h))}_getUIString(M){const h=this._locale[M];if(h==null)throw new Error(`Missing UI string '${M}'`);return h}_updateStyle(M,h){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),M){const x=Object.assign({},h);h&&h.config&&(x.initialConfig=h.config,delete x.config),this.style=new Wm(this,x).load(M),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Wm(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(i.w("There is no style added to the map."),!1)}_isValidId(M){return M==null?(this.fire(new i.y(new Error("IDs can't be empty."))),!1):!i.dr(M)||(this.fire(new i.y(new Error(`IDs can't contain special symbols: "${M}".`))),!1)}_isTargetValid(M){return"featuresetId"in M?this._isValidId("importId"in M?M.importId:M.featuresetId):"layerId"in M&&this._isValidId(M.layerId)}_areTargetsValid(M){if(Array.isArray(M)){for(const h of M)if(!this._isValidId(h))return!1;return!0}return this._isTargetValid(M)}addSource(M,h){return this._isValidId(M)?(this._lazyInitEmptyStyle(),this.style.addSource(M,h),this._update(!0)):this}isSourceLoaded(M){return!!this._isValidId(M)&&!!this.style&&this.style._isSourceCacheLoaded(M)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(M,h,x){this._lazyInitEmptyStyle(),this.style.addSourceType(M,h,x)}removeSource(M){return this._isValidId(M)?(this.style.removeSource(M),this._updateTerrain(),this._update(!0)):this}getSource(M){return this._isValidId(M)?this.style.getOwnSource(M):null}addImage(M,h,{pixelRatio:x=1,sdf:A=!1,stretchX:D,stretchY:F,content:z}={}){this._lazyInitEmptyStyle();const H=i.I.from(M);if(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap){const{width:Y,height:ae,data:oe}=i.o.getImageData(h);this.style.addImage(H,{data:new i.q({width:Y,height:ae},oe),pixelRatio:x,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:Y,height:ae}=h,oe=h;this.style.addImage(H,{data:new i.q({width:Y,height:ae},new Uint8Array(oe.data)),pixelRatio:x,stretchX:D,stretchY:F,content:z,sdf:A,usvg:!1,version:0,userImage:oe}),oe.onAdd&&oe.onAdd(this,M)}}updateImage(M,h){this._lazyInitEmptyStyle();const x=i.I.from(M),A=this.style.getImage(x);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:H}=D;if(F===void 0||z===void 0)return void this.fire(new i.y(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(F!==(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 Y=!(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap);let ae=!1;A.usvg?(A.data=new i.q({width:F,height:z},new Uint8Array(H)),A.usvg=!1,A.icon=void 0,ae=!0):A.data.replace(H,Y),this.style.updateImage(x,A,ae)}hasImage(M){return M?!!this.style&&!!this.style.getImage(i.I.from(M)):(this.fire(new i.y(new Error("Missing required image id"))),!1)}removeImage(M){this.style.removeImage(i.I.from(M))}loadImage(M,h){i.n(this._requestManager.transformRequest(M,i.R.Image),(x,A)=>{h(x,A instanceof HTMLImageElement?i.o.getImageData(A):A)})}listImages(){return this.style.listImages().map(M=>M.name)}addModel(M,h){this._lazyInitEmptyStyle(),this.style.addModel(M,h)}hasModel(M){return M?this.style.hasModel(M):(this.fire(new i.y(new Error("Missing required model id"))),!1)}removeModel(M){this.style.removeModel(M)}listModels(){return this.style.listModels()}addLayer(M,h){return this._isValidId(M.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(M,h),this._update(!0)):this}getSlot(M){const h=this.getLayer(M);return h&&h.slot||null}setSlot(M,h){return this.style.setSlot(M,h),this.style.mergeLayers(),this._update(!0)}addImport(M,h){return this.style.addImport(M,h).catch(x=>this.fire(new i.y(new Error("Failed to add import",x)))),this}updateImport(M,h){return typeof h!="string"&&h.id!==M?(this.removeImport(M),this.addImport(h)):(this.style.updateImport(M,h),this._update(!0))}removeImport(M){return this.style.removeImport(M),this}moveImport(M,h){return this.style.moveImport(M,h),this._update(!0)}moveLayer(M,h){return this._isValidId(M)?(this.style.moveLayer(M,h),this._update(!0)):this}removeLayer(M){return this._isValidId(M)?(this.style.removeLayer(M),this._update(!0)):this}getLayer(M){if(!this._isValidId(M))return null;const h=this.style.getOwnLayer(M);return h?h.type==="custom"?h.implementation:h.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(M,h,x){return this._isValidId(M)?(this.style.setLayerZoomRange(M,h,x),this._update(!0)):this}setFilter(M,h,x={}){return this._isValidId(M)?(this.style.setFilter(M,h,x),this._update(!0)):this}getFilter(M){return this._isValidId(M)?this.style.getFilter(M):null}setPaintProperty(M,h,x,A={}){return this._isValidId(M)?(this.style.setPaintProperty(M,h,x,A),this._update(!0)):this}getPaintProperty(M,h){return this._isValidId(M)?this.style.getPaintProperty(M,h):null}setLayoutProperty(M,h,x,A={}){return this._isValidId(M)?(this.style.setLayoutProperty(M,h,x,A),this._update(!0)):this}getLayoutProperty(M,h){return this._isValidId(M)?this.style.getLayoutProperty(M,h):null}setLayerProperty(M,h,x,A={}){return this._isValidId(M)?(h==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(M,h,x,A),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(M){return this.style.setGlyphsUrl(M),this._update(!0)}getSchema(M){return this.style.getSchema(M)}setSchema(M,h){return this.style.setSchema(M,h),this._update(!0)}getConfig(M){return this.style.getConfig(M)}setConfig(M,h){return this.style.setConfig(M,h),this._update(!0)}getConfigProperty(M,h){return this.style.getConfigProperty(M,h)}setConfigProperty(M,h,x){return this.style.setConfigProperty(M,h,x),this._update(!0)}getFeaturesetDescriptors(M){return this.style.getFeaturesetDescriptors(M)}setLights(M){if(this._lazyInitEmptyStyle(),M&&M.length===1&&M[0].type==="flat"){const h=M[0];h.properties?this.style.setFlatLight(h.properties,h.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(M),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const M=this.style.getLights()||[];return M.length===0&&M.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),M}setLight(M,h={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:M}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(M){return this._lazyInitEmptyStyle(),!M&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(M),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(M){return this._lazyInitEmptyStyle(),this.style.setFog(M),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(M){return this._lazyInitEmptyStyle(),this.style.setSnow(M),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(M){return this._lazyInitEmptyStyle(),this.style.setRain(M),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(M){return this._lazyInitEmptyStyle(),this.style.setColorTheme(M),this._update(!0)}setImportColorTheme(M,h){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(M,h),this._update(!0)}setCamera(M){return this.style.setCamera(M),this._triggerCameraUpdate(M)}_triggerCameraUpdate(M){return this._update(this.transform.setOrthographicProjectionAtLowPitch(M["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(M){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.aT.convert(M),this.transform):0}setFeatureState(M,h){return M.source&&!this._isValidId(M.source)?this:(this.style.setFeatureState(M,h),this._update())}removeFeatureState(M,h){return M.source&&!this._isValidId(M.source)?this:(this.style.removeFeatureState(M,h),this._update())}getFeatureState(M){return M.source&&!this._isValidId(M.source)?null:this.style.getFeatureState(M)}_selectIndoorFloor(M){this.indoor.selectFloor(M)}_setIndoorActiveFloorsVisibility(M){this.indoor.setActiveFloorsVisibility(M)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new o_),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const M=this._container.getBoundingClientRect().width||400,h=this._container.getBoundingClientRect().height||300;let x,A,D,F=this._container;for(;F&&(!A||!D);){const z=window.getComputedStyle(F).transform;z&&z!=="none"&&(x=z.match(/matrix.*\((.+)\)/)[1].split(", "),x[0]&&x[0]!=="0"&&x[0]!=="1"&&(A=x[0]),x[3]&&x[3]!=="0"&&x[3]!=="1"&&(D=x[3])),F=F.parentElement}this._containerWidth=A?Math.abs(M/A):M,this._containerHeight=D?Math.abs(h/D):h}_detectMissingCSS(){window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&i.w("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupIndoor(){this.style.isIndoorEnabled()&&(this.indoor=new cR(this.style),this.on("load",()=>{this._addIndoorControl(),this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds()),this.on("move",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())}),this.on("idle",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())})}))}_setupContainer(){const M=this._container;M.classList.add("mapboxgl-map"),(this._missingCSSCanary=w("div","mapboxgl-canary",M)).style.visibility="hidden",this._detectMissingCSS();const h=this._canvasContainer=w("div","mapboxgl-canvas-container",M);this._canvas=w("canvas","mapboxgl-canvas",h),this._interactive&&(h.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const x=this._controlContainer=w("div","mapboxgl-control-container",M),A=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(D=>{A[D]=w("div",`mapboxgl-ctrl-${D}`,x)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(M,h){const x=i.o.devicePixelRatio||1;this._canvas.width=x*Math.ceil(M),this._canvas.height=x*Math.ceil(h),this._canvas.style.width=`${M}px`,this._canvas.style.height=`${h}px`}_addMarker(M){this._markers.push(M)}_removeMarker(M){const h=this._markers.indexOf(M);h!==-1&&this._markers.splice(h,1)}_addPopup(M){this._popups.push(M)}_removePopup(M){const h=this._popups.indexOf(M);h!==-1&&this._popups.splice(h,1)}_setupPainter(){const M=Object.assign({},b.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),h=this._canvas.getContext("webgl2",M);h?(rt(h,!0),this.painter=new a3(h,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",x=>{x.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),i.k.testSupport(h)):this.fire(new i.y(new Error("Failed to initialize WebGL")))}_contextLost(M){M.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.z("webglcontextlost",{originalEvent:M}))}_contextRestored(M){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new i.z("webglcontextrestored",{originalEvent:M}))}_onMapScroll(M){if(M.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return!this.isMoving()&&this.loaded()}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(M){return this.style?(this._styleDirty=this._styleDirty||M,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(M){return this._update(),this._renderTaskQueue.add(M)}_cancelRenderFrame(M){this._renderTaskQueue.remove(M)}_requestDomTask(M){!this.loaded()||this.loaded()&&!this.isMoving()?M():this._domRenderTaskQueue.add(M)}_render(M){let h;this.fire(new i.z("renderstart")),++this._frameId;const x=this.painter.context.extTimerQuery,A=i.o.now(),D=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(h=D.createQuery(),D.beginQuery(x.TIME_ELAPSED_EXT,h)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(M),this._domRenderTaskQueue.run(M),this._removed)return;this._updateProjectionTransition();const F=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const ae=this.transform.zoom,oe=this.transform.pitch,ge=i.o.now(),fe=new i.ac(ae,{now:ge,fadeDuration:F,pitch:oe,transition:this.style.transition,worldview:this._worldview});this.style.update(fe)}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 H=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,F,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),H&&(this._placementDirty=H.needsRerender),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:F,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new i.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.mark(u.load),this.fire(new i.z("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),h){const ae=i.o.now()-A;D.endQuery(x.TIME_ELAPSED_EXT),setTimeout(()=>{const oe=D.getQueryParameter(h,D.QUERY_RESULT)/1e6;D.deleteQuery(h),this.fire(new i.z("gpu-timing-frame",{cpuTime:ae,gpuTime:oe}))},50)}if(this.listens("gpu-timing-layer")){const ae=this.painter.collectGpuTimers();setTimeout(()=>{const oe=this.painter.queryGpuTimers(ae);this.fire(new i.z("gpu-timing-layer",{layerTimes:oe}))},50)}if(this.listens("gpu-timing-deferred-render")){const ae=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const oe=this.painter.queryGpuTimeDeferredRender(ae);this.fire(new i.z("gpu-timing-deferred-render",{gpuTime:oe}))},50)}const Y=this._sourcesDirty||this._styleDirty||this._placementDirty||z;if(Y||this._repaint)this.triggerRepaint();else{const ae=this.idle();if(ae&&(z=this._updateAverageElevation(A,!0)),z)this.triggerRepaint();else if(this._triggerFrame(!1),ae&&(this.fire(new i.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const oe=this._calculateSpeedIndex();this.fire(new i.z("speedindexcompleted",{speedIndex:oe})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||Y||(this._fullyLoaded=!0,p.mark(u.fullLoad),this._performanceMetricsCollection&&Rt(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(M){for(const h of this._markers)M&&!this.getRenderWorldCopies()&&(h._lngLat=h._lngLat.wrap()),h._update();for(const h of this._popups)!M||this.getRenderWorldCopies()||h._trackPointer||(h._lngLat=h._lngLat.wrap()),h._update()}_updateAverageElevation(M,h=!1){const x=D=>(this.transform.averageElevation=D,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&x(0);const A=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(A||(h||M-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(M)){const D=this.transform.averageElevation;let F=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(F)?F=0:this._averageElevationLastSampledAt=M;const z=Math.abs(D-F);if(z>1){if(this._isInitialLoad||A)return this._averageElevation.jumpTo(F),x(F);this._averageElevation.easeTo(F,M,300)}else if(z>1e-4)return this._averageElevation.jumpTo(F),x(F)}return!!this._averageElevation.isEasing(M)&&x(this._averageElevation.getValue(M))}_authenticate(){Je(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,M=>{if(M&&(M.message===ee||M.status===401)){const h=this.painter.context.gl;rt(h,!1),this._logoControl instanceof fw&&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/")))}}),be(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Ae(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Te(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){ct(this._requestManager._customAccessToken)}_updateTerrain(){const M=this._isDragging();this.painter.updateTerrain(this.style,M)}_calculateSpeedIndex(){const M=this.painter.canvasCopy(),h=this.painter.getCanvasCopiesAndTimestamps();h.timeStamps.push(performance.now());const x=this.painter.context.gl,A=x.createFramebuffer();function D(F){x.framebufferTexture2D(x.FRAMEBUFFER,x.COLOR_ATTACHMENT0,x.TEXTURE_2D,F,0);const z=new Uint8Array(x.drawingBufferWidth*x.drawingBufferHeight*4);return x.readPixels(0,0,x.drawingBufferWidth,x.drawingBufferHeight,x.RGBA,x.UNSIGNED_BYTE,z),z}return x.bindFramebuffer(x.FRAMEBUFFER,A),this._canvasPixelComparison(D(M),h.canvasCopies.map(D),h.timeStamps)}_canvasPixelComparison(M,h,x){let A=x[1]-x[0];const D=M.length/4;for(let F=0;F{const x=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,x&&this._render(h)}))}_preloadTiles(M){const h=this.style?this.style.getSourceCaches():[];return i.bw(h,(x,A)=>x._preloadTiles(M,A),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(M){this._trackResize&&this.resize({originalEvent:M})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(M){this._showTileBoundaries!==M&&(this._showTileBoundaries=M,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(M){this._showParseStatus!==M&&(this._showParseStatus=M,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(M){this._showTerrainWireframe!==M&&(this._showTerrainWireframe=M,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(M){this._showLayers2DWireframe!==M&&(this._showLayers2DWireframe=M,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(M){this._showLayers3DWireframe!==M&&(this._showLayers3DWireframe=M,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(M){this._speedIndexTiming!==M&&(this._speedIndexTiming=M,this._update())}get showPadding(){return!!this._showPadding}set showPadding(M){this._showPadding!==M&&(this._showPadding=M,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(M){this._showCollisionBoxes!==M&&(this._showCollisionBoxes=M,this.style&&M?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(M){this._showOverdrawInspector!==M&&(this._showOverdrawInspector=M,this._update())}get repaint(){return!!this._repaint}set repaint(M){this._repaint!==M&&(this._repaint=M,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(M){this._vertices=M,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(M){this._showTileAABBs!==M&&(this._showTileAABBs=M,M&&this._update())}_setCacheLimits(M,h){i.f4(M,h)}get version(){return c}},NavigationControl:class{constructor(M={}){this.options=Object.assign({},Ume,M),this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",h=>h.preventDefault()),this.options.showZoom&&(i.aY(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",h=>{this._map&&this._map.zoomIn({},{originalEvent:h})}),w("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",h=>{this._map&&this._map.zoomOut({},{originalEvent:h})}),w("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.aY(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",h=>{const x=this._map;x&&(this.options.visualizePitch?x.resetNorthPitch({},{originalEvent:h}):x.resetNorth({},{originalEvent:h}))}),this._compassIcon=w("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const M=this._map;if(!M)return;const h=M.getZoom(),x=h===M.getMaxZoom(),A=h===M.getMinZoom();this._zoomInButton.disabled=x,this._zoomOutButton.disabled=A,this._zoomInButton.setAttribute("aria-disabled",x.toString()),this._zoomOutButton.setAttribute("aria-disabled",A.toString())}_rotateCompassArrow(){const M=this._map;if(!M)return;const h=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(M.transform.pitch*(Math.PI/180)),.5)}) rotateX(${M.transform.pitch}deg) rotateZ(${M.transform.angle*(180/Math.PI)}deg)`:`rotate(${M.transform.angle*(180/Math.PI)}deg)`;M._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=h)})}onAdd(M){return this._map=M,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),M.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&M.on("pitch",this._rotateCompassArrow),M.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Vme(M,this._compass,this.options.visualizePitch)),this._container}onRemove(){const M=this._map;M&&(this._container.remove(),this.options.showZoom&&M.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&M.off("pitch",this._rotateCompassArrow),M.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(M,h){const x=w("button",M,this._container);return x.type="button",x.addEventListener("click",h),x}_setButtonTitle(M,h){if(!this._map)return;const x=this._map._getUIString(`NavigationControl.${h}`);M.setAttribute("aria-label",x),M.firstElementChild&&M.firstElementChild.setAttribute("title",x)}},GeolocateControl:class extends i.E{constructor(M={}){super();const h=navigator.geolocation;this.options=Object.assign({geolocation:h},Hme,M),i.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=i3(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(M){return this._map=M,this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(M){const h=(x=!!this.options.geolocation)=>{this._supportsGeolocation=x,M(x)};this._supportsGeolocation!==void 0?M(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(x=>h(x.state!=="denied")).catch(()=>h()):h()}_isOutOfMapMaxBounds(M){const h=this._map.getMaxBounds(),x=M.coords;return!!h&&(x.longitudeh.getEast()||x.latitudeh.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(M){if(this._map){if(this._isOutOfMapMaxBounds(M))return this._setErrorState(),this.fire(new i.z("outofmaxbounds",M)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=M,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(M),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(M),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.z("geolocate",Object.assign({coords:M.coords,timestamp:M.timestamp},M.toJSON?{toJSON:M.toJSON.bind(M)}:{}))),this._finish()}}_updateCamera(M){const h=new i.aT(M.coords.longitude,M.coords.latitude),x=M.coords.accuracy,A=this._map.getBearing(),D=Object.assign({bearing:A},this.options.fitBoundsOptions);this._map.fitBounds(h.toBounds(x),D,{geolocateSource:!0})}_updateMarker(M){if(M){const h=new i.aT(M.coords.longitude,M.coords.latitude);this._accuracyCircleMarker.setLngLat(h).addTo(this._map),this._userLocationDotMarker.setLngLat(h).addTo(this._map),this._accuracy=M.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const M=this._map.transform,h=i.cf(1,M._center.lat)*M.worldSize,x=Math.ceil(2*this._accuracy*h);this._circleElement.style.width=`${x}px`,this._circleElement.style.height=`${x}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(M){if(this._map){if(this.options.trackUserLocation)if(M.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(M.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.z("error",M)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(M){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",h=>h.preventDefault()),this._geolocateButton=w("button","mapboxgl-ctrl-geolocate",this._container),w("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",M===!1){i.w("Geolocation support is not available so the GeolocateControl will be disabled.");const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}else{const h=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",h),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",h)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=w("div","mapboxgl-user-location"),this._dotElement.appendChild(w("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(w("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new v3({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=w("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new v3({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",h=>{h.geolocateSource||this._watchState!=="ACTIVE_LOCK"||h.originalEvent&&h.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new i.z("trackuserlocationend")))})}}_onDeviceOrientation(M){this._userLocationDotMarker&&(M.webkitCompassHeading?this._heading=M.webkitCompassHeading:M.absolute===!0&&(this._heading=-1*M.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return i.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new i.z("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new i.z("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new i.z("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let M;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(M={maximumAge:6e5,timeout:0},this._noTimeout=!0):(M=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,M),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const M=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};typeof DeviceMotionEvent<"u"&&typeof DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(h=>{h==="granted"&&M()}).catch(console.error):M()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:pw,ScaleControl:class{constructor(M={}){this.options=Object.assign({},l_,M),i.aY(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const M=this.options.maxWidth||100,h=this._map,x=h._containerHeight/2,A=h._containerWidth/2-M/2,D=h.unproject([A,x]),F=h.unproject([A+M,x]),z=D.distanceTo(F);if(this.options.unit==="imperial"){const H=3.2808*z;H>5280?this._setScale(M,H/5280,"mile"):this._setScale(M,H,"foot")}else this.options.unit==="nautical"?this._setScale(M,z/1852,"nautical-mile"):z>=1e3?this._setScale(M,z/1e3,"kilometer"):this._setScale(M,z,"meter")}_setScale(M,h,x){this._map._requestDomTask(()=>{const A=function(F){const z=Math.pow(10,`${Math.floor(F)}`.length-1);let H=F/z;return H=H>=10?10:H>=5?5:H>=3?3:H>=2?2:H>=1?1:function(Y){const ae=Math.pow(10,Math.ceil(-Math.log(Y)/Math.LN10));return Math.round(Y*ae)/ae}(H),z*H}(h),D=A/h;this._container.innerHTML=x!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:x}).format(A):`${A} ${wP[x]}`,this._container.style.width=M*D+"px"})}onAdd(M){return this._map=M,this._language=M.getLanguage(),this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-scale",M.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(M){this._language=M,this._update()}setUnit(M){this.options.unit=M,this._update()}},FullscreenControl:class{constructor(M={}){this._fullscreen=!1,M&&M.container&&(M.container instanceof HTMLElement?this._container=M.container:i.w("Full screen control 'container' must be a DOM element.")),i.aY(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(M){return this._map=M,this._container||(this._container=this._map.getContainer()),this._controlContainer=w("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const M=this._fullscreenButton=w("button","mapboxgl-ctrl-fullscreen",this._controlContainer);w("span","mapboxgl-ctrl-icon",M).setAttribute("aria-hidden","true"),M.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const M=this._getTitle();this._fullscreenButton.setAttribute("aria-label",M),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",M)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(document.fullscreenElement||document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},IndoorControl:o_,Popup:class extends i.E{constructor(M){super(),this.options=Object.assign(Object.create(Km),M),this._altitude=this.options.altitude,i.aY(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(M&&M.className?M.className.trim().split(/\s+/):[])}addTo(M){return this._map&&this.remove(),this._map=M,this.options.closeOnClick&&M.on("preclick",this._onClose),this.options.closeOnMove&&M.on("move",this._onClose),M.on("remove",this.remove),this._update(),M._addPopup(this),this._focusFirstElement(),this._trackPointer?(M.on("mousemove",this._onMouseEvent),M.on("mouseup",this._onMouseEvent),M._canvasContainer.classList.add("mapboxgl-track-pointer")):M.on("move",this._update),this.fire(new i.z("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const M=this._map;return M&&(M.off("move",this._update),M.off("move",this._onClose),M.off("preclick",this._onClose),M.off("click",this._onClose),M.off("remove",this.remove),M.off("mousemove",this._onMouseEvent),M.off("mouseup",this._onMouseEvent),M.off("drag",this._onMouseEvent),M._canvasContainer&&M._canvasContainer.classList.remove("mapboxgl-track-pointer"),M._removePopup(this),this._map=void 0),this.fire(new i.z("close")),this}getLngLat(){return this._lngLat}setLngLat(M){this._lngLat=i.aT.convert(M),this._pos=null,this._trackPointer=!1,this._update();const h=this._map;return h&&(h.on("move",this._update),h.off("mousemove",this._onMouseEvent),h._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(M){return this._altitude=M,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const M=this._map;return M&&(M.off("move",this._update),M.on("mousemove",this._onMouseEvent),M.on("drag",this._onMouseEvent),M._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(M){return this.setDOMContent(document.createTextNode(M))}setHTML(M){const h=document.createDocumentFragment(),x=document.createElement("body");let A;for(x.innerHTML=M;A=x.firstChild,A;)h.appendChild(A);return this.setDOMContent(h)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(M){return this.options.maxWidth=M,this._update(),this}setDOMContent(M){let h=this._content;if(h)for(;h.hasChildNodes();)h.firstChild&&h.removeChild(h.firstChild);else h=this._content=w("div","mapboxgl-popup-content",this._container||void 0);if(h.appendChild(M),this.options.closeButton){const x=this._closeButton=w("button","mapboxgl-popup-close-button",h);x.type="button",x.setAttribute("aria-label","Close popup"),x.innerHTML='',x.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(M){return this._classList.add(M),this._updateClassList(),this}removeClassName(M){return this._classList.delete(M),this._updateClassList(),this}setOffset(M){return this.options.offset=M,this._update(),this}toggleClassName(M){let h;return this._classList.delete(M)?h=!1:(this._classList.add(M),h=!0),this._updateClassList(),h}_onMouseEvent(M){this._update(M.point)}_getAnchor(M){if(this.options.anchor)return this.options.anchor;const h=this._map,x=this._container,A=this._pos;if(!h||!x||!A)return"bottom";const D=x.offsetWidth,F=x.offsetHeight,z=A.xh.transform.width-D/2;if(A.y+Mh.transform.height-F){if(z)return"bottom-left";if(H)return"bottom-right"}return z?"left":H?"right":"bottom"}_updateClassList(){const M=this._container;if(!M)return;const h=[...this._classList];h.push("mapboxgl-popup"),this._anchor&&h.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&h.push("mapboxgl-popup-track-pointer"),M.className=h.join(" ")}_update(M){const h=this._map,x=this._content;if(!h||!this._lngLat&&!this._trackPointer||!x)return;let A=this._container;if(A||(A=this._container=w("div","mapboxgl-popup",h.getContainer()),this._tip=w("div","mapboxgl-popup-tip",A),A.appendChild(x)),this.options.maxWidth&&A.style.maxWidth!==this.options.maxWidth&&(A.style.maxWidth=this.options.maxWidth),h.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=bP(this._lngLat,this._pos,h.transform)),!this._trackPointer||M){const D=this._pos=this._trackPointer&&M instanceof i.P?M:h.project(this._lngLat,this._altitude),F=ov(this.options.offset),z=this._anchor=this._getAnchor(F.y),H=ov(this.options.offset,z),Y=D.add(H).round();h._requestDomTask(()=>{this._container&&z&&(this._container.style.transform=`${Od[z]} translate(${Y.x}px,${Y.y}px)`)})}if(!this._marker&&h._showingGlobe()){const D=i.f5(h.transform,this._lngLat)?0:1;this._setOpacity(D)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const M=this._container.querySelector(Zm);M&&M.focus()}_onClose(){this.remove()}_setOpacity(M){this._container&&(this._container.style.opacity=`${M}`),this._content&&(this._content.style.pointerEvents=M?"auto":"none")}},Marker:v3,Style:Wm,LngLat:i.aT,LngLatBounds:i.aI,Point:i.P,MercatorCoordinate:i.ae,FreeCameraOptions:Tu,Evented:i.E,config:i.e,prewarm:i.f9,clearPrewarmedResources:i.f8,get accessToken(){return i.e.ACCESS_TOKEN},set accessToken(M){i.e.ACCESS_TOKEN=M},get baseApiUrl(){return i.e.API_URL},set baseApiUrl(M){i.e.API_URL=M},get workerCount(){return i.fi.workerCount},set workerCount(M){i.fi.workerCount=M},get maxParallelImageRequests(){return i.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(M){i.e.MAX_PARALLEL_IMAGE_REQUESTS=M},clearStorage(M){i.fh(M)},get workerUrl(){return i.fg.workerUrl},set workerUrl(M){i.fg.workerUrl=M},get workerClass(){return i.fg.workerClass},set workerClass(M){i.fg.workerClass=M},get workerParams(){return i.fg.workerParams},set workerParams(M){i.fg.workerParams=M},get dracoUrl(){return i.ff()},set dracoUrl(M){i.fe(M)},get meshoptUrl(){return i.fd()},set meshoptUrl(M){i.fc(M)},setNow:i.o.setNow,restoreNow:i.o.restoreNow}});var l=a;return l})})(IHe);var Tjt=IHe.exports;const $u=Co(Tjt);function xs({className:t,...s}){return e.jsx("div",{className:At("animate-pulse rounded-md bg-muted",t),...s})}const MEe={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},TEe={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function Ajt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function Ejt({listings:t,isLoading:s}){const r=Pr(),n=C.useRef(null),a=C.useRef(null),o=C.useRef([]),[l,i]=C.useState(""),[c,u]=C.useState(!0);return C.useEffect(()=>{(async()=>{u(!0);try{const{data:y}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();y!=null&&y.value&&i(y.value)}catch(y){console.error("Error fetching mapbox token:",y)}u(!1)})()},[]),C.useEffect(()=>{if(!n.current||!l||a.current)return;$u.accessToken=l;const f=t.filter(b=>b.latitude!=null&&b.longitude!=null);let y=[-98.5795,39.8283],_=4;if(f.length>0){const b=f.reduce((j,N)=>j+N.longitude,0)/f.length,w=f.reduce((j,N)=>j+N.latitude,0)/f.length;y=[b,w],_=f.length===1?12:10}return a.current=new $u.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:_,center:y}),a.current.addControl(new $u.NavigationControl,"top-right"),()=>{var b;(b=a.current)==null||b.remove(),a.current=null}},[l]),C.useEffect(()=>{if(!a.current||!l)return;o.current.forEach(y=>y.remove()),o.current=[];const f=t.filter(y=>y.latitude!=null&&y.longitude!=null);if(f.forEach(y=>{var I,L,R;const _=MEe[y.status]||"#10B981",b=((I=y.photos)==null?void 0:I.find($=>$.is_primary))||((L=y.photos)==null?void 0:L[0]),j=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${y.slug||y.id}`:`/public/listing/${y.slug||y.id}`,N=document.createElement("div");N.className="cursor-pointer",N.innerHTML=`
`;const S=new $u.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${b!=null&&b.photo_url?``:""}
${Ajt(y.price)}
${y.property_address||""}
${y.city}, ${y.state}
${TEe[y.status]||y.status} ${y.bedrooms?`${y.bedrooms} bed`:""} ${y.bathrooms?`${y.bathrooms} bath`:""}
${(R=y.agent)!=null&&R.name?`
Listed by ${y.agent.name}
`:""}
Click to view details →
`),T=new $u.Marker(N).setLngLat([y.longitude,y.latitude]).setPopup(S).addTo(a.current);o.current.push(T)}),f.length>1){const y=new $u.LngLatBounds;f.forEach(_=>y.extend([_.longitude,_.latitude])),a.current.fitBounds(y,{padding:60,maxZoom:13})}else f.length===1&&a.current.flyTo({center:[f[0].longitude,f[0].latitude],zoom:12})},[t,l]),C.useEffect(()=>(window.__navigateToPublicListing__=f=>{r(f)},()=>{delete window.__navigateToPublicListing__}),[r]),c||s?e.jsx(xs,{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(MEe).map(([f,y])=>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:y}}),e.jsx("span",{className:"text-xs text-gray-600",children:TEe[f]})]},f))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function I8(t,[s,r]){return Math.min(r,Math.max(s,t))}function mO(t){const s=C.useRef({value:t,previous:t});return C.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var Pjt=[" ","Enter","ArrowUp","ArrowDown"],Ijt=[" ","Enter"],vS="Select",[Lde,Dde,Ljt]=XD(vS),[EA]=Yc(vS,[Ljt,M0]),Ode=M0(),[Djt,j2]=EA(vS),[Ojt,Rjt]=EA(vS),DHe=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:y,required:_,form:b}=t,w=Ode(s),[j,N]=C.useState(null),[S,T]=C.useState(null),[I,L]=C.useState(!1),R=b2(u),[$,q]=Yu({prop:n,defaultProp:a??!1,onChange:o,caller:vS}),[U,V]=Yu({prop:l,defaultProp:i,onChange:c,caller:vS}),X=C.useRef(null),se=j?b||!!j.closest("form"):!0,[ee,Q]=C.useState(new Set),de=Array.from(ee).map(re=>re.props.value).join(";");return e.jsx(tO,{...w,children:e.jsxs(Djt,{required:_,scope:s,trigger:j,onTriggerChange:N,valueNode:S,onValueNodeChange:T,valueNodeHasChildren:I,onValueNodeHasChildrenChange:L,contentId:vu(),value:U,onValueChange:V,open:$,onOpenChange:q,dir:R,triggerPointerDownPosRef:X,disabled:y,children:[e.jsx(Lde.Provider,{scope:s,children:e.jsx(Ojt,{scope:t.__scopeSelect,onNativeOptionAdd:C.useCallback(re=>{Q(ne=>new Set(ne).add(re))},[]),onNativeOptionRemove:C.useCallback(re=>{Q(ne=>{const le=new Set(ne);return le.delete(re),le})},[]),children:r})}),se?e.jsxs(aWe,{"aria-hidden":!0,required:_,tabIndex:-1,name:p,autoComplete:f,value:U,onChange:re=>V(re.target.value),disabled:y,form:b,children:[U===void 0?e.jsx("option",{value:""}):null,Array.from(ee)]},de):null]})})};DHe.displayName=vS;var OHe="SelectTrigger",RHe=C.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=Ode(r),l=j2(OHe,r),i=l.disabled||n,c=Oa(s,l.onTriggerChange),u=Dde(r),p=C.useRef("touch"),[f,y,_]=oWe(w=>{const j=u().filter(T=>!T.disabled),N=j.find(T=>T.value===l.value),S=lWe(j,w,N);S!==void 0&&l.onValueChange(S.value)}),b=w=>{i||(l.onOpenChange(!0),_()),w&&(l.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return e.jsx(jA,{asChild:!0,...o,children:e.jsx(Jr.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":iWe(l.value)?"":void 0,...a,ref:c,onClick:Mr(a.onClick,w=>{w.currentTarget.focus(),p.current!=="mouse"&&b(w)}),onPointerDown:Mr(a.onPointerDown,w=>{p.current=w.pointerType;const j=w.target;j.hasPointerCapture(w.pointerId)&&j.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(b(w),w.preventDefault())}),onKeyDown:Mr(a.onKeyDown,w=>{const j=f.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&y(w.key),!(j&&w.key===" ")&&Pjt.includes(w.key)&&(b(),w.preventDefault())})})})});RHe.displayName=OHe;var FHe="SelectValue",zHe=C.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,c=j2(FHe,r),{onValueNodeHasChildrenChange:u}=c,p=o!==void 0,f=Oa(s,c.onValueNodeChange);return fd(()=>{u(p)},[u,p]),e.jsx(Jr.span,{...i,ref:f,style:{pointerEvents:"none"},children:iWe(c.value)?e.jsx(e.Fragment,{children:l}):o})});zHe.displayName=FHe;var Fjt="SelectIcon",BHe=C.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(Jr.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});BHe.displayName=Fjt;var zjt="SelectPortal",$He=t=>e.jsx(vA,{asChild:!0,...t});$He.displayName=zjt;var _S="SelectContent",qHe=C.forwardRef((t,s)=>{const r=j2(_S,t.__scopeSelect),[n,a]=C.useState();if(fd(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?cp.createPortal(e.jsx(UHe,{scope:t.__scopeSelect,children:e.jsx(Lde.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(VHe,{...t,ref:s})});qHe.displayName=_S;var wx=10,[UHe,k2]=EA(_S),Bjt="SelectContentImpl",$jt=e2("SelectContent.RemoveScroll"),VHe=C.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:y,collisionPadding:_,sticky:b,hideWhenDetached:w,avoidCollisions:j,...N}=t,S=j2(_S,r),[T,I]=C.useState(null),[L,R]=C.useState(null),$=Oa(s,Ae=>I(Ae)),[q,U]=C.useState(null),[V,X]=C.useState(null),se=Dde(r),[ee,Q]=C.useState(!1),de=C.useRef(!1);C.useEffect(()=>{if(T)return Sde(T)},[T]),jde();const re=C.useCallback(Ae=>{const[Re,...Te]=se().map(De=>De.ref.current),[qe]=Te.slice(-1),ct=document.activeElement;for(const De of Ae)if(De===ct||(De==null||De.scrollIntoView({block:"nearest"}),De===Re&&L&&(L.scrollTop=0),De===qe&&L&&(L.scrollTop=L.scrollHeight),De==null||De.focus(),document.activeElement!==ct))return},[se,L]),ne=C.useCallback(()=>re([q,T]),[re,q,T]);C.useEffect(()=>{ee&&ne()},[ee,ne]);const{onOpenChange:le,triggerPointerDownPosRef:he}=S;C.useEffect(()=>{if(T){let Ae={x:0,y:0};const Re=qe=>{var ct,De;Ae={x:Math.abs(Math.round(qe.pageX)-(((ct=he.current)==null?void 0:ct.x)??0)),y:Math.abs(Math.round(qe.pageY)-(((De=he.current)==null?void 0:De.y)??0))}},Te=qe=>{Ae.x<=10&&Ae.y<=10?qe.preventDefault():T.contains(qe.target)||le(!1),document.removeEventListener("pointermove",Re),he.current=null};return he.current!==null&&(document.addEventListener("pointermove",Re),document.addEventListener("pointerup",Te,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Re),document.removeEventListener("pointerup",Te,{capture:!0})}}},[T,le,he]),C.useEffect(()=>{const Ae=()=>le(!1);return window.addEventListener("blur",Ae),window.addEventListener("resize",Ae),()=>{window.removeEventListener("blur",Ae),window.removeEventListener("resize",Ae)}},[le]);const[we,ye]=oWe(Ae=>{const Re=se().filter(ct=>!ct.disabled),Te=Re.find(ct=>ct.ref.current===document.activeElement),qe=lWe(Re,Ae,Te);qe&&setTimeout(()=>qe.ref.current.focus())}),je=C.useCallback((Ae,Re,Te)=>{const qe=!de.current&&!Te;(S.value!==void 0&&S.value===Re||qe)&&(U(Ae),qe&&(de.current=!0))},[S.value]),ke=C.useCallback(()=>T==null?void 0:T.focus(),[T]),We=C.useCallback((Ae,Re,Te)=>{const qe=!de.current&&!Te;(S.value!==void 0&&S.value===Re||qe)&&X(Ae)},[S.value]),be=n==="popper"?mve:HHe,Me=be===mve?{side:i,sideOffset:c,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:y,collisionPadding:_,sticky:b,hideWhenDetached:w,avoidCollisions:j}:{};return e.jsx(UHe,{scope:r,content:T,viewport:L,onViewportChange:R,itemRefCallback:je,selectedItem:q,onItemLeave:ke,itemTextRefCallback:We,focusSelectedItem:ne,selectedItemText:V,position:n,isPositioned:ee,searchRef:we,children:e.jsx(oO,{as:$jt,allowPinchZoom:!0,children:e.jsx(aO,{asChild:!0,trapped:S.open,onMountAutoFocus:Ae=>{Ae.preventDefault()},onUnmountAutoFocus:Mr(a,Ae=>{var Re;(Re=S.trigger)==null||Re.focus({preventScroll:!0}),Ae.preventDefault()}),children:e.jsx(g2,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Ae=>Ae.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:e.jsx(be,{role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:Ae=>Ae.preventDefault(),...N,...Me,onPlaced:()=>Q(!0),ref:$,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:Mr(N.onKeyDown,Ae=>{const Re=Ae.ctrlKey||Ae.altKey||Ae.metaKey;if(Ae.key==="Tab"&&Ae.preventDefault(),!Re&&Ae.key.length===1&&ye(Ae.key),["ArrowUp","ArrowDown","Home","End"].includes(Ae.key)){let qe=se().filter(ct=>!ct.disabled).map(ct=>ct.ref.current);if(["ArrowUp","End"].includes(Ae.key)&&(qe=qe.slice().reverse()),["ArrowUp","ArrowDown"].includes(Ae.key)){const ct=Ae.target,De=qe.indexOf(ct);qe=qe.slice(De+1)}setTimeout(()=>re(qe)),Ae.preventDefault()}})})})})})})});VHe.displayName=Bjt;var qjt="SelectItemAlignedPosition",HHe=C.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=j2(_S,r),l=k2(_S,r),[i,c]=C.useState(null),[u,p]=C.useState(null),f=Oa(s,$=>p($)),y=Dde(r),_=C.useRef(!1),b=C.useRef(!0),{viewport:w,selectedItem:j,selectedItemText:N,focusSelectedItem:S}=l,T=C.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&w&&j&&N){const $=o.trigger.getBoundingClientRect(),q=u.getBoundingClientRect(),U=o.valueNode.getBoundingClientRect(),V=N.getBoundingClientRect();if(o.dir!=="rtl"){const ct=V.left-q.left,De=U.left-ct,Rt=$.left-De,pe=$.width+Rt,Je=Math.max(pe,q.width),lt=window.innerWidth-wx,rt=I8(De,[wx,Math.max(wx,lt-Je)]);i.style.minWidth=pe+"px",i.style.left=rt+"px"}else{const ct=q.right-V.right,De=window.innerWidth-U.right-ct,Rt=window.innerWidth-$.right-De,pe=$.width+Rt,Je=Math.max(pe,q.width),lt=window.innerWidth-wx,rt=I8(De,[wx,Math.max(wx,lt-Je)]);i.style.minWidth=pe+"px",i.style.right=rt+"px"}const X=y(),se=window.innerHeight-wx*2,ee=w.scrollHeight,Q=window.getComputedStyle(u),de=parseInt(Q.borderTopWidth,10),re=parseInt(Q.paddingTop,10),ne=parseInt(Q.borderBottomWidth,10),le=parseInt(Q.paddingBottom,10),he=de+re+ee+le+ne,we=Math.min(j.offsetHeight*5,he),ye=window.getComputedStyle(w),je=parseInt(ye.paddingTop,10),ke=parseInt(ye.paddingBottom,10),We=$.top+$.height/2-wx,be=se-We,Me=j.offsetHeight/2,Ae=j.offsetTop+Me,Re=de+re+Ae,Te=he-Re;if(Re<=We){const ct=X.length>0&&j===X[X.length-1].ref.current;i.style.bottom="0px";const De=u.clientHeight-w.offsetTop-w.offsetHeight,Rt=Math.max(be,Me+(ct?ke:0)+De+ne),pe=Re+Rt;i.style.height=pe+"px"}else{const ct=X.length>0&&j===X[0].ref.current;i.style.top="0px";const Rt=Math.max(We,de+w.offsetTop+(ct?je:0)+Me)+Te;i.style.height=Rt+"px",w.scrollTop=Re-We+w.offsetTop}i.style.margin=`${wx}px 0`,i.style.minHeight=we+"px",i.style.maxHeight=se+"px",n==null||n(),requestAnimationFrame(()=>_.current=!0)}},[y,o.trigger,o.valueNode,i,u,w,j,N,o.dir,n]);fd(()=>T(),[T]);const[I,L]=C.useState();fd(()=>{u&&L(window.getComputedStyle(u).zIndex)},[u]);const R=C.useCallback($=>{$&&b.current===!0&&(T(),S==null||S(),b.current=!1)},[T,S]);return e.jsx(Vjt,{scope:r,contentWrapper:i,shouldExpandOnScrollRef:_,onScrollButtonChange:R,children:e.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:I},children:e.jsx(Jr.div,{...a,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});HHe.displayName=qjt;var Ujt="SelectPopperPosition",mve=C.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=wx,...o}=t,l=Ode(r);return e.jsx(sO,{...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)"}})});mve.displayName=Ujt;var[Vjt,Xwe]=EA(_S,{}),pve="SelectViewport",WHe=C.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=k2(pve,r),l=Xwe(pve,r),i=Oa(s,o.onViewportChange),c=C.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(Lde.Slot,{scope:r,children:e.jsx(Jr.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Mr(a.onScroll,u=>{const p=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:y}=l;if(y!=null&&y.current&&f){const _=Math.abs(c.current-p.scrollTop);if(_>0){const b=window.innerHeight-wx*2,w=parseFloat(f.style.minHeight),j=parseFloat(f.style.height),N=Math.max(w,j);if(N0?I:0,f.style.justifyContent="flex-end")}}}c.current=p.scrollTop})})})]})});WHe.displayName=pve;var GHe="SelectGroup",[Hjt,Wjt]=EA(GHe),Gjt=C.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=vu();return e.jsx(Hjt,{scope:r,id:a,children:e.jsx(Jr.div,{role:"group","aria-labelledby":a,...n,ref:s})})});Gjt.displayName=GHe;var KHe="SelectLabel",ZHe=C.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Wjt(KHe,r);return e.jsx(Jr.div,{id:a.id,...n,ref:s})});ZHe.displayName=KHe;var poe="SelectItem",[Kjt,YHe]=EA(poe),XHe=C.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=j2(poe,r),c=k2(poe,r),u=i.value===n,[p,f]=C.useState(o??""),[y,_]=C.useState(!1),b=Oa(s,S=>{var T;return(T=c.itemRefCallback)==null?void 0:T.call(c,S,n,a)}),w=vu(),j=C.useRef("touch"),N=()=>{a||(i.onValueChange(n),i.onOpenChange(!1))};if(n==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(Kjt,{scope:r,value:n,disabled:a,textId:w,isSelected:u,onItemTextChange:C.useCallback(S=>{f(T=>T||((S==null?void 0:S.textContent)??"").trim())},[]),children:e.jsx(Lde.ItemSlot,{scope:r,value:n,disabled:a,textValue:p,children:e.jsx(Jr.div,{role:"option","aria-labelledby":w,"data-highlighted":y?"":void 0,"aria-selected":u&&y,"data-state":u?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:b,onFocus:Mr(l.onFocus,()=>_(!0)),onBlur:Mr(l.onBlur,()=>_(!1)),onClick:Mr(l.onClick,()=>{j.current!=="mouse"&&N()}),onPointerUp:Mr(l.onPointerUp,()=>{j.current==="mouse"&&N()}),onPointerDown:Mr(l.onPointerDown,S=>{j.current=S.pointerType}),onPointerMove:Mr(l.onPointerMove,S=>{var T;j.current=S.pointerType,a?(T=c.onItemLeave)==null||T.call(c):j.current==="mouse"&&S.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Mr(l.onPointerLeave,S=>{var T;S.currentTarget===document.activeElement&&((T=c.onItemLeave)==null||T.call(c))}),onKeyDown:Mr(l.onKeyDown,S=>{var I;((I=c.searchRef)==null?void 0:I.current)!==""&&S.key===" "||(Ijt.includes(S.key)&&N(),S.key===" "&&S.preventDefault())})})})})});XHe.displayName=poe;var sI="SelectItemText",QHe=C.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=j2(sI,r),i=k2(sI,r),c=YHe(sI,r),u=Rjt(sI,r),[p,f]=C.useState(null),y=Oa(s,N=>f(N),c.onItemTextChange,N=>{var S;return(S=i.itemTextRefCallback)==null?void 0:S.call(i,N,c.value,c.disabled)}),_=p==null?void 0:p.textContent,b=C.useMemo(()=>e.jsx("option",{value:c.value,disabled:c.disabled,children:_},c.value),[c.disabled,c.value,_]),{onNativeOptionAdd:w,onNativeOptionRemove:j}=u;return fd(()=>(w(b),()=>j(b)),[w,j,b]),e.jsxs(e.Fragment,{children:[e.jsx(Jr.span,{id:c.textId,...o,ref:y}),c.isSelected&&l.valueNode&&!l.valueNodeHasChildren?cp.createPortal(o.children,l.valueNode):null]})});QHe.displayName=sI;var JHe="SelectItemIndicator",eWe=C.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return YHe(JHe,r).isSelected?e.jsx(Jr.span,{"aria-hidden":!0,...n,ref:s}):null});eWe.displayName=JHe;var fve="SelectScrollUpButton",tWe=C.forwardRef((t,s)=>{const r=k2(fve,t.__scopeSelect),n=Xwe(fve,t.__scopeSelect),[a,o]=C.useState(!1),l=Oa(s,n.onScrollButtonChange);return fd(()=>{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(rWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=r;i&&c&&(i.scrollTop=i.scrollTop-c.offsetHeight)}}):null});tWe.displayName=fve;var gve="SelectScrollDownButton",sWe=C.forwardRef((t,s)=>{const r=k2(gve,t.__scopeSelect),n=Xwe(gve,t.__scopeSelect),[a,o]=C.useState(!1),l=Oa(s,n.onScrollButtonChange);return fd(()=>{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(rWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=r;i&&c&&(i.scrollTop=i.scrollTop+c.offsetHeight)}}):null});sWe.displayName=gve;var rWe=C.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=k2("SelectScrollButton",r),l=C.useRef(null),i=Dde(r),c=C.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return C.useEffect(()=>()=>c(),[c]),fd(()=>{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(Jr.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Mr(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Mr(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Mr(a.onPointerLeave,()=>{c()})})}),Zjt="SelectSeparator",nWe=C.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(Jr.div,{"aria-hidden":!0,...n,ref:s})});nWe.displayName=Zjt;var xve="SelectArrow",Yjt=C.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Ode(r),o=j2(xve,r),l=k2(xve,r);return o.open&&l.position==="popper"?e.jsx(rO,{...a,...n,ref:s}):null});Yjt.displayName=xve;var Xjt="SelectBubbleInput",aWe=C.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=C.useRef(null),o=Oa(n,a),l=mO(s);return C.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(Jr.select,{...r,style:{...s$e,...r.style},ref:o,defaultValue:s})});aWe.displayName=Xjt;function iWe(t){return t===""||t===void 0}function oWe(t){const s=dd(t),r=C.useRef(""),n=C.useRef(0),a=C.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=C.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return C.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function lWe(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=Qjt(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 Qjt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var Jjt=DHe,cWe=RHe,ekt=zHe,tkt=BHe,skt=$He,dWe=qHe,rkt=WHe,uWe=ZHe,hWe=XHe,nkt=QHe,akt=eWe,mWe=tWe,pWe=sWe,fWe=nWe;const rr=Jjt,nr=ekt,tr=C.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(cWe,{ref:n,className:At("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(tkt,{asChild:!0,children:e.jsx(tl,{className:"h-4 w-4 opacity-50"})})]}));tr.displayName=cWe.displayName;const gWe=C.forwardRef(({className:t,...s},r)=>e.jsx(mWe,{ref:r,className:At("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(Hx,{className:"h-4 w-4"})}));gWe.displayName=mWe.displayName;const xWe=C.forwardRef(({className:t,...s},r)=>e.jsx(pWe,{ref:r,className:At("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(tl,{className:"h-4 w-4"})}));xWe.displayName=pWe.displayName;const sr=C.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(skt,{children:e.jsxs(dWe,{ref:a,className:At("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,...n,children:[e.jsx(gWe,{}),e.jsx(rkt,{className:At("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(xWe,{})]})}));sr.displayName=dWe.displayName;const ikt=C.forwardRef(({className:t,...s},r)=>e.jsx(uWe,{ref:r,className:At("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));ikt.displayName=uWe.displayName;const Tt=C.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(hWe,{ref:n,className:At("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(akt,{children:e.jsx(ma,{className:"h-4 w-4"})})}),e.jsx(nkt,{children:s})]}));Tt.displayName=hWe.displayName;const okt=C.forwardRef(({className:t,...s},r)=>e.jsx(fWe,{ref:r,className:At("-mx-1 my-1 h-px bg-muted",t),...s}));okt.displayName=fWe.displayName;const lkt=t=>wt({queryKey:["public-listings",t],queryFn:async()=>{let s=G.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, latitude, longitude, created_at, updated_at, photos:listing_photos(id, photo_url, is_primary), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("is_public",!0).order("created_at",{ascending:!1});t!=null&&t.status&&(s=s.eq("status",t.status)),t!=null&&t.propertyType&&(s=s.eq("property_type",t.propertyType)),t!=null&&t.city&&(s=s.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(s=s.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(s=s.lte("price",t.maxPrice));const{data:r,error:n}=await s;if(n)throw n;return r}}),yWe=t=>wt({queryKey:["public-listing",t],queryFn:async()=>{const s=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t);let r=G.from("listings").select(` id, slug, agent_id, property_address, city, state, neighborhood, price, property_type, status, bedrooms, bathrooms, square_footage, lot_size, year_built, has_hoa, description, agent_notes, agent_notes_public, mls_link, video_link, video_id, latitude, longitude, created_at, updated_at, photos:listing_photos(id, photo_url, is_primary, sort_order), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage:brokerages(name)), video:agent_videos!listings_video_id_fkey(id, playback_url, thumbnail_url, title, duration_seconds, bunny_video_id) `).eq("is_approved",!0).eq("is_public",!0);s?r=r.eq("id",t):r=r.eq("slug",t);const{data:n,error:a}=await r.single();if(a)throw a;return n},enabled:!!t}),vWe=()=>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:y}=await G.from("listing_shares").select("id, sharing_agent_id").eq("share_token",l).eq("listing_id",t).maybeSingle();y&&(i=y.id,c=y.sharing_agent_id)}const{data:u,error:p}=await G.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 G.functions.invoke("process-listing-lead",{body:{leadId:u.id}});return f&&console.error("Error processing lead:",f),u}}),ckt=()=>Dt({mutationFn:async t=>{const{error:s}=await G.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),dkt={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},AEe={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},ukt={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function _We(){const[t,s]=C.useState(""),[r,n]=C.useState(!1),[a,o]=C.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=lkt({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(qh,{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(So,{to:"/public/listings",className:"flex items-center",children:e.jsx("img",{src:PHe,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(${Mjt})`},children:[e.jsx("div",{className:"absolute inset-0 bg-black/40"}),e.jsxs("div",{className:"relative max-w-7xl mx-auto px-4",children:[e.jsx("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold text-white mb-3 text-center drop-shadow-lg",children:"Find Your Perfect Home"}),e.jsx("p",{className:"text-white/90 text-center mb-10 text-lg md:text-xl drop-shadow",children:"Exclusive listings from LevelUp agents"}),e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsxs("div",{className:"flex gap-0 shadow-2xl rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"relative flex-1 bg-white",children:[e.jsx(xn,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx(Fe,{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(xn,{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(uL,{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(rr,{value:a.status||"all",onValueChange:f=>o({...a,status:f==="all"?"":f}),children:[e.jsx(tr,{className:"bg-white",children:e.jsx(nr,{placeholder:"Any status"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"Any status"}),Object.entries(AEe).map(([f,y])=>e.jsx(Tt,{value:f,children:y},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(rr,{value:a.propertyType||"all",onValueChange:f=>o({...a,propertyType:f==="all"?"":f}),children:[e.jsx(tr,{className:"bg-white",children:e.jsx(nr,{placeholder:"Any type"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"Any type"}),Object.entries(ukt).map(([f,y])=>e.jsx(Tt,{value:f,children:y},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(Fe,{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(Fe,{type:"number",placeholder:"No max",value:a.maxPrice,onChange:f=>o({...a,maxPrice:f.target.value}),className:"bg-white"})]})]}),p&&e.jsx("div",{className:"flex justify-end mt-4",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:u,className:"gap-1 text-gray-500",children:[e.jsx(Ur,{className:"h-4 w-4"}),"Clear all"]})})]})]})]})]}),l&&l.length>0&&e.jsx("section",{className:"py-8 bg-white border-b border-gray-200",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"Explore on Map"}),e.jsx(Ejt,{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,y)=>e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm",children:[e.jsx(xs,{className:"aspect-[4/3]"}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsx(xs,{className:"h-7 w-28"}),e.jsx(xs,{className:"h-4 w-full"}),e.jsx(xs,{className:"h-4 w-3/4"})]})]},y))}):l&&l.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("h2",{className:"text-xl font-semibold text-gray-900",children:[l.length," ",l.length===1?"Home":"Homes"," Available"]})}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5",children:l.map(f=>{var w,j,N;const y=((w=f.photos)==null?void 0:w.find(S=>S.is_primary))||((j=f.photos)==null?void 0:j[0]),b=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${f.slug||f.id}`:`/public/listing/${f.slug||f.id}`;return e.jsx(So,{to:b,children:e.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm hover:shadow-lg transition-shadow cursor-pointer group border border-gray-100",children:[e.jsxs("div",{className:"aspect-[4/3] relative overflow-hidden bg-gray-100",children:[y?e.jsx("img",{src:y.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(Rn,{className:"h-12 w-12 text-gray-300"})}),e.jsx(nt,{className:`absolute top-2 left-2 ${dkt[f.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:AEe[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(Ii,{className:"h-5 w-5 text-gray-600"})})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("p",{className:"text-xl font-bold text-gray-900 mb-1",children:c(f.price)}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-700 mb-2",children:[f.bedrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bedrooms}),e.jsx("span",{className:"text-gray-500",children:"bds"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.bathrooms&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.bathrooms}),e.jsx("span",{className:"text-gray-500",children:"ba"}),e.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),f.square_footage&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold",children:f.square_footage.toLocaleString()}),e.jsx("span",{className:"text-gray-500",children:"sqft"})]})]}),f.property_address&&e.jsx("p",{className:"text-sm text-gray-700 truncate",children:f.property_address}),e.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[f.city,", ",f.state]}),f.agent&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[e.jsx("p",{className:"text-xs text-gray-500 truncate",children:f.agent.name}),((N=f.agent.brokerage)==null?void 0:N.name)&&e.jsx("p",{className:"text-xs text-gray-400 truncate",children:f.agent.brokerage.name})]})]})]})},f.id)})})]}):e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-4 rounded-full bg-gray-100 flex items-center justify-center",children:e.jsx(Rn,{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:Ywe,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=C.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:At("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Ee.displayName="Card";const It=C.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:At("flex flex-col space-y-1.5 p-6",t),...s}));It.displayName="CardHeader";const Ot=C.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:At("text-2xl font-semibold leading-none tracking-tight",t),...s}));Ot.displayName="CardTitle";const fr=C.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:At("text-sm text-muted-foreground",t),...s}));fr.displayName="CardDescription";const Oe=C.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:At("p-6 pt-0",t),...s}));Oe.displayName="CardContent";const jL=C.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:At("flex items-center p-6 pt-0",t),...s}));jL.displayName="CardFooter";var hkt="Label",bWe=C.forwardRef((t,s)=>e.jsx(Jr.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())}}));bWe.displayName=hkt;var wWe=bWe;const mkt=HS("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),_e=C.forwardRef(({className:t,...s},r)=>e.jsx(wWe,{ref:r,className:At(mkt(),t),...s}));_e.displayName=wWe.displayName;const foe="/assets/levelup-logo-color-D3mY9gCJ.png";function pkt(){const t=Qu(),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(_We,{}):n.startsWith("public/")?null:e.jsx(fkt,{slug:n})}function fkt({slug:t}){return e.jsx(ykt,{slug:t})}const gkt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},xkt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},EEe={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function ykt({slug:t}){var U,V;const{data:s,isLoading:r}=yWe(t),n=vWe(),[a,o]=C.useState(""),[l,i]=C.useState(""),[c,u]=C.useState(""),[p,f]=C.useState(""),[y,_]=C.useState(!1),[b,w]=C.useState(!1),[j,N]=C.useState(null),S=X=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(X),T=async X=>{if(X.preventDefault(),!(!a.trim()||!c.trim()||!s)){_(!0);try{await n.mutateAsync({listingId:s.id,agentId:s.agent_id,firstName:a.trim(),lastName:l.trim(),email:c.trim(),phone:p.trim()}),w(!0),me.success("Thanks! The agent will be in touch soon.")}catch(se){console.error("Lead submission error:",se),me.error(`Failed to submit: ${se.message||"Please try again"}`)}finally{_(!1)}}},I=(s==null?void 0:s.photos)||[],L=I.find(X=>X.is_primary)||I[0],R=()=>{j!==null&&N(j===0?I.length-1:j-1)},$=()=>{j!==null&&N(j===I.length-1?0:j+1)};if(r)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx(xs,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(xs,{className:"h-10 w-48 mb-6"}),e.jsx(xs,{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(xs,{className:"h-12 w-48"}),e.jsx(xs,{className:"h-6 w-full"}),e.jsx(xs,{className:"h-6 w-3/4"})]}),e.jsx(xs,{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:foe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Rn,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),e.jsx(K,{asChild:!0,children:e.jsx("a",{href:"/",children:"Browse All Listings"})})]})]});const q=s.property_address?`${s.property_address} - ${s.city}, ${s.state}`:`${s.city}, ${s.state} Home for Sale`;return e.jsxs(e.Fragment,{children:[e.jsxs(qh,{children:[e.jsxs("title",{children:[q," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft":""} ${EEe[s.property_type]} in ${s.city}, ${s.state}. ${((U=s.description)==null?void 0:U.slice(0,150))||""}`}),e.jsx("meta",{property:"og:title",content:q}),e.jsx("meta",{property:"og:description",content:`${S(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA in ${s.city}, ${s.state}`}),e.jsx("meta",{property:"og:type",content:"website"}),L&&e.jsx("meta",{property:"og:image",content:L.photo_url})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("a",{href:"/",className:"flex items-center gap-2",children:e.jsx("img",{src:foe,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(di,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),I.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>N(0),children:e.jsx("img",{src:L==null?void 0:L.photo_url,alt:"Primary",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:I.slice(1,5).map((X,se)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>N(se+1),children:[e.jsx("img",{src:X.photo_url,alt:`Photo ${se+2}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),se===3&&I.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",I.length-5," more"]})]},X.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(nt,{className:`${gkt[s.status]} text-white border-0`,children:xkt[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(Ui,{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(Kv,{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(n0,{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(c0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),s.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(on,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:s.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(nt,{variant:"secondary",children:[e.jsx(La,{className:"h-3 w-3 mr-1"}),EEe[s.property_type]]}),s.lot_size&&e.jsxs(nt,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(nt,{variant:"secondary",children:"HOA"})]}),s.description&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})]}),s.agent_notes&&s.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.agent_notes})]}),s.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:s.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{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(It,{children:e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(ro,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-semibold text-lg",children:s.agent.name}),((V=s.agent.brokerage)==null?void 0:V.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.agent.brokerage.name})]})]}),e.jsxs(Ee,{className:"border-primary",children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Oe,{children:b?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:e.jsx(br,{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:T,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Fe,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:X=>o(X.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Fe,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:X=>i(X.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"email",children:"Email *"}),e.jsx(Fe,{id:"email",type:"email",placeholder:"you@example.com",value:c,onChange:X=>u(X.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"phone",children:"Phone"}),e.jsx(Fe,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:p,onChange:X=>f(X.target.value)})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:y,children:y?"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(_s,{open:j!==null,onOpenChange:()=>N(null),children:e.jsxs(vs,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(Cs,{className:"sr-only",children:e.jsx(Ns,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>N(null),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Ur,{className:"h-5 w-5"})}),j!==null&&I[j]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:I[j].photo_url,alt:`Photo ${j+1}`,className:"w-full max-h-[80vh] object-contain"}),I.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:R,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Xl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:$,className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Xa,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[j+1," / ",I.length]})]})]})]})}),e.jsx("footer",{className:"border-t py-8 mt-16",children:e.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[e.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),e.jsx("p",{className:"mt-2",children:e.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function Rde({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 jWe=t=>wt({queryKey:["agent-card-public",t],queryFn:async()=>{if(!t)throw new Error("No slug provided");const{data:s,error:r}=await G.from("agent_cards").select("*").eq("slug",t).eq("is_published",!0).single();if(r)throw r;const{data:n}=await G.from("profiles").select("name, email, phone, brokerage_id").eq("id",s.user_id).single();let a=null;if(n!=null&&n.brokerage_id){const{data:i}=await G.from("brokerages").select("name").eq("id",n.brokerage_id).single();a=(i==null?void 0:i.name)||null}let o=null;try{const{data:i}=await G.from("profiles").select("avatar_url").eq("id",s.user_id).single();if(i!=null&&i.avatar_url)o=i.avatar_url;else{const{data:c}=await G.storage.from("avatars").list(`${s.user_id}`);if(c&&c.length>0){const{data:u}=G.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}),vkt=()=>wt({queryKey:["agent-cards-admin"],queryFn:async()=>{const{data:t,error:s}=await G.from("agent_cards").select("*").order("created_at",{ascending:!1});if(s)throw s;return t}}),_kt=t=>wt({queryKey:["agent-card",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("agent_cards").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),kWe=()=>{const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("agent_cards").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),me.success("Agent card created")},onError:s=>me.error(s.message)})},NWe=()=>{const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("agent_cards").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["agent-cards-admin"]}),t.invalidateQueries({queryKey:["agent-card"]}),me.success("Agent card updated")},onError:s=>me.error(s.message)})},ho=async(t,s,r,n)=>{const a=new URLSearchParams(window.location.search);await G.from("agent_card_interactions").insert({card_id:t,interaction_type:s,interaction_detail:r||null,referrer:document.referrer||null,user_agent:navigator.userAgent||null,utm_source:a.get("utm_source")||null,utm_medium:a.get("utm_medium")||null,utm_campaign:a.get("utm_campaign")||null,metadata:{}})},bkt=async(t,s)=>{const{error:r}=await G.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},SWe=t=>wt({queryKey:["agent-card-analytics",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("agent_card_interactions").select("interaction_type, interaction_detail, created_at").eq("card_id",t).order("created_at",{ascending:!1}).limit(500);if(r)throw r;const{data:n,error:a}=await G.from("agent_card_leads").select("*").eq("card_id",t).order("created_at",{ascending:!1});if(a)throw a;const o=(s==null?void 0:s.filter(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 Fde({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=C.useState(""),[i,c]=C.useState(""),[u,p]=C.useState(""),[f,y]=C.useState(""),[_,b]=C.useState(""),[w,j]=C.useState(!1),N=async S=>{if(S.preventDefault(),!o.trim()){me.error("Please enter your name");return}j(!0);try{await bkt(r,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:_.trim()||void 0,intent:f||void 0}),ho(r,"lead_submitted",n),G.functions.invoke("card-lead-notify",{body:{cardId:r,leadType:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:_.trim()||void 0,intent:f||void 0}}).catch(T=>console.error("Card lead notify failed:",T)),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(""),y(""),b("")}catch{me.error("Something went wrong. Please try again.")}finally{j(!1)}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:n==="booking"?"Book a Call":n==="connect"?"Connect with Me":"Refer a Friend"}),e.jsx(Zr,{children:n==="booking"?`Let ${a} know you'd like to connect.`:n==="connect"?`Share your info and ${a} will reach out.`:`Know someone who could use ${a}'s help?`})]}),e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"lead-name",children:"Name *"}),e.jsx(Fe,{id:"lead-name",value:o,onChange:S=>l(S.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"lead-phone",children:"Phone"}),e.jsx(Fe,{id:"lead-phone",type:"tel",value:u,onChange:S=>p(S.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"lead-email",children:"Email"}),e.jsx(Fe,{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(_e,{htmlFor:"lead-intent",children:"I'm looking to..."}),e.jsxs(rr,{value:f,onValueChange:y,children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select one"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"buy",children:"Buy a home"}),e.jsx(Tt,{value:"sell",children:"Sell my home"}),e.jsx(Tt,{value:"both",children:"Buy & Sell"}),e.jsx(Tt,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),e.jsx(Fe,{id:"lead-message",value:_,onChange:S=>b(S.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full rounded-2xl",disabled:w,children:w?"Sending...":"Submit"})]})]})})}const wkt=t=>wt({queryKey:["card-blocks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("card_blocks").select("*").eq("card_id",t).eq("is_visible",!0).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),jkt=t=>wt({queryKey:["card-blocks-all",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("card_blocks").select("*").eq("card_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s||[]},enabled:!!t}),kkt=()=>{const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("card_blocks").insert(s).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["card-blocks",r.card_id]}),t.invalidateQueries({queryKey:["card-blocks-all",r.card_id]}),me.success("Block added")},onError:s=>me.error(s.message)})},Nkt=()=>{const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("card_blocks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),me.success("Block updated")},onError:s=>me.error(s.message)})},Skt=()=>{const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("card_blocks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["card-blocks"]}),t.invalidateQueries({queryKey:["card-blocks-all"]}),me.success("Block removed")},onError:s=>me.error(s.message)})};function Ckt(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 Mkt(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 Tkt={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 Akt({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=Mkt(r.video_url),o=n||!!a,l=n?Ckt(r.video_url):a||r.video_url;return e.jsx("div",{className:Tkt[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 Ekt={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 Pkt({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=C.useState(0);if(n.length===0)return null;const l=Ekt[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(bM,{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(Xl,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex gap-1.5",children:n.map((c,u)=>e.jsx("div",{className:`h-1.5 w-1.5 rounded-full transition-colors cursor-pointer ${u===a?l.dot:l.dotInactive}`,onClick:()=>o(u)},u))}),e.jsx("button",{onClick:()=>o(c=>(c+1)%n.length),className:l.nav,children:e.jsx(Xa,{className:"h-4 w-4"})})]})]})}const Ikt={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 Lkt({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=Ikt[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const Dkt={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 Okt({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=Dkt[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:()=>ho(s,"button_click",`custom_link_${l.label}`),className:o.link,children:[e.jsx("span",{children:l.label}),e.jsx(rn,{className:`h-4 w-4 ${o.icon}`})]},i))})}const yve={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 Rkt({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 Fkt={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 zkt({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=Fkt[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=yve[l.platform.toLowerCase()];return!c||!l.url?null:e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ho(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:c.label,children:e.jsx(Rkt,{path:c.icon,color:c.color})},i)})})]})}function zde({cardId:t,variant:s}){const{data:r}=wkt(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(Akt,{block:l,variant:s},l.id);case"testimonials":return e.jsx(Pkt,{block:l,variant:s},l.id);case"specialties":return e.jsx(Lkt,{block:l,variant:s},l.id);case"custom_links":return e.jsx(Okt,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx(zkt,{block:o,cardId:t,variant:s})]})}async function Bkt(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 $kt(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 Bde(t){const{first:s,last:r}=$kt(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 Bkt(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 qkt({card:t}){var N;const[s,r]=C.useState(!1),[n,a]=C.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,T)=>{ho(t.id,"button_click",S),T()},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),ho(t.id,"button_click","book"))},y=()=>{var S,T;ho(t.id,"contact_saved"),Bde({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(T=t.profile)==null?void 0:T.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(ho(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!")},b=()=>{a("referral"),r(!0),ho(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),ho(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-white to-slate-50",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(yn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Da,{src:t.avatar_url||void 0,alt:o}),e.jsx(vn,{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(ea,{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(po,{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(br,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),e.jsxs(K,{onClick:f,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[e.jsx(on,{className:"h-5 w-5 mr-2"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm text-slate-600",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Kn,{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(Rde,{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:y,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(ki,{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:()=>{ho(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(Kn,{className:"h-4 w-4 mr-3 text-amber-500"}),"Leave a Review"]}),t.show_refer_friend&&e.jsxs(K,{variant:"ghost",onClick:b,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(mr,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),e.jsxs(K,{variant:"ghost",onClick:w,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Pc,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),e.jsxs(K,{variant:"ghost",onClick:_,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(Ad,{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,T)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ho(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-lg transition-colors",children:j[S.platform.toLowerCase()]||"🔗"},T))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),e.jsx(Fde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Ukt({card:t}){var N;const[s,r]=C.useState(!1),[n,a]=C.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,T)=>{ho(t.id,"button_click",S),T()},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),ho(t.id,"button_click","book"))},y=()=>{var S,T;ho(t.id,"contact_saved"),Bde({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(T=t.profile)==null?void 0:T.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(ho(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!")},b=()=>{a("referral"),r(!0),ho(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),ho(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-[#0f1419] via-[#1a1f2e] to-[#0f1419]",children:[e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsx("div",{className:"w-16 h-0.5 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] mx-auto mb-8"}),e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(yn,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[e.jsx(Da,{src:t.avatar_url||void 0,alt:o}),e.jsx(vn,{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:ea,label:"Call",handler:c},{icon:po,label:"Text",handler:u},{icon:br,label:"Email",handler:p}].map(({icon:S,label:T,handler:I})=>e.jsxs("button",{onClick:I,className:"flex flex-col items-center gap-1.5 py-4 bg-[#1e2636] hover:bg-[#252d3f] border border-[#c9a84c]/20 rounded-xl transition-colors",children:[e.jsx(S,{className:"h-5 w-5 text-[#c9a84c]"}),e.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:T})]},T))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-xl mb-6 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] text-[#0f1419] hover:opacity-90 transition-opacity flex items-center justify-center gap-2",children:[e.jsx(on,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Kn,{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(Rde,{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:y,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(ki,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{ho(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(Kn,{className:"h-4 w-4 text-[#c9a84c]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(mr,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(Pc,{className:"h-4 w-4 text-[#c9a84c]"})," Connect with Me"]}),e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[e.jsx(Ad,{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,T)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ho(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-[#1e2636] border border-[#c9a84c]/20 hover:border-[#c9a84c]/50 flex items-center justify-center text-lg transition-colors",children:j[S.platform.toLowerCase()]||"🔗"},T))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(Fde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Vkt({card:t}){var T,I,L,R;const[s,r]=C.useState(!1),[n,a]=C.useState("booking"),o=((T=t.profile)==null?void 0:T.name)||"Agent",l=o.split(" ").map($=>$[0]).join("").toUpperCase().slice(0,2),i={accent:((I=t.bold_theme_colors)==null?void 0:I.accent)||"#ff5722",dark:((L=t.bold_theme_colors)==null?void 0:L.dark)||"#1a1a2e",button:((R=t.bold_theme_colors)==null?void 0:R.button)||"#ff5722"},c=($,q)=>{const U=parseInt($.replace("#",""),16),V=Math.max(0,(U>>16)-q),X=Math.max(0,(U>>8&255)-q),se=Math.max(0,(U&255)-q);return`#${(V<<16|X<<8|se).toString(16).padStart(6,"0")}`};c(i.accent,25),c(i.dark,-20),c(i.button,25);const u=($,q)=>{ho(t.id,"button_click",$),q()},p=()=>u("call",()=>{var $;($=t.profile)!=null&&$.phone?window.location.href=`tel:${t.profile.phone}`:me.error("Phone number not available")}),f=()=>u("text",()=>{var $;($=t.profile)!=null&&$.phone?window.location.href=`sms:${t.profile.phone}`:me.error("Phone number not available")}),y=()=>u("email",()=>{var $;($=t.profile)!=null&&$.email?window.location.href=`mailto:${t.profile.email}`:me.error("Email not available")}),_=()=>{t.booking_url?u("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),ho(t.id,"button_click","book"))},b=()=>{var $,q;ho(t.id,"contact_saved"),Bde({name:o,phone:($=t.profile)==null?void 0:$.phone,email:(q=t.profile)==null?void 0:q.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},w=async()=>{if(ho(t.id,"share_event"),navigator.share)try{await navigator.share({title:`${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),me.success("Link copied!")},j=()=>{a("referral"),r(!0),ho(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),ho(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(yn,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[e.jsx(Da,{src:t.avatar_url||void 0,alt:o}),e.jsx(vn,{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:ea,label:"Call",handler:p},{icon:po,label:"Text",handler:f},{icon:br,label:"Email",handler:y}].map(({icon:$,label:q,handler:U})=>e.jsxs("button",{onClick:U,className:"flex flex-col items-center gap-1.5 py-4 text-white rounded-2xl transition-opacity font-bold hover:opacity-85",style:{backgroundColor:i.dark},children:[e.jsx($,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:q})]},q))}),e.jsxs("button",{onClick:_,className:"w-full h-14 text-base font-black rounded-2xl mb-6 text-white transition-opacity hover:opacity-90 flex items-center justify-center gap-2 uppercase tracking-wide",style:{backgroundColor:i.button},children:[e.jsx(on,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"flex items-center justify-center gap-5 mb-6",children:t.review_snippet&&e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Kn,{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(Rde,{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:b,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(ki,{className:"h-4 w-4",style:{color:i.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{ho(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(Kn,{className:"h-4 w-4",style:{color:i.accent}})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:j,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(mr,{className:"h-4 w-4",style:{color:i.accent}})," Refer a Friend"]}),e.jsxs("button",{onClick:N,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(Pc,{className:"h-4 w-4",style:{color:i.accent}})," Connect with Me"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 rounded-2xl hover:bg-gray-100 transition-colors text-sm font-bold",style:{color:i.dark},children:[e.jsx(Ad,{className:"h-4 w-4",style:{color:i.accent}})," Share My Card"]})]}),t.show_social_links&&t.social_links&&t.social_links.length>0&&e.jsx("div",{className:"flex justify-center gap-4 mb-6",children:t.social_links.slice(0,3).map(($,q)=>e.jsx("a",{href:$.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ho(t.id,"button_click",`social_${$.platform}`),className:"h-10 w-10 rounded-full flex items-center justify-center text-lg transition-opacity hover:opacity-85",style:{backgroundColor:i.dark},children:S[$.platform.toLowerCase()]||"🔗"},q))})]}),e.jsx("div",{className:"text-center py-6",children:e.jsx("p",{className:"text-xs text-white/50",children:"Powered by LevelUp"})})]}),e.jsx(Fde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Hkt({card:t}){var N;const[s,r]=C.useState(!1),[n,a]=C.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),i=(S,T)=>{ho(t.id,"button_click",S),T()},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),ho(t.id,"button_click","book"))},y=()=>{var S,T;ho(t.id,"contact_saved"),Bde({name:o,phone:(S=t.profile)==null?void 0:S.phone,email:(T=t.profile)==null?void 0:T.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},_=async()=>{if(ho(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!")},b=()=>{a("referral"),r(!0),ho(t.id,"button_click","refer")},w=()=>{a("connect"),r(!0),ho(t.id,"button_click","connect")},j={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return e.jsxs("div",{className:"min-h-screen bg-[#f5f1eb]",children:[e.jsx("div",{className:"bg-[#1b3a4b] h-2"}),e.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[t.show_photo&&e.jsxs(yn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(Da,{src:t.avatar_url||void 0,alt:o}),e.jsx(vn,{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:ea,label:"Call",handler:c},{icon:po,label:"Text",handler:u},{icon:br,label:"Email",handler:p}].map(({icon:S,label:T,handler:I})=>e.jsxs("button",{onClick:I,className:"flex flex-col items-center gap-1.5 py-4 bg-white hover:bg-[#e8e3db] border border-[#d4cfc5] rounded-lg transition-colors shadow-sm",children:[e.jsx(S,{className:"h-5 w-5 text-[#1b3a4b]"}),e.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:T})]},T))}),e.jsxs("button",{onClick:f,className:"w-full h-12 text-base font-semibold rounded-lg mb-6 bg-[#1b3a4b] hover:bg-[#264d61] text-white transition-colors flex items-center justify-center gap-2 shadow-sm",children:[e.jsx(on,{className:"h-5 w-5"}),t.custom_cta_label||"Book a Call"]}),t.show_credentials&&t.review_snippet&&e.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:e.jsx("div",{className:"flex items-center justify-center gap-6",children:e.jsxs("div",{className:"text-center flex items-center gap-1",children:[e.jsx(Kn,{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(Rde,{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:y,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(ki,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{ho(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(Kn,{className:"h-4 w-4 text-[#d4a843]"})," Leave a Review"]}),t.show_refer_friend&&e.jsxs("button",{onClick:b,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(mr,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),e.jsxs("button",{onClick:w,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(Pc,{className:"h-4 w-4 text-[#5a7a6f]"})," Connect with Me"]}),e.jsxs("button",{onClick:_,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[e.jsx(Ad,{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,T)=>e.jsx("a",{href:S.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ho(t.id,"button_click",`social_${S.platform}`),className:"h-10 w-10 rounded-full bg-white border border-[#d4cfc5] hover:bg-[#e8e3db] flex items-center justify-center text-lg transition-colors shadow-sm",children:j[S.platform.toLowerCase()]||"🔗"},T))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(Fde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Qwe({card:t}){switch(t.theme){case"luxury":return e.jsx(Ukt,{card:t});case"bold":return e.jsx(Vkt,{card:t});case"classic":return e.jsx(Hkt,{card:t});case"standard":default:return e.jsx(qkt,{card:t})}}function Wkt(){const t=Qu();C.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(Gkt,{slug:s})}function Gkt({slug:t}){return e.jsx(Kkt,{slug:t})}function Kkt({slug:t}){var o;const{data:s,isLoading:r,error:n}=jWe(t);if(C.useEffect(()=>{s!=null&&s.id&&ho(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(xs,{className:"h-28 w-28 rounded-full"}),e.jsx(xs,{className:"h-6 w-48"}),e.jsx(xs,{className:"h-4 w-36"})]}),e.jsx(xs,{className:"h-12 w-full"}),e.jsx(xs,{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(qh,{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(Qwe,{card:s})]})}function CWe({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=C.useState(n||""),[c,u]=C.useState(a||""),[p,f]=C.useState(o||""),[y,_]=C.useState(""),[b,w]=C.useState(""),[j,N]=C.useState(!1),[S,T]=C.useState(!1),I=async L=>{if(L.preventDefault(),!l.trim()){me.error("Please enter your name");return}N(!0);try{const{error:R}=await G.from("smart_presentation_leads").insert({presentation_id:t,name:l.trim(),email:c.trim()||null,phone:p.trim()||null,intent:y||null,message:b.trim()||null});if(R)throw R;try{await G.rpc("log_presentation_view",{p_presentation_id:t,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}G.functions.invoke("presentation-lead-notify",{body:{presentationId:t,name:l.trim(),email:c.trim()||void 0,phone:p.trim()||void 0,intent:y||void 0,message:b.trim()||void 0}}).catch($=>console.error("Presentation lead notify failed:",$)),T(!0)}catch{me.error("Something went wrong. Please try again.")}finally{N(!1)}};return S?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(ma,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Thank you!"}),e.jsx("p",{className:"text-gray-500",children:r?`${r} will be in touch soon.`:"We'll be in touch soon."})]}):e.jsxs("form",{onSubmit:I,className:"space-y-4 max-w-md mx-auto",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"pres-lead-name",children:"Name *"}),e.jsx(Fe,{id:"pres-lead-name",value:l,onChange:L=>i(L.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"pres-lead-phone",children:"Phone"}),e.jsx(Fe,{id:"pres-lead-phone",type:"tel",value:p,onChange:L=>f(L.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"pres-lead-email",children:"Email"}),e.jsx(Fe,{id:"pres-lead-email",type:"email",value:c,onChange:L=>u(L.target.value),placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),e.jsxs(rr,{value:y,onValueChange:_,children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select one"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"buy",children:"Buy a home"}),e.jsx(Tt,{value:"sell",children:"Sell my home"}),e.jsx(Tt,{value:"both",children:"Buy & Sell"}),e.jsx(Tt,{value:"other",children:"Something else"})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"pres-lead-message",children:"Message (optional)"}),e.jsx(Fe,{id:"pres-lead-message",value:b,onChange:L=>w(L.target.value),placeholder:"Anything you'd like us to know"})]}),e.jsx(K,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:j,children:j?"Sending...":s})]})}function Zkt(){const t=Qu();C.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(Ykt,{shareToken:s})}function Ykt({shareToken:t}){var b;const[s,r]=C.useState(null),[n,a]=C.useState(!0),[o,l]=C.useState(0),[i,c]=C.useState(!1);C.useEffect(()=>{u()},[t]);const u=async()=>{const{data:w,error:j}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(j||!w){c(!0),a(!1);return}const{data:N}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let S;if(N!=null&&N.brokerage_id){const{data:I}=await G.from("brokerages").select("name").eq("id",N.brokerage_id).single();S=(I==null?void 0:I.name)||void 0}let T=null;if(w.contact_id){const{data:I}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",w.contact_id).single();T=I}r({...w,owner_name:N==null?void 0:N.name,owner_email:N==null?void 0:N.email,owner_phone:N==null?void 0:N.phone,owner_avatar:N==null?void 0:N.avatar_url,owner_title:(N==null?void 0:N.title)||void 0,brokerage_name:S,contact_name:T?[T.first_name,T.last_name].filter(Boolean).join(" "):void 0,contact_email:(T==null?void 0:T.email)||void 0,contact_phone:(T==null?void 0:T.phone)||void 0}),a(!1);try{await G.rpc("log_presentation_view",{p_presentation_id:w.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await G.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}},f=w=>{const j=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(j)return`https://www.youtube.com/embed/${j[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const T=w.replace("/play/","/embed/"),I=T.includes("?")?"&":"?";return`${T}${I}responsive=true`}if(w.includes("iframe.mediadelivery.net")){const T=w.includes("?")?"&":"?";return`${w}${T}responsive=true`}const N=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(N)return`https://www.loom.com/embed/${N[1]}`;const S=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return S?`https://iframe.mediadelivery.net/embed/${S[1]}/${S[2]}?responsive=true`:w};if(n)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[e.jsx(xs,{className:"h-12 w-3/4 mx-auto"}),e.jsx(xs,{className:"h-64 w-full"}),e.jsx(xs,{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 y=s.sections.filter(w=>w.is_visible!==!1),_=y[o];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsx("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-end",children:e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[_!=null&&_.video_url?e.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:f(_.video_url),className:"absolute inset-0 w-full h-full border-0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,loading:"lazy"})}):_!=null&&_.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:_.image_url,alt:_.title,className:"w-full h-auto object-cover",loading:"lazy"})}):e.jsxs("div",{className:"aspect-video bg-gradient-to-br from-blue-50 to-slate-100 rounded-xl flex flex-col items-center justify-center shadow-lg",children:[e.jsx("span",{className:"text-5xl mb-3",children:_==null?void 0:_.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:_==null?void 0:_.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:_==null?void 0:_.description})]}),(_==null?void 0:_.text)&&e.jsx("div",{className:"mt-4 p-4 bg-white rounded-lg border text-gray-700 text-sm leading-relaxed prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:_.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:y.map((w,j)=>e.jsx("button",{onClick:()=>l(j),className:At("w-full text-left p-4 rounded-xl border transition-all",o===j?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(j+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:w.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:w.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:w.description})]})]})},j))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),(b=s.cta_url)!=null&&b.trim()?e.jsxs(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(rn,{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(CWe,{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 Lg=()=>{const t=ai();return wt({queryKey:["user-team",t],queryFn:async()=>{const{data:s,error:r}=await G.from("team_members").select("id, team_id, role").eq("user_id",t).maybeSingle();if(console.log("[useUserTeam] membership query:",{userId:t,membership:s,error:r}),r)throw r;if(!s)return null;const{data:n,error:a}=await G.from("teams").select("*").eq("id",s.team_id).single();if(a)throw a;return{membershipId:s.id,teamId:s.team_id,role:s.role,team:n}},enabled:!!t,staleTime:5*60*1e3})};function Xkt(){const{user:t}=Ws(),s=ai(),{data:r}=Lg();return wt({queryKey:["open-houses",s,r==null?void 0:r.teamId,r==null?void 0:r.role],queryFn:async()=>{const{data:n,error:a}=await G.from("open_houses").select("*").eq("agent_id",s).order("event_date",{ascending:!1});if(a)throw a;let o=n||[];if((r==null?void 0:r.role)==="team_leader"&&r.teamId){const{data:l,error:i}=await G.rpc("get_team_open_houses",{_user_id:s});if(!i&&l){const c=[...new Set(l.map(f=>f.agent_id))],u={};if(c.length>0){const{data:f}=await G.from("profiles").select("id, name").in("id",c);f==null||f.forEach(y=>{y.name&&(u[y.id]=y.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 v3s(t){const{user:s}=Ws();return wt({queryKey:["open-house",t],queryFn:async()=>{const{data:r,error:n}=await G.from("open_houses").select("*").eq("id",t).single();if(n)throw n;return r},enabled:!!s&&!!t})}function MWe(t){const{user:s}=Ws(),r=ss();return C.useEffect(()=>{if(!t)return;const n=G.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()=>{G.removeChannel(n)}},[t,r]),wt({queryKey:["open-house-visitors",t],queryFn:async()=>{const{data:n,error:a}=await G.from("open_house_visitors").select("*").eq("open_house_id",t).order("created_at",{ascending:!1});if(a)throw a;return n},enabled:!!s&&!!t})}function Qkt(){const t=ss(),s=ai();return Dt({mutationFn:async r=>{const{data:n,error:a}=await G.from("open_houses").insert({...r,agent_id:s}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),fn({title:"Open house created!"})},onError:r=>{fn({title:"Error",description:r.message,variant:"destructive"})}})}function TWe(){const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{error:n}=await G.from("open_houses").update(r).eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["open-houses"]}),t.invalidateQueries({queryKey:["open-house",r.id]})}})}function Jkt(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("open_houses").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["open-houses"]}),fn({title:"Open house deleted"})}})}function eNt(t){return wt({queryKey:["public-open-house",t],queryFn:async()=>{const{data:s,error:r}=await G.from("open_houses").select("*, profiles:agent_id(name, avatar_url, title)").eq("slug",t).eq("is_active",!0).single();if(r)throw r;let n=null;if(s.agent_id){const{data:a}=await G.from("agent_cards").select("slug").eq("user_id",s.agent_id).eq("is_published",!0).maybeSingle();a&&(n=a.slug)}return{...s,agent_card_slug:n}},enabled:!!t})}function tNt(t){const{user:s}=Ws();return wt({queryKey:["survey-questions",t],queryFn:async()=>{const{data:r,error:n}=await G.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;return r},enabled:!!s&&!!t})}function sNt(t){return wt({queryKey:["public-survey-questions",t],queryFn:async()=>{const{data:s,error:r}=await G.from("open_house_survey_questions").select("*").eq("open_house_id",t).eq("is_active",!0).order("sort_order");if(r)throw r;return s},enabled:!!t})}function rNt(){return Dt({mutationFn:async t=>{const{error:s}=await G.from("open_house_survey_responses").insert(t);if(s)throw s}})}function nNt(t){const{user:s}=Ws();return wt({queryKey:["survey-responses",t],queryFn:async()=>{const{data:r,error:n}=await G.from("open_house_survey_questions").select("*").eq("open_house_id",t).order("sort_order");if(n)throw n;const a=(r||[]).map(i=>i.id);if(a.length===0)return{questions:[],responses:[]};const{data:o,error:l}=await G.from("open_house_survey_responses").select("*").in("question_id",a).order("created_at",{ascending:!1});if(l)throw l;return{questions:r,responses:o||[]}},enabled:!!s&&!!t})}function aNt(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("open_house_survey_questions").insert(s).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function iNt(){const t=ss();return Dt({mutationFn:async({id:s,open_house_id:r,...n})=>{const{error:a}=await G.from("open_house_survey_questions").update(n).eq("id",s);if(a)throw a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function oNt(){const t=ss();return Dt({mutationFn:async({id:s,open_house_id:r})=>{const{error:n}=await G.from("open_house_survey_questions").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r.open_house_id]})}})}function lNt(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.rpc("seed_default_survey_questions",{_open_house_id:s});if(r)throw r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["survey-questions",r]})}})}function cNt(){return Dt({mutationFn:async t=>{const{data:s,error:r}=await G.from("open_house_visitors").insert(t).select("id").single();if(r)throw r;return s}})}var $de="Switch",[dNt]=Yc($de),[uNt,hNt]=dNt($de),AWe=C.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,[y,_]=C.useState(null),b=Oa(s,T=>_(T)),w=C.useRef(!1),j=y?p||!!y.closest("form"):!0,[N,S]=Yu({prop:a,defaultProp:o??!1,onChange:u,caller:$de});return e.jsxs(uNt,{scope:r,checked:N,disabled:i,children:[e.jsx(Jr.button,{type:"button",role:"switch","aria-checked":N,"aria-required":l,"data-state":LWe(N),"data-disabled":i?"":void 0,disabled:i,value:c,...f,ref:b,onClick:Mr(t.onClick,T=>{S(I=>!I),j&&(w.current=T.isPropagationStopped(),w.current||T.stopPropagation())})}),j&&e.jsx(IWe,{control:y,bubbles:!w.current,name:n,value:c,checked:N,required:l,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});AWe.displayName=$de;var EWe="SwitchThumb",PWe=C.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=hNt(EWe,r);return e.jsx(Jr.span,{"data-state":LWe(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});PWe.displayName=EWe;var mNt="SwitchBubbleInput",IWe=C.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=C.useRef(null),i=Oa(l,o),c=mO(r),u=eO(s);return C.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&_){const b=new Event("click",{bubbles:n});_.call(p,r),p.dispatchEvent(b)}},[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}})});IWe.displayName=mNt;function LWe(t){return t?"checked":"unchecked"}var DWe=AWe,pNt=PWe;const Br=C.forwardRef(({className:t,...s},r)=>e.jsx(DWe,{className:At("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(pNt,{className:At("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Br.displayName=DWe.displayName;function Zn(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 ll(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function kl(t,s){const r=Zn(t);return isNaN(s)?ll(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function Em(t,s){const r=Zn(t);if(isNaN(s))return ll(t,NaN);if(!s)return r;const n=r.getDate(),a=ll(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 OWe(t,s){const r=+Zn(t);return ll(t,r+s)}const Jwe=6048e5,fNt=864e5,qde=6e4,pO=36e5,gNt=1e3,I7=43200,PEe=1440;function IEe(t,s){return OWe(t,s*pO)}let xNt={};function N2(){return xNt}function Uh(t,s){var i,c,u,p;const r=N2(),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=Zn(t),o=a.getDay(),l=(o=a.getTime()?r+1:s.getTime()>=l.getTime()?r:r-1}function Pm(t){const s=Zn(t);return s.setHours(0,0,0,0),s}function n2(t){const s=Zn(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 af(t,s){const r=Pm(t),n=Pm(s),a=+r-n2(r),o=+n-n2(n);return Math.round((a-o)/fNt)}function yNt(t){const s=RWe(t),r=ll(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),b1(r)}function R5(t,s){return OWe(t,s*qde)}function c4(t,s){const r=s*7;return kl(t,r)}function vNt(t,s){return Em(t,s*12)}function _Nt(t){let s;return t.forEach(function(r){const n=Zn(r);(s===void 0||s{const n=Zn(r);(!s||s>n||isNaN(+n))&&(s=n)}),s||new Date(NaN)}function nie(t,s){const r=Zn(t),n=Zn(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function eje(t){return ll(t,Date.now())}function _l(t,s){const r=Pm(t),n=Pm(s);return+r==+n}function tje(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function vve(t){if(!tje(t)&&typeof t!="number")return!1;const s=Zn(t);return!isNaN(Number(s))}function gT(t,s){const r=Zn(t),n=Zn(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function wNt(t,s,r){const n=Uh(t,r),a=Uh(s,r),o=+n-n2(n),l=+a-n2(a);return Math.round((o-l)/Jwe)}function ty(t,s){const r=Zn(t),n=Zn(s),a=LEe(r,n),o=Math.abs(af(r,n));r.setDate(r.getDate()-a*o);const l=+(LEe(r,n)===-a),i=a*(o-l);return i===0?0:i}function LEe(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 FWe(t){return s=>{const n=(t?Math[t]:Math.trunc)(s);return n===0?0:n}}function zWe(t,s){return+Zn(t)-+Zn(s)}function jNt(t,s,r){const n=zWe(t,s)/pO;return FWe(r==null?void 0:r.roundingMethod)(n)}function kNt(t){const s=Zn(t);return s.setHours(23,59,59,999),s}function eg(t){const s=Zn(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function NNt(t){const s=Zn(t);return+kNt(s)==+eg(s)}function SNt(t,s){const r=Zn(t),n=Zn(s),a=nie(r,n),o=Math.abs(gT(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=nie(r,n)===-a;NNt(Zn(t))&&o===1&&nie(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function CNt(t,s,r){const n=zWe(t,s)/1e3;return FWe(r==null?void 0:r.roundingMethod)(n)}function MNt(t,s){const r=Zn(t.start),n=Zn(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(Zn(l)),l.setDate(l.getDate()+i),l.setHours(0,0,0,0);return a?c.reverse():c}function Mc(t){const s=Zn(t);return s.setDate(1),s.setHours(0,0,0,0),s}function BWe(t){const s=Zn(t),r=ll(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Ude(t,s){var i,c,u,p;const r=N2(),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=Zn(t),o=a.getDay(),l=(o{let n;const a=TNt[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 pge(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const ENt={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},PNt={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},INt={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},LNt={date:pge({formats:ENt,defaultWidth:"full"}),time:pge({formats:PNt,defaultWidth:"full"}),dateTime:pge({formats:INt,defaultWidth:"full"})},DNt={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ONt=(t,s,r,n)=>DNt[t];function j6(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 RNt={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},FNt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},zNt={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"]},BNt={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"]},$Nt={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"}},qNt={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"}},UNt=(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"},VNt={ordinalNumber:UNt,era:j6({values:RNt,defaultWidth:"wide"}),quarter:j6({values:FNt,defaultWidth:"wide",argumentCallback:t=>t-1}),month:j6({values:zNt,defaultWidth:"wide"}),day:j6({values:BNt,defaultWidth:"wide"}),dayPeriod:j6({values:$Nt,defaultWidth:"wide",formattingValues:qNt,defaultFormattingWidth:"wide"})};function k6(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)?WNt(i,f=>f.test(l)):HNt(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 HNt(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function WNt(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 KNt=/^(\d+)(th|st|nd|rd)?/i,ZNt=/\d+/i,YNt={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},XNt={any:[/^b/i,/^(a|c)/i]},QNt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},JNt={any:[/1/i,/2/i,/3/i,/4/i]},e4t={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},t4t={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]},s4t={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},r4t={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]},n4t={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},a4t={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}},i4t={ordinalNumber:GNt({matchPattern:KNt,parsePattern:ZNt,valueCallback:t=>parseInt(t,10)}),era:k6({matchPatterns:YNt,defaultMatchWidth:"wide",parsePatterns:XNt,defaultParseWidth:"any"}),quarter:k6({matchPatterns:QNt,defaultMatchWidth:"wide",parsePatterns:JNt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:k6({matchPatterns:e4t,defaultMatchWidth:"wide",parsePatterns:t4t,defaultParseWidth:"any"}),day:k6({matchPatterns:s4t,defaultMatchWidth:"wide",parsePatterns:r4t,defaultParseWidth:"any"}),dayPeriod:k6({matchPatterns:n4t,defaultMatchWidth:"any",parsePatterns:a4t,defaultParseWidth:"any"})},Vde={code:"en-US",formatDistance:ANt,formatLong:LNt,formatRelative:ONt,localize:VNt,match:i4t,options:{weekStartsOn:0,firstWeekContainsDate:1}};function o4t(t){const s=Zn(t);return af(s,BWe(s))+1}function sje(t){const s=Zn(t),r=+b1(s)-+yNt(s);return Math.round(r/Jwe)+1}function rje(t,s){var p,f,y,_;const r=Zn(t),n=r.getFullYear(),a=N2(),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??((_=(y=a.locale)==null?void 0:y.options)==null?void 0:_.firstWeekContainsDate)??1,l=ll(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=Uh(l,s),c=ll(t,0);c.setFullYear(n,0,o),c.setHours(0,0,0,0);const u=Uh(c,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function l4t(t,s){var i,c,u,p;const r=N2(),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=rje(t,s),o=ll(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),Uh(o,s)}function nje(t,s){const r=Zn(t),n=+Uh(r,s)-+l4t(r,s);return Math.round(n/Jwe)+1}function ol(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const k_={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return ol(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):ol(r+1,2)},d(t,s){return ol(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 ol(t.getHours()%12||12,s.length)},H(t,s){return ol(t.getHours(),s.length)},m(t,s){return ol(t.getMinutes(),s.length)},s(t,s){return ol(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return ol(a,s.length)}},Q3={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},DEe={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 k_.y(t,s)},Y:function(t,s,r,n){const a=rje(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return ol(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):ol(o,s.length)},R:function(t,s){const r=RWe(t);return ol(r,s.length)},u:function(t,s){const r=t.getFullYear();return ol(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 ol(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 ol(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 k_.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 ol(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=nje(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):ol(a,s.length)},I:function(t,s,r){const n=sje(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):ol(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):k_.d(t,s)},D:function(t,s,r){const n=o4t(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):ol(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 ol(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 ol(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 ol(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=Q3.noon:n===0?a=Q3.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=Q3.evening:n>=12?a=Q3.afternoon:n>=4?a=Q3.morning:a=Q3.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 k_.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):k_.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):ol(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):ol(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):k_.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):k_.s(t,s)},S:function(t,s){return k_.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return REe(n);case"XXXX":case"XX":return ZN(n);case"XXXXX":case"XXX":default:return ZN(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return REe(n);case"xxxx":case"xx":return ZN(n);case"xxxxx":case"xxx":default:return ZN(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+OEe(n,":");case"OOOO":default:return"GMT"+ZN(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+OEe(n,":");case"zzzz":default:return"GMT"+ZN(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return ol(n,s.length)},T:function(t,s,r){const n=t.getTime();return ol(n,s.length)}};function OEe(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+ol(o,2)}function REe(t,s){return t%60===0?(t>0?"-":"+")+ol(Math.abs(t)/60,2):ZN(t,s)}function ZN(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=ol(Math.trunc(n/60),2),o=ol(n%60,2);return r+a+s+o}const FEe=(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"})}},qWe=(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"})}},c4t=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return FEe(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}}",FEe(n,s)).replace("{{time}}",qWe(a,s))},_ve={p:qWe,P:c4t},d4t=/^D+$/,u4t=/^Y+$/,h4t=["D","DD","YY","YYYY"];function UWe(t){return d4t.test(t)}function VWe(t){return u4t.test(t)}function bve(t,s,r){const n=m4t(t,s,r);if(console.warn(n),h4t.includes(t))throw new RangeError(n)}function m4t(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 p4t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,f4t=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,g4t=/^'([^]*?)'?$/,x4t=/''/g,y4t=/[a-zA-Z]/;function ys(t,s,r){var p,f,y,_,b,w,j,N;const n=N2(),a=(r==null?void 0:r.locale)??n.locale??Vde,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??((_=(y=n.locale)==null?void 0:y.options)==null?void 0:_.firstWeekContainsDate)??1,l=(r==null?void 0:r.weekStartsOn)??((w=(b=r==null?void 0:r.locale)==null?void 0:b.options)==null?void 0:w.weekStartsOn)??n.weekStartsOn??((N=(j=n.locale)==null?void 0:j.options)==null?void 0:N.weekStartsOn)??0,i=Zn(t);if(!vve(i))throw new RangeError("Invalid time value");let c=s.match(f4t).map(S=>{const T=S[0];if(T==="p"||T==="P"){const I=_ve[T];return I(S,a.formatLong)}return S}).join("").match(p4t).map(S=>{if(S==="''")return{isToken:!1,value:"'"};const T=S[0];if(T==="'")return{isToken:!1,value:v4t(S)};if(DEe[T])return{isToken:!0,value:S};if(T.match(y4t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+T+"`");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 T=S.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&VWe(T)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&UWe(T))&&bve(T,s,String(t));const I=DEe[T[0]];return I(i,T,a.localize,u)}).join("")}function v4t(t){const s=t.match(g4t);return s?s[1].replace(x4t,"'"):t}function _4t(t,s,r){const n=N2(),a=(r==null?void 0:r.locale)??n.locale??Vde,o=2520,l=nie(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=Zn(s),u=Zn(t)):(c=Zn(t),u=Zn(s));const p=CNt(u,c),f=(n2(u)-n2(c))/1e3,y=Math.round((p-f)/60);let _;if(y<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):y===0?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",y,i);if(y<45)return a.formatDistance("xMinutes",y,i);if(y<90)return a.formatDistance("aboutXHours",1,i);if(yn.getTime()}function wS(t,s){const r=Zn(t),n=Zn(s);return+r<+n}function C4t(t){return+Zn(t)>Date.now()}function M4t(t,s){const r=s instanceof Date?ll(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 T4t=10;class HWe{constructor(){bn(this,"subPriority",0)}validate(s,r){return!0}}class A4t extends HWe{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 E4t extends HWe{constructor(){super(...arguments);bn(this,"priority",T4t);bn(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:ll(r,M4t(r,Date))}}class Xo{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new A4t(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class P4t extends Xo{constructor(){super(...arguments);bn(this,"priority",140);bn(this,"incompatibleTokens",["R","u","t","T"])}parse(r,n,a){switch(n){case"G":case"GG":case"GGG":return a.era(r,{width:"abbreviated"})||a.era(r,{width:"narrow"});case"GGGGG":return a.era(r,{width:"narrow"});case"GGGG":default:return a.era(r,{width:"wide"})||a.era(r,{width:"abbreviated"})||a.era(r,{width:"narrow"})}}set(r,n,a){return n.era=a,r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}const Sd={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},Zy={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 Cd(t,s){return t&&{value:s(t.value),rest:t.rest}}function qc(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function Yy(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*gNt),rest:s.slice(r[0].length)}}function WWe(t){return qc(Sd.anyDigitsSigned,t)}function gd(t,s){switch(t){case 1:return qc(Sd.singleDigit,s);case 2:return qc(Sd.twoDigits,s);case 3:return qc(Sd.threeDigits,s);case 4:return qc(Sd.fourDigits,s);default:return qc(new RegExp("^\\d{1,"+t+"}"),s)}}function goe(t,s){switch(t){case 1:return qc(Sd.singleDigitSigned,s);case 2:return qc(Sd.twoDigitsSigned,s);case 3:return qc(Sd.threeDigitsSigned,s);case 4:return qc(Sd.fourDigitsSigned,s);default:return qc(new RegExp("^-?\\d{1,"+t+"}"),s)}}function aje(t){switch(t){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;case"am":case"midnight":case"night":default:return 0}}function GWe(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 KWe(t){return t%400===0||t%4===0&&t%100!==0}class I4t extends Xo{constructor(){super(...arguments);bn(this,"priority",130);bn(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 Cd(gd(4,r),o);case"yo":return Cd(a.ordinalNumber(r,{unit:"year"}),o);default:return Cd(gd(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=GWe(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 L4t extends Xo{constructor(){super(...arguments);bn(this,"priority",130);bn(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 Cd(gd(4,r),o);case"Yo":return Cd(a.ordinalNumber(r,{unit:"year"}),o);default:return Cd(gd(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=rje(r,o);if(a.isTwoDigitYear){const c=GWe(a.year,l);return r.setFullYear(c,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Uh(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),Uh(r,o)}}class D4t extends Xo{constructor(){super(...arguments);bn(this,"priority",130);bn(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return goe(n==="R"?4:n.length,r)}set(r,n,a){const o=ll(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),b1(o)}}class O4t extends Xo{constructor(){super(...arguments);bn(this,"priority",130);bn(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return goe(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class R4t extends Xo{constructor(){super(...arguments);bn(this,"priority",120);bn(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 gd(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 F4t extends Xo{constructor(){super(...arguments);bn(this,"priority",120);bn(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 gd(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 z4t extends Xo{constructor(){super(...arguments);bn(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);bn(this,"priority",110)}parse(r,n,a){const o=l=>l-1;switch(n){case"M":return Cd(qc(Sd.month,r),o);case"MM":return Cd(gd(2,r),o);case"Mo":return Cd(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 B4t extends Xo{constructor(){super(...arguments);bn(this,"priority",110);bn(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 Cd(qc(Sd.month,r),o);case"LL":return Cd(gd(2,r),o);case"Lo":return Cd(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 $4t(t,s,r){const n=Zn(t),a=nje(n,r)-s;return n.setDate(n.getDate()-a*7),n}class q4t extends Xo{constructor(){super(...arguments);bn(this,"priority",100);bn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,a){switch(n){case"w":return qc(Sd.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return gd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return Uh($4t(r,a,o),o)}}function U4t(t,s){const r=Zn(t),n=sje(r)-s;return r.setDate(r.getDate()-n*7),r}class V4t extends Xo{constructor(){super(...arguments);bn(this,"priority",100);bn(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 qc(Sd.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return gd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return b1(U4t(r,a))}}const H4t=[31,28,31,30,31,30,31,31,30,31,30,31],W4t=[31,29,31,30,31,30,31,31,30,31,30,31];class G4t extends Xo{constructor(){super(...arguments);bn(this,"priority",90);bn(this,"subPriority",1);bn(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"d":return qc(Sd.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return gd(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=KWe(a),l=r.getMonth();return o?n>=1&&n<=W4t[l]:n>=1&&n<=H4t[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class K4t extends Xo{constructor(){super(...arguments);bn(this,"priority",90);bn(this,"subpriority",1);bn(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 qc(Sd.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return gd(n.length,r)}}validate(r,n){const a=r.getFullYear();return KWe(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 ije(t,s,r){var f,y,_,b;const n=N2(),a=(r==null?void 0:r.weekStartsOn)??((y=(f=r==null?void 0:r.locale)==null?void 0:f.options)==null?void 0:y.weekStartsOn)??n.weekStartsOn??((b=(_=n.locale)==null?void 0:_.options)==null?void 0:b.weekStartsOn)??0,o=Zn(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 kl(o,p)}class Z4t extends Xo{constructor(){super(...arguments);bn(this,"priority",90);bn(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=ije(r,a,o),r.setHours(0,0,0,0),r}}class Y4t extends Xo{constructor(){super(...arguments);bn(this,"priority",90);bn(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 Cd(gd(n.length,r),l);case"eo":return Cd(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=ije(r,a,o),r.setHours(0,0,0,0),r}}class X4t extends Xo{constructor(){super(...arguments);bn(this,"priority",90);bn(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 Cd(gd(n.length,r),l);case"co":return Cd(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=ije(r,a,o),r.setHours(0,0,0,0),r}}function Q4t(t,s){const r=Zn(t),n=j4t(r),a=s-n;return kl(r,a)}class J4t extends Xo{constructor(){super(...arguments);bn(this,"priority",90);bn(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 gd(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return Cd(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 Cd(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return Cd(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return Cd(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=Q4t(r,a),r.setHours(0,0,0,0),r}}class eSt extends Xo{constructor(){super(...arguments);bn(this,"priority",80);bn(this,"incompatibleTokens",["b","B","H","k","t","T"])}parse(r,n,a){switch(n){case"a":case"aa":case"aaa":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaaa":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaa":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(aje(a),0,0,0),r}}class tSt extends Xo{constructor(){super(...arguments);bn(this,"priority",80);bn(this,"incompatibleTokens",["a","B","H","k","t","T"])}parse(r,n,a){switch(n){case"b":case"bb":case"bbb":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbbb":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbb":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(aje(a),0,0,0),r}}class sSt extends Xo{constructor(){super(...arguments);bn(this,"priority",80);bn(this,"incompatibleTokens",["a","b","t","T"])}parse(r,n,a){switch(n){case"B":case"BB":case"BBB":return a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBBB":return a.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBB":default:return a.dayPeriod(r,{width:"wide",context:"formatting"})||a.dayPeriod(r,{width:"abbreviated",context:"formatting"})||a.dayPeriod(r,{width:"narrow",context:"formatting"})}}set(r,n,a){return r.setHours(aje(a),0,0,0),r}}class rSt extends Xo{constructor(){super(...arguments);bn(this,"priority",70);bn(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return qc(Sd.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return gd(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 nSt extends Xo{constructor(){super(...arguments);bn(this,"priority",70);bn(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,a){switch(n){case"H":return qc(Sd.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return gd(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class aSt extends Xo{constructor(){super(...arguments);bn(this,"priority",70);bn(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return qc(Sd.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return gd(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 iSt extends Xo{constructor(){super(...arguments);bn(this,"priority",70);bn(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,a){switch(n){case"k":return qc(Sd.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return gd(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 oSt extends Xo{constructor(){super(...arguments);bn(this,"priority",60);bn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return qc(Sd.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return gd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class lSt extends Xo{constructor(){super(...arguments);bn(this,"priority",50);bn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return qc(Sd.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return gd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class cSt extends Xo{constructor(){super(...arguments);bn(this,"priority",30);bn(this,"incompatibleTokens",["t","T"])}parse(r,n){const a=o=>Math.trunc(o*Math.pow(10,-n.length+3));return Cd(gd(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class dSt extends Xo{constructor(){super(...arguments);bn(this,"priority",10);bn(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return Yy(Zy.basicOptionalMinutes,r);case"XX":return Yy(Zy.basic,r);case"XXXX":return Yy(Zy.basicOptionalSeconds,r);case"XXXXX":return Yy(Zy.extendedOptionalSeconds,r);case"XXX":default:return Yy(Zy.extended,r)}}set(r,n,a){return n.timestampIsSet?r:ll(r,r.getTime()-n2(r)-a)}}class uSt extends Xo{constructor(){super(...arguments);bn(this,"priority",10);bn(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return Yy(Zy.basicOptionalMinutes,r);case"xx":return Yy(Zy.basic,r);case"xxxx":return Yy(Zy.basicOptionalSeconds,r);case"xxxxx":return Yy(Zy.extendedOptionalSeconds,r);case"xxx":default:return Yy(Zy.extended,r)}}set(r,n,a){return n.timestampIsSet?r:ll(r,r.getTime()-n2(r)-a)}}class hSt extends Xo{constructor(){super(...arguments);bn(this,"priority",40);bn(this,"incompatibleTokens","*")}parse(r){return WWe(r)}set(r,n,a){return[ll(r,a*1e3),{timestampIsSet:!0}]}}class mSt extends Xo{constructor(){super(...arguments);bn(this,"priority",20);bn(this,"incompatibleTokens","*")}parse(r){return WWe(r)}set(r,n,a){return[ll(r,a),{timestampIsSet:!0}]}}const pSt={G:new P4t,y:new I4t,Y:new L4t,R:new D4t,u:new O4t,Q:new R4t,q:new F4t,M:new z4t,L:new B4t,w:new q4t,I:new V4t,d:new G4t,D:new K4t,E:new Z4t,e:new Y4t,c:new X4t,i:new J4t,a:new eSt,b:new tSt,B:new sSt,h:new rSt,H:new nSt,K:new aSt,k:new iSt,m:new oSt,s:new lSt,S:new cSt,X:new dSt,x:new uSt,t:new hSt,T:new mSt},fSt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,gSt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,xSt=/^'([^]*?)'?$/,ySt=/''/g,vSt=/\S/,_St=/[a-zA-Z]/;function oje(t,s,r,n){var w,j,N,S;const a=w4t(),o=a.locale??Vde,l=a.firstWeekContainsDate??((j=(w=a.locale)==null?void 0:w.options)==null?void 0:j.firstWeekContainsDate)??1,i=a.weekStartsOn??((S=(N=a.locale)==null?void 0:N.options)==null?void 0:S.weekStartsOn)??0;if(s==="")return t===""?Zn(r):ll(r,NaN);const c={firstWeekContainsDate:l,weekStartsOn:i,locale:o},u=[new E4t],p=s.match(gSt).map(T=>{const I=T[0];if(I in _ve){const L=_ve[I];return L(T,o.formatLong)}return T}).join("").match(fSt),f=[];for(let T of p){VWe(T)&&bve(T,s,t),UWe(T)&&bve(T,s,t);const I=T[0],L=pSt[I];if(L){const{incompatibleTokens:R}=L;if(Array.isArray(R)){const q=f.find(U=>R.includes(U.token)||U.token===I);if(q)throw new RangeError(`The format string mustn't contain \`${q.fullToken}\` and \`${T}\` at the same time`)}else if(L.incompatibleTokens==="*"&&f.length>0)throw new RangeError(`The format string mustn't contain \`${T}\` and any other token at the same time`);f.push({token:I,fullToken:T});const $=L.run(t,T,o.match,c);if(!$)return ll(r,NaN);u.push($.setter),t=$.rest}else{if(I.match(_St))throw new RangeError("Format string contains an unescaped latin alphabet character `"+I+"`");if(T==="''"?T="'":I==="'"&&(T=bSt(T)),t.indexOf(T)===0)t=t.slice(T.length);else return ll(r,NaN)}}if(t.length>0&&vSt.test(t))return ll(r,NaN);const y=u.map(T=>T.priority).sort((T,I)=>I-T).filter((T,I,L)=>L.indexOf(T)===I).map(T=>u.filter(I=>I.priority===T).sort((I,L)=>L.subPriority-I.subPriority)).map(T=>T[0]);let _=Zn(r);if(isNaN(_.getTime()))return ll(r,NaN);const b={};for(const T of y){if(!T.validate(_,c))return ll(r,NaN);const I=T.set(_,b,c);Array.isArray(I)?(_=I[0],Object.assign(b,I[1])):_=I}return ll(r,_)}function bSt(t){return t.match(xSt)[1].replace(ySt,"'")}function u0(t){return+Zn(t)o-l);return r>=n&&r<=a}function aie(t,s){return kl(t,-s)}function gm(t,s){const n=MSt(t);let a;if(n.date){const c=TSt(n.date,2);a=ASt(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=ESt(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=PSt(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 L7={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},NSt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,SSt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,CSt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function MSt(t){const s={},r=t.split(L7.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],L7.timeZoneDelimiter.test(s.date)&&(s.date=t.split(L7.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=L7.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function TSt(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 ASt(t,s){if(s===null)return new Date(NaN);const r=t.match(NSt);if(!r)return new Date(NaN);const n=!!r[4],a=N6(r[1]),o=N6(r[2])-1,l=N6(r[3]),i=N6(r[4]),c=N6(r[5])-1;if(n)return RSt(s,i,c)?ISt(s,i,c):new Date(NaN);{const u=new Date(0);return!DSt(s,o,l)||!OSt(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function N6(t){return t?parseInt(t):1}function ESt(t){const s=t.match(SSt);if(!s)return NaN;const r=fge(s[1]),n=fge(s[2]),a=fge(s[3]);return FSt(r,n,a)?r*pO+n*qde+a*1e3:NaN}function fge(t){return t&&parseFloat(t.replace(",","."))||0}function PSt(t){if(t==="Z")return 0;const s=t.match(CSt);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return zSt(n,a)?r*(n*pO+a*qde):NaN}function ISt(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 LSt=[31,null,31,30,31,30,31,31,30,31,30,31];function ZWe(t){return t%400===0||t%4===0&&t%100!==0}function DSt(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(LSt[s]||(ZWe(t)?29:28))}function OSt(t,s){return s>=1&&s<=(ZWe(t)?366:365)}function RSt(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function FSt(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function zSt(t,s){return s>=0&&s<=59}function gge(t,s){const r=Zn(t),n=r.getFullYear(),a=r.getDate(),o=ll(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=b4t(o);return r.setMonth(s,Math.min(a,l)),r}function kL(t,s){const r=Zn(t);return r.setHours(s),r}function NL(t,s){const r=Zn(t);return r.setMinutes(s),r}function BEe(t,s){const r=Zn(t);return isNaN(+r)?ll(t,NaN):(r.setFullYear(s),r)}function d4(t,s){return Em(t,-s)}var $o;(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})($o||($o={}));var $Ee;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})($Ee||($Ee={}));const ia=$o.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),R_=t=>{switch(typeof t){case"undefined":return ia.undefined;case"string":return ia.string;case"number":return Number.isNaN(t)?ia.nan:ia.number;case"boolean":return ia.boolean;case"function":return ia.function;case"bigint":return ia.bigint;case"symbol":return ia.symbol;case"object":return Array.isArray(t)?ia.array:t===null?ia.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?ia.promise:typeof Map<"u"&&t instanceof Map?ia.map:typeof Set<"u"&&t instanceof Set?ia.set:typeof Date<"u"&&t instanceof Date?ia.date:ia.object;default:return ia.unknown}},tn=$o.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 y0 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()}}y0.create=t=>new y0(t);const wve=(t,s)=>{let r;switch(t.code){case tn.invalid_type:t.received===ia.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case tn.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,$o.jsonStringifyReplacer)}`;break;case tn.unrecognized_keys:r=`Unrecognized key(s) in object: ${$o.joinValues(t.keys,", ")}`;break;case tn.invalid_union:r="Invalid input";break;case tn.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${$o.joinValues(t.options)}`;break;case tn.invalid_enum_value:r=`Invalid enum value. Expected ${$o.joinValues(t.options)}, received '${t.received}'`;break;case tn.invalid_arguments:r="Invalid function arguments";break;case tn.invalid_return_type:r="Invalid function return type";break;case tn.invalid_date:r="Invalid date";break;case tn.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:$o.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case tn.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case tn.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case tn.custom:r="Invalid input";break;case tn.invalid_intersection_types:r="Intersection results could not be merged";break;case tn.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case tn.not_finite:r="Number must be finite";break;default:r=s.defaultError,$o.assertNever(t)}return{message:r}};let BSt=wve;function $St(){return BSt}const qSt=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 Un(t,s){const r=$St(),n=qSt({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===wve?void 0:wve].filter(a=>!!a)});t.common.issues.push(n)}class vf{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 Li;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 vf.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 Li;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 Li=Object.freeze({status:"aborted"}),rI=t=>({status:"dirty",value:t}),Dg=t=>({status:"valid",value:t}),qEe=t=>t.status==="aborted",UEe=t=>t.status==="dirty",xT=t=>t.status==="valid",xoe=t=>typeof Promise<"u"&&t instanceof Promise;var ya;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(ya||(ya={}));class a2{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 VEe=(t,s)=>{if(xT(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 y0(t.common.issues);return this._error=r,this._error}}};function so(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 Ro{get description(){return this._def.description}_getType(s){return R_(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:R_(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new vf,ctx:{common:s.parent.common,data:s.data,parsedType:R_(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(xoe(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:R_(s)},a=this._parseSync({data:s,path:n.path,parent:n});return VEe(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:R_(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return xT(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=>xT(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:R_(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(xoe(a)?a:Promise.resolve(a));return VEe(n,o)}refine(s,r){const n=a=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(a):r;return this._refinement((a,o)=>{const l=s(a),i=()=>o.addIssue({code:tn.custom,...n(a)});return typeof Promise<"u"&&l instanceof Promise?l.then(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 _T({schema:this,typeName:Di.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 Ub.create(this,this._def)}nullable(){return bT.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return h0.create(this)}promise(){return boe.create(this,this._def)}or(s){return voe.create([this,s],this._def)}and(s){return _oe.create(this,s,this._def)}transform(s){return new _T({...so(this._def),schema:this,typeName:Di.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new Sve({...so(this._def),innerType:this,defaultValue:r,typeName:Di.ZodDefault})}brand(){return new uCt({typeName:Di.ZodBranded,type:this,...so(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new Cve({...so(this._def),innerType:this,catchValue:r,typeName:Di.ZodCatch})}describe(s){const r=this.constructor;return new r({...this._def,description:s})}pipe(s){return lje.create(this,s)}readonly(){return Mve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const USt=/^c[^\s-]{8,}$/i,VSt=/^[0-9a-z]+$/,HSt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,WSt=/^[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,GSt=/^[a-z0-9_-]{21}$/i,KSt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ZSt=/^[-+]?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)?)??$/,YSt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,XSt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let xge;const QSt=/^(?:(?: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])$/,JSt=/^(?:(?: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])$/,eCt=/^(([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]))$/,tCt=/^(([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])$/,sCt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,rCt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,YWe="((\\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])))",nCt=new RegExp(`^${YWe}$`);function XWe(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 aCt(t){return new RegExp(`^${XWe(t)}$`)}function iCt(t){let s=`${YWe}T${XWe(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 oCt(t,s){return!!((s==="v4"||!s)&&QSt.test(t)||(s==="v6"||!s)&&eCt.test(t))}function lCt(t,s){if(!KSt.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 cCt(t,s){return!!((s==="v4"||!s)&&JSt.test(t)||(s==="v6"||!s)&&tCt.test(t))}class pb extends Ro{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==ia.string){const o=this._getOrReturnCtx(s);return Un(o,{code:tn.invalid_type,expected:ia.string,received:o.parsedType}),Li}const n=new vf;let a;for(const o of this._def.checks)if(o.kind==="min")s.data.lengtho.value&&(a=this._getOrReturnCtx(s,a),Un(a,{code:tn.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){const l=s.data.length>o.value,i=s.data.lengths.test(a),{validation:r,code:tn.invalid_string,...ya.errToObj(n)})}_addCheck(s){return new pb({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",...ya.errToObj(s)})}url(s){return this._addCheck({kind:"url",...ya.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",...ya.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",...ya.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",...ya.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",...ya.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",...ya.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",...ya.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",...ya.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",...ya.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",...ya.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",...ya.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",...ya.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,...ya.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,...ya.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",...ya.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,...ya.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,...ya.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,...ya.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,...ya.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,...ya.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,...ya.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,...ya.errToObj(r)})}nonempty(s){return this.min(1,ya.errToObj(s))}trim(){return new pb({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new pb({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new pb({...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 pb({checks:[],typeName:Di.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...so(t)});function dCt(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 yT extends Ro{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)!==ia.number){const o=this._getOrReturnCtx(s);return Un(o,{code:tn.invalid_type,expected:ia.number,received:o.parsedType}),Li}let n;const a=new vf;for(const o of this._def.checks)o.kind==="int"?$o.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),Un(n,{code:tn.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty()):o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),Un(n,{code:tn.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?dCt(s.data,o.value)!==0&&(n=this._getOrReturnCtx(s,n),Un(n,{code:tn.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),Un(n,{code:tn.not_finite,message:o.message}),a.dirty()):$o.assertNever(o);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,ya.toString(r))}gt(s,r){return this.setLimit("min",s,!1,ya.toString(r))}lte(s,r){return this.setLimit("max",s,!0,ya.toString(r))}lt(s,r){return this.setLimit("max",s,!1,ya.toString(r))}setLimit(s,r,n,a){return new yT({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ya.toString(a)}]})}_addCheck(s){return new yT({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:ya.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ya.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ya.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ya.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ya.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:ya.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:ya.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ya.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ya.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"&&$o.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 yT({checks:[],typeName:Di.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...so(t)});class L8 extends Ro{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)!==ia.bigint)return this._getInvalidInput(s);let n;const a=new vf;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),Un(n,{code:tn.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="multipleOf"?s.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(s,n),Un(n,{code:tn.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):$o.assertNever(o);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return Un(r,{code:tn.invalid_type,expected:ia.bigint,received:r.parsedType}),Li}gte(s,r){return this.setLimit("min",s,!0,ya.toString(r))}gt(s,r){return this.setLimit("min",s,!1,ya.toString(r))}lte(s,r){return this.setLimit("max",s,!0,ya.toString(r))}lt(s,r){return this.setLimit("max",s,!1,ya.toString(r))}setLimit(s,r,n,a){return new L8({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:ya.toString(a)}]})}_addCheck(s){return new L8({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ya.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ya.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ya.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ya.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:ya.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 L8({checks:[],typeName:Di.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...so(t)});class jve extends Ro{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==ia.boolean){const n=this._getOrReturnCtx(s);return Un(n,{code:tn.invalid_type,expected:ia.boolean,received:n.parsedType}),Li}return Dg(s.data)}}jve.create=t=>new jve({typeName:Di.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...so(t)});class yoe extends Ro{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==ia.date){const o=this._getOrReturnCtx(s);return Un(o,{code:tn.invalid_type,expected:ia.date,received:o.parsedType}),Li}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return Un(o,{code:tn.invalid_date}),Li}const n=new vf;let a;for(const o of this._def.checks)o.kind==="min"?s.data.getTime()o.value&&(a=this._getOrReturnCtx(s,a),Un(a,{code:tn.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):$o.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new yoe({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:ya.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:ya.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 yoe({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Di.ZodDate,...so(t)});class HEe extends Ro{_parse(s){if(this._getType(s)!==ia.symbol){const n=this._getOrReturnCtx(s);return Un(n,{code:tn.invalid_type,expected:ia.symbol,received:n.parsedType}),Li}return Dg(s.data)}}HEe.create=t=>new HEe({typeName:Di.ZodSymbol,...so(t)});class WEe extends Ro{_parse(s){if(this._getType(s)!==ia.undefined){const n=this._getOrReturnCtx(s);return Un(n,{code:tn.invalid_type,expected:ia.undefined,received:n.parsedType}),Li}return Dg(s.data)}}WEe.create=t=>new WEe({typeName:Di.ZodUndefined,...so(t)});class GEe extends Ro{_parse(s){if(this._getType(s)!==ia.null){const n=this._getOrReturnCtx(s);return Un(n,{code:tn.invalid_type,expected:ia.null,received:n.parsedType}),Li}return Dg(s.data)}}GEe.create=t=>new GEe({typeName:Di.ZodNull,...so(t)});class KEe extends Ro{constructor(){super(...arguments),this._any=!0}_parse(s){return Dg(s.data)}}KEe.create=t=>new KEe({typeName:Di.ZodAny,...so(t)});class ZEe extends Ro{constructor(){super(...arguments),this._unknown=!0}_parse(s){return Dg(s.data)}}ZEe.create=t=>new ZEe({typeName:Di.ZodUnknown,...so(t)});class i2 extends Ro{_parse(s){const r=this._getOrReturnCtx(s);return Un(r,{code:tn.invalid_type,expected:ia.never,received:r.parsedType}),Li}}i2.create=t=>new i2({typeName:Di.ZodNever,...so(t)});class YEe extends Ro{_parse(s){if(this._getType(s)!==ia.undefined){const n=this._getOrReturnCtx(s);return Un(n,{code:tn.invalid_type,expected:ia.void,received:n.parsedType}),Li}return Dg(s.data)}}YEe.create=t=>new YEe({typeName:Di.ZodVoid,...so(t)});class h0 extends Ro{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==ia.array)return Un(r,{code:tn.invalid_type,expected:ia.array,received:r.parsedType}),Li;if(a.exactLength!==null){const l=r.data.length>a.exactLength.value,i=r.data.lengtha.maxLength.value&&(Un(r,{code:tn.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((l,i)=>a.type._parseAsync(new a2(r,l,r.path,i)))).then(l=>vf.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new a2(r,l,r.path,i)));return vf.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new h0({...this._def,minLength:{value:s,message:ya.toString(r)}})}max(s,r){return new h0({...this._def,maxLength:{value:s,message:ya.toString(r)}})}length(s,r){return new h0({...this._def,exactLength:{value:s,message:ya.toString(r)}})}nonempty(s){return this.min(1,s)}}h0.create=(t,s)=>new h0({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Di.ZodArray,...so(s)});function g5(t){if(t instanceof Ud){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=Ub.create(g5(n))}return new Ud({...t._def,shape:()=>s})}else return t instanceof h0?new h0({...t._def,type:g5(t.element)}):t instanceof Ub?Ub.create(g5(t.unwrap())):t instanceof bT?bT.create(g5(t.unwrap())):t instanceof jS?jS.create(t.items.map(s=>g5(s))):t}class Ud extends Ro{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=$o.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==ia.object){const u=this._getOrReturnCtx(s);return Un(u,{code:tn.invalid_type,expected:ia.object,received:u.parsedType}),Li}const{status:n,ctx:a}=this._processInputParams(s),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof i2&&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 a2(a,f,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof i2){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&&(Un(a,{code:tn.unrecognized_keys,keys:i}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of i){const f=a.data[p];c.push({key:{status:"valid",value:p},value:u._parse(new a2(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,y=await p.value;u.push({key:f,value:y,alwaysSet:p.alwaysSet})}return u}).then(u=>vf.mergeObjectSync(n,u)):vf.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(s){return ya.errToObj,new Ud({...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:ya.errToObj(s).message??a}:{message:a}}}:{}})}strip(){return new Ud({...this._def,unknownKeys:"strip"})}passthrough(){return new Ud({...this._def,unknownKeys:"passthrough"})}extend(s){return new Ud({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new Ud({unknownKeys:s._def.unknownKeys,catchall:s._def.catchall,shape:()=>({...this._def.shape(),...s._def.shape()}),typeName:Di.ZodObject})}setKey(s,r){return this.augment({[s]:r})}catchall(s){return new Ud({...this._def,catchall:s})}pick(s){const r={};for(const n of $o.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Ud({...this._def,shape:()=>r})}omit(s){const r={};for(const n of $o.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new Ud({...this._def,shape:()=>r})}deepPartial(){return g5(this)}partial(s){const r={};for(const n of $o.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new Ud({...this._def,shape:()=>r})}required(s){const r={};for(const n of $o.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Ub;)o=o._def.innerType;r[n]=o}return new Ud({...this._def,shape:()=>r})}keyof(){return QWe($o.objectKeys(this.shape))}}Ud.create=(t,s)=>new Ud({shape:()=>t,unknownKeys:"strip",catchall:i2.create(),typeName:Di.ZodObject,...so(s)});Ud.strictCreate=(t,s)=>new Ud({shape:()=>t,unknownKeys:"strict",catchall:i2.create(),typeName:Di.ZodObject,...so(s)});Ud.lazycreate=(t,s)=>new Ud({shape:t,unknownKeys:"strip",catchall:i2.create(),typeName:Di.ZodObject,...so(s)});class voe extends Ro{_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 y0(i.ctx.common.issues));return Un(r,{code:tn.invalid_union,unionErrors:l}),Li}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 y0(c));return Un(r,{code:tn.invalid_union,unionErrors:i}),Li}}get options(){return this._def.options}}voe.create=(t,s)=>new voe({options:t,typeName:Di.ZodUnion,...so(s)});function kve(t,s){const r=R_(t),n=R_(s);if(t===s)return{valid:!0,data:t};if(r===ia.object&&n===ia.object){const a=$o.objectKeys(s),o=$o.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const c=kve(t[i],s[i]);if(!c.valid)return{valid:!1};l[i]=c.data}return{valid:!0,data:l}}else if(r===ia.array&&n===ia.array){if(t.length!==s.length)return{valid:!1};const a=[];for(let o=0;o{if(qEe(o)||qEe(l))return Li;const i=kve(o.value,l.value);return i.valid?((UEe(o)||UEe(l))&&r.dirty(),{status:r.value,value:i.data}):(Un(n,{code:tn.invalid_intersection_types}),Li)};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}))}}_oe.create=(t,s,r)=>new _oe({left:t,right:s,typeName:Di.ZodIntersection,...so(r)});class jS extends Ro{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ia.array)return Un(n,{code:tn.invalid_type,expected:ia.array,received:n.parsedType}),Li;if(n.data.lengththis._def.items.length&&(Un(n,{code:tn.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const o=[...n.data].map((l,i)=>{const c=this._def.items[i]||this._def.rest;return c?c._parse(new a2(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>vf.mergeArray(r,l)):vf.mergeArray(r,o)}get items(){return this._def.items}rest(s){return new jS({...this._def,rest:s})}}jS.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new jS({items:t,typeName:Di.ZodTuple,rest:null,...so(s)})};class XEe extends Ro{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!==ia.map)return Un(n,{code:tn.invalid_type,expected:ia.map,received:n.parsedType}),Li;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,c],u)=>({key:a._parse(new a2(n,i,n.path,[u,"key"])),value:o._parse(new a2(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 Li;(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 Li;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value)}return{status:r.value,value:i}}}}XEe.create=(t,s,r)=>new XEe({valueType:s,keyType:t,typeName:Di.ZodMap,...so(r)});class D8 extends Ro{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==ia.set)return Un(n,{code:tn.invalid_type,expected:ia.set,received:n.parsedType}),Li;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&(Un(n,{code:tn.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const o=this._def.valueType;function l(c){const u=new Set;for(const p of c){if(p.status==="aborted")return Li;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 a2(n,c,n.path,u)));return n.common.async?Promise.all(i).then(c=>l(c)):l(i)}min(s,r){return new D8({...this._def,minSize:{value:s,message:ya.toString(r)}})}max(s,r){return new D8({...this._def,maxSize:{value:s,message:ya.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}D8.create=(t,s)=>new D8({valueType:t,minSize:null,maxSize:null,typeName:Di.ZodSet,...so(s)});class QEe extends Ro{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})}}QEe.create=(t,s)=>new QEe({getter:t,typeName:Di.ZodLazy,...so(s)});class Nve extends Ro{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return Un(r,{received:r.data,code:tn.invalid_literal,expected:this._def.value}),Li}return{status:"valid",value:s.data}}get value(){return this._def.value}}Nve.create=(t,s)=>new Nve({value:t,typeName:Di.ZodLiteral,...so(s)});function QWe(t,s){return new vT({values:t,typeName:Di.ZodEnum,...so(s)})}class vT extends Ro{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return Un(r,{expected:$o.joinValues(n),received:r.parsedType,code:tn.invalid_type}),Li}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 Un(r,{received:r.data,code:tn.invalid_enum_value,options:n}),Li}return Dg(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 vT.create(s,{...this._def,...r})}exclude(s,r=this._def){return vT.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}vT.create=QWe;class JEe extends Ro{_parse(s){const r=$o.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==ia.string&&n.parsedType!==ia.number){const a=$o.objectValues(r);return Un(n,{expected:$o.joinValues(a),received:n.parsedType,code:tn.invalid_type}),Li}if(this._cache||(this._cache=new Set($o.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=$o.objectValues(r);return Un(n,{received:n.data,code:tn.invalid_enum_value,options:a}),Li}return Dg(s.data)}get enum(){return this._def.values}}JEe.create=(t,s)=>new JEe({values:t,typeName:Di.ZodNativeEnum,...so(s)});class boe extends Ro{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==ia.promise&&r.common.async===!1)return Un(r,{code:tn.invalid_type,expected:ia.promise,received:r.parsedType}),Li;const n=r.parsedType===ia.promise?r.data:Promise.resolve(r.data);return Dg(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}boe.create=(t,s)=>new boe({type:t,typeName:Di.ZodPromise,...so(s)});class _T extends Ro{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Di.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=>{Un(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 Li;const c=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return c.status==="aborted"?Li:c.status==="dirty"||r.value==="dirty"?rI(c.value):c});{if(r.value==="aborted")return Li;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?Li:i.status==="dirty"||r.value==="dirty"?rI(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"?Li:(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"?Li:(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(!xT(l))return Li;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=>xT(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):Li);$o.assertNever(a)}}_T.create=(t,s,r)=>new _T({schema:t,typeName:Di.ZodEffects,effect:s,...so(r)});_T.createWithPreprocess=(t,s,r)=>new _T({schema:s,effect:{type:"preprocess",transform:t},typeName:Di.ZodEffects,...so(r)});class Ub extends Ro{_parse(s){return this._getType(s)===ia.undefined?Dg(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}Ub.create=(t,s)=>new Ub({innerType:t,typeName:Di.ZodOptional,...so(s)});class bT extends Ro{_parse(s){return this._getType(s)===ia.null?Dg(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}bT.create=(t,s)=>new bT({innerType:t,typeName:Di.ZodNullable,...so(s)});class Sve extends Ro{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===ia.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Sve.create=(t,s)=>new Sve({innerType:t,typeName:Di.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...so(s)});class Cve extends Ro{_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 xoe(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new y0(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new y0(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Cve.create=(t,s)=>new Cve({innerType:t,typeName:Di.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...so(s)});class ePe extends Ro{_parse(s){if(this._getType(s)!==ia.nan){const n=this._getOrReturnCtx(s);return Un(n,{code:tn.invalid_type,expected:ia.nan,received:n.parsedType}),Li}return{status:"valid",value:s.data}}}ePe.create=t=>new ePe({typeName:Di.ZodNaN,...so(t)});class uCt extends Ro{_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 lje extends Ro{_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"?Li:o.status==="dirty"?(r.dirty(),rI(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"?Li: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 lje({in:s,out:r,typeName:Di.ZodPipeline})}}class Mve extends Ro{_parse(s){const r=this._def.innerType._parse(s),n=a=>(xT(a)&&(a.value=Object.freeze(a.value)),a);return xoe(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Mve.create=(t,s)=>new Mve({innerType:t,typeName:Di.ZodReadonly,...so(s)});var Di;(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"})(Di||(Di={}));const uc=pb.create,SL=yT.create,hCt=jve.create;i2.create;h0.create;const ZS=Ud.create;voe.create;_oe.create;jS.create;const woe=Nve.create,JWe=vT.create;boe.create;Ub.create;bT.create;const Ar=C.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:At("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}));Ar.displayName="Textarea";const mCt=["Excellent","Good","Neutral","Bad","Very Bad"],pCt=[5,4,3,2,1];function fCt({questions:t,visitorId:s,onComplete:r,onSkip:n}){const a=rNt(),[o,l]=C.useState({}),i=t.filter(y=>y.question_type==="rating"),c=t.filter(y=>y.question_type!=="rating"),u=(y,_)=>{l(b=>({...b,[y]:{rating_value:_}}))},p=(y,_)=>{l(b=>({...b,[y]:{text_value:_}}))},f=async()=>{const y=Object.entries(o).filter(([,_])=>_.rating_value!=null||_.text_value&&_.text_value.trim()).map(([_,b])=>{var w;return{visitor_id:s,question_id:_,rating_value:b.rating_value??null,text_value:((w=b.text_value)==null?void 0:w.trim())||null}});if(y.length>0)try{await a.mutateAsync(y)}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"}),mCt.map(y=>e.jsx("div",{className:"w-12 text-center",children:e.jsx("span",{className:"text-[10px] text-slate-400 leading-tight block",children:y})},y))]}),i.map(y=>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:y.question_text}),pCt.map(_=>{var b;return e.jsx("div",{className:"w-12 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>u(y.id,_),className:`w-6 h-6 rounded-full border-2 transition-all ${((b=o[y.id])==null?void 0:b.rating_value)===_?"bg-slate-900 border-slate-900":"border-slate-300 hover:border-slate-500"}`})},_)})]},y.id))]}),c.map(y=>{var _;return e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 block mb-1",children:y.question_text}),e.jsx(Ar,{value:((_=o[y.id])==null?void 0:_.text_value)||"",onChange:b=>p(y.id,b.target.value),placeholder:"Your thoughts...",className:"h-16 text-sm resize-none rounded-xl border-slate-200"})]},y.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(Ss,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}const gCt=ZS({first_name:uc().trim().min(1,"First name is required").max(50),last_name:uc().trim().max(50).optional(),email:uc().trim().email("Please enter a valid email").max(255).optional().or(woe("")),phone:uc().trim().max(20).optional().or(woe(""))}),xCt=[{value:"buying",label:"Looking to Buy",emoji:"🏠"},{value:"selling",label:"Thinking of Selling",emoji:"📋"},{value:"browsing",label:"Just Browsing",emoji:"👀"},{value:"neighbor",label:"I'm a Neighbor",emoji:"👋"}];function eGe({slug:t}={}){var re;const s=Po(),r=t||s.slug,{data:n,isLoading:a,error:o}=eNt(r),l=cNt(),[i,c]=C.useState("welcome"),[u,p]=C.useState(null),[f,y]=C.useState({first_name:"",last_name:"",email:"",phone:""}),[_,b]=C.useState(""),[w,j]=C.useState(!1),[N,S]=C.useState(!1),[T,I]=C.useState(""),[L,R]=C.useState(""),{data:$,isLoading:q}=sNt(n==null?void 0:n.id),U=!!(n!=null&&n.enable_survey);C.useEffect(()=>{i==="pending_survey"&&(q||c(U&&(($==null?void 0:$.length)??0)>0?"survey":"done"))},[i,q,U,$]);const V=ne=>{if(!ne)return"";const[le,he]=ne.split(":"),we=parseInt(le),ye=we>=12?"PM":"AM";return`${we>12?we-12:we||12}:${he} ${ye}`},X=()=>{R("");const ne=gCt.safeParse(f);if(!ne.success){R(ne.error.issues[0].message);return}if(!f.email&&!f.phone){R("Please provide either an email or phone number");return}c("intent")},se=async ne=>{b(ne);try{const le=await l.mutateAsync({open_house_id:n.id,first_name:f.first_name.trim(),last_name:f.last_name.trim()||void 0,email:f.email.trim()||void 0,phone:f.phone.trim()||void 0,visitor_intent:ne,wants_market_updates:w,has_agent:N,working_with_agent_name:N&&T.trim()?T.trim():void 0});p(le.id),U?!q&&$&&$.length>0?c("survey"):c("pending_survey"):c("done")}catch{R("Something went wrong. Please try again.")}};if(a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center",children:e.jsx("div",{className:"w-10 h-10 border-4 border-white/20 border-t-white rounded-full animate-spin"})});if(o||!n)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(Rn,{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(ne=>ne[0]).join("").slice(0,2))||"?",de=n.event_type==="community";return e.jsxs(e.Fragment,{children:[e.jsxs(qh,{children:[e.jsxs("title",{children:[de?"Community Event":"Open House"," | ",n.property_address]}),e.jsx("meta",{name:"description",content:`Sign in to the ${de?"community event":"open house"} at ${n.property_address}`}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsxs(yn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx(Da,{src:(ee==null?void 0:ee.avatar_url)||"",alt:(ee==null?void 0:ee.name)||""}),e.jsx(vn,{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(Ui,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ys(new Date(n.event_date+"T00:00:00"),"MMM d, yyyy")]}),n.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),V(n.start_time),n.end_time?` – ${V(n.end_time)}`:""]})]})]})]}),!n.photo_url&&e.jsx("div",{className:"bg-gradient-to-r from-slate-800 to-slate-700 px-6 py-5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/10 flex items-center justify-center shrink-0 mt-0.5",children:de?e.jsx(La,{className:"h-5 w-5 text-white"}):e.jsx(Rn,{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(Ui,{className:"h-3 w-3"}),n.city,n.state?`, ${n.state}`:""," ",n.zip]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ys(new Date(n.event_date+"T00:00:00"),"MMM d, yyyy")]}),n.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),V(n.start_time),n.end_time?` – ${V(n.end_time)}`:""]})]})]})]})}),e.jsxs("div",{className:"p-6",children:[i==="welcome"&&e.jsxs("div",{className:"text-center space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"Welcome!"}),e.jsx("p",{className:"text-slate-500 text-sm",children:n.agent_greeting||"Please sign in below."})]}),e.jsxs(K,{onClick:()=>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(Ki,{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(di,{className:"h-4 w-4"})}),e.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"Your Info"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(Fe,{value:f.first_name,onChange:ne=>y(le=>({...le,first_name:ne.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(Fe,{value:f.last_name,onChange:ne=>y(le=>({...le,last_name:ne.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(Fe,{type:"email",value:f.email,onChange:ne=>y(le=>({...le,email:ne.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(Fe,{type:"tel",value:f.phone,onChange:ne=>y(le=>({...le,phone:ne.target.value})),placeholder:"(555) 123-4567",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer pt-1",children:[e.jsx("input",{type:"checkbox",checked:w,onChange:ne=>j(ne.target.checked),className:"rounded border-slate-300 text-slate-900 focus:ring-slate-500"}),e.jsx("span",{className:"text-sm text-slate-600",children:"Send me market updates for this area"})]}),e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-slate-600",children:"Already working with an agent?"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-400",children:N?"Yes":"No"}),e.jsx(Br,{checked:N,onCheckedChange:S})]})]}),N&&e.jsx(Fe,{value:T,onChange:ne=>I(ne.target.value),placeholder:"Agent's name",className:"mt-1 h-10 rounded-xl border-slate-200 text-sm"})]}),L&&e.jsx("p",{className:"text-destructive text-sm",children:L}),e.jsxs(K,{onClick:X,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(Ki,{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(di,{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:xCt.map(ne=>e.jsxs("button",{onClick:()=>se(ne.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:ne.emoji}),e.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:ne.label})]},ne.value))}),L&&e.jsx("p",{className:"text-destructive text-sm text-center",children:L})]}),i==="pending_survey"&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-3",children:[e.jsx("div",{className:"w-8 h-8 border-[3px] border-slate-200 border-t-slate-900 rounded-full animate-spin"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading survey..."})]}),i==="survey"&&u&&$&&e.jsx(fCt,{questions:$,visitorId:u,onComplete:()=>c("done"),onSkip:()=>c("done")}),i==="done"&&e.jsxs("div",{className:"text-center space-y-4 py-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-green-100 flex items-center justify-center mx-auto",children:e.jsx(ha,{className:"h-8 w-8 text-green-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-slate-900",children:"You're all set!"}),e.jsxs("p",{className:"text-slate-500 text-sm mt-1",children:["Thanks for signing in, ",f.first_name,". ",de?"Enjoy the event!":"Enjoy the open house!"]})]}),(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 _3s(t){const{user:s}=Ws();return wt({queryKey:["cohost-tokens",t],queryFn:async()=>{const{data:r,error:n}=await G.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 b3s(){const t=ss(),{user:s}=Ws();return Dt({mutationFn:async({openHouseId:r,label:n})=>{const{data:a,error:o}=await G.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 w3s(){const t=ss();return Dt({mutationFn:async({id:s,openHouseId:r})=>{const{error:n}=await G.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 yCt(t){return wt({queryKey:["cohost-validate",t],queryFn:async()=>{const{data:s,error:r}=await G.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 cje="ScrollArea",[tGe]=Yc(cje),[_Ct,Og]=tGe(cje),sGe=C.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,c]=C.useState(null),[u,p]=C.useState(null),[f,y]=C.useState(null),[_,b]=C.useState(null),[w,j]=C.useState(null),[N,S]=C.useState(0),[T,I]=C.useState(0),[L,R]=C.useState(!1),[$,q]=C.useState(!1),U=Oa(s,X=>c(X)),V=b2(a);return e.jsx(_Ct,{scope:r,type:n,dir:V,scrollHideDelay:o,scrollArea:i,viewport:u,onViewportChange:p,content:f,onContentChange:y,scrollbarX:_,onScrollbarXChange:b,scrollbarXEnabled:L,onScrollbarXEnabledChange:R,scrollbarY:w,onScrollbarYChange:j,scrollbarYEnabled:$,onScrollbarYEnabledChange:q,onCornerWidthChange:S,onCornerHeightChange:I,children:e.jsx(Jr.div,{dir:V,...l,ref:U,style:{position:"relative","--radix-scroll-area-corner-width":N+"px","--radix-scroll-area-corner-height":T+"px",...t.style}})})});sGe.displayName=cje;var rGe="ScrollAreaViewport",nGe=C.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=Og(rGe,r),i=C.useRef(null),c=Oa(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(Jr.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})})]})});nGe.displayName=rGe;var A0="ScrollAreaScrollbar",dje=C.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Og(A0,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return C.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?e.jsx(bCt,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(wCt,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx(aGe,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(uje,{...n,ref:s}):null});dje.displayName=A0;var bCt=C.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Og(A0,t.__scopeScrollArea),[o,l]=C.useState(!1);return C.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(Id,{present:r||o,children:e.jsx(aGe,{"data-state":o?"visible":"hidden",...n,ref:s})})}),wCt=C.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Og(A0,t.__scopeScrollArea),o=t.orientation==="horizontal",l=Gde(()=>c("SCROLL_END"),100),[i,c]=vCt("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 C.useEffect(()=>{if(i==="idle"){const u=window.setTimeout(()=>c("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,a.scrollHideDelay,c]),C.useEffect(()=>{const u=a.viewport,p=o?"scrollLeft":"scrollTop";if(u){let f=u[p];const y=()=>{const _=u[p];f!==_&&(c("SCROLL"),l()),f=_};return u.addEventListener("scroll",y),()=>u.removeEventListener("scroll",y)}},[a.viewport,o,c,l]),e.jsx(Id,{present:r||i!=="hidden",children:e.jsx(uje,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Mr(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Mr(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),aGe=C.forwardRef((t,s)=>{const r=Og(A0,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=C.useState(!1),i=t.orientation==="horizontal",c=Gde(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=Og(A0,t.__scopeScrollArea),o=C.useRef(null),l=C.useRef(0),[i,c]=C.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=dGe(i.viewport,i.content),p={...n,sizes:i,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:y=>o.current=y,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:y=>l.current=y};function f(y,_){return MCt(y,l.current,i,_)}return r==="horizontal"?e.jsx(jCt,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const y=a.viewport.scrollLeft,_=tPe(y,i,a.dir);o.current.style.transform=`translate3d(${_}px, 0, 0)`}},onWheelScroll:y=>{a.viewport&&(a.viewport.scrollLeft=y)},onDragScroll:y=>{a.viewport&&(a.viewport.scrollLeft=f(y,a.dir))}}):r==="vertical"?e.jsx(kCt,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const y=a.viewport.scrollTop,_=tPe(y,i);o.current.style.transform=`translate3d(0, ${_}px, 0)`}},onWheelScroll:y=>{a.viewport&&(a.viewport.scrollTop=y)},onDragScroll:y=>{a.viewport&&(a.viewport.scrollTop=f(y))}}):null}),jCt=C.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Og(A0,t.__scopeScrollArea),[l,i]=C.useState(),c=C.useRef(null),u=Oa(s,c,o.onScrollbarXChange);return C.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),e.jsx(oGe,{"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":Wde(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.x),onDragScroll:p=>t.onDragScroll(p.x),onWheelScroll:(p,f)=>{if(o.viewport){const y=o.viewport.scrollLeft+p.deltaX;t.onWheelScroll(y),hGe(y,f)&&p.preventDefault()}},onResize:()=>{c.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:koe(l.paddingLeft),paddingEnd:koe(l.paddingRight)}})}})}),kCt=C.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=Og(A0,t.__scopeScrollArea),[l,i]=C.useState(),c=C.useRef(null),u=Oa(s,c,o.onScrollbarYChange);return C.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),e.jsx(oGe,{"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":Wde(r)+"px",...t.style},onThumbPointerDown:p=>t.onThumbPointerDown(p.y),onDragScroll:p=>t.onDragScroll(p.y),onWheelScroll:(p,f)=>{if(o.viewport){const y=o.viewport.scrollTop+p.deltaY;t.onWheelScroll(y),hGe(y,f)&&p.preventDefault()}},onResize:()=>{c.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:koe(l.paddingTop),paddingEnd:koe(l.paddingBottom)}})}})}),[NCt,iGe]=tGe(A0),oGe=C.forwardRef((t,s)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:p,onResize:f,...y}=t,_=Og(A0,r),[b,w]=C.useState(null),j=Oa(s,U=>w(U)),N=C.useRef(null),S=C.useRef(""),T=_.viewport,I=n.content-n.viewport,L=dd(p),R=dd(c),$=Gde(f,10);function q(U){if(N.current){const V=U.clientX-N.current.left,X=U.clientY-N.current.top;u({x:V,y:X})}}return C.useEffect(()=>{const U=V=>{const X=V.target;(b==null?void 0:b.contains(X))&&L(V,I)};return document.addEventListener("wheel",U,{passive:!1}),()=>document.removeEventListener("wheel",U,{passive:!1})},[T,b,I,L]),C.useEffect(R,[n,R]),wT(b,$),wT(_.content,$),e.jsx(NCt,{scope:r,scrollbar:b,hasThumb:a,onThumbChange:dd(o),onThumbPointerUp:dd(l),onThumbPositionChange:R,onThumbPointerDown:dd(i),children:e.jsx(Jr.div,{...y,ref:j,style:{position:"absolute",...y.style},onPointerDown:Mr(t.onPointerDown,U=>{U.button===0&&(U.target.setPointerCapture(U.pointerId),N.current=b.getBoundingClientRect(),S.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",_.viewport&&(_.viewport.style.scrollBehavior="auto"),q(U))}),onPointerMove:Mr(t.onPointerMove,q),onPointerUp:Mr(t.onPointerUp,U=>{const V=U.target;V.hasPointerCapture(U.pointerId)&&V.releasePointerCapture(U.pointerId),document.body.style.webkitUserSelect=S.current,_.viewport&&(_.viewport.style.scrollBehavior=""),N.current=null})})})}),joe="ScrollAreaThumb",lGe=C.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=iGe(joe,t.__scopeScrollArea);return e.jsx(Id,{present:r||a.hasThumb,children:e.jsx(SCt,{ref:s,...n})})}),SCt=C.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=Og(joe,r),l=iGe(joe,r),{onThumbPositionChange:i}=l,c=Oa(s,f=>l.onThumbChange(f)),u=C.useRef(void 0),p=Gde(()=>{u.current&&(u.current(),u.current=void 0)},100);return C.useEffect(()=>{const f=o.viewport;if(f){const y=()=>{if(p(),!u.current){const _=TCt(f,i);u.current=_,i()}};return i(),f.addEventListener("scroll",y),()=>f.removeEventListener("scroll",y)}},[o.viewport,p,i]),e.jsx(Jr.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:Mr(t.onPointerDownCapture,f=>{const _=f.target.getBoundingClientRect(),b=f.clientX-_.left,w=f.clientY-_.top;l.onThumbPointerDown({x:b,y:w})}),onPointerUp:Mr(t.onPointerUp,l.onThumbPointerUp)})});lGe.displayName=joe;var hje="ScrollAreaCorner",cGe=C.forwardRef((t,s)=>{const r=Og(hje,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(CCt,{...t,ref:s}):null});cGe.displayName=hje;var CCt=C.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=Og(hje,r),[o,l]=C.useState(0),[i,c]=C.useState(0),u=!!(o&&i);return wT(a.scrollbarX,()=>{var f;const p=((f=a.scrollbarX)==null?void 0:f.offsetHeight)||0;a.onCornerHeightChange(p),c(p)}),wT(a.scrollbarY,()=>{var f;const p=((f=a.scrollbarY)==null?void 0:f.offsetWidth)||0;a.onCornerWidthChange(p),l(p)}),u?e.jsx(Jr.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 koe(t){return t?parseInt(t,10):0}function dGe(t,s){const r=t/s;return isNaN(r)?0:r}function Wde(t){const s=dGe(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function MCt(t,s,r,n="ltr"){const a=Wde(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 uGe([c,u],f)(t)}function tPe(t,s,r="ltr"){const n=Wde(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=I8(t,c);return uGe([0,l],[0,i])(u)}function uGe(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 hGe(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 Gde(t,s){const r=dd(t),n=C.useRef(0);return C.useEffect(()=>()=>window.clearTimeout(n.current),[]),C.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function wT(t,s){const r=dd(s);fd(()=>{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 mGe=sGe,ACt=nGe,ECt=cGe;const Vi=C.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(mGe,{ref:n,className:At("relative overflow-hidden",t),...r,children:[e.jsx(ACt,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(Kde,{}),e.jsx(ECt,{})]}));Vi.displayName=mGe.displayName;const Kde=C.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(dje,{ref:n,orientation:s,className:At("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(lGe,{className:"relative flex-1 rounded-full bg-border"})}));Kde.displayName=dje.displayName;const mje=C.createContext({});function pje(t){const s=C.useRef(null);return s.current===null&&(s.current=t()),s.current}const PCt=typeof window<"u",pGe=PCt?C.useLayoutEffect:C.useEffect,Zde=C.createContext(null);function fje(t,s){t.indexOf(s)===-1&&t.push(s)}function Noe(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const v0=(t,s,r)=>r>s?s:r{};const o2={},fGe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function gGe(t){return typeof t=="object"&&t!==null}const xGe=t=>/^0[^.\s]+$/u.test(t);function yGe(t){let s;return()=>(s===void 0&&(s=t()),s)}const _g=t=>t,ICt=(t,s)=>r=>s(t(r)),fO=(...t)=>t.reduce(ICt),O8=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class xje{constructor(){this.subscriptions=[]}add(s){return fje(this.subscriptions,s),()=>Noe(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,hg=t=>t/1e3;function vGe(t,s){return s?t*(1e3/s):0}const _Ge=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,LCt=1e-7,DCt=12;function OCt(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=_Ge(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>LCt&&++iOCt(o,0,1,t,r);return o=>o===0||o===1?o:_Ge(a(o),s,n)}const bGe=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,wGe=t=>s=>1-t(1-s),jGe=gO(.33,1.53,.69,.99),yje=wGe(jGe),kGe=bGe(yje),NGe=t=>t>=1?1:(t*=2)<1?.5*yje(t):.5*(2-Math.pow(2,-10*(t-1))),vje=t=>1-Math.sin(Math.acos(t)),SGe=wGe(vje),CGe=bGe(vje),RCt=gO(.42,0,1,1),FCt=gO(0,0,.58,1),MGe=gO(.42,0,.58,1),zCt=t=>Array.isArray(t)&&typeof t[0]!="number",TGe=t=>Array.isArray(t)&&typeof t[0]=="number",BCt={linear:_g,easeIn:RCt,easeInOut:MGe,easeOut:FCt,circIn:vje,circInOut:CGe,circOut:SGe,backIn:yje,backInOut:kGe,backOut:jGe,anticipate:NGe},$Ct=t=>typeof t=="string",sPe=t=>{if(TGe(t)){gje(t.length===4);const[s,r,n,a]=t;return gO(s,r,n,a)}else if($Ct(t))return BCt[t];return t},D7=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function qCt(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,y=!1)=>{const b=y&&a?r:n;return f&&l.add(p),b.add(p),p},cancel:p=>{n.delete(p),l.delete(p)},process:p=>{if(i=p,a){o=!0;return}a=!0;const f=r;r=n,n=f,r.forEach(c),r.clear(),a=!1,o&&(o=!1,u.process(p))}};return u}const UCt=40;function AGe(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=D7.reduce((T,I)=>(T[I]=qCt(o),T),{}),{setup:i,read:c,resolveKeyframes:u,preUpdate:p,update:f,preRender:y,render:_,postRender:b}=l,w=()=>{const T=o2.useManualTiming,I=T?a.timestamp:performance.now();r=!1,T||(a.delta=n?1e3/60:Math.max(Math.min(I-a.timestamp,UCt),1)),a.timestamp=I,a.isProcessing=!0,i.process(a),c.process(a),u.process(a),p.process(a),f.process(a),y.process(a),_.process(a),b.process(a),a.isProcessing=!1,r&&s&&(n=!1,t(w))},j=()=>{r=!0,n=!0,a.isProcessing||t(w)};return{schedule:D7.reduce((T,I)=>{const L=l[I];return T[I]=(R,$=!1,q=!1)=>(r||j(),L.schedule(R,$,q)),T},{}),cancel:T=>{for(let I=0;I(iie===void 0&&xm.set(dh.isProcessing||o2.useManualTiming?dh.timestamp:performance.now()),iie),set:t=>{iie=t,queueMicrotask(VCt)}},EGe=t=>s=>typeof s=="string"&&s.startsWith(t),PGe=EGe("--"),HCt=EGe("var(--"),_je=t=>HCt(t)?WCt.test(t.split("/*")[0].trim()):!1,WCt=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function rPe(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const PA={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},R8={...PA,transform:t=>v0(0,1,t)},O7={...PA,default:1},CL=t=>Math.round(t*1e5)/1e5,bje=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function GCt(t){return t==null}const KCt=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,wje=(t,s)=>r=>!!(typeof r=="string"&&KCt.test(r)&&r.startsWith(t)||s&&!GCt(r)&&Object.prototype.hasOwnProperty.call(r,s)),IGe=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(bje);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},ZCt=t=>v0(0,255,t),vge={...PA,transform:t=>Math.round(ZCt(t))},u4={test:wje("rgb","red"),parse:IGe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+vge.transform(t)+", "+vge.transform(s)+", "+vge.transform(r)+", "+CL(R8.transform(n))+")"};function YCt(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 Tve={test:wje("#"),parse:YCt,transform:u4.transform},xO=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),E_=xO("deg"),m0=xO("%"),ta=xO("px"),XCt=xO("vh"),QCt=xO("vw"),nPe={...m0,parse:t=>m0.parse(t)/100,transform:t=>m0.transform(t*100)},F5={test:wje("hsl","hue"),parse:IGe("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+m0.transform(CL(s))+", "+m0.transform(CL(r))+", "+CL(R8.transform(n))+")"},Vd={test:t=>u4.test(t)||Tve.test(t)||F5.test(t),parse:t=>u4.test(t)?u4.parse(t):F5.test(t)?F5.parse(t):Tve.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?u4.transform(t):F5.transform(t),getAnimatableNone:t=>{const s=Vd.parse(t);return s.alpha=0,Vd.transform(s)}},JCt=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function e3t(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(bje))==null?void 0:s.length)||0)+(((r=t.match(JCt))==null?void 0:r.length)||0)>0}const LGe="number",DGe="color",t3t="var",s3t="var(",aPe="${}",r3t=/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 jT(t){const s=t.toString(),r=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=s.replace(r3t,c=>(Vd.test(c)?(n.color.push(o),a.push(DGe),r.push(Vd.parse(c))):c.startsWith(s3t)?(n.var.push(o),a.push(t3t),r.push(c)):(n.number.push(o),a.push(LGe),r.push(parseFloat(c))),++o,aPe)).split(aPe);return{values:r,split:i,indexes:n,types:a}}function n3t(t){return jT(t).values}function OGe({split:t,types:s}){const r=t.length;return n=>{let a="";for(let o=0;otypeof t=="number"?0:Vd.test(t)?Vd.getAnimatableNone(t):t,o3t=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:i3t(t);function l3t(t){const s=jT(t);return OGe(s)(s.values.map((n,a)=>o3t(n,s.split[a])))}const Zx={test:e3t,parse:n3t,createTransformer:a3t,getAnimatableNone:l3t};function _ge(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 c3t({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=_ge(c,i,t+1/3),o=_ge(c,i,t),l=_ge(c,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function Soe(t,s){return r=>r>0?s:t}const mc=(t,s,r)=>t+(s-t)*r,bge=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},d3t=[Tve,u4,F5],u3t=t=>d3t.find(s=>s.test(t));function iPe(t){const s=u3t(t);if(!s)return!1;let r=s.parse(t);return s===F5&&(r=c3t(r)),r}const oPe=(t,s)=>{const r=iPe(t),n=iPe(s);if(!r||!n)return Soe(t,s);const a={...r};return o=>(a.red=bge(r.red,n.red,o),a.green=bge(r.green,n.green,o),a.blue=bge(r.blue,n.blue,o),a.alpha=mc(r.alpha,n.alpha,o),u4.transform(a))},Ave=new Set(["none","hidden"]);function h3t(t,s){return Ave.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function m3t(t,s){return r=>mc(t,s,r)}function jje(t){return typeof t=="number"?m3t:typeof t=="string"?_je(t)?Soe:Vd.test(t)?oPe:g3t:Array.isArray(t)?RGe:typeof t=="object"?Vd.test(t)?oPe:p3t:Soe}function RGe(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>jje(o)(o,s[l]));return o=>{for(let l=0;l{for(const o in n)r[o]=n[o](a);return r}}function f3t(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=Zx.createTransformer(s),n=jT(t),a=jT(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?Ave.has(t)&&!a.values.length||Ave.has(s)&&!n.values.length?h3t(t,s):fO(RGe(f3t(n,a),a.values),r):Soe(t,s)};function FGe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?mc(t,s,r):jje(t)(t,s)}const x3t=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>Cl.update(s,r),stop:()=>l2(s),now:()=>dh.isProcessing?dh.timestamp:xm.now()}},zGe=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=Coe?1/0:s}function y3t(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(kje(n),Coe);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:hg(a)}}const nd={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 Eve(t,s){return t*Math.sqrt(1-s*s)}const v3t=12;function _3t(t,s,r){let n=r;for(let a=1;a{const p=u*l,f=p*t,y=p-r,_=Eve(u,l),b=Math.exp(-f);return wge-y/_*b},o=u=>{const f=u*l*t,y=f*r+r,_=Math.pow(l,2)*Math.pow(u,2)*t,b=Math.exp(-f),w=Eve(Math.pow(u,2),l);return(-a(u)+wge>0?-1:1)*((y-_)*b)/w}):(a=u=>{const p=Math.exp(-u*t),f=(u-r)*t+1;return-wge+p*f},o=u=>{const p=Math.exp(-u*t),f=(r-u)*(t*t);return p*f});const i=5/t,c=_3t(a,o,i);if(t=uf(t),isNaN(c))return{stiffness:nd.stiffness,damping:nd.damping,duration:t};{const u=Math.pow(c,2)*n;return{stiffness:u,damping:l*2*Math.sqrt(n*u),duration:t}}}const w3t=["duration","bounce"],j3t=["stiffness","damping","mass"];function lPe(t,s){return s.some(r=>t[r]!==void 0)}function k3t(t){let s={velocity:nd.velocity,stiffness:nd.stiffness,damping:nd.damping,mass:nd.mass,isResolvedFromDuration:!1,...t};if(!lPe(t,j3t)&&lPe(t,w3t))if(s.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),a=n*n,o=2*v0(.05,1,1-(t.bounce||0))*Math.sqrt(a);s={...s,mass:nd.mass,stiffness:a,damping:o}}else{const r=b3t({...t,velocity:0});s={...s,...r,mass:nd.mass},s.isResolvedFromDuration=!0}return s}function Moe(t=nd.visualDuration,s=nd.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:y,isResolvedFromDuration:_}=k3t({...r,velocity:-hg(r.velocity||0)}),b=y||0,w=u/(2*Math.sqrt(c*p)),j=l-o,N=hg(Math.sqrt(c/p)),S=Math.abs(j)<5;n||(n=S?nd.restSpeed.granular:nd.restSpeed.default),a||(a=S?nd.restDelta.granular:nd.restDelta.default);let T,I,L,R,$,q;if(w<1)L=Eve(N,w),R=(b+w*N*j)/L,T=V=>{const X=Math.exp(-w*N*V);return l-X*(R*Math.sin(L*V)+j*Math.cos(L*V))},$=w*N*R+j*L,q=w*N*j-R*L,I=V=>Math.exp(-w*N*V)*($*Math.sin(L*V)+q*Math.cos(L*V));else if(w===1){T=X=>l-Math.exp(-N*X)*(j+(b+N*j)*X);const V=b+N*j;I=X=>Math.exp(-N*X)*(N*V*X-b)}else{const V=N*Math.sqrt(w*w-1);T=Q=>{const de=Math.exp(-w*N*Q),re=Math.min(V*Q,300);return l-de*((b+w*N*j)*Math.sinh(re)+V*j*Math.cosh(re))/V};const X=(b+w*N*j)/V,se=w*N*X-j*V,ee=w*N*j-X*V;I=Q=>{const de=Math.exp(-w*N*Q),re=Math.min(V*Q,300);return de*(se*Math.sinh(re)+ee*Math.cosh(re))}}const U={calculatedDuration:_&&f||null,velocity:V=>uf(I(V)),next:V=>{if(!_&&w<1){const se=Math.exp(-w*N*V),ee=Math.sin(L*V),Q=Math.cos(L*V),de=l-se*(R*ee+j*Q),re=uf(se*($*ee+q*Q));return i.done=Math.abs(re)<=n&&Math.abs(l-de)<=a,i.value=i.done?l:de,i}const X=T(V);if(_)i.done=V>=f;else{const se=uf(I(V));i.done=Math.abs(se)<=n&&Math.abs(l-X)<=a}return i.value=i.done?l:X,i},toString:()=>{const V=Math.min(kje(U),Coe),X=zGe(se=>U.next(V*se).value,V,30);return V+"ms "+X},toTransition:()=>{}};return U}Moe.applyToOptions=t=>{const s=y3t(t,100,Moe);return t.ease=s.ease,t.duration=uf(s.duration),t.type="keyframes",t};const N3t=5;function BGe(t,s,r){const n=Math.max(s-N3t,0);return vGe(r-t(n),s-n)}function Pve({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],y={done:!1,value:f},_=q=>i!==void 0&&qc,b=q=>i===void 0?c:c===void 0||Math.abs(i-q)-w*Math.exp(-q/n),T=q=>N+S(q),I=q=>{const U=S(q),V=T(q);y.done=Math.abs(U)<=u,y.value=y.done?N:V};let L,R;const $=q=>{_(y.value)&&(L=q,R=Moe({keyframes:[y.value,b(y.value)],velocity:BGe(T,q,y.value),damping:a,stiffness:o,restDelta:u,restSpeed:p}))};return $(0),{calculatedDuration:null,next:q=>{let U=!1;return!R&&L===void 0&&(U=!0,I(q),$(q)),L!==void 0&&q>=L?R.next(q-L):(!U&&I(q),y)}}}function S3t(t,s,r){const n=[],a=r||o2.mix||FGe,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=S3t(s,n,a),c=i.length,u=p=>{if(l&&p1)for(;fu(v0(t[0],t[o-1],p)):u}function M3t(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=O8(0,s,n);t.push(mc(r,1,a))}}function T3t(t){const s=[0];return M3t(s,t.length-1),s}function A3t(t,s){return t.map(r=>r*s)}function E3t(t,s){return t.map(()=>s||MGe).splice(0,t.length-1)}function ML({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=zCt(n)?n.map(sPe):sPe(n),o={done:!1,value:s[0]},l=A3t(r&&r.length===s.length?r:T3t(s),t),i=C3t(l,s,{ease:Array.isArray(a)?a:E3t(s,a)});return{calculatedDuration:t,next:c=>(o.value=i(c),o.done=c>=t,o)}}const P3t=t=>t!==null;function Yde(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(P3t),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const I3t={decay:Pve,inertia:Pve,tween:ML,keyframes:ML,spring:Moe};function $Ge(t){typeof t.type=="string"&&(t.type=I3t[t.type])}class Nje{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 L3t=t=>t/100;class Toe extends Nje{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!==xm.now()&&this.tick(xm.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;$Ge(s);const{type:r=ML,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const c=r||ML;c!==ML&&typeof i[0]!="number"&&(this.mixKeyframes=fO(L3t,FGe(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=kje(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:y,repeatDelay:_,type:b,onUpdate:w,finalKeyframe:j}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-a/this.speed,this.startTime)),r?this.currentTime=s:this.updateTime(s);const N=this.currentTime-u*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?N<0:N>a;this.currentTime=Math.max(N,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let T=this.currentTime,I=n;if(f){const q=Math.min(this.currentTime,a)/i;let U=Math.floor(q),V=q%1;!V&&q>=1&&(V=1),V===1&&U--,U=Math.min(U,f+1),!!(U%2)&&(y==="reverse"?(V=1-V,_&&(V-=_/i)):y==="mirror"&&(I=l)),T=v0(0,1,V)*i}let L;S?(this.delayState.value=p[0],L=this.delayState):L=I.next(T),o&&!S&&(L.value=o(L.value));let{done:R}=L;!S&&c!==null&&(R=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const $=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&R);return $&&b!==Pve&&(L.value=Yde(p,this.options,j,this.speed)),w&&w(L.value),$&&this.finish(),L}then(s,r){return this.finished.then(s,r)}get duration(){return hg(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+hg(s)}get time(){return hg(this.currentTime)}set time(s){s=uf(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 BGe(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(xm.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=hg(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:s=x3t,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(xm.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 D3t(t){for(let s=1;st*180/Math.PI,Ive=t=>{const s=h4(Math.atan2(t[1],t[0]));return Lve(s)},O3t={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Ive,rotateZ:Ive,skewX:t=>h4(Math.atan(t[1])),skewY:t=>h4(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Lve=t=>(t=t%360,t<0&&(t+=360),t),cPe=Ive,dPe=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),uPe=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),R3t={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:dPe,scaleY:uPe,scale:t=>(dPe(t)+uPe(t))/2,rotateX:t=>Lve(h4(Math.atan2(t[6],t[5]))),rotateY:t=>Lve(h4(Math.atan2(-t[2],t[0]))),rotateZ:cPe,rotate:cPe,skewX:t=>h4(Math.atan(t[4])),skewY:t=>h4(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Dve(t){return t.includes("scale")?1:0}function Ove(t,s){if(!t||t==="none")return Dve(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=R3t,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=O3t,a=i}if(!a)return Dve(s);const o=n[s],l=a[1].split(",").map(z3t);return typeof o=="function"?o(l):l[o]}const F3t=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return Ove(r,s)};function z3t(t){return parseFloat(t.trim())}const IA=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],LA=new Set(IA),hPe=t=>t===PA||t===ta,B3t=new Set(["x","y","z"]),$3t=IA.filter(t=>!B3t.has(t));function q3t(t){const s=[];return $3t.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const fb={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})=>Ove(s,"x"),y:(t,{transform:s})=>Ove(s,"y")};fb.translateX=fb.x;fb.translateY=fb.y;const Y4=new Set;let Rve=!1,Fve=!1,zve=!1;function qGe(){if(Fve){const t=Array.from(Y4).filter(n=>n.needsMeasurement),s=new Set(t.map(n=>n.element)),r=new Map;s.forEach(n=>{const a=q3t(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)})}Fve=!1,Rve=!1,Y4.forEach(t=>t.complete(zve)),Y4.clear()}function UGe(){Y4.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Fve=!0)})}function U3t(){zve=!0,UGe(),qGe(),zve=!1}class Sje{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?(Y4.add(this),Rve||(Rve=!0,Cl.read(UGe),Cl.resolveKeyframes(qGe))):(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])}D3t(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),Y4.delete(this)}cancel(){this.state==="scheduled"&&(Y4.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const V3t=t=>t.startsWith("--");function VGe(t,s,r){V3t(s)?t.style.setProperty(s,r):t.style[s]=r}const H3t={};function HGe(t,s){const r=yGe(t);return()=>H3t[s]??r()}const W3t=HGe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),WGe=HGe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),nI=([t,s,r,n])=>`cubic-bezier(${t}, ${s}, ${r}, ${n})`,mPe={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:nI([0,.65,.55,1]),circOut:nI([.55,0,1,.45]),backIn:nI([.31,.01,.66,-.59]),backOut:nI([.33,1.53,.69,.99])};function GGe(t,s){if(t)return typeof t=="function"?WGe()?zGe(t,s):"ease-out":TGe(t)?nI(t):Array.isArray(t)?t.map(r=>GGe(r,s)||mPe.easeOut):mPe[t]}function G3t(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=GGe(i,a);Array.isArray(f)&&(p.easing=f);const y={delay:n,duration:a,easing:Array.isArray(f)?"linear":f,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return u&&(y.pseudoElement=u),t.animate(p,y)}function KGe(t){return typeof t=="function"&&"applyToOptions"in t}function K3t({type:t,...s}){return KGe(t)&&WGe()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class ZGe extends Nje{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,gje(typeof s.type!="string");const u=K3t(s);this.animation=G3t(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=Yde(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(p),VGe(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 hg(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+hg(s)}get time(){return hg(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=uf(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&&W3t()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),_g):a(this)}}const YGe={anticipate:NGe,backInOut:kGe,circInOut:CGe};function Z3t(t){return t in YGe}function Y3t(t){typeof t.ease=="string"&&Z3t(t.ease)&&(t.ease=YGe[t.ease])}const jge=10;class X3t extends ZGe{constructor(s){Y3t(s),$Ge(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 Toe({...l,autoplay:!1}),c=Math.max(jge,xm.now()-this.startTime),u=v0(0,jge,c-jge),p=i.sample(c).value,{name:f}=this.options;o&&f&&VGe(o,f,p),r.setWithVelocity(i.sample(Math.max(0,c-u)).value,p,u),i.stop()}}const pPe=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Zx.test(t)||t==="0")&&!t.startsWith("url("));function Q3t(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function n5t(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 r5t()&&r&&(XGe.has(r)||s5t.has(r)&&t5t(i))&&(r!=="transform"||!p)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const a5t=40;class i5t extends Nje{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 b;super(),this.stop=()=>{var w,j;this._animation&&(this._animation.stop(),(w=this.stopTimeline)==null||w.call(this)),(j=this.keyframeResolver)==null||j.cancel()},this.createdAt=xm.now();const y={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:c,motionValue:u,element:p,...f},_=(p==null?void 0:p.KeyframeResolver)||Sje;this.keyframeResolver=new _(i,(w,j,N)=>this.onKeyframesResolved(w,j,y,!N),c,u,p),(b=this.keyframeResolver)==null||b.scheduleResolve()}onKeyframesResolved(s,r,n,a){var N,S;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:c,isHandoff:u,onUpdate:p}=n;this.resolvedAt=xm.now();let f=!0;J3t(s,o,l,i)||(f=!1,(o2.instantAnimations||!c)&&(p==null||p(Yde(s,n,r))),s[0]=s[s.length-1],Bve(n),n.repeat=0);const _={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>a5t?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},b=f&&!u&&n5t(_),w=(S=(N=_.motionValue)==null?void 0:N.owner)==null?void 0:S.current;let j;if(b)try{j=new X3t({..._,element:w})}catch{j=new Toe(_)}else j=new Toe(_);j.finished.then(()=>{this.notifyFinished()}).catch(_g),this.pendingTimeline&&(this.stopTimeline=j.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=j}get finished(){return this._animation?this.animation.finished:this._finished}then(s,r){return this.finished.finally(s).then(()=>{})}get animation(){var s;return this._animation||((s=this.keyframeResolver)==null||s.resume(),U3t()),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 QGe(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 o5t=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function l5t(t){const s=o5t.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}function JGe(t,s,r=1){const[n,a]=l5t(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return fGe(l)?parseFloat(l):l}return _je(a)?JGe(a,s,r+1):a}const c5t={type:"spring",stiffness:500,damping:25,restSpeed:10},d5t=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),u5t={type:"keyframes",duration:.8},h5t={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},m5t=(t,{keyframes:s})=>s.length>2?u5t:LA.has(t)?t.startsWith("scale")?d5t(s[1]):c5t:h5t;function eKe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function Cje(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?eKe(r,t):r}const p5t=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function f5t(t){for(const s in t)if(!p5t.has(s))return!0;return!1}const Mje=(t,s,r,n={},a,o)=>l=>{const i=Cje(n,t)||{},c=i.delay||n.delay||0;let{elapsed:u=0}=n;u=u-uf(c);const p={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:s.getVelocity(),...i,delay:-u,onUpdate:y=>{s.set(y),i.onUpdate&&i.onUpdate(y)},onComplete:()=>{l(),i.onComplete&&i.onComplete()},name:t,motionValue:s,element:o?void 0:a};f5t(i)||Object.assign(p,m5t(t,p)),p.duration&&(p.duration=uf(p.duration)),p.repeatDelay&&(p.repeatDelay=uf(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let f=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(Bve(p),p.delay===0&&(f=!0)),(o2.instantAnimations||o2.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(f=!0,Bve(p),p.delay=0),p.allowFlatten=!i.type&&!i.ease,f&&!o&&s.get()!==void 0){const y=Yde(p.keyframes,i);if(y!==void 0){Cl.update(()=>{p.onUpdate(y),p.onComplete()});return}}return i.isSync?new Toe(p):new i5t(p)};function fPe(t){const s=[{},{}];return t==null||t.values.forEach((r,n)=>{s[0][n]=r.get(),s[1][n]=r.getVelocity()}),s}function Tje(t,s,r,n){if(typeof s=="function"){const[a,o]=fPe(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]=fPe(n);s=s(r!==void 0?r:t.custom,a,o)}return s}function X4(t,s,r){const n=t.getProps();return Tje(n,s,r!==void 0?r:n.custom,t)}const tKe=new Set(["width","height","top","left","right","bottom",...IA]),gPe=30,g5t=t=>!isNaN(parseFloat(t));class x5t{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=xm.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=xm.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=g5t(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 xje);const n=this.events[s].add(r);return s==="change"?()=>{n(),Cl.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=xm.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>gPe)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,gPe);return vGe(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 kT(t,s){return new x5t(t,s)}const $ve=t=>Array.isArray(t);function y5t(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,kT(r))}function v5t(t){return $ve(t)?t[t.length-1]||0:t}function _5t(t,s){const r=X4(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=v5t(o[l]);y5t(t,l,i)}}const ph=t=>!!(t&&t.getVelocity);function b5t(t){return!!(ph(t)&&t.add)}function qve(t,s){const r=t.getValue("willChange");if(b5t(r))return r.add(s);if(!r&&o2.WillChange){const n=new o2.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function Aje(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const w5t="framerAppearId",sKe="data-"+Aje(w5t);function rKe(t){return t.props[sKe]}function j5t({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function nKe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const c=t.getDefaultTransition();o=o?eKe(o,c):c;const u=o==null?void 0:o.reduceMotion;n&&(o=n);const p=[],f=a&&t.animationState&&t.animationState.getState()[a];for(const y in i){const _=t.getValue(y,t.latestValues[y]??null),b=i[y];if(b===void 0||f&&j5t(f,y))continue;const w={delay:r,...Cje(o||{},y)},j=_.get();if(j!==void 0&&!_.isAnimating()&&!Array.isArray(b)&&b===j&&!w.velocity){Cl.update(()=>_.set(b));continue}let N=!1;if(window.MotionHandoffAnimation){const I=rKe(t);if(I){const L=window.MotionHandoffAnimation(I,y,Cl);L!==null&&(w.startTime=L,N=!0)}}qve(t,y);const S=u??t.shouldReduceMotion;_.start(Mje(y,_,b,S&&tKe.has(y)?{type:!1}:w,t,N));const T=_.animation;T&&p.push(T)}if(l){const y=()=>Cl.update(()=>{l&&_5t(t,l)});p.length?Promise.all(p).then(y):y()}return p}function Uve(t,s,r={}){var c;const n=X4(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(nKe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:p=0,staggerChildren:f,staggerDirection:y}=a;return k5t(t,s,u,p,f,y,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 k5t(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(Uve(c,s,{...l,delay:r+(typeof n=="function"?0:n)+QGe(t.variantChildren,c,n,a,o)}).then(()=>c.notify("AnimationComplete",s)));return Promise.all(i)}function N5t(t,s,r={}){t.notify("AnimationStart",s);let n;if(Array.isArray(s)){const a=s.map(o=>Uve(t,o,r));n=Promise.all(a)}else if(typeof s=="string")n=Uve(t,s,r);else{const a=typeof s=="function"?X4(t,s,r.custom):s;n=Promise.all(nKe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const S5t={test:t=>t==="auto",parse:t=>t},aKe=t=>s=>s.test(t),iKe=[PA,ta,m0,E_,QCt,XCt,S5t],xPe=t=>iKe.find(aKe(t));function C5t(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||xGe(t):!0}const M5t=new Set(["brightness","contrast","saturate","opacity"]);function T5t(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(bje)||[];if(!n)return t;const a=r.replace(n,"");let o=M5t.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const A5t=/\b([a-z-]*)\(.*?\)/gu,Vve={...Zx,getAnimatableNone:t=>{const s=t.match(A5t);return s?s.map(T5t).join(" "):t}},Hve={...Zx,getAnimatableNone:t=>{const s=Zx.parse(t);return Zx.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},yPe={...PA,transform:Math.round},E5t={rotate:E_,rotateX:E_,rotateY:E_,rotateZ:E_,scale:O7,scaleX:O7,scaleY:O7,scaleZ:O7,skew:E_,skewX:E_,skewY:E_,distance:ta,translateX:ta,translateY:ta,translateZ:ta,x:ta,y:ta,z:ta,perspective:ta,transformPerspective:ta,opacity:R8,originX:nPe,originY:nPe,originZ:ta},Eje={borderWidth:ta,borderTopWidth:ta,borderRightWidth:ta,borderBottomWidth:ta,borderLeftWidth:ta,borderRadius:ta,borderTopLeftRadius:ta,borderTopRightRadius:ta,borderBottomRightRadius:ta,borderBottomLeftRadius:ta,width:ta,maxWidth:ta,height:ta,maxHeight:ta,top:ta,right:ta,bottom:ta,left:ta,inset:ta,insetBlock:ta,insetBlockStart:ta,insetBlockEnd:ta,insetInline:ta,insetInlineStart:ta,insetInlineEnd:ta,padding:ta,paddingTop:ta,paddingRight:ta,paddingBottom:ta,paddingLeft:ta,paddingBlock:ta,paddingBlockStart:ta,paddingBlockEnd:ta,paddingInline:ta,paddingInlineStart:ta,paddingInlineEnd:ta,margin:ta,marginTop:ta,marginRight:ta,marginBottom:ta,marginLeft:ta,marginBlock:ta,marginBlockStart:ta,marginBlockEnd:ta,marginInline:ta,marginInlineStart:ta,marginInlineEnd:ta,fontSize:ta,backgroundPositionX:ta,backgroundPositionY:ta,...E5t,zIndex:yPe,fillOpacity:R8,strokeOpacity:R8,numOctaves:yPe},P5t={...Eje,color:Vd,backgroundColor:Vd,outlineColor:Vd,fill:Vd,stroke:Vd,borderColor:Vd,borderTopColor:Vd,borderRightColor:Vd,borderBottomColor:Vd,borderLeftColor:Vd,filter:Vve,WebkitFilter:Vve,mask:Hve,WebkitMask:Hve},oKe=t=>P5t[t],I5t=new Set([Vve,Hve]);function lKe(t,s){let r=oKe(t);return I5t.has(r)||(r=Zx),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const L5t=new Set(["auto","none","0"]);function D5t(t,s,r){let n=0,a;for(;n{s.getValue(c).set(u)}),this.resolveNoneKeyframes()}}function cKe(t,s,r){if(t==null)return[];if(t instanceof EventTarget)return[t];if(typeof t=="string"){let n=document;const a=(r==null?void 0:r[t])??n.querySelectorAll(t);return a?Array.from(a):[]}return Array.from(t).filter(n=>n!=null)}const dKe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function oie(t){return gGe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:Pje}=AGe(queueMicrotask,!1),jx={x:!1,y:!1};function uKe(){return jx.x||jx.y}function R5t(t){return t==="x"||t==="y"?jx[t]?null:(jx[t]=!0,()=>{jx[t]=!1}):jx.x||jx.y?null:(jx.x=jx.y=!0,()=>{jx.x=jx.y=!1})}function hKe(t,s){const r=cKe(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function F5t(t){return!(t.pointerType==="touch"||uKe())}function z5t(t,s,r={}){const[n,a,o]=hKe(t,r);return n.forEach(l=>{let i=!1,c=!1,u;const p=()=>{l.removeEventListener("pointerleave",b)},f=j=>{u&&(u(j),u=void 0),p()},y=j=>{i=!1,window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),c&&(c=!1,f(j))},_=()=>{i=!0,window.addEventListener("pointerup",y,a),window.addEventListener("pointercancel",y,a)},b=j=>{if(j.pointerType!=="touch"){if(i){c=!0;return}f(j)}},w=j=>{if(!F5t(j))return;c=!1;const N=s(l,j);typeof N=="function"&&(u=N,l.addEventListener("pointerleave",b,a))};l.addEventListener("pointerenter",w,a),l.addEventListener("pointerdown",_,a)}),o}const mKe=(t,s)=>s?t===s?!0:mKe(t,s.parentElement):!1,Ije=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,B5t=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function $5t(t){return B5t.has(t.tagName)||t.isContentEditable===!0}const q5t=new Set(["INPUT","SELECT","TEXTAREA"]);function U5t(t){return q5t.has(t.tagName)||t.isContentEditable===!0}const lie=new WeakSet;function vPe(t){return s=>{s.key==="Enter"&&t(s)}}function kge(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const V5t=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=vPe(()=>{if(lie.has(r))return;kge(r,"down");const a=vPe(()=>{kge(r,"up")}),o=()=>kge(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 _Pe(t){return Ije(t)&&!uKe()}const bPe=new WeakSet;function H5t(t,s,r={}){const[n,a,o]=hKe(t,r),l=i=>{const c=i.currentTarget;if(!_Pe(i)||bPe.has(i))return;lie.add(c),r.stopPropagation&&bPe.add(i);const u=s(c,i),p=(_,b)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",y),lie.has(c)&&lie.delete(c),_Pe(_)&&typeof u=="function"&&u(_,{success:b})},f=_=>{p(_,c===window||c===document||r.useGlobalTarget||mKe(c,_.target))},y=_=>{p(_,!1)};window.addEventListener("pointerup",f,a),window.addEventListener("pointercancel",y,a)};return n.forEach(i=>{(r.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),oie(i)&&(i.addEventListener("focus",u=>V5t(u,a)),!$5t(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function Lje(t){return gGe(t)&&"ownerSVGElement"in t}const cie=new WeakMap;let P_;const pKe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:Lje(n)&&"getBBox"in n?n.getBBox()[s]:n[r],W5t=pKe("inline","width","offsetWidth"),G5t=pKe("block","height","offsetHeight");function K5t({target:t,borderBoxSize:s}){var r;(r=cie.get(t))==null||r.forEach(n=>{n(t,{get width(){return W5t(t,s)},get height(){return G5t(t,s)}})})}function Z5t(t){t.forEach(K5t)}function Y5t(){typeof ResizeObserver>"u"||(P_=new ResizeObserver(Z5t))}function X5t(t,s){P_||Y5t();const r=cKe(t);return r.forEach(n=>{let a=cie.get(n);a||(a=new Set,cie.set(n,a)),a.add(s),P_==null||P_.observe(n)}),()=>{r.forEach(n=>{const a=cie.get(n);a==null||a.delete(s),a!=null&&a.size||P_==null||P_.unobserve(n)})}}const die=new Set;let z5;function Q5t(){z5=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};die.forEach(s=>s(t))},window.addEventListener("resize",z5)}function J5t(t){return die.add(t),z5||Q5t(),()=>{die.delete(t),!die.size&&typeof z5=="function"&&(window.removeEventListener("resize",z5),z5=void 0)}}function wPe(t,s){return typeof t=="function"?J5t(t):X5t(t,s)}function eMt(t){return Lje(t)&&t.tagName==="svg"}const tMt=[...iKe,Vd,Zx],sMt=t=>tMt.find(aKe(t)),jPe=()=>({translate:0,scale:1,origin:0,originPoint:0}),B5=()=>({x:jPe(),y:jPe()}),kPe=()=>({min:0,max:0}),ou=()=>({x:kPe(),y:kPe()}),rMt=new WeakMap;function Xde(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function F8(t){return typeof t=="string"||Array.isArray(t)}const Dje=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Oje=["initial",...Dje];function Qde(t){return Xde(t.animate)||Oje.some(s=>F8(t[s]))}function fKe(t){return!!(Qde(t)||t.variants)}function nMt(t,s,r){for(const n in s){const a=s[n],o=r[n];if(ph(a))t.addValue(n,a);else if(ph(o))t.addValue(n,kT(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,kT(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const Wve={current:null},gKe={current:!1},aMt=typeof window<"u";function iMt(){if(gKe.current=!0,!!aMt)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>Wve.current=t.matches;t.addEventListener("change",s),s()}else Wve.current=!1}const NPe=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Aoe={};function xKe(t){Aoe=t}function oMt(){return Aoe}class lMt{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=Sje,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 _=xm.now();this.renderScheduledAt<_&&(this.renderScheduledAt=_,Cl.render(this.render,!1,!0))};const{latestValues:u,renderState:p}=i;this.latestValues=u,this.baseTarget={...u},this.initialValues=r.initial?{...u}:{},this.renderState=p,this.parent=s,this.props=r,this.presenceContext=n,this.depth=s?s.depth+1:0,this.reducedMotionConfig=a,this.skipAnimationsConfig=o,this.options=c,this.blockInitialAnimation=!!l,this.isControllingVariants=Qde(r),this.isVariantNode=fKe(r),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(s&&s.current);const{willChange:f,...y}=this.scrapeMotionValuesFromProps(r,{},this);for(const _ in y){const b=y[_];u[_]!==void 0&&ph(b)&&b.set(u[_])}}mount(s){var r,n;if(this.hasBeenMounted)for(const a in this.initialValues)(r=this.values.get(a))==null||r.jump(this.initialValues[a]),this.latestValues[a]=this.initialValues[a];this.current=s,rMt.set(s,this),this.projection&&!this.projection.instance&&this.projection.mount(s),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((a,o)=>this.bindToMotionValue(o,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(gKe.current||iMt(),this.shouldReduceMotion=Wve.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(),l2(this.notifyUpdate),l2(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&&XGe.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:c,ease:u,duration:p}=r.accelerate,f=new ZGe({element:this.current,name:s,keyframes:i,times:c,ease:u,duration:uf(p)}),y=l(f);this.valueSubscriptions.set(s,()=>{y(),f.cancel()});return}const n=LA.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&Cl.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 Aoe){const r=Aoe[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):ou()}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=kT(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"&&(fGe(n)||xGe(n))?n=parseFloat(n):!sMt(n)&&Zx.test(r)&&(n=lKe(s,r)),this.setBaseTarget(s,ph(n)?n.get():n)),ph(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=Tje(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&&!ph(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 xje),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){Pje.render(this.render)}}class yKe extends lMt{constructor(){super(...arguments),this.KeyframeResolver=O5t}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;ph(s)&&(this.childSubscription=s.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class S2{constructor(s){this.isMounted=!1,this.node=s}update(){}}function vKe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function cMt({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function dMt(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 Nge(t){return t===void 0||t===1}function Gve({scale:t,scaleX:s,scaleY:r}){return!Nge(t)||!Nge(s)||!Nge(r)}function YN(t){return Gve(t)||_Ke(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function _Ke(t){return SPe(t.x)||SPe(t.y)}function SPe(t){return t&&t!=="0%"}function Eoe(t,s,r){const n=t-r,a=s*n;return r+a}function CPe(t,s,r,n,a){return a!==void 0&&(t=Eoe(t,a,n)),Eoe(t,r,n)+s}function Kve(t,s=0,r=1,n,a){t.min=CPe(t.min,s,r,n,a),t.max=CPe(t.max,s,r,n,a)}function bKe(t,{x:s,y:r}){Kve(t.x,s.translate,s.scale,s.originPoint),Kve(t.y,r.translate,r.scale,r.originPoint)}const MPe=.999999999999,TPe=1.0000000000001;function uMt(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;cMPe&&(s.x=1),s.yMPe&&(s.y=1)}function Gy(t,s){t.min+=s,t.max+=s}function APe(t,s,r,n,a=.5){const o=mc(t.min,t.max,a);Kve(t,s,r,o,n)}function EPe(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function uie(t,s,r){const n=r??t;APe(t.x,EPe(s.x,n.x),s.scaleX,s.scale,s.originX),APe(t.y,EPe(s.y,n.y),s.scaleY,s.scale,s.originY)}function wKe(t,s){return vKe(dMt(t.getBoundingClientRect(),s))}function hMt(t,s,r){const n=wKe(t,r),{scroll:a}=s;return a&&(Gy(n.x,a.offset.x),Gy(n.y,a.offset.y)),n}const mMt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},pMt=IA.length;function fMt(t,s,r){let n="",a=!0;for(let o=0;o{if(!s.target)return t;if(typeof t=="string")if(ta.test(t))t=parseFloat(t);else return t;const r=PPe(t,s.target.x),n=PPe(t,s.target.y);return`${r}% ${n}%`}},gMt={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=Zx.parse(t);if(a.length>5)return n;const o=Zx.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=mc(i,c,.5);return typeof a[2+l]=="number"&&(a[2+l]/=u),typeof a[3+l]=="number"&&(a[3+l]/=u),o(a)}},Zve={borderRadius:{...S6,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:S6,borderTopRightRadius:S6,borderBottomLeftRadius:S6,borderBottomRightRadius:S6,boxShadow:gMt};function kKe(t,{layout:s,layoutId:r}){return LA.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!Zve[t]||t==="opacity")}function Fje(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)(ph(n[i])||a&&ph(a[i])||kKe(i,t)||((l=r==null?void 0:r.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function xMt(t){return window.getComputedStyle(t)}class yMt extends yKe{constructor(){super(...arguments),this.type="html",this.renderInstance=jKe}readValueFromInstance(s,r){var n;if(LA.has(r))return(n=this.projection)!=null&&n.isProjecting?Dve(r):F3t(s,r);{const a=xMt(s),o=(PGe(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return wKe(s,r)}build(s,r,n){Rje(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return Fje(s,r,n)}}const vMt={offset:"stroke-dashoffset",array:"stroke-dasharray"},_Mt={offset:"strokeDashoffset",array:"strokeDasharray"};function bMt(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?vMt:_Mt;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const wMt=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function NKe(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},c,u,p){if(Rje(t,i,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:f,style:y}=t;f.transform&&(y.transform=f.transform,delete f.transform),(y.transform||f.transformOrigin)&&(y.transformOrigin=f.transformOrigin??"50% 50%",delete f.transformOrigin),y.transform&&(y.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete f.transformBox);for(const _ of wMt)f[_]!==void 0&&(y[_]=f[_],delete f[_]);s!==void 0&&(f.x=s),r!==void 0&&(f.y=r),n!==void 0&&(f.scale=n),a!==void 0&&bMt(f,a,o,l,!1)}const SKe=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"]),CKe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function jMt(t,s,r,n){jKe(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(SKe.has(a)?a:Aje(a),s.attrs[a])}function MKe(t,s,r){const n=Fje(t,s,r);for(const a in t)if(ph(t[a])||ph(s[a])){const o=IA.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class kMt extends yKe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=ou}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(LA.has(r)){const n=oKe(r);return n&&n.default||0}return r=SKe.has(r)?r:Aje(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return MKe(s,r,n)}build(s,r,n){NKe(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){jMt(s,r,n,a)}mount(s){this.isSVGTag=CKe(s.tagName),super.mount(s)}}const NMt=Oje.length;function TKe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?TKe(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})=>N5t(t,r,n)))}function TMt(t){let s=MMt(t),r=IPe(),n=!0,a=!1;const o=u=>(p,f)=>{var _;const y=X4(t,f,u==="exit"?(_=t.presenceContext)==null?void 0:_.custom:void 0);if(y){const{transition:b,transitionEnd:w,...j}=y;p={...p,...j,...w}}return p};function l(u){s=u(t)}function i(u){const{props:p}=t,f=TKe(t.parent)||{},y=[],_=new Set;let b={},w=1/0;for(let N=0;Nw&&L,V=!1;const X=Array.isArray(I)?I:[I];let se=X.reduce(o(S),{});R===!1&&(se={});const{prevResolvedValues:ee={}}=T,Q={...ee,...se},de=le=>{U=!0,_.has(le)&&(V=!0,_.delete(le)),T.needsAnimating[le]=!0;const he=t.getValue(le);he&&(he.liveStyle=!1)};for(const le in Q){const he=se[le],we=ee[le];if(b.hasOwnProperty(le))continue;let ye=!1;$ve(he)&&$ve(we)?ye=!AKe(he,we):ye=he!==we,ye?he!=null?de(le):_.add(le):he!==void 0&&_.has(le)?de(le):T.protectedKeys[le]=!0}T.prevProp=I,T.prevResolvedValues=se,T.isActive&&(b={...b,...se}),(n||a)&&t.blockInitialAnimation&&(U=!1);const re=$&&q;U&&(!re||V)&&y.push(...X.map(le=>{const he={type:S};if(typeof le=="string"&&(n||a)&&!re&&t.manuallyAnimateOnMount&&t.parent){const{parent:we}=t,ye=X4(we,le);if(we.enteringChildren&&ye){const{delayChildren:je}=ye.transition||{};he.delay=QGe(we.enteringChildren,t,je)}}return{animation:le,options:he}}))}if(_.size){const N={};if(typeof p.initial!="boolean"){const S=X4(t,Array.isArray(p.initial)?p.initial[0]:p.initial);S&&S.transition&&(N.transition=S.transition)}_.forEach(S=>{const T=t.getBaseTarget(S),I=t.getValue(S);I&&(I.liveStyle=!0),N[S]=T??null}),y.push({animation:N})}let j=!!y.length;return n&&(p.initial===!1||p.initial===p.animate)&&!t.manuallyAnimateOnMount&&(j=!1),n=!1,a=!1,j?s(y):Promise.resolve()}function c(u,p){var y;if(r[u].isActive===p)return Promise.resolve();(y=t.variantChildren)==null||y.forEach(_=>{var b;return(b=_.animationState)==null?void 0:b.setActive(u,p)}),r[u].isActive=p;const f=i(u);for(const _ in r)r[_].protectedKeys={};return f}return{animateChanges:i,setActive:c,setAnimateFunction:l,getState:()=>r,reset:()=>{r=IPe(),a=!0}}}function AMt(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!AKe(s,t):!1}function Aw(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function IPe(){return{animate:Aw(!0),whileInView:Aw(),whileHover:Aw(),whileTap:Aw(),whileDrag:Aw(),whileFocus:Aw(),exit:Aw()}}function Yve(t,s){t.min=s.min,t.max=s.max}function xx(t,s){Yve(t.x,s.x),Yve(t.y,s.y)}function LPe(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const EKe=1e-4,EMt=1-EKe,PMt=1+EKe,PKe=.01,IMt=0-PKe,LMt=0+PKe;function ym(t){return t.max-t.min}function DMt(t,s,r){return Math.abs(t-s)<=r}function DPe(t,s,r,n=.5){t.origin=n,t.originPoint=mc(s.min,s.max,t.origin),t.scale=ym(r)/ym(s),t.translate=mc(r.min,r.max,t.origin)-t.originPoint,(t.scale>=EMt&&t.scale<=PMt||isNaN(t.scale))&&(t.scale=1),(t.translate>=IMt&&t.translate<=LMt||isNaN(t.translate))&&(t.translate=0)}function TL(t,s,r,n){DPe(t.x,s.x,r.x,n?n.originX:void 0),DPe(t.y,s.y,r.y,n?n.originY:void 0)}function OPe(t,s,r,n=0){const a=n?mc(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+ym(s)}function OMt(t,s,r,n){OPe(t.x,s.x,r.x,n==null?void 0:n.x),OPe(t.y,s.y,r.y,n==null?void 0:n.y)}function RPe(t,s,r,n=0){const a=n?mc(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+ym(s)}function Poe(t,s,r,n){RPe(t.x,s.x,r.x,n==null?void 0:n.x),RPe(t.y,s.y,r.y,n==null?void 0:n.y)}function FPe(t,s,r,n,a){return t-=s,t=Eoe(t,1/r,n),a!==void 0&&(t=Eoe(t,1/a,n)),t}function RMt(t,s=0,r=1,n=.5,a,o=t,l=t){if(m0.test(s)&&(s=parseFloat(s),s=mc(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=mc(o.min,o.max,n);t===o&&(i-=s),t.min=FPe(t.min,s,r,i,a),t.max=FPe(t.max,s,r,i,a)}function zPe(t,s,[r,n,a],o,l){RMt(t,s[r],s[n],s[a],s.scale,o,l)}const FMt=["x","scaleX","originX"],zMt=["y","scaleY","originY"];function BPe(t,s,r,n){zPe(t.x,s,FMt,r?r.x:void 0,n?n.x:void 0),zPe(t.y,s,zMt,r?r.y:void 0,n?n.y:void 0)}function $Pe(t){return t.translate===0&&t.scale===1}function IKe(t){return $Pe(t.x)&&$Pe(t.y)}function qPe(t,s){return t.min===s.min&&t.max===s.max}function BMt(t,s){return qPe(t.x,s.x)&&qPe(t.y,s.y)}function UPe(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function LKe(t,s){return UPe(t.x,s.x)&&UPe(t.y,s.y)}function VPe(t){return ym(t.x)/ym(t.y)}function HPe(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function Fy(t){return[t("x"),t("y")]}function $Mt(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:y,skewX:_,skewY:b}=r;u&&(n=`perspective(${u}px) ${n}`),p&&(n+=`rotate(${p}deg) `),f&&(n+=`rotateX(${f}deg) `),y&&(n+=`rotateY(${y}deg) `),_&&(n+=`skewX(${_}deg) `),b&&(n+=`skewY(${b}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 DKe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],qMt=DKe.length,WPe=t=>typeof t=="string"?parseFloat(t):t,GPe=t=>typeof t=="number"||ta.test(t);function UMt(t,s,r,n,a,o){a?(t.opacity=mc(0,r.opacity??1,VMt(n)),t.opacityExit=mc(s.opacity??1,0,HMt(n))):o&&(t.opacity=mc(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(O8(t,s,n))}function WMt(t,s,r){const n=ph(t)?t:kT(t);return n.start(Mje("",n,s,r)),n.animation}function z8(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const GMt=(t,s)=>t.depth-s.depth;class KMt{constructor(){this.children=[],this.isDirty=!1}add(s){fje(this.children,s),this.isDirty=!0}remove(s){Noe(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(GMt),this.isDirty=!1,this.children.forEach(s)}}function ZMt(t,s){const r=xm.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(l2(n),t(o-s))};return Cl.setup(n,!0),()=>l2(n)}function hie(t){return ph(t)?t.get():t}class YMt{constructor(){this.members=[]}add(s){fje(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&&(Noe(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(Noe(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 mie={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Sge=["","X","Y","Z"],XMt=1e3;let QMt=0;function Cge(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function RKe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=rKe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",Cl,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&RKe(n)}function FKe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=QMt++,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(tTt),this.nodes.forEach(oTt),this.nodes.forEach(lTt),this.nodes.forEach(sTt)},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;Cl.read(()=>{f=window.innerWidth}),t(l,()=>{const _=window.innerWidth;_!==f&&(f=_,this.root.updateBlockedByResize=!0,p&&p(),p=ZMt(y,250),mie.hasAnimatedSinceResize&&(mie.hasAnimatedSinceResize=!1,this.nodes.forEach(XPe)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&u&&(i||c)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:f,hasRelativeLayoutChanged:y,layout:_})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const b=this.options.transition||u.getDefaultTransition()||mTt,{onLayoutAnimationStart:w,onLayoutAnimationComplete:j}=u.getProps(),N=!this.targetLayout||!LKe(this.targetLayout,_),S=!f&&y;if(this.options.layoutRoot||this.resumeFrom||S||f&&(N||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const T={...Cje(b,"layout"),onPlay:w,onComplete:j};(u.shouldReduceMotion||this.options.layoutRoot)&&(T.delay=0,T.type=!1),this.startAnimation(T),this.setAnimationOrigin(p,S)}else f||XPe(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=_})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const l=this.getStack();l&&l.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),l2(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(cTt),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&&RKe(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&&!ym(this.snapshot.measuredBox.x)&&!ym(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c{const L=I/1e3;QPe(f.x,l.x,L),QPe(f.y,l.y,L),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Poe(y,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),uTt(this.relativeTarget,this.relativeTargetOrigin,y,L),T&&BMt(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=ou()),xx(T,this.relativeTarget)),w&&(this.animationValues=p,UMt(p,u,this.latestValues,L,S,N)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=L},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var i,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&&(l2(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Cl.update(()=>{mie.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=kT(0)),this.motionValue.jump(0,!1),this.currentAnimation=WMt(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(XMt),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&&zKe(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||ou();const f=ym(this.layout.layoutBox.x);c.x.min=l.target.x.min,c.x.max=c.x.min+f;const y=ym(this.layout.layoutBox.y);c.y.min=l.target.y.min,c.y.max=c.y.min+y}xx(i,c),uie(i,p),TL(this.projectionDeltaWithTransform,this.layoutCorrected,i,p)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new YMt),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&&Cge("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(ZPe),this.root.sharedNodes.clear()}}}function JMt(t){t.updateLayout()}function eTt(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")Fy(f=>{const y=l?s.measuredBox[f]:s.layoutBox[f],_=ym(y);y.min=n[f].min,y.max=y.min+_});else if(o==="x"||o==="y"){const f=o==="x"?"y":"x";Yve(l?s.measuredBox[f]:s.layoutBox[f],n[f])}else zKe(o,s.layoutBox,n)&&Fy(f=>{const y=l?s.measuredBox[f]:s.layoutBox[f],_=ym(n[f]);y.max=y.min+_,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[f].max=t.relativeTarget[f].min+_)});const i=B5();TL(i,n,s.layoutBox);const c=B5();l?TL(c,t.applyTransform(a,!0),s.measuredBox):TL(c,n,s.layoutBox);const u=!IKe(i);let p=!1;if(!t.resumeFrom){const f=t.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:y,layout:_}=f;if(y&&_){const b=t.options.layoutAnchor||void 0,w=ou();Poe(w,s.layoutBox,y.layoutBox,b);const j=ou();Poe(j,n,_.layoutBox,b),LKe(w,j)||(p=!0),f.options.layoutRoot&&(t.relativeTarget=j,t.relativeTargetOrigin=w,t.relativeParent=f)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:s,delta:c,layoutDelta:i,hasLayoutChanged:u,hasRelativeLayoutChanged:p})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function tTt(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 sTt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function rTt(t){t.clearSnapshot()}function ZPe(t){t.clearMeasurements()}function nTt(t){t.isLayoutDirty=!0,t.updateLayout()}function YPe(t){t.isLayoutDirty=!1}function aTt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function iTt(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function XPe(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function oTt(t){t.resolveTargetDelta()}function lTt(t){t.calcProjection()}function cTt(t){t.resetSkewAndRotation()}function dTt(t){t.removeLeadSnapshot()}function QPe(t,s,r){t.translate=mc(s.translate,0,r),t.scale=mc(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function JPe(t,s,r,n){t.min=mc(s.min,r.min,n),t.max=mc(s.max,r.max,n)}function uTt(t,s,r,n){JPe(t.x,s.x,r.x,n),JPe(t.y,s.y,r.y,n)}function hTt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const mTt={duration:.45,ease:[.4,0,.1,1]},e6e=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),t6e=e6e("applewebkit/")&&!e6e("chrome/")?Math.round:_g;function s6e(t){t.min=t6e(t.min),t.max=t6e(t.max)}function pTt(t){s6e(t.x),s6e(t.y)}function zKe(t,s,r){return t==="position"||t==="preserve-aspect"&&!DMt(VPe(s),VPe(r),.2)}function fTt(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const gTt=FKe({attachResizeListener:(t,s)=>z8(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}),Mge={current:void 0},BKe=FKe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Mge.current){const t=new gTt({});t.mount(window),t.setOptions({layoutScroll:!0}),Mge.current=t}return Mge.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),zje=C.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function r6e(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function xTt(...t){return s=>{let r=!1;const n=t.map(a=>{const o=r6e(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{width:_,height:b,top:w,left:j,right:N,bottom:S}=c.current;if(s||o===!1||!i.current||!_||!b)return;const T=r==="left"?`left: ${j}`:`right: ${N}`,I=n==="bottom"?`bottom: ${S}`:`top: ${w}`;i.current.dataset.motionPopId=l;const L=document.createElement("style");u&&(L.nonce=u);const R=a??document.head;return R.appendChild(L),L.sheet&&L.sheet.insertRule(` [data-motion-pop-id="${l}"] { position: absolute !important; width: ${_}px !important; height: ${b}px !important; ${T}px !important; ${I}px !important; } `),()=>{var $;($=i.current)==null||$.removeAttribute("data-motion-pop-id"),R.contains(L)&&R.removeChild(L)}},[s]),e.jsx(vTt,{isPresent:s,childRef:i,sizeRef:c,pop:o,children:o===!1?t:C.cloneElement(t,{ref:f})})}const bTt=({children:t,initial:s,isPresent:r,onExitComplete:n,custom:a,presenceAffectsLayout:o,mode:l,anchorX:i,anchorY:c,root:u})=>{const p=pje(wTt),f=C.useId();let y=!0,_=C.useMemo(()=>(y=!1,{id:f,initial:s,isPresent:r,custom:a,onExitComplete:b=>{p.set(b,!0);for(const w of p.values())if(!w)return;n&&n()},register:b=>(p.set(b,!1),()=>p.delete(b))}),[r,p,n]);return o&&y&&(_={..._}),C.useMemo(()=>{p.forEach((b,w)=>p.set(w,!1))},[r]),C.useEffect(()=>{!r&&!p.size&&n&&n()},[r]),t=e.jsx(_Tt,{pop:l==="popLayout",isPresent:r,anchorX:i,anchorY:c,root:u,children:t}),e.jsx(Zde.Provider,{value:_,children:t})};function wTt(){return new Map}function $Ke(t=!0){const s=C.useContext(Zde);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=C.useId();C.useEffect(()=>{if(t)return a(o)},[t]);const l=C.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const R7=t=>t.key||"";function n6e(t){const s=[];return C.Children.forEach(t,r=>{C.isValidElement(r)&&s.push(r)}),s}const qKe=({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]=$Ke(l),y=C.useMemo(()=>n6e(t),[t]),_=l&&!p?[]:y.map(R7),b=C.useRef(!0),w=C.useRef(y),j=pje(()=>new Map),N=C.useRef(new Set),[S,T]=C.useState(y),[I,L]=C.useState(y);pGe(()=>{b.current=!1,w.current=y;for(let q=0;q{const U=R7(q),V=l&&!p?!1:y===I||_.includes(U),X=()=>{if(N.current.has(U))return;if(j.has(U))N.current.add(U),j.set(U,!0);else return;let se=!0;j.forEach(ee=>{ee||(se=!1)}),se&&($==null||$(),L(w.current),l&&(f==null||f()),n&&n())};return e.jsx(bTt,{isPresent:V,initial:!b.current||r?void 0:!1,custom:s,presenceAffectsLayout:a,mode:o,root:u,onExitComplete:V?void 0:X,anchorX:i,anchorY:c,children:q},U)})})},UKe=C.createContext({strict:!1}),a6e={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 i6e=!1;function jTt(){if(i6e)return;const t={};for(const s in a6e)t[s]={isEnabled:r=>a6e[s].some(n=>!!r[n])};xKe(t),i6e=!0}function VKe(){return jTt(),oMt()}function kTt(t){const s=VKe();for(const r in t)s[r]={...s[r],...t[r]};xKe(s)}const NTt=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 Ioe(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||NTt.has(t)}let HKe=t=>!Ioe(t);function STt(t){typeof t=="function"&&(HKe=s=>s.startsWith("on")?!Ioe(s):t(s))}try{STt(require("@emotion/is-prop-valid").default)}catch{}function CTt(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||ph(t[a])||(HKe(a)||r===!0&&Ioe(a)||!s&&!Ioe(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const Jde=C.createContext({});function MTt(t,s){if(Qde(t)){const{initial:r,animate:n}=t;return{initial:r===!1||F8(r)?r:void 0,animate:F8(n)?n:void 0}}return t.inherit!==!1?s:{}}function TTt(t){const{initial:s,animate:r}=MTt(t,C.useContext(Jde));return C.useMemo(()=>({initial:s,animate:r}),[o6e(s),o6e(r)])}function o6e(t){return Array.isArray(t)?t.join(" "):t}const Bje=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function WKe(t,s,r){for(const n in s)!ph(s[n])&&!kKe(n,r)&&(t[n]=s[n])}function ATt({transformTemplate:t},s){return C.useMemo(()=>{const r=Bje();return Rje(r,s,t),Object.assign({},r.vars,r.style)},[s])}function ETt(t,s){const r=t.style||{},n={};return WKe(n,r,t),Object.assign(n,ATt(t,s)),n}function PTt(t,s){const r={},n=ETt(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 GKe=()=>({...Bje(),attrs:{}});function ITt(t,s,r,n){const a=C.useMemo(()=>{const o=GKe();return NKe(o,s,CKe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};WKe(o,t.style,t),a.style={...o,...a.style}}return a}const LTt=["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 $je(t){return typeof t!="string"||t.includes("-")?!1:!!(LTt.indexOf(t)>-1||/[A-Z]/u.test(t))}function DTt(t,s,r,{latestValues:n},a,o=!1,l){const c=(l??$je(t)?ITt:PTt)(s,n,a,t),u=CTt(s,typeof t=="string",o),p=t!==C.Fragment?{...u,...c,ref:r}:{},{children:f}=s,y=C.useMemo(()=>ph(f)?f.get():f,[f]);return C.createElement(t,{...p,children:y})}function OTt({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:RTt(r,n,a,t),renderState:s()}}function RTt(t,s,r,n){const a={},o=n(t,{});for(const y in o)a[y]=hie(o[y]);let{initial:l,animate:i}=t;const c=Qde(t),u=fKe(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"&&!Xde(f)){const y=Array.isArray(f)?f:[f];for(let _=0;_(s,r)=>{const n=C.useContext(Jde),a=C.useContext(Zde),o=()=>OTt(t,s,n,a);return r?o():pje(o)},FTt=KKe({scrapeMotionValuesFromProps:Fje,createRenderState:Bje}),zTt=KKe({scrapeMotionValuesFromProps:MKe,createRenderState:GKe}),BTt=Symbol.for("motionComponentSymbol");function $Tt(t,s,r){const n=C.useRef(r);C.useInsertionEffect(()=>{n.current=r});const a=C.useRef(null);return C.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 ZKe=C.createContext({});function x5(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function qTt(t,s,r,n,a,o){var T,I;const{visualElement:l}=C.useContext(Jde),i=C.useContext(UKe),c=C.useContext(Zde),u=C.useContext(zje),p=u.reducedMotion,f=u.skipAnimations,y=C.useRef(null),_=C.useRef(!1);n=n||i.renderer,!y.current&&n&&(y.current=n(t,{visualState:s,parent:l,props:r,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:p,skipAnimations:f,isSVG:o}),_.current&&y.current&&(y.current.manuallyAnimateOnMount=!0));const b=y.current,w=C.useContext(ZKe);b&&!b.projection&&a&&(b.type==="html"||b.type==="svg")&&UTt(y.current,r,a,w);const j=C.useRef(!1);C.useInsertionEffect(()=>{b&&j.current&&b.update(r,c)});const N=r[sKe],S=C.useRef(!!N&&typeof window<"u"&&!((T=window.MotionHandoffIsComplete)!=null&&T.call(window,N))&&((I=window.MotionHasOptimisedAnimation)==null?void 0:I.call(window,N)));return pGe(()=>{_.current=!0,b&&(j.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),b.scheduleRenderMicrotask(),S.current&&b.animationState&&b.animationState.animateChanges())}),C.useEffect(()=>{b&&(!S.current&&b.animationState&&b.animationState.animateChanges(),S.current&&(queueMicrotask(()=>{var L;(L=window.MotionHandoffMarkAsComplete)==null||L.call(window,N)}),S.current=!1),b.enteringChildren=void 0)}),b}function UTt(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:YKe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&x5(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:c,layoutRoot:u,layoutAnchor:p})}function YKe(t){if(t)return t.options.allowProjection!==!1?t.projection:YKe(t.parent)}function Tge(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&kTt(n);const o=r?r==="svg":$je(t),l=o?zTt:FTt;function i(u,p){let f;const y={...C.useContext(zje),...u,layoutId:VTt(u)},{isStatic:_}=y,b=TTt(u),w=l(u,_);if(!_&&typeof window<"u"){HTt();const j=WTt(y);f=j.MeasureLayout,b.visualElement=qTt(t,w,y,a,j.ProjectionNode,o)}return e.jsxs(Jde.Provider,{value:b,children:[f&&b.visualElement?e.jsx(f,{visualElement:b.visualElement,...y}):null,DTt(t,u,$Tt(w,b.visualElement,p),w,_,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const c=C.forwardRef(i);return c[BTt]=t,c}function VTt({layoutId:t}){const s=C.useContext(mje).id;return s&&t!==void 0?s+"-"+t:t}function HTt(t,s){C.useContext(UKe).strict}function WTt(t){const s=VKe(),{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 GTt(t,s){if(typeof Proxy>"u")return Tge;const r=new Map,n=(o,l)=>Tge(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,Tge(l,void 0,t,s)),r.get(l))})}const KTt=(t,s)=>s.isSVG??$je(t)?new kMt(s):new yMt(s,{allowProjection:t!==C.Fragment});class ZTt extends S2{constructor(s){super(s),s.animationState||(s.animationState=TMt(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();Xde(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 YTt=0;class XTt extends S2{constructor(){super(...arguments),this.id=YTt++,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=X4(this.node,l,i);if(c){const{transition:u,transitionEnd:p,...f}=c;for(const y in f)(o=this.node.getValue(y))==null||o.jump(f[y])}}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 QTt={animation:{Feature:ZTt},exit:{Feature:XTt}};function yO(t){return{point:{x:t.pageX,y:t.pageY}}}const JTt=t=>s=>Ije(s)&&t(s,yO(s));function AL(t,s,r,n){return z8(t,s,JTt(r),n)}const XKe=({current:t})=>t?t.ownerDocument.defaultView:null,l6e=(t,s)=>Math.abs(t-s);function eAt(t,s){const r=l6e(t.x,s.x),n=l6e(t.y,s.y);return Math.sqrt(r**2+n**2)}const c6e=new Set(["auto","scroll"]);class QKe{constructor(s,r,{transformPagePoint:n,contextWindow:a=window,dragSnapToOrigin:o=!1,distanceThreshold:l=3,element:i}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=_=>{this.handleScroll(_.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=F7(this.lastRawMoveEventInfo,this.transformPagePoint));const _=Age(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,w=eAt(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!b&&!w)return;const{point:j}=_,{timestamp:N}=dh;this.history.push({...j,timestamp:N});const{onStart:S,onMove:T}=this.handlers;b||(S&&S(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),T&&T(this.lastMoveEvent,_)},this.handlePointerMove=(_,b)=>{this.lastMoveEvent=_,this.lastRawMoveEventInfo=b,this.lastMoveEventInfo=F7(b,this.transformPagePoint),Cl.update(this.updatePoint,!0)},this.handlePointerUp=(_,b)=>{this.end();const{onEnd:w,onSessionEnd:j,resumeAnimation:N}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=Age(_.type==="pointercancel"?this.lastMoveEventInfo:F7(b,this.transformPagePoint),this.history);this.startEvent&&w&&w(_,S),j&&j(_,S)},!Ije(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const c=yO(s),u=F7(c,this.transformPagePoint),{point:p}=u,{timestamp:f}=dh;this.history=[{...p,timestamp:f}];const{onSessionStart:y}=r;y&&y(s,Age(u,this.history)),this.removeListeners=fO(AL(this.contextWindow,"pointermove",this.handlePointerMove),AL(this.contextWindow,"pointerup",this.handlePointerUp),AL(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(c6e.has(n.overflowX)||c6e.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),Cl.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),l2(this.updatePoint)}}function F7(t,s){return s?{point:s(t.point)}:t}function d6e(t,s){return{x:t.x-s.x,y:t.y-s.y}}function Age({point:t},s){return{point:t,delta:d6e(t,JKe(s)),offset:d6e(t,tAt(s)),velocity:sAt(s,.1)}}function tAt(t){return t[0]}function JKe(t){return t[t.length-1]}function sAt(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=JKe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>uf(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>uf(s)*2&&(n=t[1]);const o=hg(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 rAt(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?mc(r,t,n.max):Math.min(t,r)),t}function u6e(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 nAt(t,{top:s,left:r,bottom:n,right:a}){return{x:u6e(t.x,r,a),y:u6e(t.y,s,n)}}function h6e(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=O8(s.min,s.max-n,t.min):n>a&&(r=O8(t.min,t.max-a,s.min)),v0(0,1,r)}function oAt(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 Xve=.35;function lAt(t=Xve){return t===!1?t=0:t===!0&&(t=Xve),{x:m6e(t,"left","right"),y:m6e(t,"top","bottom")}}function m6e(t,s,r){return{min:p6e(t,s),max:p6e(t,r)}}function p6e(t,s){return typeof t=="number"?t:t[s]||0}const cAt=new WeakMap;class dAt{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=ou(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=s}start(s,{snapToCursor:r=!1,distanceThreshold:n}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const o=f=>{r&&this.snapToCursor(yO(f).point),this.stopAnimation()},l=(f,y)=>{const{drag:_,dragPropagation:b,onDragStart:w}=this.getProps();if(_&&!b&&(this.openDragLock&&this.openDragLock(),this.openDragLock=R5t(_),!this.openDragLock))return;this.latestPointerEvent=f,this.latestPanInfo=y,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Fy(N=>{let S=this.getAxisMotionValue(N).get()||0;if(m0.test(S)){const{projection:T}=this.visualElement;if(T&&T.layout){const I=T.layout.layoutBox[N];I&&(S=ym(I)*(parseFloat(S)/100))}}this.originPoint[N]=S}),w&&Cl.update(()=>w(f,y),!1,!0),qve(this.visualElement,"transform");const{animationState:j}=this.visualElement;j&&j.setActive("whileDrag",!0)},i=(f,y)=>{this.latestPointerEvent=f,this.latestPanInfo=y;const{dragPropagation:_,dragDirectionLock:b,onDirectionLock:w,onDrag:j}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:N}=y;if(b&&this.currentDirection===null){this.currentDirection=hAt(N),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",y.point,N),this.updateAxis("y",y.point,N),this.visualElement.render(),j&&Cl.update(()=>j(f,y),!1,!0)},c=(f,y)=>{this.latestPointerEvent=f,this.latestPanInfo=y,this.stop(f,y),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 QKe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:n,contextWindow:XKe(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&&Cl.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||!z7(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=rAt(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&&x5(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=nAt(n.layoutBox,s):this.constraints=!1,this.elastic=lAt(r),a!==this.constraints&&!x5(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&Fy(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=oAt(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!x5(s))return!1;const n=s.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=hMt(n,a.root,this.visualElement.getTransformPagePoint());let l=aAt(a.layout.layoutBox,o);if(r){const i=r(cMt(l));this.hasMutatedConstraints=!!i,i&&(l=vKe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),c=this.constraints||{},u=Fy(p=>{if(!z7(p,r,this.currentDirection))return;let f=c&&c[p]||{};(l===!0||l===p)&&(f={min:0,max:0});const y=a?200:1e6,_=a?40:1e7,b={type:"inertia",velocity:n?s[p]:0,bounceStiffness:y,bounceDamping:_,timeConstant:750,restDelta:1,restSpeed:10,...o,...f};return this.startAxisValueAnimation(p,b)});return Promise.all(u).then(i)}startAxisValueAnimation(s,r){const n=this.getAxisMotionValue(s);return qve(this.visualElement,s),n.start(Mje(s,n,0,r,this.visualElement,!1))}stopAnimation(){Fy(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){Fy(r=>{const{drag:n}=this.getProps();if(!z7(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]-mc(l,i,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!x5(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Fy(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const c=i.get();a[l]=iAt({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(),Fy(l=>{if(!z7(l,s,null))return;const i=this.getAxisMotionValue(l),{min:c,max:u}=this.constraints[l];i.set(mc(c,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;cAt.set(this.visualElement,this);const s=this.visualElement.current,r=AL(s,"pointerdown",u=>{const{drag:p,dragListener:f=!0}=this.getProps(),y=u.target,_=y!==s&&U5t(y);p&&f&&!_&&this.start(u)});let n;const a=()=>{const{dragConstraints:u}=this.getProps();x5(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),n||(n=uAt(s,u.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),Cl.read(a);const i=z8(window,"resize",()=>this.scalePositionWithinConstraints()),c=o.addEventListener("didUpdate",({delta:u,hasLayoutChanged:p})=>{this.isDragging&&p&&(Fy(f=>{const y=this.getAxisMotionValue(f);y&&(this.originPoint[f]+=u[f].translate,y.set(y.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=Xve,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function f6e(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function uAt(t,s,r){const n=wPe(t,f6e(r)),a=wPe(s,f6e(r));return()=>{n(),a()}}function z7(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function hAt(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class mAt extends S2{constructor(s){super(s),this.removeGroupControls=_g,this.removeListeners=_g,this.controls=new dAt(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||_g}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 Ege=t=>(s,r)=>{t&&Cl.update(()=>t(s,r),!1,!0)};class pAt extends S2{constructor(){super(...arguments),this.removePointerDownListener=_g}onPointerDown(s){this.session=new QKe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:XKe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:Ege(s),onStart:Ege(r),onMove:Ege(n),onEnd:(o,l)=>{delete this.session,a&&Cl.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=AL(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 Pge=!1;class fAt extends C.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),Pge&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),mie.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}),Pge=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||Cl.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(),Pje.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;Pge=!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 eZe(t){const[s,r]=$Ke(),n=C.useContext(mje);return e.jsx(fAt,{...t,layoutGroup:n,switchLayoutGroup:C.useContext(ZKe),isPresent:s,safeToRemove:r})}const gAt={pan:{Feature:pAt},drag:{Feature:mAt,ProjectionNode:BKe,MeasureLayout:eZe}};function g6e(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&&Cl.postRender(()=>o(s,yO(s)))}class xAt extends S2{mount(){const{current:s}=this.node;s&&(this.unmount=z5t(s,(r,n)=>(g6e(this.node,n,"Start"),a=>g6e(this.node,a,"End"))))}unmount(){}}class yAt extends S2{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=fO(z8(this.node.current,"focus",()=>this.onFocus()),z8(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function x6e(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&&Cl.postRender(()=>o(s,yO(s)))}class vAt extends S2{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=H5t(s,(a,o)=>(x6e(this.node,o,"Start"),(l,{success:i})=>x6e(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const Qve=new WeakMap,Ige=new WeakMap,_At=t=>{const s=Qve.get(t.target);s&&s(t)},bAt=t=>{t.forEach(_At)};function wAt({root:t,...s}){const r=t||document;Ige.has(r)||Ige.set(r,{});const n=Ige.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(bAt,{root:t,...s})),n[a]}function jAt(t,s,r){const n=wAt(s);return Qve.set(t,r),n.observe(t),()=>{Qve.delete(t),n.unobserve(t)}}const kAt={some:0,all:1};class NAt extends S2{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:kAt[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:y}=this.node.getProps(),_=p?f:y;_&&_(u)};this.stopObserver=jAt(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(SAt(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function SAt({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const CAt={inView:{Feature:NAt},tap:{Feature:vAt},focus:{Feature:yAt},hover:{Feature:xAt}},MAt={layout:{ProjectionNode:BKe,MeasureLayout:eZe}},TAt={...QTt,...CAt,...gAt,...MAt},wr=GTt(TAt,KTt);function AAt(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 y6e(t){return t.visitor_intent==="buying"&&!t.has_agent}function EAt({token:t}={}){var b;const s=Po(),r=t||s.token,{data:n,isLoading:a,isError:o}=yCt(r),l=ss(),i=(b=n==null?void 0:n.open_houses)==null?void 0:b.id,{data:c}=wt({queryKey:["cohost-visitors",i],queryFn:async()=>{const{data:w,error:j}=await G.from("open_house_visitors").select("*").eq("open_house_id",i).order("created_at",{ascending:!1});if(j)throw j;return w},enabled:!!i});if(C.useEffect(()=>{if(!i)return;const w=G.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()=>{G.removeChannel(w)}},[i,l]),a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center",children:e.jsx("div",{className:"animate-pulse text-white/40",children:"Validating access..."})});if(o||!n)return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("h1",{className:"text-xl font-bold mb-2",children:"Link Expired or Invalid"}),e.jsx("p",{className:"text-white/40 text-sm",children:"This co-host link is no longer active. Ask the host for a new one."})]})});const u=n.open_houses,p=(c==null?void 0:c.length)||0,f=(c==null?void 0:c.filter(w=>w.visitor_intent==="buying").length)||0,y=(c==null?void 0:c.filter(y6e).length)||0,_=w=>{if(!w)return"";const[j,N]=w.split(":"),S=parseInt(j);return`${S>12?S-12:S||12}:${N} ${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(mr,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:p})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-orange-400",children:[e.jsx(Fh,{className:"h-4 w-4"}),e.jsx("span",{className:"font-bold text-white",children:y})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Rn,{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:ys(new Date(u.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy")}),u.start_time&&e.jsxs("span",{children:[_(u.start_time),u.end_time?` – ${_(u.end_time)}`:""]})]}),e.jsx(Vi,{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(qKe,{children:c.map((w,j)=>{var T;const N=AAt(w.visitor_intent),S=y6e(w);return e.jsxs(wr.div,{initial:{opacity:0,x:-40,scale:.95},animate:{opacity:1,x:0,scale:1},transition:{duration:.4,delay:j*.05},className:`flex items-center gap-4 p-4 rounded-xl border ${S?"bg-orange-500/10 border-orange-500/30":"bg-white/5 border-white/10"}`,children:[e.jsx("div",{className:`w-11 h-11 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${S?"bg-gradient-to-br from-orange-500 to-amber-500 text-white":"bg-white/10 text-white/80"}`,children:(T=w.first_name[0])==null?void 0:T.toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"font-semibold text-white truncate",children:[w.first_name," ",w.last_name||""]}),S&&e.jsx(nt,{className:"bg-orange-500/20 text-orange-300 border-orange-500/40 text-[10px] px-1.5 py-0",children:"🔥 HOT"}),w.has_agent&&e.jsx(nt,{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(nt,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${N.color}`,children:[N.emoji," ",N.label]}),e.jsx("span",{className:"text-white/30 text-xs",children:ys(new Date(w.created_at),"h:mm a")})]})]})]},w.id)})})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-20",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-white/5 flex items-center justify-center mb-4",children:e.jsx(n1,{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 PAt(){const s=Qu().pathname.slice(1);if(C.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(EAt,{token:r})}return!s||s===""?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Guest Book"}),e.jsx("p",{className:"text-white/60",children:"The modern open house sign-in experience."}),e.jsx("p",{className:"text-white/40 text-sm mt-2",children:"Visit a specific open house link to sign in."})]})}):e.jsx(eGe,{slug:s})}function IAt({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(Rn,{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(Ui,{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(ea,{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(br,{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(Ec,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function LAt({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(Ki,{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 Ml(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 RAt(t,s){const r=ys(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 FAt(t,s){const r=ys(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 zAt({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:lM,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:xn,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:Rn,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||t,icon:on,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,c,u)=>{const p=Ml(c);if(u==="google")window.open(RAt(i,p),"_blank");else{const f=FAt(i,p),y=document.createElement("a");y.href=f,y.download=`${i.replace(/\s+/g,"-").toLowerCase()}.ics`,y.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=Ml(c),y=u0(f)&&!uu(f),_=uu(f),b=!y&&!_;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${p}`,children:e.jsx(u,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs text-slate-500",children:i}),e.jsxs("p",{className:`text-sm font-medium ${_?"text-emerald-600":y?"text-slate-400":"text-slate-800"}`,children:[ys(f,"MMM d, yyyy"),_&&e.jsx("span",{className:"ml-1.5 text-xs bg-emerald-100 text-emerald-700 px-1.5 py-0.5 rounded-full",children:"Today"})]})]}),y&&e.jsx("span",{className:"text-xs text-slate-400",children:"✓"}),b&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>l(i,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(Tb,{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 BAt({documents:t}){const s=n=>n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(0)} KB`:`${(n/1048576).toFixed(1)} MB`,r=async n=>{const{data:a}=await G.storage.from("deal-files").createSignedUrl(n.storage_path,300);a!=null&&a.signedUrl&&window.open(a.signedUrl,"_blank")};return e.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-3",children:"Documents"}),e.jsx("div",{className:"space-y-2",children:t.map(n=>e.jsxs("button",{onClick:()=>r(n),className:"w-full flex items-center gap-3 p-3 rounded-xl hover:bg-slate-50 transition-colors text-left group",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-slate-100 flex items-center justify-center flex-shrink-0 group-hover:bg-blue-50 transition-colors",children:e.jsx(In,{className:"w-4 h-4 text-slate-500 group-hover:text-blue-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-700 truncate",children:n.file_name}),e.jsx("p",{className:"text-xs text-slate-400",children:s(n.file_size)})]}),e.jsx(ki,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function $At({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(ud,{className:"w-3.5 h-3.5 text-emerald-600"}):e.jsx(gg,{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:ys(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 qAt({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var b,w;const[l,i]=C.useState({first_name:((b=t.client_name)==null?void 0:b.split(" ")[0])||"",last_name:((w=t.client_name)==null?void 0:w.split(" ").slice(1).join(" "))||"",email:t.client_email||"",phone:t.client_phone||"",preferred_contact_method:"email",client_role:"buyer",notes:"",spouse_first_name:"",spouse_last_name:"",spouse_email:"",spouse_phone:""}),[c,u]=C.useState({}),[p,f]=C.useState(!1),y=Dt({mutationFn:async()=>{const{error:j}=await G.from("portal_onboarding_submissions").insert({portal_id:t.id,first_name:l.first_name,last_name:l.last_name||null,email:l.email||null,phone:l.phone||null,preferred_contact_method:l.preferred_contact_method,client_role:l.client_role,notes:l.notes||null,device_fingerprint:a,custom_answers:Object.keys(c).length>0?c:null,spouse_first_name:p&&l.spouse_first_name||null,spouse_last_name:p&&l.spouse_last_name||null,spouse_email:p&&l.spouse_email||null,spouse_phone:p&&l.spouse_phone||null});if(j)throw j},onSuccess:o,onError:j=>{console.error("[PortalOnboarding] Submit failed:",j),me.error("Something went wrong. Please try again.")}}),_=s!=null&&s.property_address?`${s.property_address}, ${s.city||""}, ${s.state||""}`:null;return e.jsxs("div",{className:"max-w-md mx-auto px-4 py-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[(r==null?void 0:r.avatar_url)&&e.jsx("img",{src:r.avatar_url,alt:r.name,className:"w-14 h-14 rounded-full border-2 border-slate-200 mx-auto mb-3 object-cover"}),e.jsx("h1",{className:"text-xl font-bold text-slate-800",children:"Welcome to Your Portal"}),_&&e.jsxs("div",{className:"flex items-center justify-center gap-1 text-slate-500 text-sm mt-1",children:[e.jsx(Ui,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:_.replace(/,\s*,/g,",").replace(/,\s*$/,"")})]}),e.jsx("p",{className:"text-sm text-slate-500 mt-2",children:"Please fill in your details to access your transaction portal."})]}),e.jsxs("form",{onSubmit:j=>{j.preventDefault(),y.mutate()},className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"First Name *"}),e.jsx(Fe,{required:!0,value:l.first_name,onChange:j=>i(N=>({...N,first_name:j.target.value})),className:"mt-1 rounded-xl",placeholder:"John"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Fe,{value:l.last_name,onChange:j=>i(N=>({...N,last_name:j.target.value})),className:"mt-1 rounded-xl",placeholder:"Doe"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Fe,{type:"email",value:l.email,onChange:j=>i(N=>({...N,email:j.target.value})),className:"mt-1 rounded-xl",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Fe,{type:"tel",value:l.phone,onChange:j=>i(N=>({...N,phone:j.target.value})),className:"mt-1 rounded-xl",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Preferred Contact Method"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:[{value:"email",label:"Email"},{value:"call",label:"Phone"},{value:"text",label:"Text"}].map(j=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,preferred_contact_method:j.value})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===j.value?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:j.label},j.value))})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Your Role"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:["buyer","seller","both"].map(j=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,client_role:j})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===j?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:j.charAt(0).toUpperCase()+j.slice(1)},j))})]}),n.map(j=>e.jsxs("div",{children:[e.jsxs(_e,{className:"text-xs text-slate-600",children:[j.question_text," ",j.is_required&&"*"]}),j.field_type==="text"&&e.jsx(Fe,{required:j.is_required,value:c[j.id]||"",onChange:N=>u(S=>({...S,[j.id]:N.target.value})),className:"mt-1 rounded-xl"}),j.field_type==="textarea"&&e.jsx("textarea",{required:j.is_required,value:c[j.id]||"",onChange:N=>u(S=>({...S,[j.id]:N.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),j.field_type==="dropdown"&&e.jsxs("select",{required:j.is_required,value:c[j.id]||"",onChange:N=>u(S=>({...S,[j.id]:N.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm h-10",children:[e.jsx("option",{value:"",children:"Select..."}),(j.options||[]).map(N=>e.jsx("option",{value:N,children:N},N))]}),j.field_type==="toggle"&&e.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(N=>e.jsx("button",{type:"button",onClick:()=>u(S=>({...S,[j.id]:N})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${c[j.id]===N?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:N},N))})]},j.id)),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Notes for your agent"}),e.jsx("textarea",{value:l.notes,onChange:j=>i(N=>({...N,notes:j.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Anything you'd like your agent to know..."})]}),t.allow_spouse&&e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>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(_e,{className:"text-xs text-slate-600",children:"First Name"}),e.jsx(Fe,{value:l.spouse_first_name,onChange:j=>i(N=>({...N,spouse_first_name:j.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(Fe,{value:l.spouse_last_name,onChange:j=>i(N=>({...N,spouse_last_name:j.target.value})),className:"mt-1 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(Fe,{type:"email",value:l.spouse_email,onChange:j=>i(N=>({...N,spouse_email:j.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(Fe,{type:"tel",value:l.spouse_phone,onChange:j=>i(N=>({...N,spouse_phone:j.target.value})),className:"mt-1 rounded-xl"})]})]})]}),e.jsx(K,{type:"submit",disabled:y.isPending||!l.first_name,className:"w-full h-12 rounded-full text-sm font-semibold bg-slate-900 hover:bg-slate-800",children:y.isPending?"Submitting...":"Access My Portal"})]})]})}function UAt(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function VAt(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 HAt={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. 🎉"}},tZe=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function qje(t){return tZe.map(s=>{if(s==="Active")return{key:"Active",label:UAt(t),description:VAt(t)};const r=HAt[s];return{key:s,label:r.label,description:r.description}})}function v6e(t){if(!t)return 0;const s=tZe.indexOf(t);return s>=0?s:0}function WAt(t,s){return wt({queryKey:["client-portal-public",t],queryFn:async()=>{if(!t)return null;const{data:r,error:n}=await G.from("client_portals").select(` *, deal_pipeline ( id, deal_name, property_address, city, state, deal_type, target_close_date, contract_date, expected_price, actual_close_date, stage_id, owner_user_id, deal_pipeline_stages (id, name, color, icon, sort_order, is_won_stage, is_lost_stage) ) `).eq("slug",t).eq("is_enabled",!0).maybeSingle();if(n)throw n;return r},enabled:s})}function GAt(t){return wt({queryKey:["client-portal-by-id",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("client_portals").select(` *, deal_pipeline ( id, deal_name, property_address, city, state, deal_type, target_close_date, contract_date, expected_price, actual_close_date, stage_id, owner_user_id, deal_pipeline_stages (id, name, color, icon, sort_order, is_won_stage, is_lost_stage) ) `).eq("id",t).eq("is_enabled",!0).maybeSingle();if(r)throw r;return s},enabled:!!t})}function sZe({slug:t}){var ee,Q,de,re,ne,le;const[s,r]=C.useState(!1),[n,a]=C.useState("primary"),[o]=C.useState(()=>{const he=`portal_fp_${t}`;let we=localStorage.getItem(he);return we||(we=localStorage.getItem("portal_fp"),we?localStorage.setItem(he,we):(we=crypto.randomUUID(),localStorage.setItem(he,we),localStorage.setItem("portal_fp",we))),we});C.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:c}=WAt(t,!0),u=l==null?void 0:l.linked_portal_id,{data:p}=GAt(u),f=(ee=l==null?void 0:l.deal_pipeline)==null?void 0:ee.owner_user_id,{data:y}=wt({queryKey:["portal-stages",f],queryFn:async()=>{const{data:he,error:we}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",f).order("sort_order",{ascending:!0});if(we)throw we;return he},enabled:!!f}),{data:_}=wt({queryKey:["portal-agent",f],queryFn:async()=>{const{data:he,error:we}=await G.from("profiles").select("id, name, avatar_url, phone, email").eq("id",f).single();if(we)throw we;return he},enabled:!!f}),b=n==="linked"&&p?p:l,w=b==null?void 0:b.id,{data:j}=wt({queryKey:["portal-updates-public",w],queryFn:async()=>{const{data:he,error:we}=await G.from("portal_updates").select("*").eq("portal_id",w).order("created_at",{ascending:!1});if(we)throw we;return he},enabled:!!w}),N=(Q=b==null?void 0:b.deal_pipeline)==null?void 0:Q.id,{data:S}=wt({queryKey:["portal-documents",N],queryFn:async()=>{const{data:he,error:we}=await G.from("deal_files").select("*").eq("deal_id",N).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(we)throw we;return he},enabled:!!N}),T=l==null?void 0:l.id,{data:I,isLoading:L}=wt({queryKey:["portal-onboarding-check",T,o],queryFn:async()=>{const{data:he,error:we}=await G.from("portal_onboarding_submissions").select("id").eq("portal_id",T).eq("device_fingerprint",o).maybeSingle();if(we)throw we;return he},enabled:!!T&&!!(l!=null&&l.require_onboarding)}),{data:R}=wt({queryKey:["portal-custom-questions-public",f],queryFn:async()=>{const{data:he,error:we}=await G.from("portal_custom_questions").select("*").eq("owner_user_id",f).eq("is_active",!0).order("sort_order",{ascending:!0});if(we)throw we;return he},enabled:!!f&&!!(l!=null&&l.require_onboarding)}),$=!!I||s||!(l!=null&&l.require_onboarding);if(i||l!=null&&l.require_onboarding&&L)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-lg mx-auto p-6 space-y-6",children:[e.jsx(xs,{className:"h-48 w-full rounded-2xl"}),e.jsx(xs,{className:"h-10 w-48 mx-auto"}),e.jsx(xs,{className:"h-32 w-full rounded-2xl"}),e.jsx(xs,{className:"h-24 w-full rounded-2xl"})]})});if(c||!l)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx("span",{className:"text-2xl",children:"🔒"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Available"}),e.jsx("p",{className:"text-slate-500",children:"This portal is no longer active or doesn't exist."})]})});if(!$){const he=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(qAt,{portal:l,dealData:he,agentProfile:_,customQuestions:R||[],deviceFingerprint:o,onComplete:()=>r(!0)})})}const q=(de=l==null?void 0:l.deal_pipeline)==null?void 0:de.deal_type,U=(re=p==null?void 0:p.deal_pipeline)==null?void 0:re.deal_type,V=!!p,X=he=>he==="listing"?"Your Sale":he==="buy-side"?"Your Purchase":"Transaction",se=he=>he==="listing"?e.jsx(Rn,{className:"w-3.5 h-3.5"}):e.jsx(vp,{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(IAt,{dealData:b==null?void 0:b.deal_pipeline,agentProfile:_,welcomeMessage:b==null?void 0:b.welcome_message,isWon:(le=(ne=b==null?void 0:b.deal_pipeline)==null?void 0:ne.deal_pipeline_stages)==null?void 0:le.is_won_stage}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 space-y-5 mt-6",children:[V&&e.jsxs("div",{className:"flex gap-1 bg-slate-100 rounded-xl p-1",children:[e.jsxs("button",{onClick:()=>a("primary"),className:`flex-1 flex items-center justify-center gap-1.5 rounded-lg py-2.5 text-sm font-medium transition-all ${n==="primary"?"bg-white text-slate-800 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[se(q),X(q)]}),e.jsxs("button",{onClick:()=>a("linked"),className:`flex-1 flex items-center justify-center gap-1.5 rounded-lg py-2.5 text-sm font-medium transition-all ${n==="linked"?"bg-white text-slate-800 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[se(U),X(U)]})]}),e.jsx(KAt,{portal:b,updates:j,documents:S}),e.jsxs("div",{className:"text-center pt-6 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-slate-400",children:[e.jsx(Bh,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs",children:"Secure Client Portal"})]}),_&&e.jsxs("p",{className:"text-xs text-slate-400",children:["Managed by ",e.jsx("span",{className:"font-medium text-slate-500",children:_.name})]}),e.jsx("p",{className:"text-[10px] text-slate-300",children:"Powered by ReLevelUp"})]})]})]})}function KAt({portal:t,updates:s,documents:r}){const n=t,a=n==null?void 0:n.deal_pipeline,o=a==null?void 0:a.deal_pipeline_stages,l=o==null?void 0:o.is_won_stage,i=a==null?void 0:a.deal_type,c=t.stage_mapping;let u=qje(i);c&&c.length>0&&(u=c.map((_,b)=>{var w,j;return{key:`custom-${b}`,label:_.label||((w=u[b])==null?void 0:w.label)||`Stage ${b+1}`,description:_.description||((j=u[b])==null?void 0:j.description)||"",video_url:_.video_url||void 0}}));const p=c&&c.length>0?Math.min(v6e(o==null?void 0:o.name),u.length-1):v6e(o==null?void 0:o.name),f=u[p],y=f==null?void 0:f.video_url;return e.jsxs(e.Fragment,{children:[e.jsx(DAt,{targetCloseDate:a==null?void 0:a.target_close_date,actualCloseDate:a==null?void 0:a.actual_close_date,clientName:t.client_name}),e.jsx(LAt,{journeyStages:u,currentIndex:p}),f&&e.jsx(OAt,{currentStage:f,nextStepText:t.next_step_text,nextStepVideoUrl:y||t.next_step_video_url}),e.jsx(zAt,{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(BAt,{documents:r}),s&&s.length>0&&e.jsx($At,{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 ZAt(){const s=Qu().pathname.slice(1);return C.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(sZe,{slug:s})}const Jve="levelup_affiliate_ref",YAt=30,XAt=()=>{const[t]=Xc();C.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(Jve,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},QAt=()=>{try{const t=localStorage.getItem(Jve);if(!t)return null;const s=JSON.parse(t),r=YAt*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(Jve),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},Loe="/assets/levelup-logo-header-_ZX7DvlA.png",JAt="/assets/scale-your-team-ku4MPatU.png";function eEt({open:t,onOpenChange:s}){return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Cs,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-[#4a6b6d]/10 rounded-lg",children:e.jsx(La,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Ns,{children:"Schedule a Brokerage Interest Meeting"}),e.jsx(Zr,{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 Lu={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"]}},tEt=[{icon:ap,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Ql,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:on,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:Ec,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:In,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:bo,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],sEt=[{icon:mr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:hn,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:ea,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:xh,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Ui,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:xl,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Ii,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:wp,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],rEt=[{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."}],nEt=()=>{const{user:t,loading:s}=Ws(),r=Pr(),[n]=Xc();C.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",q=window.location.pathname==="/";if($&&q){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=C.useState(null),[l,i]=C.useState(null),[c,u]=C.useState(!1),[p,f]=C.useState(""),[y,_]=C.useState(""),[b,w]=C.useState(""),[j,N]=C.useState(!1),[S,T]=C.useState(!1),I=($,q=!1)=>{i({tier:$,skipTrial:q}),u(!0)};XAt(),C.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",q=location.pathname.startsWith("/public/");!s&&t&&!$&&!q&&r("/dashboard")},[t,s,r,location.pathname]),C.useEffect(()=>{n.get("canceled")==="true"&&me.error("Checkout was canceled. Feel free to try again when you're ready!")},[n]);const L=async($,q=!1)=>{if(!p){me.error("Please enter your email address");return}if(!y.trim()){me.error("Please enter your full name");return}N(!0),o($+(q?"_direct":""));const U=QAt();try{const{data:V,error:X}=await G.functions.invoke("create-checkout",{body:{tier:$,email:p,name:y.trim(),couponCode:b.trim()||void 0,skipTrial:q,referralCode:U}});if(X)throw X;if(V!=null&&V.url)window.open(V.url,"_blank","noopener,noreferrer"),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{N(!1),o(null),u(!1),i(null)}},R=()=>{l&&L(l.tier,l.skipTrial)};return s?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#4a6b6d]",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-white border-t-transparent"})}):e.jsxs("div",{className:"min-h-screen bg-background overflow-hidden",children:[e.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:e.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("img",{src:Loe,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var $;return($=document.getElementById("features"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},children:"Features"}),e.jsx(K,{variant:"ghost",className:"text-white/90 hover:text-white hover:bg-white/10 hidden sm:inline-flex",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},children:"Pricing"}),e.jsx(K,{onClick:()=>r("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),e.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-8",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx("img",{alt:"LevelUp Consulting Group",className:"h-[136px] md:h-[164px] drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),e.jsxs("p",{className:"text-lg text-white/80 max-w-3xl mx-auto leading-relaxed font-sans font-bold md:text-4xl",children:["The tools you need to get it done.",e.jsx("br",{}),e.jsx("em",{children:"The platform you need to keep it going."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center items-center pt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("free-trial"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold bg-white text-[#1e3a4c] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",children:["Start Your Free Trial",e.jsx(Ki,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(K,{size:"lg",variant:"outline",onClick:()=>{var $;return($=document.getElementById("features"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-8 py-7 text-lg font-semibold border-2 border-white text-white bg-transparent hover:bg-white hover:text-[#1e3a4c] rounded-full",children:"See What's Included"})]})]})})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl md:text-5xl leading-tight font-sans font-semibold text-secondary",children:"We help brokerages and agents grow with training, tools, and built-in execution."}),e.jsxs("div",{className:"space-y-2 text-lg text-muted-foreground",children:[e.jsx("p",{children:"Agents get weekly coaching + plug-and-play marketing."}),e.jsx("p",{children:"Brokerages get higher adoption, consistency, and real engagement."})]}),e.jsx("p",{className:"text-2xl md:text-4xl text-[#4a6b6d] pt-4 font-sans font-bold",children:"LEVELUP EQUIPS BOTH TO THRIVE."}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Learn how we support agents and empower brokerages to grow—together."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center pt-4",children:[e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>{var $;return($=document.getElementById("brokerage"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/5",children:[e.jsx(La,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:[e.jsx(ro,{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:tEt.map(($,q)=>e.jsxs(Ee,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(It,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx($.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(Ot,{className:"text-xl font-sans",children:$.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:$.description})})]},q))})]})}),e.jsxs("section",{id:"agent-os",className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs("div",{className:"container mx-auto px-4 relative",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium mb-6",children:[e.jsx(hn,{className:"w-4 h-4"}),"Included with Membership"]}),e.jsxs("h2",{className:"text-3xl mb-6 text-white font-sans font-bold md:text-6xl",children:["Meet ",e.jsx("span",{className:"italic",children:"Agent OS"})]}),e.jsx("p",{className:"text-lg text-white/80",children:"Your relationship-first operating system. Never forget a follow-up, track every touchpoint, and turn your sphere into a referral machine."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 max-w-6xl mx-auto",children:sEt.map(($,q)=>e.jsxs(Ee,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(It,{className:"pb-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:e.jsx($.icon,{className:"w-6 h-6 text-white"})}),e.jsx(Ot,{className:"text-lg font-semibold text-white",children:$.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:$.description})})]},q))}),e.jsx("div",{className:"text-center mt-12",children:e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-white text-[#4a6b6d] hover:bg-white/90 shadow-xl transition-all hover:scale-105",children:["Get Agent OS with Your Membership",e.jsx(Ki,{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(La,{className:"w-4 h-4"}),"For Brokerages"]}),e.jsxs("h2",{className:"text-3xl font-sans font-bold md:text-6xl",children:["Empower Your"," ",e.jsx("span",{className:"italic text-[#4a6b6d]",children:"Entire Team"})]}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Give every agent on your team access to world-class training and resources. Track performance, streamline onboarding, and watch your brokerage thrive."}),e.jsx("ul",{className:"space-y-4",children:["Dedicated brokerage manager dashboard","Invite and manage agents with one click","Exclusive brokerage-only resources","Team analytics and performance tracking","Simplified agent onboarding","Share resources across your team"].map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center flex-shrink-0",children:e.jsx(ma,{className:"w-4 h-4 text-[#4a6b6d]"})}),e.jsx("span",{className:"text-foreground",children:$})]},q))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["See Brokerage Plans",e.jsx(Xa,{className:"ml-2 w-5 h-5"})]}),e.jsxs(K,{size:"lg",variant:"outline",onClick:()=>T(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[e.jsx(on,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:JAt,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:rEt.map(($,q)=>e.jsx(Ee,{className:"bg-muted/30 border-0",children:e.jsxs(Oe,{className:"pt-8",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(U=>e.jsx(Kn,{className:"w-5 h-5 fill-yellow-400 text-yellow-400"},U))}),e.jsxs("p",{className:"text-lg mb-6 italic text-muted-foreground",children:['"',$.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:$.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:$.role})]})]})},q))})]})}),e.jsxs("section",{id:"free-trial",className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-8",children:[e.jsxs("h2",{className:"text-3xl md:text-5xl font-bold text-white",children:["Start Your Free Trial ",e.jsx("span",{className:"italic",children:"Today"})]}),e.jsx("p",{className:"text-lg md:text-xl text-white/80 leading-relaxed",children:"Get instant access to 7 days of trainings, templates, and tools — designed to give you quick wins now and resources you'll keep forever."}),e.jsx("div",{className:"pt-4",children:e.jsxs(K,{size:"lg",className:"px-12 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 group rounded-full",onClick:()=>I("individual_agent"),children:["Start Free Trial",e.jsx(Ki,{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(It,{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(ro,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsx(Ot,{className:"text-xl font-sans",children:Lu.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:Lu.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Lu.individual_agent.period})]}),e.jsx(fr,{className:"text-base mt-2",children:Lu.individual_agent.description}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-green-500/10 text-green-600 text-sm font-medium mt-4",children:[e.jsx(Tn,{className:"w-4 h-4"}),Lu.individual_agent.trial]})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Lu.individual_agent.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ma,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsxs(jL,{className:"flex flex-col gap-3 pt-4",children:[e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("individual_agent"),children:"Start Free Trial"}),e.jsx(K,{variant:"outline",className:"w-full rounded-full border-2 border-[#4a6b6d] text-[#4a6b6d] bg-white hover:bg-[#4a6b6d]/5 uppercase text-sm font-medium tracking-wide",onClick:()=>I("individual_agent",!0),children:"Skip Trial, Subscribe Now"})]})]}),e.jsxs(Ee,{className:"relative flex flex-col border-2 border-[#4a6b6d] shadow-2xl scale-105 bg-background",children:[e.jsx("div",{className:"absolute -top-4 left-1/2 -translate-x-1/2 px-6 py-2 bg-[#4a6b6d] text-white text-sm font-semibold rounded-full shadow-lg",children:"Most Popular"}),e.jsxs(It,{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(La,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-xl font-sans",children:Lu.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Lu.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:Lu.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Lu.brokerage_under_25.period})]}),e.jsx(fr,{className:"text-base mt-2",children:Lu.brokerage_under_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Lu.brokerage_under_25.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ma,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsx(jL,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg shadow-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("brokerage_under_25"),children:"Get Started"})})]}),e.jsxs(Ee,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(It,{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(La,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-xl font-sans",children:Lu.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Lu.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:Lu.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:Lu.brokerage_over_25.period})]}),e.jsx(fr,{className:"text-base mt-2",children:Lu.brokerage_over_25.description})]}),e.jsx(Oe,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:Lu.brokerage_over_25.features.map(($,q)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(ma,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:$})]},q))})}),e.jsx(jL,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("brokerage_over_25"),children:"Get Started"})})]})]})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[e.jsx("h2",{className:"text-3xl text-white font-sans md:text-5xl",children:"Ready to Level Up?"}),e.jsx("p",{className:"text-lg text-white/80 max-w-2xl mx-auto",children:"Join thousands of agents who are closing more deals, saving time, and growing their business with LevelUp."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs(K,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"px-10 py-7 text-lg font-semibold bg-white text-[#4a6b6d] hover:bg-white/90 shadow-2xl transition-all hover:scale-105",children:["Start Your Free Trial",e.jsx(Ki,{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:Loe,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(eEt,{open:S,onOpenChange:T}),e.jsx(_s,{open:c,onOpenChange:u,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{className:"text-xl font-sans font-semibold",children:"Enter your details to get started"}),e.jsx(Zr,{children:(l==null?void 0:l.tier)==="individual_agent"&&!(l!=null&&l.skipTrial)?"Start your 7-day free trial":(l==null?void 0:l.tier)==="individual_agent"?"Subscribe to Individual Agent":(l==null?void 0:l.tier)==="brokerage_under_25"?"Subscribe to Brokerage (Under 25 Agents)":"Subscribe to Brokerage (Over 25 Agents)"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsxs(_e,{htmlFor:"dialog-name",children:["Full Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Fe,{id:"dialog-name",type:"text",placeholder:"John Smith",value:y,onChange:$=>_($.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(_e,{htmlFor:"dialog-email",children:["Email Address ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Fe,{id:"dialog-email",type:"email",placeholder:"you@example.com",value:p,onChange:$=>f($.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(_e,{htmlFor:"dialog-coupon",children:["Discount Code ",e.jsx("span",{className:"text-muted-foreground",children:"(Optional)"})]}),e.jsx(Fe,{id:"dialog-coupon",type:"text",placeholder:"Enter discount code",value:b,onChange:$=>w($.target.value),className:"mt-1"})]})]}),e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:R,disabled:j,children:j?"Loading...":"Continue to Checkout"})]})})]})},aEt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(qh,{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"})]})]})]})]})})]}),iEt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(qh,{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"})]})]})]})]})})]}),oEt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(qh,{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"})]})]})]})]})})]}),lEt=ZS({email:uc().email("Invalid email address"),password:uc().min(6,"Password must be at least 6 characters")}),cEt=()=>{const{signIn:t,user:s}=Ws(),r=Pr(),[n,a]=C.useState(!1),[o,l]=C.useState({}),[i,c]=C.useState(""),[u,p]=C.useState(!1),[f,y]=C.useState(!1);C.useEffect(()=>{s&&r("/dashboard")},[s,r]);const _=async w=>{w.preventDefault(),l({}),a(!0);const j=new FormData(w.currentTarget),N=j.get("email"),S=j.get("password");try{lEt.parse({email:N,password:S}),await t(N,S)}catch(T){if(T instanceof y0){const I={};T.errors.forEach(L=>{L.path[0]&&(I[L.path[0]]=L.message)}),l(I)}}finally{a(!1)}},b=async()=>{if(!i){me.error("Please enter your email address");return}p(!0);try{const{error:w}=await G.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(w)throw w;me.success("Password reset email sent! Check your inbox."),y(!1),c("")}catch(w){me.error(w.message||"Failed to send reset email")}finally{p(!1)}};return e.jsxs("div",{className:"min-h-screen relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-[#4a6b6d] via-[#3d5a5c] to-[#2a4347]",children:e.jsxs("div",{className:"absolute inset-0 opacity-30",children:[e.jsx("div",{className:"absolute top-0 left-0 w-96 h-96 bg-white/10 rounded-full blur-3xl animate-pulse"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-96 h-96 bg-white/5 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/2 w-64 h-64 bg-white/5 rounded-full blur-3xl animate-pulse",style:{animationDelay:"2s"}})]})}),e.jsxs("div",{className:"relative z-10 flex flex-col min-h-screen",children:[e.jsx("header",{className:"p-6",children:e.jsxs(So,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[e.jsx(di,{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:PHe,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(Ee,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[e.jsxs(It,{className:"space-y-1 text-center pb-4",children:[e.jsx(Ot,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(fr,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),e.jsx(Oe,{children:e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"signin-email",className:"text-gray-700",children:"Email"}),e.jsx(Fe,{id:"signin-email",name:"email",type:"email",placeholder:"your@email.com",required:!0,className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"}),o.email&&e.jsx("p",{className:"text-sm text-red-600",children:o.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"signin-password",className:"text-gray-700",children:"Password"}),e.jsx(Fe,{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(_s,{open:f,onOpenChange:y,children:[e.jsx(Fi,{asChild:!0,children:e.jsx(K,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),e.jsxs(vs,{className:"bg-white",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{className:"text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Reset Password"}),e.jsx(Zr,{className:"text-gray-600",children:"Enter your email address and we'll send you a link to reset your password."})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"reset-email",className:"text-gray-700",children:"Email"}),e.jsx(Fe,{id:"reset-email",type:"email",placeholder:"your@email.com",value:i,onChange:w=>c(w.target.value),className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"})]}),e.jsx(K,{onClick:b,className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white",disabled:u,children:u?"Sending...":"Send Reset Link"})]})]})]})]})})]}),e.jsxs("p",{className:"text-center text-white/70 text-sm mt-6",children:["Don't have an account?"," ",e.jsx(So,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},dEt=()=>{const[t]=Xc(),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(It,{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(vi,{className:"w-10 h-10 text-green-500"})}),e.jsx(Ot,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(fr,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-primary/10 border border-primary/20 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(br,{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]=C.useState(null),[n,a]=C.useState(!0);return C.useEffect(()=>{if(!t){a(!1);return}(async()=>{try{const{data:i}=await G.storage.from("avatars").list(`${t}`);if(i&&i.length>0){const{data:c}=G.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 G.storage.from("avatars").list(`${t}`);if(l&&l.length>0){const{data:i}=G.storage.from("avatars").getPublicUrl(`${t}/${l[0].name}`);r(`${i.publicUrl}?t=${Date.now()}`)}}catch(l){console.error("Error refreshing avatar:",l)}}}},nZe=async t=>{const s=new Map;return await Promise.all(t.map(async r=>{try{const{data:n}=await G.storage.from("avatars").list(`${r}`);if(n&&n.length>0){const{data:a}=G.storage.from("avatars").getPublicUrl(`${r}/${n[0].name}`);s.set(r,a.publicUrl)}}catch{}})),s},uEt=t=>{const[s,r]=C.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return C.useEffect(()=>{if(!t){r(a=>({...a,loading:!1}));return}(async()=>{try{const{data:a,error:o}=await G.from("profiles").select("is_trial, trial_expires_at, subscription_status, subscription_end_date").eq("id",t).single();if(o){console.error("Error fetching trial status:",o),r(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},aZe=()=>{const{data:t,isLoading:s}=wt({queryKey:["feature-flags"],queryFn:async()=>{const{data:n,error:a}=await G.from("feature_flags").select("*");if(a)throw a;return n}}),r=n=>{if(!t)return!1;const a=t.find(o=>o.key===n);return(a==null?void 0:a.enabled)??!1};return{flags:t,isLoading:s,isFeatureEnabled:r,isAgentOSEnabled:r("agent_os_enabled"),isInnerCircleEnabled:r("innercircle_enabled"),isMarketplaceEnabled:r("marketplace")}},_6e="community_last_seen_post_at";function hEt(){const{user:t}=Ws(),s=Qu(),[r,n]=C.useState(0),[a,o]=C.useState(null);C.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${_6e}_${t.id}`);o(i)},[t]),C.useEffect(()=>{if(!t)return;(async()=>{let c=G.from("community_posts").select("id",{count:"exact",head:!0});a&&(c=c.gt("created_at",a));const{data:u}=await G.from("profiles").select("brokerage_id").eq("id",t.id).single(),{count:p,error:f}=await c;!f&&p!==null&&n(p)})()},[t,a]),C.useEffect(()=>{if(!t)return;const i=G.channel("community-new-posts").on("postgres_changes",{event:"INSERT",schema:"public",table:"community_posts"},async c=>{const u=c.new;if(u.user_id===t.id)return;const p=s.pathname==="/community";p||n(w=>w+1);const{data:f}=await G.from("profiles").select("name").eq("id",u.user_id).single(),y=(f==null?void 0:f.name)||"Someone",_=u.content.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),b=_.length>50?_.substring(0,50)+"...":_;p||me("New Community Post",{description:`${y}: ${b}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{G.removeChannel(i)}},[t,s.pathname]);const l=C.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${_6e}_${t.id}`,i),o(i),n(0)},[t]);return C.useEffect(()=>{s.pathname==="/community"&&r>0&&l()},[s.pathname,r,l]),{unreadCount:r,markAsRead:l}}function mEt(){const{isAdmin:t}=Ws(),{data:s=0}=wt({queryKey:["wishlist-open-count"],queryFn:async()=>{const{count:r,error:n}=await G.from("wishlist_items").select("*",{count:"exact",head:!0}).eq("status","open");if(n)throw n;return r||0},enabled:t,staleTime:6e4});return{openCount:t?s:0}}const DA=Pde,Uje=Zwe,pEt=Ide,iZe=C.forwardRef(({className:t,...s},r)=>e.jsx(TA,{className:At("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}));iZe.displayName=TA.displayName;const fEt=HS("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"}}),YS=C.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(pEt,{children:[e.jsx(iZe,{}),e.jsxs(AA,{ref:a,className:At(fEt({side:t}),s),...n,children:[r,e.jsxs(hO,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(Ur,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));YS.displayName=AA.displayName;const OA=({className:t,...s})=>e.jsx("div",{className:At("flex flex-col space-y-2 text-center sm:text-left",t),...s});OA.displayName="SheetHeader";const RA=C.forwardRef(({className:t,...s},r)=>e.jsx(dO,{ref:r,className:At("text-lg font-semibold text-foreground",t),...s}));RA.displayName=dO.displayName;const oZe=C.forwardRef(({className:t,...s},r)=>e.jsx(uO,{ref:r,className:At("text-sm text-muted-foreground",t),...s}));oZe.displayName=uO.displayName;var eue="Collapsible",[gEt]=Yc(eue),[xEt,Vje]=gEt(eue),lZe=C.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[c,u]=Yu({prop:n,defaultProp:a??!1,onChange:l,caller:eue});return e.jsx(xEt,{scope:r,disabled:o,contentId:vu(),open:c,onOpenToggle:C.useCallback(()=>u(p=>!p),[u]),children:e.jsx(Jr.div,{"data-state":Wje(c),"data-disabled":o?"":void 0,...i,ref:s})})});lZe.displayName=eue;var cZe="CollapsibleTrigger",dZe=C.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=Vje(cZe,r);return e.jsx(Jr.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":Wje(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Mr(t.onClick,a.onOpenToggle)})});dZe.displayName=cZe;var Hje="CollapsibleContent",uZe=C.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=Vje(Hje,t.__scopeCollapsible);return e.jsx(Id,{present:r||a.open,children:({present:o})=>e.jsx(yEt,{...n,ref:s,present:o})})});uZe.displayName=Hje;var yEt=C.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=Vje(Hje,r),[i,c]=C.useState(n),u=C.useRef(null),p=Oa(s,u),f=C.useRef(0),y=f.current,_=C.useRef(0),b=_.current,w=l.open||i,j=C.useRef(w),N=C.useRef(void 0);return C.useEffect(()=>{const S=requestAnimationFrame(()=>j.current=!1);return()=>cancelAnimationFrame(S)},[]),fd(()=>{const S=u.current;if(S){N.current=N.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const T=S.getBoundingClientRect();f.current=T.height,_.current=T.width,j.current||(S.style.transitionDuration=N.current.transitionDuration,S.style.animationName=N.current.animationName),c(n)}},[l.open,n]),e.jsx(Jr.div,{"data-state":Wje(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!w,...o,ref:p,style:{"--radix-collapsible-content-height":y?`${y}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...t.style},children:w&&a})});function Wje(t){return t?"open":"closed"}var vEt=lZe;const bg=vEt,wg=dZe,jg=uZe,_Et="/assets/levelup-logo-Eif24dqY.png",bEt="/assets/levelup-logo-icon-C-7iromj.png",wEt="/assets/levelup-logo-mobile-B9skSjUG.png";var vO=t=>t.type==="checkbox",m4=t=>t instanceof Date,fm=t=>t==null;const hZe=t=>typeof t=="object";var Pd=t=>!fm(t)&&!Array.isArray(t)&&hZe(t)&&!m4(t),mZe=t=>Pd(t)&&t.target?vO(t.target)?t.target.checked:t.target.value:t,jEt=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,pZe=(t,s)=>t.has(jEt(s)),kEt=t=>{const s=t.constructor&&t.constructor.prototype;return Pd(s)&&s.hasOwnProperty("isPrototypeOf")},Gje=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function iu(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(!(Gje&&(t instanceof Blob||n))&&(r||Pd(t)))if(s=r?[]:{},!r&&!kEt(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=iu(t[a]));else return t;return s}var tue=t=>/^\w*$/.test(t),jd=t=>t===void 0,Kje=t=>Array.isArray(t)?t.filter(Boolean):[],Zje=t=>Kje(t.replace(/["|']|\]/g,"").split(/\.|\[/)),wn=(t,s,r)=>{if(!s||!Pd(t))return r;const n=(tue(s)?[s]:Zje(s)).reduce((a,o)=>fm(a)?a:a[o],t);return jd(n)||n===t?jd(t[s])?r:t[s]:n},Yp=t=>typeof t=="boolean",il=(t,s,r)=>{let n=-1;const a=tue(s)?[s]:Zje(s),o=a.length,l=o-1;for(;++nht.useContext(Yje),NEt=t=>{const{children:s,...r}=t;return ht.createElement(Yje.Provider,{value:r},s)};var fZe=(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]!==Lx.all&&(s._proxyFormState[l]=!n||Lx.all),r&&(r[l]=!0),t[l]}});return a};const Xje=typeof window<"u"?ht.useLayoutEffect:ht.useEffect;function SEt(t){const s=sue(),{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 Xje(()=>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(()=>fZe(l,r,c.current,!1),[l,r])}var Qy=t=>typeof t=="string",gZe=(t,s,r,n,a)=>Qy(t)?(n&&s.watch.add(t),wn(r,t,a)):Array.isArray(t)?t.map(o=>(n&&s.watch.add(o),wn(r,o))):(n&&(s.watchAll=!0),r),e1e=t=>fm(t)||!hZe(t);function Ov(t,s,r=new WeakSet){if(e1e(t)||e1e(s))return t===s;if(m4(t)&&m4(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(m4(l)&&m4(i)||Pd(l)&&Pd(i)||Array.isArray(l)&&Array.isArray(i)?!Ov(l,i,r):l!==i)return!1}}return!0}function CEt(t){const s=sue(),{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]),[y,_]=ht.useState(u.current?u.current(f):f);return Xje(()=>r._subscribe({name:n,formState:{values:!0},exact:l,callback:b=>{if(!o){const w=gZe(n,r._names,b.values||r._formValues,!1,c.current);if(u.current){const j=u.current(w);Ov(j,p.current)||(_(j),p.current=j)}else _(w)}}}),[r,o,n,l]),ht.useEffect(()=>r._removeUnmounted()),y}function MEt(t){const s=sue(),{name:r,disabled:n,control:a=s.control,shouldUnregister:o,defaultValue:l}=t,i=pZe(a._names.array,r),c=ht.useMemo(()=>wn(a._formValues,r,wn(a._defaultValues,r,l)),[a,r,l]),u=CEt({control:a,name:r,defaultValue:c,exact:!0}),p=SEt({control:a,name:r,exact:!0}),f=ht.useRef(t),y=ht.useRef(a.register(r,{...t.rules,value:u,...Yp(t.disabled)?{disabled:t.disabled}:{}}));f.current=t;const _=ht.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!wn(p.errors,r)},isDirty:{enumerable:!0,get:()=>!!wn(p.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!wn(p.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!wn(p.validatingFields,r)},error:{enumerable:!0,get:()=>wn(p.errors,r)}}),[p,r]),b=ht.useCallback(S=>y.current.onChange({target:{value:mZe(S),name:r},type:Doe.CHANGE}),[r]),w=ht.useCallback(()=>y.current.onBlur({target:{value:wn(a._formValues,r),name:r},type:Doe.BLUR}),[r,a._formValues]),j=ht.useCallback(S=>{const T=wn(a._fields,r);T&&S&&(T._f.ref={focus:()=>S.focus&&S.focus(),select:()=>S.select&&S.select(),setCustomValidity:I=>S.setCustomValidity(I),reportValidity:()=>S.reportValidity()})},[a._fields,r]),N=ht.useMemo(()=>({name:r,value:u,...Yp(n)||p.disabled?{disabled:p.disabled||n}:{},onChange:b,onBlur:w,ref:j}),[r,n,p.disabled,b,w,j,u]);return ht.useEffect(()=>{const S=a._options.shouldUnregister||o;a.register(r,{...f.current.rules,...Yp(f.current.disabled)?{disabled:f.current.disabled}:{}});const T=(I,L)=>{const R=wn(a._fields,I);R&&R._f&&(R._f.mount=L)};if(T(r,!0),S){const I=iu(wn(a._options.defaultValues,r));il(a._defaultValues,r,I),jd(wn(a._formValues,r))&&il(a._formValues,r,I)}return!i&&a.register(r),()=>{(i?S&&!a._state.action:S)?a.unregister(r):T(r,!1)}},[r,a,i,o]),ht.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),ht.useMemo(()=>({field:N,formState:p,fieldState:_}),[N,p,_])}const TEt=t=>t.render(MEt(t));var xZe=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},EL=t=>Array.isArray(t)?t:[t],b6e=()=>{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=[]}}},tp=t=>Pd(t)&&!Object.keys(t).length,Qje=t=>t.type==="file",Dx=t=>typeof t=="function",Ooe=t=>{if(!Gje)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},yZe=t=>t.type==="select-multiple",Jje=t=>t.type==="radio",AEt=t=>Jje(t)||vO(t),Lge=t=>Ooe(t)&&t.isConnected;function EEt(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if(Dx(t[s]))return!0;return!1};function Roe(t,s={}){const r=Array.isArray(t);if(Pd(t)||r)for(const n in t)Array.isArray(t[n])||Pd(t[n])&&!vZe(t[n])?(s[n]=Array.isArray(t[n])?[]:{},Roe(t[n],s[n])):fm(t[n])||(s[n]=!0);return s}function _Ze(t,s,r){const n=Array.isArray(t);if(Pd(t)||n)for(const a in t)Array.isArray(t[a])||Pd(t[a])&&!vZe(t[a])?jd(s)||e1e(r[a])?r[a]=Array.isArray(t[a])?Roe(t[a],[]):{...Roe(t[a])}:_Ze(t[a],fm(s)?{}:s[a],r[a]):r[a]=!Ov(t[a],s[a]);return r}var C6=(t,s)=>_Ze(t,s,Roe(s));const w6e={value:!1,isValid:!1},j6e={value:!0,isValid:!0};var bZe=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&&!jd(t[0].attributes.value)?jd(t[0].value)||t[0].value===""?j6e:{value:t[0].value,isValid:!0}:j6e:w6e}return w6e},wZe=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>jd(t)?t:s?t===""?NaN:t&&+t:r&&Qy(t)?new Date(t):n?n(t):t;const k6e={isValid:!1,value:null};var jZe=t=>Array.isArray(t)?t.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,k6e):k6e;function N6e(t){const s=t.ref;return Qje(s)?s.files:Jje(s)?jZe(t.refs).value:yZe(s)?[...s.selectedOptions].map(({value:r})=>r):vO(s)?bZe(t.refs).value:wZe(jd(s.value)?t.ref.value:s.value,t)}var IEt=(t,s,r,n)=>{const a={};for(const o of t){const l=wn(s,o);l&&il(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},Foe=t=>t instanceof RegExp,M6=t=>jd(t)?t:Foe(t)?t.source:Pd(t)?Foe(t.value)?t.value.source:t.value:t,S6e=t=>({isOnSubmit:!t||t===Lx.onSubmit,isOnBlur:t===Lx.onBlur,isOnChange:t===Lx.onChange,isOnAll:t===Lx.all,isOnTouch:t===Lx.onTouched});const C6e="AsyncFunction";var LEt=t=>!!t&&!!t.validate&&!!(Dx(t.validate)&&t.validate.constructor.name===C6e||Pd(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===C6e)),DEt=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),M6e=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const PL=(t,s,r,n)=>{for(const a of r||Object.keys(t)){const o=wn(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(PL(i,s))break}else if(Pd(i)&&PL(i,s))break}}};function T6e(t,s,r){const n=wn(t,r);if(n||tue(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const o=a.join("."),l=wn(s,o),i=wn(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 OEt=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return tp(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||Lx.all))},REt=(t,s,r)=>!t||!s||t===s||EL(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),FEt=(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,zEt=(t,s)=>!Kje(wn(t,s)).length&&Bd(t,s),BEt=(t,s,r)=>{const n=EL(wn(t,r));return il(n,"root",s[r]),il(t,r,n),t},pie=t=>Qy(t);function A6e(t,s,r="validate"){if(pie(t)||Array.isArray(t)&&t.every(pie)||Yp(t)&&!t)return{type:r,message:pie(t)?t:"",ref:s}}var J3=t=>Pd(t)&&!Foe(t)?t:{value:t,message:""},E6e=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:c,maxLength:u,minLength:p,min:f,max:y,pattern:_,validate:b,name:w,valueAsNumber:j,mount:N}=t._f,S=wn(r,w);if(!N||s.has(w))return{};const T=i?i[0]:l,I=se=>{a&&T.reportValidity&&(T.setCustomValidity(Yp(se)?"":se||""),T.reportValidity())},L={},R=Jje(l),$=vO(l),q=R||$,U=(j||Qje(l))&&jd(l.value)&&jd(S)||Ooe(l)&&l.value===""||S===""||Array.isArray(S)&&!S.length,V=xZe.bind(null,w,n,L),X=(se,ee,Q,de=mv.maxLength,re=mv.minLength)=>{const ne=se?ee:Q;L[w]={type:se?de:re,message:ne,ref:l,...V(se?de:re,ne)}};if(o?!Array.isArray(S)||!S.length:c&&(!q&&(U||fm(S))||Yp(S)&&!S||$&&!bZe(i).isValid||R&&!jZe(i).isValid)){const{value:se,message:ee}=pie(c)?{value:!!c,message:c}:J3(c);if(se&&(L[w]={type:mv.required,message:ee,ref:T,...V(mv.required,ee)},!n))return I(ee),L}if(!U&&(!fm(f)||!fm(y))){let se,ee;const Q=J3(y),de=J3(f);if(!fm(S)&&!isNaN(S)){const re=l.valueAsNumber||S&&+S;fm(Q.value)||(se=re>Q.value),fm(de.value)||(ee=renew Date(new Date().toDateString()+" "+we),le=l.type=="time",he=l.type=="week";Qy(Q.value)&&S&&(se=le?ne(S)>ne(Q.value):he?S>Q.value:re>new Date(Q.value)),Qy(de.value)&&S&&(ee=le?ne(S)+se.value,de=!fm(ee.value)&&S.length<+ee.value;if((Q||de)&&(X(Q,se.message,ee.message),!n))return I(L[w].message),L}if(_&&!U&&Qy(S)){const{value:se,message:ee}=J3(_);if(Foe(se)&&!S.match(se)&&(L[w]={type:mv.pattern,message:ee,ref:l,...V(mv.pattern,ee)},!n))return I(ee),L}if(b){if(Dx(b)){const se=await b(S,r),ee=A6e(se,T);if(ee&&(L[w]={...ee,...V(mv.validate,ee.message)},!n))return I(ee.message),L}else if(Pd(b)){let se={};for(const ee in b){if(!tp(se)&&!n)break;const Q=A6e(await b[ee](S,r),T,ee);Q&&(se={...Q,...V(ee,Q.message)},I(Q.message),n&&(L[w]=se))}if(!tp(se)&&(L[w]={ref:T,...se},!n))return L}}return I(!0),L};const $Et={mode:Lx.onSubmit,reValidateMode:Lx.onChange,shouldFocusError:!0};function qEt(t={}){let s={...$Et,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:Dx(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=Pd(s.defaultValues)||Pd(s.values)?iu(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:iu(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 y={array:b6e(),state:b6e()},_=s.criteriaMode===Lx.all,b=$e=>ot=>{clearTimeout(u),u=setTimeout($e,ot)},w=async $e=>{if(!s.disabled&&(p.isValid||f.isValid||$e)){const ot=s.resolver?tp((await $()).errors):await U(n,!0);ot!==r.isValid&&y.state.next({isValid:ot})}},j=($e,ot)=>{!s.disabled&&(p.isValidating||p.validatingFields||f.isValidating||f.validatingFields)&&(($e||Array.from(i.mount)).forEach(Ue=>{Ue&&(ot?il(r.validatingFields,Ue,ot):Bd(r.validatingFields,Ue))}),y.state.next({validatingFields:r.validatingFields,isValidating:!tp(r.validatingFields)}))},N=($e,ot=[],Ue,Ke,Xe=!0,He=!0)=>{if(Ke&&Ue&&!s.disabled){if(l.action=!0,He&&Array.isArray(wn(n,$e))){const Ye=Ue(wn(n,$e),Ke.argA,Ke.argB);Xe&&il(n,$e,Ye)}if(He&&Array.isArray(wn(r.errors,$e))){const Ye=Ue(wn(r.errors,$e),Ke.argA,Ke.argB);Xe&&il(r.errors,$e,Ye),zEt(r.errors,$e)}if((p.touchedFields||f.touchedFields)&&He&&Array.isArray(wn(r.touchedFields,$e))){const Ye=Ue(wn(r.touchedFields,$e),Ke.argA,Ke.argB);Xe&&il(r.touchedFields,$e,Ye)}(p.dirtyFields||f.dirtyFields)&&(r.dirtyFields=C6(a,o)),y.state.next({name:$e,isDirty:X($e,ot),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else il(o,$e,ot)},S=($e,ot)=>{il(r.errors,$e,ot),y.state.next({errors:r.errors})},T=$e=>{r.errors=$e,y.state.next({errors:r.errors,isValid:!1})},I=($e,ot,Ue,Ke)=>{const Xe=wn(n,$e);if(Xe){const He=wn(o,$e,jd(Ue)?wn(a,$e):Ue);jd(He)||Ke&&Ke.defaultChecked||ot?il(o,$e,ot?He:N6e(Xe._f)):Q($e,He),l.mount&&w()}},L=($e,ot,Ue,Ke,Xe)=>{let He=!1,Ye=!1;const tt={name:$e};if(!s.disabled){if(!Ue||Ke){(p.isDirty||f.isDirty)&&(Ye=r.isDirty,r.isDirty=tt.isDirty=X(),He=Ye!==tt.isDirty);const Et=Ov(wn(a,$e),ot);Ye=!!wn(r.dirtyFields,$e),Et?Bd(r.dirtyFields,$e):il(r.dirtyFields,$e,!0),tt.dirtyFields=r.dirtyFields,He=He||(p.dirtyFields||f.dirtyFields)&&Ye!==!Et}if(Ue){const Et=wn(r.touchedFields,$e);Et||(il(r.touchedFields,$e,Ue),tt.touchedFields=r.touchedFields,He=He||(p.touchedFields||f.touchedFields)&&Et!==Ue)}He&&Xe&&y.state.next(tt)}return He?tt:{}},R=($e,ot,Ue,Ke)=>{const Xe=wn(r.errors,$e),He=(p.isValid||f.isValid)&&Yp(ot)&&r.isValid!==ot;if(s.delayError&&Ue?(c=b(()=>S($e,Ue)),c(s.delayError)):(clearTimeout(u),c=null,Ue?il(r.errors,$e,Ue):Bd(r.errors,$e)),(Ue?!Ov(Xe,Ue):Xe)||!tp(Ke)||He){const Ye={...Ke,...He&&Yp(ot)?{isValid:ot}:{},errors:r.errors,name:$e};r={...r,...Ye},y.state.next(Ye)}},$=async $e=>{j($e,!0);const ot=await s.resolver(o,s.context,IEt($e||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return j($e),ot},q=async $e=>{const{errors:ot}=await $($e);if($e)for(const Ue of $e){const Ke=wn(ot,Ue);Ke?il(r.errors,Ue,Ke):Bd(r.errors,Ue)}else r.errors=ot;return ot},U=async($e,ot,Ue={valid:!0})=>{for(const Ke in $e){const Xe=$e[Ke];if(Xe){const{_f:He,...Ye}=Xe;if(He){const tt=i.array.has(He.name),Et=Xe._f&&LEt(Xe._f);Et&&p.validatingFields&&j([Ke],!0);const qt=await E6e(Xe,i.disabled,o,_,s.shouldUseNativeValidation&&!ot,tt);if(Et&&p.validatingFields&&j([Ke]),qt[He.name]&&(Ue.valid=!1,ot))break;!ot&&(wn(qt,He.name)?tt?BEt(r.errors,qt,He.name):il(r.errors,He.name,qt[He.name]):Bd(r.errors,He.name))}!tp(Ye)&&await U(Ye,ot,Ue)}}return Ue.valid},V=()=>{for(const $e of i.unMount){const ot=wn(n,$e);ot&&(ot._f.refs?ot._f.refs.every(Ue=>!Lge(Ue)):!Lge(ot._f.ref))&&Ae($e)}i.unMount=new Set},X=($e,ot)=>!s.disabled&&($e&&ot&&il(o,$e,ot),!Ov(we(),a)),se=($e,ot,Ue)=>gZe($e,i,{...l.mount?o:jd(ot)?a:Qy($e)?{[$e]:ot}:ot},Ue,ot),ee=$e=>Kje(wn(l.mount?o:a,$e,s.shouldUnregister?wn(a,$e,[]):[])),Q=($e,ot,Ue={})=>{const Ke=wn(n,$e);let Xe=ot;if(Ke){const He=Ke._f;He&&(!He.disabled&&il(o,$e,wZe(ot,He)),Xe=Ooe(He.ref)&&fm(ot)?"":ot,yZe(He.ref)?[...He.ref.options].forEach(Ye=>Ye.selected=Xe.includes(Ye.value)):He.refs?vO(He.ref)?He.refs.forEach(Ye=>{(!Ye.defaultChecked||!Ye.disabled)&&(Array.isArray(Xe)?Ye.checked=!!Xe.find(tt=>tt===Ye.value):Ye.checked=Xe===Ye.value||!!Xe)}):He.refs.forEach(Ye=>Ye.checked=Ye.value===Xe):Qje(He.ref)?He.ref.value="":(He.ref.value=Xe,He.ref.type||y.state.next({name:$e,values:iu(o)})))}(Ue.shouldDirty||Ue.shouldTouch)&&L($e,Xe,Ue.shouldTouch,Ue.shouldDirty,!0),Ue.shouldValidate&&he($e)},de=($e,ot,Ue)=>{for(const Ke in ot){if(!ot.hasOwnProperty(Ke))return;const Xe=ot[Ke],He=$e+"."+Ke,Ye=wn(n,He);(i.array.has($e)||Pd(Xe)||Ye&&!Ye._f)&&!m4(Xe)?de(He,Xe,Ue):Q(He,Xe,Ue)}},re=($e,ot,Ue={})=>{const Ke=wn(n,$e),Xe=i.array.has($e),He=iu(ot);il(o,$e,He),Xe?(y.array.next({name:$e,values:iu(o)}),(p.isDirty||p.dirtyFields||f.isDirty||f.dirtyFields)&&Ue.shouldDirty&&y.state.next({name:$e,dirtyFields:C6(a,o),isDirty:X($e,He)})):Ke&&!Ke._f&&!fm(He)?de($e,He,Ue):Q($e,He,Ue),M6e($e,i)&&y.state.next({...r,name:$e}),y.state.next({name:l.mount?$e:void 0,values:iu(o)})},ne=async $e=>{l.mount=!0;const ot=$e.target;let Ue=ot.name,Ke=!0;const Xe=wn(n,Ue),He=Et=>{Ke=Number.isNaN(Et)||m4(Et)&&isNaN(Et.getTime())||Ov(Et,wn(o,Ue,Et))},Ye=S6e(s.mode),tt=S6e(s.reValidateMode);if(Xe){let Et,qt;const ms=ot.type?N6e(Xe._f):mZe($e),Xt=$e.type===Doe.BLUR||$e.type===Doe.FOCUS_OUT,rs=!DEt(Xe._f)&&!s.resolver&&!wn(r.errors,Ue)&&!Xe._f.deps||FEt(Xt,wn(r.touchedFields,Ue),r.isSubmitted,tt,Ye),ps=M6e(Ue,i,Xt);il(o,Ue,ms),Xt?(Xe._f.onBlur&&Xe._f.onBlur($e),c&&c(0)):Xe._f.onChange&&Xe._f.onChange($e);const Ms=L(Ue,ms,Xt),jt=!tp(Ms)||ps;if(!Xt&&y.state.next({name:Ue,type:$e.type,values:iu(o)}),rs)return(p.isValid||f.isValid)&&(s.mode==="onBlur"?Xt&&w():Xt||w()),jt&&y.state.next({name:Ue,...ps?{}:Ms});if(!Xt&&ps&&y.state.next({...r}),s.resolver){const{errors:As}=await $([Ue]);if(He(ms),Ke){const Ps=T6e(r.errors,n,Ue),ar=T6e(As,n,Ps.name||Ue);Et=ar.error,Ue=ar.name,qt=tp(As)}}else j([Ue],!0),Et=(await E6e(Xe,i.disabled,o,_,s.shouldUseNativeValidation))[Ue],j([Ue]),He(ms),Ke&&(Et?qt=!1:(p.isValid||f.isValid)&&(qt=await U(n,!0)));Ke&&(Xe._f.deps&&he(Xe._f.deps),R(Ue,qt,Et,Ms))}},le=($e,ot)=>{if(wn(r.errors,ot)&&$e.focus)return $e.focus(),1},he=async($e,ot={})=>{let Ue,Ke;const Xe=EL($e);if(s.resolver){const He=await q(jd($e)?$e:Xe);Ue=tp(He),Ke=$e?!Xe.some(Ye=>wn(He,Ye)):Ue}else $e?(Ke=(await Promise.all(Xe.map(async He=>{const Ye=wn(n,He);return await U(Ye&&Ye._f?{[He]:Ye}:Ye)}))).every(Boolean),!(!Ke&&!r.isValid)&&w()):Ke=Ue=await U(n);return y.state.next({...!Qy($e)||(p.isValid||f.isValid)&&Ue!==r.isValid?{}:{name:$e},...s.resolver||!$e?{isValid:Ue}:{},errors:r.errors}),ot.shouldFocus&&!Ke&&PL(n,le,$e?Xe:i.mount),Ke},we=$e=>{const ot={...l.mount?o:a};return jd($e)?ot:Qy($e)?wn(ot,$e):$e.map(Ue=>wn(ot,Ue))},ye=($e,ot)=>({invalid:!!wn((ot||r).errors,$e),isDirty:!!wn((ot||r).dirtyFields,$e),error:wn((ot||r).errors,$e),isValidating:!!wn(r.validatingFields,$e),isTouched:!!wn((ot||r).touchedFields,$e)}),je=$e=>{$e&&EL($e).forEach(ot=>Bd(r.errors,ot)),y.state.next({errors:$e?r.errors:{}})},ke=($e,ot,Ue)=>{const Ke=(wn(n,$e,{_f:{}})._f||{}).ref,Xe=wn(r.errors,$e)||{},{ref:He,message:Ye,type:tt,...Et}=Xe;il(r.errors,$e,{...Et,...ot,ref:Ke}),y.state.next({name:$e,errors:r.errors,isValid:!1}),Ue&&Ue.shouldFocus&&Ke&&Ke.focus&&Ke.focus()},We=($e,ot)=>Dx($e)?y.state.subscribe({next:Ue=>"values"in Ue&&$e(se(void 0,ot),Ue)}):se($e,ot,!0),be=$e=>y.state.subscribe({next:ot=>{REt($e.name,ot.name,$e.exact)&&OEt(ot,$e.formState||p,rt,$e.reRenderRoot)&&$e.callback({values:{...o},...r,...ot,defaultValues:a})}}).unsubscribe,Me=$e=>(l.mount=!0,f={...f,...$e.formState},be({...$e,formState:f})),Ae=($e,ot={})=>{for(const Ue of $e?EL($e):i.mount)i.mount.delete(Ue),i.array.delete(Ue),ot.keepValue||(Bd(n,Ue),Bd(o,Ue)),!ot.keepError&&Bd(r.errors,Ue),!ot.keepDirty&&Bd(r.dirtyFields,Ue),!ot.keepTouched&&Bd(r.touchedFields,Ue),!ot.keepIsValidating&&Bd(r.validatingFields,Ue),!s.shouldUnregister&&!ot.keepDefaultValue&&Bd(a,Ue);y.state.next({values:iu(o)}),y.state.next({...r,...ot.keepDirty?{isDirty:X()}:{}}),!ot.keepIsValid&&w()},Re=({disabled:$e,name:ot})=>{(Yp($e)&&l.mount||$e||i.disabled.has(ot))&&($e?i.disabled.add(ot):i.disabled.delete(ot))},Te=($e,ot={})=>{let Ue=wn(n,$e);const Ke=Yp(ot.disabled)||Yp(s.disabled);return il(n,$e,{...Ue||{},_f:{...Ue&&Ue._f?Ue._f:{ref:{name:$e}},name:$e,mount:!0,...ot}}),i.mount.add($e),Ue?Re({disabled:Yp(ot.disabled)?ot.disabled:s.disabled,name:$e}):I($e,!0,ot.value),{...Ke?{disabled:ot.disabled||s.disabled}:{},...s.progressive?{required:!!ot.required,min:M6(ot.min),max:M6(ot.max),minLength:M6(ot.minLength),maxLength:M6(ot.maxLength),pattern:M6(ot.pattern)}:{},name:$e,onChange:ne,onBlur:ne,ref:Xe=>{if(Xe){Te($e,ot),Ue=wn(n,$e);const He=jd(Xe.value)&&Xe.querySelectorAll&&Xe.querySelectorAll("input,select,textarea")[0]||Xe,Ye=AEt(He),tt=Ue._f.refs||[];if(Ye?tt.find(Et=>Et===He):He===Ue._f.ref)return;il(n,$e,{_f:{...Ue._f,...Ye?{refs:[...tt.filter(Lge),He,...Array.isArray(wn(a,$e))?[{}]:[]],ref:{type:He.type,name:$e}}:{ref:He}}}),I($e,!1,void 0,He)}else Ue=wn(n,$e,{}),Ue._f&&(Ue._f.mount=!1),(s.shouldUnregister||ot.shouldUnregister)&&!(pZe(i.array,$e)&&l.action)&&i.unMount.add($e)}}},qe=()=>s.shouldFocusError&&PL(n,le,i.mount),ct=$e=>{Yp($e)&&(y.state.next({disabled:$e}),PL(n,(ot,Ue)=>{const Ke=wn(n,Ue);Ke&&(ot.disabled=Ke._f.disabled||$e,Array.isArray(Ke._f.refs)&&Ke._f.refs.forEach(Xe=>{Xe.disabled=Ke._f.disabled||$e}))},0,!1))},De=($e,ot)=>async Ue=>{let Ke;Ue&&(Ue.preventDefault&&Ue.preventDefault(),Ue.persist&&Ue.persist());let Xe=iu(o);if(y.state.next({isSubmitting:!0}),s.resolver){const{errors:He,values:Ye}=await $();r.errors=He,Xe=iu(Ye)}else await U(n);if(i.disabled.size)for(const He of i.disabled)Bd(Xe,He);if(Bd(r.errors,"root"),tp(r.errors)){y.state.next({errors:{}});try{await $e(Xe,Ue)}catch(He){Ke=He}}else ot&&await ot({...r.errors},Ue),qe(),setTimeout(qe);if(y.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:tp(r.errors)&&!Ke,submitCount:r.submitCount+1,errors:r.errors}),Ke)throw Ke},Rt=($e,ot={})=>{wn(n,$e)&&(jd(ot.defaultValue)?re($e,iu(wn(a,$e))):(re($e,ot.defaultValue),il(a,$e,iu(ot.defaultValue))),ot.keepTouched||Bd(r.touchedFields,$e),ot.keepDirty||(Bd(r.dirtyFields,$e),r.isDirty=ot.defaultValue?X($e,iu(wn(a,$e))):X()),ot.keepError||(Bd(r.errors,$e),p.isValid&&w()),y.state.next({...r}))},pe=($e,ot={})=>{const Ue=$e?iu($e):a,Ke=iu(Ue),Xe=tp($e),He=Xe?a:Ke;if(ot.keepDefaultValues||(a=Ue),!ot.keepValues){if(ot.keepDirtyValues){const Ye=new Set([...i.mount,...Object.keys(C6(a,o))]);for(const tt of Array.from(Ye))wn(r.dirtyFields,tt)?il(He,tt,wn(o,tt)):re(tt,wn(He,tt))}else{if(Gje&&jd($e))for(const Ye of i.mount){const tt=wn(n,Ye);if(tt&&tt._f){const Et=Array.isArray(tt._f.refs)?tt._f.refs[0]:tt._f.ref;if(Ooe(Et)){const qt=Et.closest("form");if(qt){qt.reset();break}}}}if(ot.keepFieldsRef)for(const Ye of i.mount)re(Ye,wn(He,Ye));else n={}}o=s.shouldUnregister?ot.keepDefaultValues?iu(a):{}:iu(He),y.array.next({values:{...He}}),y.state.next({values:{...He}})}i={mount:ot.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!p.isValid||!!ot.keepIsValid||!!ot.keepDirtyValues,l.watch=!!s.shouldUnregister,y.state.next({submitCount:ot.keepSubmitCount?r.submitCount:0,isDirty:Xe?!1:ot.keepDirty?r.isDirty:!!(ot.keepDefaultValues&&!Ov($e,a)),isSubmitted:ot.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:Xe?{}:ot.keepDirtyValues?ot.keepDefaultValues&&o?C6(a,o):r.dirtyFields:ot.keepDefaultValues&&$e?C6(a,$e):ot.keepDirty?r.dirtyFields:{},touchedFields:ot.keepTouched?r.touchedFields:{},errors:ot.keepErrors?r.errors:{},isSubmitSuccessful:ot.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Je=($e,ot)=>pe(Dx($e)?$e(o):$e,ot),lt=($e,ot={})=>{const Ue=wn(n,$e),Ke=Ue&&Ue._f;if(Ke){const Xe=Ke.refs?Ke.refs[0]:Ke.ref;Xe.focus&&(Xe.focus(),ot.shouldSelect&&Dx(Xe.select)&&Xe.select())}},rt=$e=>{r={...r,...$e}},it={control:{register:Te,unregister:Ae,getFieldState:ye,handleSubmit:De,setError:ke,_subscribe:be,_runSchema:$,_focusError:qe,_getWatch:se,_getDirty:X,_setValid:w,_setFieldArray:N,_setDisabledField:Re,_setErrors:T,_getFieldArray:ee,_reset:pe,_resetDefaultValues:()=>Dx(s.defaultValues)&&s.defaultValues().then($e=>{Je($e,s.resetOptions),y.state.next({isLoading:!1})}),_removeUnmounted:V,_disableForm:ct,_subjects:y,_proxyFormState:p,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state($e){l=$e},get _defaultValues(){return a},get _names(){return i},set _names($e){i=$e},get _formState(){return r},get _options(){return s},set _options($e){s={...s,...$e}}},subscribe:Me,trigger:he,register:Te,handleSubmit:De,watch:We,setValue:re,getValues:we,reset:Je,resetField:Rt,clearErrors:je,unregister:Ae,setError:ke,setFocus:lt,getFieldState:ye};return{...it,formControl:it}}function rue(t={}){const s=ht.useRef(void 0),r=ht.useRef(void 0),[n,a]=ht.useState({isDirty:!1,isValidating:!1,isLoading:Dx(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:Dx(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!Dx(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=qEt(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,Xje(()=>{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&&!Ov(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=fZe(n,o),s.current}const P6e=(t,s,r)=>{if(t&&"reportValidity"in t){const n=wn(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},kZe=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?P6e(n.ref,r,t):n.refs&&n.refs.forEach(a=>P6e(a,r,t))}},UEt=(t,s)=>{s.shouldUseNativeValidation&&kZe(t,s);const r={};for(const n in t){const a=wn(s.fields,n),o=Object.assign(t[n]||{},{ref:a&&a.ref});if(VEt(s.names||Object.keys(t),n)){const l=Object.assign({},wn(r,n));il(l,"root",o),il(r,n,l)}else il(r,n,o)}return r},VEt=(t,s)=>t.some(r=>r.startsWith(s+"."));var HEt=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},nue=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&&kZe({},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:UEt(HEt(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const aue=NEt,NZe=C.createContext({}),Rc=({...t})=>e.jsx(NZe.Provider,{value:{name:t.name},children:e.jsx(TEt,{...t})}),iue=()=>{const t=C.useContext(NZe),s=C.useContext(SZe),{getFieldState:r,formState:n}=sue(),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}},SZe=C.createContext({}),kc=C.forwardRef(({className:t,...s},r)=>{const n=C.useId();return e.jsx(SZe.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:At("space-y-2",t),...s})})});kc.displayName="FormItem";const Nc=C.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=iue();return e.jsx(_e,{ref:r,className:At(n&&"text-destructive",t),htmlFor:a,...s})});Nc.displayName="FormLabel";const Sc=C.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=iue();return e.jsx(J2e,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});Sc.displayName="FormControl";const fie=C.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=iue();return e.jsx("p",{ref:r,id:n,className:At("text-sm text-muted-foreground",t),...s})});fie.displayName="FormDescription";const vm=C.forwardRef(({className:t,children:s,...r},n)=>{const{error:a,formMessageId:o}=iue(),l=a?String(a==null?void 0:a.message):s;return l?e.jsx("p",{ref:n,id:o,className:At("text-sm font-medium text-destructive",t),...r,children:l}):null});vm.displayName="FormMessage";const WEt=ZS({category:JWe(["general","technology","crm","marketing"]),subject:uc().min(5,"Subject must be at least 5 characters").max(200),description:uc().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),GEt={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function t1e({trigger:t}){const[s,r]=C.useState(!1),[n,a]=C.useState(!1),{user:o}=Ws(),l=rue({resolver:nue(WEt),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 G.from("support_tickets").insert({user_id:o.id,category:c.category,subject:c.subject,description:c.description});if(u)throw u;try{await G.functions.invoke("support-ticket-notify",{body:{category:GEt[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(_s,{open:s,onOpenChange:r,children:[e.jsx(Fi,{asChild:!0,children:t||e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(KI,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:"Support"})]})}),e.jsxs(vs,{className:"sm:max-w-[500px]",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Need Help?"}),e.jsx(Zr,{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(ea,{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(aue,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(Rc,{control:l.control,name:"category",render:({field:c})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Category"}),e.jsxs(rr,{onValueChange:c.onChange,defaultValue:c.value,children:[e.jsx(Sc,{children:e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select a category"})})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"general",children:"General Support"}),e.jsx(Tt,{value:"technology",children:"Technology Support"}),e.jsx(Tt,{value:"crm",children:"CRM Support"}),e.jsx(Tt,{value:"marketing",children:"Marketing Support"})]})]}),e.jsx(vm,{})]})}),e.jsx(Rc,{control:l.control,name:"subject",render:({field:c})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Subject"}),e.jsx(Sc,{children:e.jsx(Fe,{placeholder:"Brief description of your issue",...c})}),e.jsx(vm,{})]})}),e.jsx(Rc,{control:l.control,name:"description",render:({field:c})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Description"}),e.jsx(Sc,{children:e.jsx(Ar,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...c})}),e.jsx(vm,{})]})}),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 KEt=()=>{const{user:t}=Ws(),s=Pr(),[r,n]=C.useState([]),[a,o]=C.useState(0),[l,i]=C.useState(!1),[c,u]=C.useState(null);C.useEffect(()=>{if(!t)return;const b=`notification_last_read_${t.id}`;let w=c;if(!w){const S=localStorage.getItem(b);S&&(w=S,u(S))}(async()=>{const{data:S,error:T}=await G.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!T&&S){n(S);const I=w?new Date(w):null,L=S.filter(R=>I?new Date(R.created_at)>I:!0);o(L.length)}})();const N=G.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},S=>{const T=S.new;n(L=>[T,...L].slice(0,20));const I=w?new Date(w):null;(!I||new Date(T.created_at)>I)&&o(L=>L+1),Notification.permission==="granted"&&new Notification(T.title,{body:T.body,icon:"/favicon.ico"})}).subscribe();return()=>{G.removeChannel(N)}},[t,c]);const p=b=>{const w=b.toLowerCase();return w.includes("community")||w.includes("post")?po:w.includes("academy")||w.includes("video")?Nn:w.includes("template")?Ql:w.includes("event")?on:w.includes("newsletter")?s1:w.includes("brokerage")?Rh:w.includes("swag")||w.includes("social")?bo:w.includes("toolbox")||w.includes("tool")?Kx:w.includes("brief")?hn:po},f=b=>{i(!1),b.url&&b.url!=="/"&&s(b.url)},y=()=>{if(!t)return;const b=new Date().toISOString(),w=`notification_last_read_${t.id}`;localStorage.setItem(w,b),u(b),o(0)},_=b=>{i(b),b&&a>0&&y()};return e.jsxs(ju,{open:l,onOpenChange:_,children:[e.jsx(ku,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(gg,{className:"h-5 w-5"}),a>0&&e.jsx(nt,{variant:"destructive",className:"absolute -top-1 -right-1 h-5 w-5 flex items-center justify-center p-0 text-xs",children:a>9?"9+":a})]})}),e.jsxs(Jd,{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:y,children:"Mark all read"})]}),e.jsx(Vi,{className:"h-[300px]",children:r.length===0?e.jsx("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No notifications yet"}):r.map(b=>{const w=p(b.title);return e.jsxs(Ta,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>f(b),children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx(w,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-sm",children:b.title}),e.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2 group-data-[highlighted]:text-accent-foreground/80",children:b.body}),e.jsx("span",{className:"text-xs text-muted-foreground group-data-[highlighted]:text-accent-foreground/80",children:Yd(new Date(b.created_at),{addSuffix:!0})})]})]},b.id)})})]})]})};var I6e=1,ZEt=.9,YEt=.8,XEt=.17,Dge=.1,Oge=.999,QEt=.9999,JEt=.99,ePt=/[\\\/_+.#"@\[\(\{&]/,tPt=/[\\\/_+.#"@\[\(\{&]/g,sPt=/[\s-]/,CZe=/[\s-]/g;function s1e(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?I6e:JEt;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,y,_,b;u>=0;)f=s1e(t,s,r,n,u+1,o+1,l),f>p&&(u===a?f*=I6e:ePt.test(t.charAt(u-1))?(f*=YEt,_=t.slice(a,u-1).match(tPt),_&&a>0&&(f*=Math.pow(Oge,_.length))):sPt.test(t.charAt(u-1))?(f*=ZEt,b=t.slice(a,u-1).match(CZe),b&&a>0&&(f*=Math.pow(Oge,b.length))):(f*=XEt,a>0&&(f*=Math.pow(Oge,u-a))),t.charAt(u)!==s.charAt(o)&&(f*=QEt)),(ff&&(f=y*Dge)),f>p&&(p=f),u=r.indexOf(c,u+1);return l[i]=p,p}function L6e(t){return t.toLowerCase().replace(CZe," ")}function rPt(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,s1e(t,s,L6e(t),L6e(s),0,0,{})}var T6='[cmdk-group=""]',Rge='[cmdk-group-items=""]',nPt='[cmdk-group-heading=""]',MZe='[cmdk-item=""]',D6e=`${MZe}:not([aria-disabled="true"])`,r1e="cmdk-item-select",y5="data-value",aPt=(t,s,r)=>rPt(t,s,r),TZe=C.createContext(void 0),_O=()=>C.useContext(TZe),AZe=C.createContext(void 0),eke=()=>C.useContext(AZe),EZe=C.createContext(void 0),PZe=C.forwardRef((t,s)=>{let r=v5(()=>{var je,ke;return{search:"",value:(ke=(je=t.value)!=null?je:t.defaultValue)!=null?ke:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=v5(()=>new Set),a=v5(()=>new Map),o=v5(()=>new Map),l=v5(()=>new Set),i=IZe(t),{label:c,children:u,value:p,onValueChange:f,filter:y,shouldFilter:_,loop:b,disablePointerSelection:w=!1,vimBindings:j=!0,...N}=t,S=vu(),T=vu(),I=vu(),L=C.useRef(null),R=gPt();kS(()=>{if(p!==void 0){let je=p.trim();r.current.value=je,$.emit()}},[p]),kS(()=>{R(6,ee)},[]);let $=C.useMemo(()=>({subscribe:je=>(l.current.add(je),()=>l.current.delete(je)),snapshot:()=>r.current,setState:(je,ke,We)=>{var be,Me,Ae,Re;if(!Object.is(r.current[je],ke)){if(r.current[je]=ke,je==="search")se(),V(),R(1,X);else if(je==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Te=document.getElementById(I);Te?Te.focus():(be=document.getElementById(S))==null||be.focus()}if(R(7,()=>{var Te;r.current.selectedItemId=(Te=Q())==null?void 0:Te.id,$.emit()}),We||R(5,ee),((Me=i.current)==null?void 0:Me.value)!==void 0){let Te=ke??"";(Re=(Ae=i.current).onValueChange)==null||Re.call(Ae,Te);return}}$.emit()}},emit:()=>{l.current.forEach(je=>je())}}),[]),q=C.useMemo(()=>({value:(je,ke,We)=>{var be;ke!==((be=o.current.get(je))==null?void 0:be.value)&&(o.current.set(je,{value:ke,keywords:We}),r.current.filtered.items.set(je,U(ke,We)),R(2,()=>{V(),$.emit()}))},item:(je,ke)=>(n.current.add(je),ke&&(a.current.has(ke)?a.current.get(ke).add(je):a.current.set(ke,new Set([je]))),R(3,()=>{se(),V(),r.current.value||X(),$.emit()}),()=>{o.current.delete(je),n.current.delete(je),r.current.filtered.items.delete(je);let We=Q();R(4,()=>{se(),(We==null?void 0:We.getAttribute("id"))===je&&X(),$.emit()})}),group:je=>(a.current.has(je)||a.current.set(je,new Set),()=>{o.current.delete(je),a.current.delete(je)}),filter:()=>i.current.shouldFilter,label:c||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:S,inputId:I,labelId:T,listInnerRef:L}),[]);function U(je,ke){var We,be;let Me=(be=(We=i.current)==null?void 0:We.filter)!=null?be:aPt;return je?Me(je,r.current.search,ke):0}function V(){if(!r.current.search||i.current.shouldFilter===!1)return;let je=r.current.filtered.items,ke=[];r.current.filtered.groups.forEach(be=>{let Me=a.current.get(be),Ae=0;Me.forEach(Re=>{let Te=je.get(Re);Ae=Math.max(Te,Ae)}),ke.push([be,Ae])});let We=L.current;de().sort((be,Me)=>{var Ae,Re;let Te=be.getAttribute("id"),qe=Me.getAttribute("id");return((Ae=je.get(qe))!=null?Ae:0)-((Re=je.get(Te))!=null?Re:0)}).forEach(be=>{let Me=be.closest(Rge);Me?Me.appendChild(be.parentElement===Me?be:be.closest(`${Rge} > *`)):We.appendChild(be.parentElement===We?be:be.closest(`${Rge} > *`))}),ke.sort((be,Me)=>Me[1]-be[1]).forEach(be=>{var Me;let Ae=(Me=L.current)==null?void 0:Me.querySelector(`${T6}[${y5}="${encodeURIComponent(be[0])}"]`);Ae==null||Ae.parentElement.appendChild(Ae)})}function X(){let je=de().find(We=>We.getAttribute("aria-disabled")!=="true"),ke=je==null?void 0:je.getAttribute(y5);$.setState("value",ke||void 0)}function se(){var je,ke,We,be;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Me=0;for(let Ae of n.current){let Re=(ke=(je=o.current.get(Ae))==null?void 0:je.value)!=null?ke:"",Te=(be=(We=o.current.get(Ae))==null?void 0:We.keywords)!=null?be:[],qe=U(Re,Te);r.current.filtered.items.set(Ae,qe),qe>0&&Me++}for(let[Ae,Re]of a.current)for(let Te of Re)if(r.current.filtered.items.get(Te)>0){r.current.filtered.groups.add(Ae);break}r.current.filtered.count=Me}function ee(){var je,ke,We;let be=Q();be&&(((je=be.parentElement)==null?void 0:je.firstChild)===be&&((We=(ke=be.closest(T6))==null?void 0:ke.querySelector(nPt))==null||We.scrollIntoView({block:"nearest"})),be.scrollIntoView({block:"nearest"}))}function Q(){var je;return(je=L.current)==null?void 0:je.querySelector(`${MZe}[aria-selected="true"]`)}function de(){var je;return Array.from(((je=L.current)==null?void 0:je.querySelectorAll(D6e))||[])}function re(je){let ke=de()[je];ke&&$.setState("value",ke.getAttribute(y5))}function ne(je){var ke;let We=Q(),be=de(),Me=be.findIndex(Re=>Re===We),Ae=be[Me+je];(ke=i.current)!=null&&ke.loop&&(Ae=Me+je<0?be[be.length-1]:Me+je===be.length?be[0]:be[Me+je]),Ae&&$.setState("value",Ae.getAttribute(y5))}function le(je){let ke=Q(),We=ke==null?void 0:ke.closest(T6),be;for(;We&&!be;)We=je>0?pPt(We,T6):fPt(We,T6),be=We==null?void 0:We.querySelector(D6e);be?$.setState("value",be.getAttribute(y5)):ne(je)}let he=()=>re(de().length-1),we=je=>{je.preventDefault(),je.metaKey?he():je.altKey?le(1):ne(1)},ye=je=>{je.preventDefault(),je.metaKey?re(0):je.altKey?le(-1):ne(-1)};return C.createElement(Jr.div,{ref:s,tabIndex:-1,...N,"cmdk-root":"",onKeyDown:je=>{var ke;(ke=N.onKeyDown)==null||ke.call(N,je);let We=je.nativeEvent.isComposing||je.keyCode===229;if(!(je.defaultPrevented||We))switch(je.key){case"n":case"j":{j&&je.ctrlKey&&we(je);break}case"ArrowDown":{we(je);break}case"p":case"k":{j&&je.ctrlKey&&ye(je);break}case"ArrowUp":{ye(je);break}case"Home":{je.preventDefault(),re(0);break}case"End":{je.preventDefault(),he();break}case"Enter":{je.preventDefault();let be=Q();if(be){let Me=new Event(r1e);be.dispatchEvent(Me)}}}}},C.createElement("label",{"cmdk-label":"",htmlFor:q.inputId,id:q.labelId,style:yPt},c),oue(t,je=>C.createElement(AZe.Provider,{value:$},C.createElement(TZe.Provider,{value:q},je))))}),iPt=C.forwardRef((t,s)=>{var r,n;let a=vu(),o=C.useRef(null),l=C.useContext(EZe),i=_O(),c=IZe(t),u=(n=(r=c.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;kS(()=>{if(!u)return i.item(a,l==null?void 0:l.id)},[u]);let p=LZe(a,o,[t.value,t.children,o],t.keywords),f=eke(),y=c2(R=>R.value&&R.value===p.current),_=c2(R=>u||i.filter()===!1?!0:R.search?R.filtered.items.get(a)>0:!0);C.useEffect(()=>{let R=o.current;if(!(!R||t.disabled))return R.addEventListener(r1e,b),()=>R.removeEventListener(r1e,b)},[_,t.onSelect,t.disabled]);function b(){var R,$;w(),($=(R=c.current).onSelect)==null||$.call(R,p.current)}function w(){f.setState("value",p.current,!0)}if(!_)return null;let{disabled:j,value:N,onSelect:S,forceMount:T,keywords:I,...L}=t;return C.createElement(Jr.div,{ref:y1(o,s),...L,id:a,"cmdk-item":"",role:"option","aria-disabled":!!j,"aria-selected":!!y,"data-disabled":!!j,"data-selected":!!y,onPointerMove:j||i.getDisablePointerSelection()?void 0:w,onClick:j?void 0:b},t.children)}),oPt=C.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=vu(),i=C.useRef(null),c=C.useRef(null),u=vu(),p=_O(),f=c2(_=>a||p.filter()===!1?!0:_.search?_.filtered.groups.has(l):!0);kS(()=>p.group(l),[]),LZe(l,i,[t.value,t.heading,c]);let y=C.useMemo(()=>({id:l,forceMount:a}),[a]);return C.createElement(Jr.div,{ref:y1(i,s),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},r&&C.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),oue(t,_=>C.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},C.createElement(EZe.Provider,{value:y},_))))}),lPt=C.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=C.useRef(null),o=c2(l=>!l.search);return!r&&!o?null:C.createElement(Jr.div,{ref:y1(a,s),...n,"cmdk-separator":"",role:"separator"})}),cPt=C.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=eke(),l=c2(u=>u.search),i=c2(u=>u.selectedItemId),c=_O();return C.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),C.createElement(Jr.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)}})}),dPt=C.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=C.useRef(null),l=C.useRef(null),i=c2(u=>u.selectedItemId),c=_O();return C.useEffect(()=>{if(l.current&&o.current){let u=l.current,p=o.current,f,y=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let _=u.offsetHeight;p.style.setProperty("--cmdk-list-height",_.toFixed(1)+"px")})});return y.observe(u),()=>{cancelAnimationFrame(f),y.unobserve(u)}}},[]),C.createElement(Jr.div,{ref:y1(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:c.listId},oue(t,u=>C.createElement("div",{ref:y1(l,c.listInnerRef),"cmdk-list-sizer":""},u)))}),uPt=C.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return C.createElement(Pde,{open:r,onOpenChange:n},C.createElement(Ide,{container:l},C.createElement(TA,{"cmdk-overlay":"",className:a}),C.createElement(AA,{"aria-label":t.label,"cmdk-dialog":"",className:o},C.createElement(PZe,{ref:s,...i}))))}),hPt=C.forwardRef((t,s)=>c2(r=>r.filtered.count===0)?C.createElement(Jr.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),mPt=C.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return C.createElement(Jr.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},oue(t,l=>C.createElement("div",{"aria-hidden":!0},l)))}),Np=Object.assign(PZe,{List:dPt,Item:iPt,Input:cPt,Group:oPt,Separator:lPt,Dialog:uPt,Empty:hPt,Loading:mPt});function pPt(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function fPt(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function IZe(t){let s=C.useRef(t);return kS(()=>{s.current=t}),s}var kS=typeof window>"u"?C.useEffect:C.useLayoutEffect;function v5(t){let s=C.useRef();return s.current===void 0&&(s.current=t()),s}function c2(t){let s=eke(),r=()=>t(s.snapshot());return C.useSyncExternalStore(s.subscribe,r,r)}function LZe(t,s,r,n=[]){let a=C.useRef(),o=_O();return kS(()=>{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(y5,i),a.current=i}),a}var gPt=()=>{let[t,s]=C.useState(),r=v5(()=>new Map);return kS(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function xPt(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function oue({asChild:t,children:s},r){return t&&C.isValidElement(s)?C.cloneElement(xPt(s),{ref:s.ref},r(s.props.children)):r(s)}var yPt={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Mg=C.forwardRef(({className:t,...s},r)=>e.jsx(Np,{ref:r,className:At("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));Mg.displayName=Np.displayName;const vPt=({children:t,...s})=>e.jsx(_s,{...s,children:e.jsx(vs,{className:"overflow-hidden p-0 shadow-lg",children:e.jsx(Mg,{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})})}),Tg=C.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(xn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Np.Input,{ref:r,className:At("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})]}));Tg.displayName=Np.Input.displayName;const Ag=C.forwardRef(({className:t,...s},r)=>e.jsx(Np.List,{ref:r,className:At("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));Ag.displayName=Np.List.displayName;const Eg=C.forwardRef((t,s)=>e.jsx(Np.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Eg.displayName=Np.Empty.displayName;const Pg=C.forwardRef(({className:t,...s},r)=>e.jsx(Np.Group,{ref:r,className:At("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}));Pg.displayName=Np.Group.displayName;const _Pt=C.forwardRef(({className:t,...s},r)=>e.jsx(Np.Separator,{ref:r,className:At("-mx-1 h-px bg-border",t),...s}));_Pt.displayName=Np.Separator.displayName;const up=C.forwardRef(({className:t,...s},r)=>e.jsx(Np.Item,{ref:r,className:At("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}));up.displayName=Np.Item.displayName;const bPt={event:{label:"Events",icon:Md,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:Ql,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:zh,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:Kx,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:hn,color:"bg-fuchsia-500/10 text-fuchsia-600"}},O6e=()=>{const[t,s]=C.useState(!1),[r,n]=C.useState(""),[a,o]=C.useState([]),[l,i]=C.useState(!1),c=Pr();C.useEffect(()=>{const y=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),s(b=>!b))};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[]);const u=C.useCallback(async y=>{if(!y.trim()){o([]);return}i(!0);const _=`%${y}%`;try{const[b,w,j,N,S]=await Promise.all([G.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),G.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${_},description.ilike.${_}`).limit(5),G.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),G.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${_},description.ilike.${_}`).limit(5),G.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5)]),T=[];b.data&&b.data.forEach(I=>{T.push({id:I.id,title:I.title,description:I.description,type:"event",date:I.event_date,path:`/event/${I.id}`})}),w.data&&w.data.forEach(I=>{T.push({id:I.id,title:I.name,description:I.description,type:"template",date:I.publish_date,path:`/templates/${I.id}`})}),j.data&&j.data.forEach(I=>{T.push({id:I.id,title:I.title,description:I.description,type:"academy",date:I.publish_date,path:`/academy/${I.id}`})}),N.data&&N.data.forEach(I=>{T.push({id:I.id,title:I.name,description:I.description,type:"toolbox",date:I.publish_date,path:`/toolbox/${I.id}`})}),S.data&&S.data.forEach(I=>{T.push({id:I.id,title:I.title,description:I.description,type:"social-swag",date:I.publish_date,path:`/social-swag/${I.id}`})}),o(T)}catch(b){console.error("Search error:",b)}finally{i(!1)}},[]);C.useEffect(()=>{const y=setTimeout(()=>{u(r)},300);return()=>clearTimeout(y)},[r,u]);const p=y=>{s(!1),n(""),c(y)},f=a.reduce((y,_)=>(y[_.type]||(y[_.type]=[]),y[_.type].push(_),y),{});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(xn,{className:"h-4 w-4 xl:mr-2"}),e.jsx("span",{className:"hidden xl:inline-flex text-muted-foreground text-sm",children:"Search..."}),e.jsxs("kbd",{className:"pointer-events-none absolute right-1.5 top-1.5 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 xl:flex",children:[e.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),e.jsxs(vPt,{open:t,onOpenChange:s,children:[e.jsx(Tg,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(Ag,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(Eg,{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(([y,_])=>{const b=bPt[y],w=b.icon;return e.jsx(Pg,{heading:b.label,children:_.map(j=>e.jsxs(up,{value:`${j.type}-${j.id}-${j.title}`,onSelect:()=>p(j.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[e.jsx("div",{className:`p-2 rounded-md ${b.color}`,children:e.jsx(w,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:j.title}),j.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:j.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(nt,{variant:"secondary",className:"text-xs",children:b.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Yd(new Date(j.date),{addSuffix:!0})})]})]},`${j.type}-${j.id}`))},y)})]})]})]})},wPt=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=C.useState(null),o=Pr();if(C.useEffect(()=>{const u=()=>{const f=new Date().getTime(),_=new Date(t).getTime()-f;if(_<=0){a({days:0,hours:0,minutes:0});return}const b=Math.floor(_/(1e3*60*60*24)),w=Math.floor(_%(1e3*60*60*24)/(1e3*60*60)),j=Math.floor(_%(1e3*60*60)/(1e3*60));a({days:b,hours:w,minutes:j})};u();const 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:At("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(uh,{className:"h-4 w-4 text-destructive"}),e.jsx("span",{className:"text-sm font-medium text-destructive",children:"Your free trial has expired"})]}),r&&e.jsxs(K,{size:"sm",onClick:()=>o("/subscription"),className:"bg-primary hover:bg-primary/90 text-xs h-7 px-3",children:[e.jsx(hn,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):e.jsxs("div",{className:At("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(Tn,{className:At("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:At("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:At("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:At("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:At("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:At("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:At("text-xs h-7 px-3",c&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[e.jsx(hn,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},jPt=()=>{const t=Pr();return e.jsx("div",{className:"fixed inset-0 bg-background/95 backdrop-blur-sm z-50 flex items-center justify-center p-4 overflow-y-auto",children:e.jsxs(Ee,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[e.jsxs(It,{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(uh,{className:"h-8 w-8 text-destructive"})}),e.jsx(Ot,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(fr,{className:"text-base",children:"Your 7-day free trial has expired. Upgrade now to continue accessing all the powerful tools and resources LevelUp has to offer!"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(Ee,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(mr,{className:"h-6 w-6 text-primary"})}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Individual Agent"}),e.jsxs("p",{className:"text-2xl font-bold text-primary mb-2",children:["$39",e.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Perfect for solo agents ready to level up"}),e.jsxs(K,{className:"w-full",onClick:s=>{s.stopPropagation(),t("/subscription")},children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),e.jsx(Ee,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Oe,{className:"p-5 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(La,{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(La,{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(ea,{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(br,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},kPt=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(hd,{children:[e.jsx(md,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",onClick:s,className:At("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[e.jsx(bp,{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(Uc,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var lue="Checkbox",[NPt]=Yc(lue),[SPt,tke]=NPt(lue);function CPt(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,[y,_]=Yu({prop:r,defaultProp:a??!1,onChange:c,caller:lue}),[b,w]=C.useState(null),[j,N]=C.useState(null),S=C.useRef(!1),T=b?!!l||!!b.closest("form"):!0,I={checked:y,disabled:o,setChecked:_,control:b,setControl:w,name:i,form:l,value:p,hasConsumerStoppedPropagationRef:S,required:u,defaultChecked:Vb(a)?!1:a,isFormControl:T,bubbleInput:j,setBubbleInput:N};return e.jsx(SPt,{scope:s,...I,children:MPt(f)?f(I):n})}var DZe="CheckboxTrigger",OZe=C.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:y,isFormControl:_,bubbleInput:b}=tke(DZe,t),w=Oa(a,p),j=C.useRef(c);return C.useEffect(()=>{const N=o==null?void 0:o.form;if(N){const S=()=>f(j.current);return N.addEventListener("reset",S),()=>N.removeEventListener("reset",S)}},[o,f]),e.jsx(Jr.button,{type:"button",role:"checkbox","aria-checked":Vb(c)?"mixed":c,"aria-required":u,"data-state":$Ze(c),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:w,onKeyDown:Mr(s,N=>{N.key==="Enter"&&N.preventDefault()}),onClick:Mr(r,N=>{f(S=>Vb(S)?!0:!S),b&&_&&(y.current=N.isPropagationStopped(),y.current||N.stopPropagation())})})});OZe.displayName=DZe;var ske=C.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(CPt,{__scopeCheckbox:r,checked:a,defaultChecked:o,disabled:i,required:l,onCheckedChange:u,name:n,form:p,value:c,internal_do_not_use_render:({isFormControl:y})=>e.jsxs(e.Fragment,{children:[e.jsx(OZe,{...f,ref:s,__scopeCheckbox:r}),y&&e.jsx(BZe,{__scopeCheckbox:r})]})})});ske.displayName=lue;var RZe="CheckboxIndicator",FZe=C.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=tke(RZe,r);return e.jsx(Id,{present:n||Vb(o.checked)||o.checked===!0,children:e.jsx(Jr.span,{"data-state":$Ze(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});FZe.displayName=RZe;var zZe="CheckboxBubbleInput",BZe=C.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:y,setBubbleInput:_}=tke(zZe,t),b=Oa(r,_),w=mO(o),j=eO(n);C.useEffect(()=>{const S=y;if(!S)return;const T=window.HTMLInputElement.prototype,L=Object.getOwnPropertyDescriptor(T,"checked").set,R=!a.current;if(w!==o&&L){const $=new Event("click",{bubbles:R});S.indeterminate=Vb(o),L.call(S,Vb(o)?!1:o),S.dispatchEvent($)}},[y,w,o,a]);const N=C.useRef(Vb(o)?!1:o);return e.jsx(Jr.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??N.current,required:i,disabled:c,name:u,value:p,form:f,...s,tabIndex:-1,ref:b,style:{...s.style,...j,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});BZe.displayName=zZe;function MPt(t){return typeof t=="function"}function Vb(t){return t==="indeterminate"}function $Ze(t){return Vb(t)?"indeterminate":t?"checked":"unchecked"}const Yo=C.forwardRef(({className:t,...s},r)=>e.jsx(ske,{ref:r,className:At("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(FZe,{className:At("flex items-center justify-center text-current"),children:e.jsx(ma,{className:"h-4 w-4"})})}));Yo.displayName=ske.displayName;var rke="Radio",[TPt,qZe]=Yc(rke),[APt,EPt]=TPt(rke),UZe=C.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,y]=C.useState(null),_=Oa(s,j=>y(j)),b=C.useRef(!1),w=f?u||!!f.closest("form"):!0;return e.jsxs(APt,{scope:r,checked:a,disabled:l,children:[e.jsx(Jr.button,{type:"button",role:"radio","aria-checked":a,"data-state":GZe(a),"data-disabled":l?"":void 0,disabled:l,value:i,...p,ref:_,onClick:Mr(t.onClick,j=>{a||c==null||c(),w&&(b.current=j.isPropagationStopped(),b.current||j.stopPropagation())})}),w&&e.jsx(WZe,{control:f,bubbles:!b.current,name:n,value:i,checked:a,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});UZe.displayName=rke;var VZe="RadioIndicator",HZe=C.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=EPt(VZe,r);return e.jsx(Id,{present:n||o.checked,children:e.jsx(Jr.span,{"data-state":GZe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});HZe.displayName=VZe;var PPt="RadioBubbleInput",WZe=C.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=C.useRef(null),i=Oa(l,o),c=mO(r),u=eO(s);return C.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&_){const b=new Event("click",{bubbles:n});_.call(p,r),p.dispatchEvent(b)}},[c,r,n]),e.jsx(Jr.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}})});WZe.displayName=PPt;function GZe(t){return t?"checked":"unchecked"}var IPt=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],cue="RadioGroup",[LPt]=Yc(cue,[w2,qZe]),KZe=w2(),ZZe=qZe(),[DPt,OPt]=LPt(cue),YZe=C.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,...y}=t,_=KZe(r),b=b2(u),[w,j]=Yu({prop:o,defaultProp:a??null,onChange:f,caller:cue});return e.jsx(DPt,{scope:r,name:n,required:l,disabled:i,value:w,onValueChange:j,children:e.jsx(kde,{asChild:!0,..._,orientation:c,dir:b,loop:p,children:e.jsx(Jr.div,{role:"radiogroup","aria-required":l,"aria-orientation":c,"data-disabled":i?"":void 0,dir:b,...y,ref:s})})})});YZe.displayName=cue;var XZe="RadioGroupItem",QZe=C.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=OPt(XZe,r),l=o.disabled||n,i=KZe(r),c=ZZe(r),u=C.useRef(null),p=Oa(s,u),f=o.value===a.value,y=C.useRef(!1);return C.useEffect(()=>{const _=w=>{IPt.includes(w.key)&&(y.current=!0)},b=()=>y.current=!1;return document.addEventListener("keydown",_),document.addEventListener("keyup",b),()=>{document.removeEventListener("keydown",_),document.removeEventListener("keyup",b)}},[]),e.jsx(Nde,{asChild:!0,...i,focusable:!l,active:f,children:e.jsx(UZe,{disabled:l,required:o.required,checked:f,...c,...a,name:o.name,ref:p,onCheck:()=>o.onValueChange(a.value),onKeyDown:Mr(_=>{_.key==="Enter"&&_.preventDefault()}),onFocus:Mr(a.onFocus,()=>{var _;y.current&&((_=u.current)==null||_.click())})})})});QZe.displayName=XZe;var RPt="RadioGroupIndicator",JZe=C.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=ZZe(r);return e.jsx(HZe,{...a,...n,ref:s})});JZe.displayName=RPt;var eYe=YZe,tYe=QZe,FPt=JZe;const nke=C.forwardRef(({className:t,...s},r)=>e.jsx(eYe,{className:At("grid gap-2",t),...s,ref:r}));nke.displayName=eYe.displayName;const zoe=C.forwardRef(({className:t,...s},r)=>e.jsx(tYe,{ref:r,className:At("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(FPt,{className:"flex items-center justify-center",children:e.jsx(pd,{className:"h-2.5 w-2.5 fill-current text-current"})})}));zoe.displayName=tYe.displayName;const zPt=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=Ws(),[o,l]=C.useState({}),[i,c]=C.useState({}),[u,p]=C.useState([]);C.useEffect(()=>{s&&a&&t.polls.length>0&&f()},[s,a,t.polls]);const f=async()=>{if(!a)return;const j=t.polls.map(S=>S.id),{data:N}=await G.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",j);if(N){const S={};N.forEach(T=>{S[T.poll_id]||(S[T.poll_id]=[]),S[T.poll_id].push(T.option_id)}),c(S)}},y=(j,N)=>{l(S=>({...S,[j]:N}))},_=(j,N,S)=>{l(T=>{const I=T[j]||[];return S?{...T,[j]:[...I,N]}:{...T,[j]:I.filter(L=>L!==N)}})},b=async j=>{if(!a)return;const N=o[j];if(!N||Array.isArray(N)&&N.length===0){me.error("Please select an option");return}p(S=>[...S,j]);try{await G.from("levelup_brief_poll_responses").delete().eq("poll_id",j).eq("user_id",a.id);const S=Array.isArray(N)?N:[N],T=S.map(L=>({poll_id:j,option_id:L,user_id:a.id})),{error:I}=await G.from("levelup_brief_poll_responses").insert(T);if(I)throw I;c(L=>({...L,[j]:S})),me.success("Response submitted!")}catch(S){console.error("Error submitting poll response:",S),me.error("Failed to submit response")}finally{p(S=>S.filter(T=>T!==j))}},w=j=>(j.includes("mediadelivery.net")||j.includes("bunny"),j);return e.jsx(_s,{open:s,onOpenChange:j=>!j&&r(),children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] p-0 overflow-hidden [&>button]:hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-primary to-primary/80 p-4 pr-12 text-primary-foreground relative",children:[e.jsx("button",{onClick:r,className:"absolute top-3 right-3 p-1.5 rounded-full bg-white/30 hover:bg-white/50 transition-colors","aria-label":"Close",children:e.jsx(Ur,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-white/20 rounded-lg",children:e.jsx(bp,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx(nt,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),e.jsx(Ns,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),e.jsx(Vi,{className:"max-h-[calc(90vh-240px)]",children:e.jsxs("div",{className:"p-6 space-y-6",children:[t.brief.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.brief.description}}),t.brief.video_url&&e.jsx("div",{className:"relative w-full aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:w(t.brief.video_url),className:"absolute inset-0 w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})}),t.brief.graphic_url&&!t.brief.video_url&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted",children:t.brief.graphic_link_url?e.jsx("a",{href:t.brief.graphic_link_url,target:"_blank",rel:"noopener noreferrer",className:"block",children:e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain cursor-pointer hover:opacity-90 transition-opacity"})}):e.jsx("img",{src:t.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain"})}),t.links.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:"Quick Links"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.links.map(j=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.open(j.url,"_blank"),className:"gap-2",children:[e.jsx(rn,{className:"h-4 w-4"}),j.title]},j.id))})]}),t.polls.map(j=>{var T,I;const N=((T=i[j.id])==null?void 0:T.length)>0,S=u.includes(j.id);return e.jsxs("div",{className:"space-y-3 p-4 bg-muted/50 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"font-semibold text-foreground",children:j.question}),N&&e.jsxs(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(ha,{className:"h-3 w-3"}),"Responded"]})]}),j.poll_type==="single"?e.jsx(nke,{value:o[j.id]||((I=i[j.id])==null?void 0:I[0])||"",onValueChange:L=>y(j.id,L),className:"space-y-2",children:j.options.map(L=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(zoe,{value:L.id,id:L.id}),e.jsx(_e,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id))}):e.jsx("div",{className:"space-y-2",children:j.options.map(L=>{const $=(o[j.id]||i[j.id]||[]).includes(L.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Yo,{id:L.id,checked:$,onCheckedChange:q=>_(j.id,L.id,q)}),e.jsx(_e,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id)})}),e.jsx(K,{size:"sm",onClick:()=>b(j.id),disabled:S,children:S?"Submitting...":N?"Update Response":"Submit"})]},j.id)})]})}),e.jsxs("div",{className:"p-4 pb-[calc(1rem+env(safe-area-inset-bottom))] border-t bg-muted/30 flex flex-col items-center gap-2 sticky bottom-0 z-10",children:[e.jsx(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"})]})]})})},BPt=()=>{const{user:t}=Ws(),[s,r]=C.useState(null),[n,a]=C.useState(!1),[o,l]=C.useState(!0),[i,c]=C.useState(!1),u=C.useCallback(async()=>{if(!t){l(!1);return}try{const{data:b,error:w}=await G.from("levelup_briefs").select("*").eq("is_published",!0).lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(1).single();if(w||!b){l(!1);return}const{data:j}=await G.from("levelup_brief_views").select("*").eq("brief_id",b.id).eq("user_id",t.id).maybeSingle(),[N,S]=await Promise.all([G.from("levelup_brief_links").select("*").eq("brief_id",b.id).order("sort_order"),G.from("levelup_brief_polls").select("*").eq("brief_id",b.id).order("sort_order")]),T=[];if(S.data)for(const q of S.data){const{data:U}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",q.id).order("sort_order");T.push({...q,options:U||[]})}const I={brief:b,links:N.data||[],polls:T};r(I);const L=!!j,R=(j==null?void 0:j.dismissed_at)!=null,$=localStorage.getItem(`brief-dismissed-${b.id}`)==="true";if(R||$)c(!1),a(!1);else if(!L)a(!0),c(!0);else if(b.show_frequency==="every_login")a(!0),c(!0);else if(b.show_frequency==="daily"){const q=new Date(j.viewed_at);(new Date().getTime()-q.getTime())/(1e3*60*60)>=24&&(a(!0),c(!0))}else c(!1)}catch(b){console.error("Error fetching brief:",b)}finally{l(!1)}},[t]);C.useEffect(()=>{u()},[u]);const p=async()=>{if(!(!t||!s))try{const{data:b}=await G.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();b?await G.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",b.id):await G.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id})}catch(b){console.error("Error marking brief as viewed:",b)}};return{currentBrief:s,shouldShowPopup:n,hasUnseenBrief:i,loading:o,openBrief:()=>{a(!0)},closeBrief:()=>{a(!1),p()},dismissBrief:async()=>{if(!(!t||!s)){a(!1),c(!1);try{const{data:b,error:w}=await G.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();if(w&&console.error("Error checking existing brief view:",w),b){const{error:j}=await G.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",b.id).eq("user_id",t.id);j&&console.error("Error updating brief dismiss:",j)}else{const{error:j}=await G.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});j&&console.error("Error inserting brief dismiss:",j)}localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}catch(b){console.error("Error dismissing brief:",b),s&&localStorage.setItem(`brief-dismissed-${s.brief.id}`,"true")}}},refetch:u}};function $Pt(){const[t,s]=C.useState(!1),[r,n]=C.useState(!1),[a,o]=C.useState(null);C.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 y=_=>{_.preventDefault(),o(_)};return window.addEventListener("beforeinstallprompt",y),()=>{window.removeEventListener("beforeinstallprompt",y)}},[]);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(ki,{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(cL,{className:"h-3 w-3 inline"}),' then "Add to Home Screen"']}):e.jsx("p",{className:"text-xs opacity-80",children:"Quick access anytime"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!r&&a&&e.jsx(K,{size:"sm",variant:"secondary",onClick:i,className:"text-xs",children:"Install"}),e.jsx("button",{onClick:l,className:"p-1.5 hover:bg-primary-foreground/10 rounded-full transition-colors","aria-label":"Dismiss",children:e.jsx(Ur,{className:"h-4 w-4"})})]})]})}):null}const qPt=({children:t,onRefresh:s})=>{const[r,n]=C.useState(!1),[a,o]=C.useState(0),[l,i]=C.useState(!1),c=C.useRef(null),u=C.useRef(0),p=ss(),f=80,y=120,_=C.useCallback(S=>{const T=c.current;T&&T.scrollTop<=0&&(u.current=S.touches[0].clientY,n(!0))},[]),b=C.useCallback(S=>{if(!r||l)return;const T=c.current;if(!T||T.scrollTop>0){n(!1),o(0);return}const L=S.touches[0].clientY-u.current;if(L>0){const $=Math.min(L*.5,y);o($),$>10&&S.preventDefault()}},[r,l]),w=C.useCallback(async()=>{if(r)if(n(!1),a>=f&&!l){i(!0),o(f);try{s?await s():await p.invalidateQueries()}catch(S){console.error("Refresh failed:",S)}finally{i(!1),o(0)}}else o(0)},[r,a,l,s,p]),j=Math.min(a/f,1),N=j*180;return e.jsxs("div",{ref:c,className:"h-full overflow-auto",onTouchStart:_,onTouchMove:b,onTouchEnd:w,children:[e.jsx("div",{className:"flex justify-center items-center overflow-hidden transition-all duration-200 ease-out",style:{height:a>0?a:0,opacity:j},children:e.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${N}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:e.jsx(Bo,{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})]})},sYe=()=>{const{user:t}=Ws(),[s,r]=C.useState(!1),[n,a]=C.useState(!1),[o,l]=C.useState(0),[i,c]=C.useState(!0);C.useEffect(()=>{(async()=>{if(!t){c(!1);return}try{const{data:_}=await G.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(_){a(!0),r(!1),c(!1);return}const{data:b}=await G.from("profiles").select("login_count").eq("id",t.id).single(),w=(b==null?void 0:b.login_count)||0;l(w);const j=sessionStorage.getItem("review-prompt-dismissed");r(w>=4&&!j)}catch(_){console.error("Error checking review eligibility:",_)}finally{c(!1)}})()},[t]);const u=C.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),p=C.useCallback(async(y,_)=>{if(!t)return{success:!1,error:"Not authenticated"};try{const{error:b}=await G.from("membership_reviews").insert({user_id:t.id,rating:y,review_text:_});if(b)throw b;return a(!0),r(!1),{success:!0,pointsAwarded:25}}catch(b){return console.error("Error submitting review:",b),{success:!1,error:b.message}}},[t]),f=C.useCallback(async()=>{if(t)try{await G.from("membership_reviews").update({posted_to_google:!0}).eq("user_id",t.id)}catch(y){console.error("Error updating Google review status:",y)}},[t]);return{shouldShowPrompt:s,hasSubmittedReview:n,loginCount:o,isLoading:i,dismissPrompt:u,submitReview:p,markPostedToGoogle:f}},UPt="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",VPt=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=sYe(),[o,l]=C.useState(!1),[i,c]=C.useState("review"),[u,p]=C.useState(0),[f,y]=C.useState(0),[_,b]=C.useState(""),[w,j]=C.useState(!1),[N,S]=C.useState(!1);if(s||!t&&!N)return null;const T=async()=>{if(u===0){fn({title:"Please select a rating",variant:"destructive"});return}j(!0);const R=await n(u,_);j(!1),R.success?(S(!0),fn({title:"Thank you for your feedback!",description:"Your review helps us improve."}),c("google")):fn({title:"Error submitting review",description:R.error,variant:"destructive"})},I=async R=>{R&&(await navigator.clipboard.writeText(_||`${u} star rating for LevelUp!`),fn({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(UPt,"_blank")),l(!1),r()},L=()=>{l(!1),r()};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>l(!0),className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-40 flex items-center gap-2 rounded-full bg-primary/90 px-3 py-2 text-xs text-primary-foreground shadow-lg backdrop-blur-sm transition-all hover:bg-primary hover:scale-105 md:bottom-6",children:[e.jsx(Kn,{className:"h-3.5 w-3.5 fill-current"}),e.jsx("span",{className:"hidden sm:inline",children:"Leave a Review"})]}),e.jsx(_s,{open:o,onOpenChange:L,children:e.jsx(vs,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{className:"text-center",children:"How are you enjoying LevelUp?"}),e.jsx(Zr,{className:"text-center",children:"Your feedback helps us improve the experience for all members."})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsx("div",{className:"flex justify-center gap-1",children:[1,2,3,4,5].map(R=>e.jsx("button",{type:"button",onClick:()=>p(R),onMouseEnter:()=>y(R),onMouseLeave:()=>y(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx(Kn,{className:At("h-8 w-8 transition-colors",(f||u)>=R?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},R))}),e.jsx(Ar,{placeholder:"Tell us about your experience (optional)",value:_,onChange:R=>b(R.target.value),rows:4,className:"resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:L,className:"flex-1",children:"Maybe Later"}),e.jsx(K,{onClick:T,disabled:w||u===0,className:"flex-1",children:w?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{className:"text-center",children:"🎉 Thank you!"}),e.jsx(Zr,{className:"text-center",children:"Would you mind sharing your review on Google? It really helps other agents discover LevelUp!"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"We'll copy your review so you can easily paste it."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>I(!1),className:"flex-1",children:"No Thanks"}),e.jsx(K,{onClick:()=>I(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function HPt(t){const s="=".repeat((4-t.length%4)%4),r=(t+s).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(r),a=new Uint8Array(n.length);for(let o=0;o{if(!f){l(!1);return}(async()=>{try{const w="vapid_public_key";let j=localStorage.getItem(w);if(!j){const{data:T,error:I}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(I)throw I;if(j=(T==null?void 0:T.vapidPublicKey)??null,!j)throw new Error("Missing VAPID public key");localStorage.setItem(w,j)}p(j);const N=await navigator.serviceWorker.register("/push-sw.js");c(N),r(Notification.permission);const S=await N.pushManager.getSubscription();a(!!S)}catch(w){console.error("Error initializing push notifications:",w)}finally{l(!1)}})()},[f]);const y=C.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 b=await i.pushManager.getSubscription();if(b){try{await b.unsubscribe()}catch(I){console.warn("Failed to unsubscribe existing push subscription:",I)}const{error:T}=await G.from("push_subscriptions").delete().eq("user_id",t.id);T&&console.warn("Failed to cleanup push_subscriptions rows:",T)}if(Notification.permission!=="granted"){const T=await Notification.requestPermission();if(r(T),T!=="granted")return T==="denied"?me.error("Notifications blocked. Please enable them in your browser settings (click the lock icon in the address bar)."):me.error("Notification permission was dismissed. Please try again."),!1}const w=HPt(u);let j;try{j=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:w})}catch(T){console.error("PushManager.subscribe() failed:",T);const I=(T==null?void 0:T.message)||String(T);return I.includes("permission")?me.error("Push permission denied. Check your browser notification settings."):I.includes("key")||I.includes("VAPID")?me.error("Push configuration error. Please contact support."):I.includes("AbortError")?me.error("Push subscription was cancelled. Please try again."):me.error(`Failed to subscribe: ${I}`),!1}const N=j.toJSON(),{error:S}=await G.from("push_subscriptions").upsert({user_id:t.id,endpoint:N.endpoint,p256dh_key:N.keys.p256dh,auth_key:N.keys.auth},{onConflict:"user_id,endpoint"});if(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(b){if(console.error("Error subscribing to push notifications:",b),!(b instanceof Error&&b.message.includes("toast"))){const w=b instanceof Error?b.message:"Unknown error";me.error("Failed to enable push notifications: "+w)}return!1}finally{l(!1)}},[f,i,t,u]),_=C.useCallback(async()=>{if(!i||!t)return!1;try{l(!0);const b=await i.pushManager.getSubscription();return b&&await b.unsubscribe(),await G.from("push_subscriptions").delete().eq("user_id",t.id),a(!1),me.success("Push notifications disabled"),!0}catch(b){console.error("Error unsubscribing:",b);const w=b instanceof Error?b.message:"Unknown error";return me.error("Failed to disable push notifications: "+w),!1}finally{l(!1)}},[i,t]);return{isSupported:f,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:u,subscribe:y,unsubscribe:_}}const Fge="push_notification_prompt_dismissed",WPt=()=>{const{user:t}=Ws(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=rYe(),[o,l]=C.useState(!1),[i,c]=C.useState(!1);C.useEffect(()=>{if(!t||!s||r||n||localStorage.getItem(`${Fge}_${t.id}`))return;const y=setTimeout(()=>{l(!0)},2e3);return()=>clearTimeout(y)},[t,s,r,n]);const u=async()=>{c(!0);const f=await a();c(!1),f&&(t&&localStorage.setItem(`${Fge}_${t.id}`,"true"),l(!1))},p=()=>{t&&localStorage.setItem(`${Fge}_${t.id}`,"true"),l(!1)};return!s||r?null:e.jsx(_s,{open:o,onOpenChange:f=>!f&&p(),children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:e.jsx(gg,{className:"h-6 w-6 text-primary"})}),e.jsx(Ns,{className:"text-center",children:"Stay in the Loop!"}),e.jsx(Zr,{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."})]})})},R6e=t=>{let s;const r=new Set,n=(u,p)=>{const f=typeof u=="function"?u(s):u;if(!Object.is(f,s)){const y=s;s=p??(typeof f!="object"||f===null)?f:Object.assign({},s,f),r.forEach(_=>_(s,y))}},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},GPt=t=>t?R6e(t):R6e,KPt=t=>t;function ZPt(t,s=KPt){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 F6e=t=>{const s=GPt(t),r=n=>ZPt(s,n);return Object.assign(r,s),r},YPt=t=>t?F6e(t):F6e;function XPt(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 n1e=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return n1e(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return n1e(n)(r)}}}},QPt=(t,s)=>(r,n,a)=>{let o={storage:XPt(()=>localStorage),partialize:w=>w,version:0,merge:(w,j)=>({...j,...w}),...s},l=!1;const i=new Set,c=new Set;let u=o.storage;if(!u)return t((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...w)},n,a);const p=()=>{const w=o.partialize({...n()});return u.setItem(o.name,{state:w,version:o.version})},f=a.setState;a.setState=(w,j)=>(f(w,j),p());const y=t((...w)=>(r(...w),p()),n,a);a.getInitialState=()=>y;let _;const b=()=>{var w,j;if(!u)return;l=!1,i.forEach(S=>{var T;return S((T=n())!=null?T:y)});const N=((j=o.onRehydrateStorage)==null?void 0:j.call(o,(w=n())!=null?w:y))||void 0;return n1e(u.getItem.bind(u))(o.name).then(S=>{if(S)if(typeof S.version=="number"&&S.version!==o.version){if(o.migrate){const T=o.migrate(S.state,S.version);return T instanceof Promise?T.then(I=>[!0,I]):[!0,T]}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 T;const[I,L]=S;if(_=o.merge(L,(T=n())!=null?T:y),r(_,!0),I)return p()}).then(()=>{N==null||N(_,void 0),_=n(),l=!0,c.forEach(S=>S(_))}).catch(S=>{N==null||N(void 0,S)})};return a.persist={setOptions:w=>{o={...o,...w},w.storage&&(u=w.storage)},clearStorage:()=>{u==null||u.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>b(),hasHydrated:()=>l,onHydrate:w=>(i.add(w),()=>{i.delete(w)}),onFinishHydration:w=>(c.add(w),()=>{c.delete(w)})},o.skipHydration||b(),_||y},JPt=QPt,due=YPt()(JPt((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})})),nYe=C.createContext({onlineUsers:[],totalOnline:0}),e6t=async t=>{try{const{data:s}=await G.storage.from("avatars").list(`${t}`);if(s&&s.length>0){const{data:r}=G.storage.from("avatars").getPublicUrl(`${t}/${s[0].name}`);return r.publicUrl}}catch{}},t6t=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=Ws(),[a,o]=C.useState([]),[l,i]=C.useState(null);C.useEffect(()=>{if(!s)return;const u=G.channel("app-presence",{config:{presence:{key:s.id}}});return u.on("presence",{event:"sync"},()=>{const p=u.presenceState(),f=[];Object.entries(p).forEach(([y,_])=>{if(_&&_.length>0){const b=_[0];f.push({id:y,name:b.name||"Unknown",avatarUrl:b.avatarUrl,brokerageId:b.brokerageId,onlineSince:b.onlineSince})}}),o(f)}).on("presence",{event:"join"},()=>{}).on("presence",{event:"leave"},()=>{}).subscribe(async p=>{var f;if(p==="SUBSCRIBED"){const{data:y}=await G.from("profiles").select("name, brokerage_id").eq("id",s.id).single(),_=await e6t(s.id);await u.track({name:(y==null?void 0:y.name)||((f=s.email)==null?void 0:f.split("@")[0])||"User",avatarUrl:_,brokerageId:y==null?void 0:y.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(nYe.Provider,{value:{onlineUsers:c,totalOnline:a.length},children:t})},aYe=()=>C.useContext(nYe),z6e="dashboard-sidebar-collapsed",Es=({children:t,title:s})=>{var qe;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Ws(),{isAssistant:i,actingAsAgent:c,hasPermission:u}=Owe(),{isImpersonating:p}=Dwe(),y=(i&&!!c?40:0)+(p?40:0),{avatarUrl:_}=rZe(r==null?void 0:r.id),{isTrial:b,isExpired:w,expiresAt:j}=uEt(r==null?void 0:r.id),{isMarketplaceEnabled:N}=aZe(),{currentBrief:S,shouldShowPopup:T,hasUnseenBrief:I,openBrief:L,closeBrief:R,dismissBrief:$}=BPt(),{unreadCount:q}=hEt(),{openCount:U}=mEt(),{data:V}=Lg(),X=!!V,ee=due(ct=>ct.cartItems).reduce((ct,De)=>ct+De.quantity,0),Q=Pr(),de=Qu(),[re,ne]=C.useState(null);C.useEffect(()=>{r!=null&&r.id&&G.from("profiles").select("name").eq("id",r.id).single().then(({data:ct})=>{ct!=null&&ct.name&&ne(ct.name)})},[r==null?void 0:r.id]);const le=re||((qe=r==null?void 0:r.user_metadata)==null?void 0:qe.name)||(r==null?void 0:r.email)||"User",[he,we]=C.useState(()=>typeof window<"u"?localStorage.getItem(z6e)==="true":!1);C.useEffect(()=>{localStorage.setItem(z6e,String(he))},[he]);const[ye,je]=C.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,contacts:!0,help:!1}),ke=ct=>{je(De=>({...De,[ct]:!De[ct]}))},We=ct=>ct.split(" ").map(De=>De[0]).join("").toUpperCase().slice(0,2),be=ct=>de.pathname===ct,Me=ct=>ct.some(De=>de.pathname===De),Ae=({path:ct,icon:De,label:Rt,badgeCount:pe})=>{const Je=e.jsxs(K,{variant:"ghost",size:"sm",className:At("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",be(ct)&&"bg-sidebar-accent text-sidebar-accent-foreground",he?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>Q(ct),children:[e.jsxs("div",{className:"relative",children:[e.jsx(De,{className:"h-4 w-4 shrink-0"}),he&&pe!=null&&pe>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!he&&Rt,!he&&pe!=null&&pe>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:pe>9?"9+":pe})]});return he?e.jsxs(hd,{delayDuration:0,children:[e.jsx(md,{asChild:!0,children:Je}),e.jsxs(Uc,{side:"right",className:"flex items-center gap-2",children:[Rt,pe!=null&&pe>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:pe>9?"9+":pe})]})]}):Je},Re=({id:ct,label:De,icon:Rt,children:pe,activePaths:Je,showBetaBadge:lt,defaultPath:rt,badgeCount:Se})=>{if(he){const it=rt||Je[0];return e.jsxs(hd,{delayDuration:0,children:[e.jsx(md,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:At("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Me(Je)&&"text-primary"),onClick:()=>Q(it),children:e.jsxs("div",{className:"relative",children:[e.jsx(Rt,{className:"h-4 w-4"}),Se!=null&&Se>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(Uc,{side:"right",className:"flex items-center gap-2",children:[De,lt&&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"}),Se!=null&&Se>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:Se>9?"9+":Se})]})]})}return e.jsxs(bg,{open:ye[ct],onOpenChange:()=>ke(ct),children:[e.jsx(wg,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:At("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me(Je)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(Rt,{className:"h-4 w-4"}),De,lt&&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:[Se!=null&&Se>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:Se>9?"9+":Se}),e.jsx(tl,{className:At("h-4 w-4 transition-transform duration-200",ye[ct]&&"rotate-180")})]})]})}),e.jsx(jg,{className:"pl-4 space-y-1 mt-1",children:pe})]})},Te=({isMobile:ct=!1})=>{const De=ct?!1:he;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:At("p-3 border-b border-sidebar-border",De?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[De?e.jsx("img",{src:bEt,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:_Et,alt:"LevelUp",className:"h-8 w-auto"}),!ct&&e.jsxs(hd,{delayDuration:0,children:[e.jsx(md,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>we(!De),children:e.jsx(Xl,{className:At("h-4 w-4 transition-transform duration-300",De&&"rotate-180")})})}),e.jsx(Uc,{side:"right",children:De?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(Vi,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:e.jsxs("nav",{className:At("p-3 space-y-1",De&&"flex flex-col items-center"),children:[e.jsx(Ae,{path:"/dashboard",icon:U4,label:"Dashboard"}),e.jsx(Ae,{path:"/apps",icon:Yf,label:"Apps & Tools"}),he?e.jsxs(hd,{delayDuration:0,children:[e.jsx(md,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:At("w-10 h-10 p-0 justify-center relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",be("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/levelup-u"),children:[e.jsx(zh,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 h-2 w-2 rounded-full bg-primary animate-pulse"})]})}),e.jsxs(Uc,{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:At("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",be("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/levelup-u"),children:[e.jsx(zh,{className:"h-4 w-4 shrink-0"}),"LevelUp U",e.jsx("span",{className:"ml-auto text-[10px] font-bold uppercase tracking-wider text-primary-foreground bg-primary rounded px-1.5 py-0.5",children:"New"})]}),e.jsx(Ae,{path:"/events",icon:Md,label:"Events"}),e.jsxs(Re,{id:"agentos",label:"Agent OS",icon:oM,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(Ae,{path:"/mission-control",icon:Ii,label:"Mission Control"}),u("contacts")&&!De&&e.jsxs(bg,{open:ye.contacts,onOpenChange:()=>ke("contacts"),children:[e.jsx(wg,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:At("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me(["/mission-control/contacts","/mission-control/relationship-scorecard","/mission-control/sphere-gaps","/mission-control/connect-page"])&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),"Contacts"]}),e.jsx(tl,{className:At("h-3.5 w-3.5 transition-transform duration-200",ye.contacts&&"rotate-180")})]})}),e.jsxs(jg,{className:"pl-4 pr-1 space-y-0.5 mt-0.5",children:[e.jsx(Ae,{path:"/mission-control/contacts",icon:mr,label:"All Contacts"}),e.jsx(Ae,{path:"/mission-control/relationship-scorecard",icon:gp,label:"Relationship Report"}),e.jsx(Ae,{path:"/mission-control/sphere-gaps",icon:oL,label:"Sphere Gaps"}),e.jsx(Ae,{path:"/mission-control/connect-page",icon:sl,label:"Connect Page"})]})]}),u("contacts")&&De&&e.jsx(Ae,{path:"/mission-control/contacts",icon:mr,label:"Contacts"}),u("contacts")&&e.jsx(Ae,{path:"/mission-control/plans",icon:Md,label:"TouchPlans"}),u("pipeline")&&e.jsx(Ae,{path:"/mission-control/pipeline",icon:i0,label:"Deal Pipeline"}),u("pipeline")&&e.jsx(Ae,{path:"/mission-control/tasks",icon:Pv,label:"Tasks"}),u("popbys")&&e.jsx(Ae,{path:"/mission-control/popbys",icon:bo,label:"Popbys"}),u("videos")&&e.jsx(Ae,{path:"/mission-control/video-library",icon:Nn,label:"Video Library"}),u("scorecard")&&e.jsx(Ae,{path:"/mission-control/scorecard",icon:xl,label:"Scorecard"}),u("listings")&&e.jsx(Ae,{path:"/mission-control/listings",icon:La,label:"Listing Exchange"}),!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:At("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",be("/mission-control/smart-drips")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/mission-control/smart-drips"),children:[e.jsx(wp,{className:"h-4 w-4"}),"Smart Drips",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),De&&e.jsx(Ae,{path:"/mission-control/smart-drips",icon:wp,label:"Smart Drips"})]}),e.jsxs(Re,{id:"marketing",label:"Marketing",icon:bp,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx(Ae,{path:"/templates",icon:Ql,label:"Templates"}),e.jsx(Ae,{path:"/social-swag-2",icon:i1,label:"Social Swag"}),e.jsx(Ae,{path:"/newsletters",icon:s1,label:"Newsletters"})]}),e.jsxs(Re,{id:"learning",label:"Learning",icon:gh,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx(Ae,{path:"/academy",icon:zh,label:"Academy"}),e.jsx(Ae,{path:"/toolbox",icon:Kx,label:"Toolbox"})]}),e.jsxs(Re,{id:"community",label:"Community",icon:po,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:q,children:[e.jsx(Ae,{path:"/community",icon:mr,label:"Community",badgeCount:q}),e.jsx(Ae,{path:"/wishlist",icon:Ib,label:"Wishlist",badgeCount:U}),!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",onClick:()=>window.open("https://www.facebook.com/share/g/1CC6thti2V/","_blank"),children:[e.jsx(rn,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(Re,{id:"goods",label:"The Goods",icon:dp,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[N&&!De&&e.jsxs(K,{variant:"ghost",size:"sm",className:At("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",de.pathname.startsWith("/marketplace")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/marketplace"),children:[e.jsx(dp,{className:"h-4 w-4"}),"Marketplace",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1.5 py-0.5 rounded-full bg-primary text-primary-foreground",children:"New"})]}),N&&De&&e.jsx(Ae,{path:"/marketplace",icon:dp,label:"Marketplace"}),e.jsx(Ae,{path:"/reward-store",icon:mo,label:"Reward Store"})]}),e.jsxs(Re,{id:"help",label:"Help & Services",icon:Mv,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx(Ae,{path:"/support",icon:fM,label:"Support"}),e.jsx(Ae,{path:"/additional-services",icon:hn,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!De&&e.jsx("div",{className:"pt-3 pb-1",children:e.jsx("p",{className:"px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Admin"})}),De?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx(Ae,{path:"/admin",icon:vh,label:"Admin Dashboard"})}):e.jsxs(K,{variant:"ghost",size:"sm",className:At("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",de.pathname==="/admin"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/admin"),children:[e.jsx(vh,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!De&&e.jsx("div",{className:"pt-3 pb-1",children:e.jsx("p",{className:"px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"My Brokerage"})}),De?e.jsxs("div",{className:"border-t border-sidebar-border mt-3 pt-3 space-y-1",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx(Ae,{path:"/my-brokerage",icon:La,label:"My Brokerage"}),e.jsx(Ae,{path:"/brokerage-content",icon:gh,label:"Brokerage Content"})]}),X&&!o&&e.jsx(Ae,{path:"/my-team",icon:mr,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx(Ae,{path:"/brokerage/dashboard",icon:Jl,label:"Manage Brokerages"}),e.jsx(Ae,{path:"/brokerage/teams",icon:mr,label:"Teams"}),e.jsx(Ae,{path:"/brokerage-resources",icon:Rh,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:At("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",be("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/my-brokerage"),children:[e.jsx(La,{className:"h-4 w-4"}),"My Brokerage"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:At("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",be("/brokerage-content")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/brokerage-content"),children:[e.jsx(gh,{className:"h-4 w-4"}),"Brokerage Content"]})]}),X&&!o&&e.jsxs(K,{variant:"ghost",size:"sm",className:At("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",be("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/my-team"),children:[e.jsx(mr,{className:"h-4 w-4"}),"My Team"]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:At("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",be("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/brokerage/dashboard"),children:[e.jsx(Jl,{className:"h-4 w-4"}),"Manage Brokerages"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:At("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",be("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/brokerage/teams"),children:[e.jsx(mr,{className:"h-4 w-4"}),"Teams",e.jsx("span",{className:"ml-auto text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"New"})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:At("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",be("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/brokerage-resources"),children:[e.jsx(Rh,{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:At("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",be("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>Q("/profile"),children:[e.jsx(ro,{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(xM,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(t6t,{children:e.jsx(x2,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[b&&w&&e.jsx(jPt,{}),typeof document<"u"&&cp.createPortal(e.jsx("aside",{className:At("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-30 !pointer-events-auto transition-[width] duration-300",he?"w-16":"w-56"),style:{top:`${y}px`,height:`calc(100vh - ${y}px)`},children:e.jsx(Te,{})}),document.body),e.jsxs("div",{className:At("flex-1 flex flex-col overflow-hidden transition-all duration-300",he?"md:ml-16":"md:ml-56"),style:{height:`calc(100vh - ${y}px)`,marginTop:`${y}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(DA,{children:[e.jsx(Uje,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(GI,{className:"h-5 w-5"})})}),e.jsx(YS,{side:"left",className:"w-56 p-0 bg-card",children:e.jsx(Te,{isMobile:!0})})]}),e.jsx("div",{className:"flex-1 md:hidden",children:e.jsx("img",{src:wEt,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(O6e,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[b&&!w&&j&&e.jsx(wPt,{expiresAt:j,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(O6e,{})}),S&&e.jsx(kPt,{hasUnseenBrief:I,onClick:L}),N&&e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",onClick:()=>Q("/marketplace/cart"),children:[e.jsx(dp,{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(KEt,{}),e.jsx(t1e,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",le.split(" ")[0],"!"]}),e.jsxs(ju,{children:[e.jsx(ku,{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(yn,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[e.jsx(Da,{src:_||void 0}),e.jsx(vn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:We(le)})]})})}),e.jsxs(Jd,{align:"end",className:"w-48",children:[e.jsxs(Ta,{onClick:()=>Q("/profile"),className:"cursor-pointer",children:[e.jsx(ro,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(Ta,{onClick:()=>Q("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(JI,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(r2,{}),e.jsxs(Ta,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(xM,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(qPt,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),S&&e.jsx(zPt,{brief:S,open:T,onClose:R,onDismiss:$}),e.jsx($Pt,{}),e.jsx(VPt,{}),e.jsx(WPt,{})]})]})})})},s6t=()=>{const{user:t}=Ws(),[s,r]=C.useState(!1),[n,a]=C.useState(null),[o,l]=C.useState(""),i=async f=>{var y;if(!(t!=null&&t.email)){me.error("Please sign in to upgrade");return}r(!0),a(f);try{const{data:_,error:b}=await G.functions.invoke("create-checkout",{body:{tier:f,email:t.email,name:((y=t.user_metadata)==null?void 0:y.full_name)||t.email,couponCode:o.trim()||void 0,skipTrial:!0}});if(b)throw b;if(_!=null&&_.url)window.open(_.url,"_blank","noopener,noreferrer"),me.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(_){console.error("Checkout error:",_),me.error(_.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(Es,{children:e.jsxs("div",{className:"container max-w-6xl py-8 px-4",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold mb-2",children:"Upgrade Your Membership"}),e.jsx("p",{className:"text-muted-foreground text-lg",children:"Choose the plan that's right for you and unlock the full power of LevelUp"})]}),e.jsxs("div",{className:"max-w-md mx-auto mb-8",children:[e.jsx(_e,{htmlFor:"coupon",className:"text-sm font-medium",children:"Have a discount code?"}),e.jsx(Fe,{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(It,{className:"text-center pb-2",children:[e.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(mr,{className:"h-7 w-7 text-primary"})}),e.jsx(Ot,{className:"text-xl",children:"Individual Agent"}),e.jsx(fr,{children:"Perfect for solo agents ready to level up"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-primary",children:"$39"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:c.map((f,y)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ma,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},y))}),e.jsxs(K,{className:"w-full",size:"lg",onClick:()=>i("individual_agent"),disabled:s,children:[s&&n==="individual_agent"?e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Ee,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors",children:[e.jsxs(It,{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(La,{className:"h-7 w-7 text-amber-600"})}),e.jsx(Ot,{className:"text-xl",children:"Brokerage"}),e.jsx(fr,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-amber-600",children:"$299"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:u.map((f,y)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ma,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},y))}),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(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(La,{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(It,{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(La,{className:"h-7 w-7 text-purple-600"})}),e.jsx(Ot,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(fr,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-4xl font-bold text-purple-600",children:"$499"}),e.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),e.jsx("ul",{className:"space-y-2",children:p.map((f,y)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[e.jsx(ma,{className:"h-4 w-4 text-purple-600 mt-0.5 shrink-0"}),e.jsx("span",{children:f})]},y))}),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(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(La,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),e.jsx(Ee,{className:"bg-muted/50",children:e.jsxs(Oe,{className:"py-6",children:[e.jsx("p",{className:"text-center font-medium mb-4",children:"Questions? We're here to help!"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[e.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[e.jsx(ea,{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(br,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},r6t=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=Ws(),a=Pr(),[o,l]=C.useState(""),[i,c]=C.useState(!1),[u,p]=C.useState(!1);C.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),C.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:y}=await G.auth.getSession(),_=y.session;if(!t||!_){me.error("Please sign in again to create your brokerage."),a("/auth");return}c(!0);try{console.log("[SetupBrokerage] Creating brokerage…",{hasUser:!!t,hasSession:!!_,userId:t==null?void 0:t.id});const{data:b,error:w}=await G.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:b,error:w}),w)throw w;if(!(b!=null&&b.ok))throw new Error((b==null?void 0:b.error)||"Failed to create brokerage");c(!1),p(!0),me.success("Brokerage created! Setting up your account..."),setTimeout(()=>{a("/profile?setup=true")},2e3)}catch(b){console.error("Error creating brokerage:",b),me.error(b.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(It,{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(Ss,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(Ot,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(fr,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(vi,{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(Ss,{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(It,{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(La,{className:"w-10 h-10 text-primary"})}),e.jsx(Ot,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(fr,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(Fe,{id:"brokerage-name",placeholder:"Enter your brokerage name",value:o,onChange:y=>l(y.target.value),onKeyDown:y=>y.key==="Enter"&&f()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This is how your brokerage will appear to your agents"})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-muted/50 space-y-3",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(mr,{className:"w-4 h-4 text-primary"}),"What you can do as a Brokerage Manager:"]}),e.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(vi,{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(vi,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(vi,{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(vi,{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(Ki,{className:"w-4 h-4 ml-2"})]})]})]})})},B6e=()=>{const t=Pr(),[s,r]=C.useState("verifying"),[n,a]=C.useState("");C.useEffect(()=>{(async()=>{try{const{data:{session:i},error:c}=await G.auth.getSession();if(c)throw c;if(i!=null&&i.user){const{data:u}=await G.from("profiles").select("login_count").eq("id",i.user.id).single();if(((u==null?void 0:u.login_count)||0)>1){console.log("Account already claimed, redirecting to dashboard"),r("already_claimed");return}console.log("User logged in successfully:",i.user.email),r("success");try{await G.functions.invoke("trial-claim-hook",{body:{userId:i.user.id}})}catch(p){console.log("Trial claim hook (non-critical):",p)}setTimeout(()=>{t("/profile?setup=true")},1500)}else setTimeout(()=>{r("already_claimed")},2e3)}catch(i){console.error("Claim error:",i),r("already_claimed")}})()},[t]);const o=()=>{window.location.href="https://dashboard.relevelup.com/auth"};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(It,{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(Ot,{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(fr,{children:[s==="verifying"&&"Please wait while we verify your account...",s==="success"&&"Redirecting you to complete your profile...",s==="already_claimed"&&"This account has already been set up. Please log in to access your dashboard.",s==="error"&&n]})]}),(s==="already_claimed"||s==="error")&&e.jsx(Oe,{children:e.jsx(K,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},n6t=()=>{const t=Pr(),[s]=Xc(),[r,n]=C.useState(s.get("code")||""),[a,o]=C.useState(""),[l,i]=C.useState(""),[c,u]=C.useState(""),[p,f]=C.useState(!1),[y,_]=C.useState(!1),[b,w]=C.useState(!1),[j,N]=C.useState(!1),[S,T]=C.useState(null),[I,L]=C.useState(null),[R,$]=C.useState(null),[q,U]=C.useState(null);C.useEffect(()=>{const ee=s.get("code");ee&&(n(ee),V(ee))},[s]);const V=async ee=>{w(!0);const{data:Q,error:de}=await G.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(de||!Q){me.error("Invalid invite code"),w(!1);return}if(!Q.is_active){me.error("This invite code is no longer active"),w(!1);return}if(Q.max_uses&&Q.uses_count>=Q.max_uses){me.error("This invite code has reached its maximum uses"),w(!1);return}if(Q.expires_at&&new Date(Q.expires_at){ee.preventDefault(),V(r)},se=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}_(!0);try{const de=`${window.location.origin}/`,{data:re,error:ne}=await G.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:de,data:{name:c.trim()}}});if(ne){ne.message.includes("already registered")?me.error("This email is already registered. Please sign in instead."):me.error(ne.message);return}re.user&&(await G.rpc("add_default_signup_tag",{user_id:re.user.id}),I?await G.functions.invoke("assign-brokerage",{body:{userId:re.user.id,brokerageId:I}}):q?await G.functions.invoke("assign-brokerage",{body:{userId:re.user.id,trialDays:q}}):await G.functions.invoke("assign-brokerage",{body:{userId:re.user.id,grandfathered:!0}}),S&&await G.from("invite_codes").update({uses_count:((Q=(await G.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(de){console.error("Signup error:",de),me.error("An unexpected error occurred")}finally{_(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Ee,{className:"w-full max-w-md",children:[e.jsxs(It,{className:"text-center",children:[e.jsx(Ot,{className:"text-2xl font-bold text-primary",children:R?`Join ${R}`:"Join LevelUp"}),e.jsx(fr,{children:j?R?`Create your account to join ${R}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(Oe,{children:j?e.jsxs("form",{onSubmit:se,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"name",children:"Full Name"}),e.jsx(Fe,{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(_e,{htmlFor:"email",children:"Email"}),e.jsx(Fe,{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(_e,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{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(xp,{className:"h-4 w-4"}):e.jsx(va,{className:"h-4 w-4"})})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:y,children:y?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:X,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"inviteCode",children:"Invite Code"}),e.jsx(Fe,{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:b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},a6t="/assets/testimonial-avatar-1-BsCQFauB.jpg",i6t="/assets/testimonial-avatar-2-B6VPVc2t.jpg",o6t="/assets/testimonial-avatar-3-GuEFwYUE.jpg",l6t="/assets/testimonial-avatar-4-98iKMtkB.jpg",c6t="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",d6t=[a6t,i6t,o6t,l6t,c6t],u6t=ZS({name:uc().trim().min(2,"Name must be at least 2 characters").max(100),email:uc().trim().email("Please enter a valid email address").max(255),phone:uc().trim().min(10,"Please enter a valid phone number").max(20).optional().or(woe("")),brokerage:uc().trim().max(200).optional().or(woe(""))}),h6t=[{icon:ap,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:Ql,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:on,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:Ec,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:In,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:bo,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],m6t=[{icon:mr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:hn,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:ea,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:xh,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Ui,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:xl,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Ii,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:wp,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],p6t=[{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."}],f6t=()=>{const t=Pr(),[s,r]=C.useState(!1),[n,a]=C.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=C.useState({}),i=async c=>{var p,f;c.preventDefault(),l({});const u=u6t.safeParse(n);if(!u.success){const y={};u.error.errors.forEach(_=>{_.path[0]&&(y[_.path[0]]=_.message)}),l(y);return}r(!0);try{const{data:y,error:_}=await G.functions.invoke("create-trial-signup",{body:{name:n.name.trim(),email:n.email.trim().toLowerCase(),phone:((p=n.phone)==null?void 0:p.trim())||void 0,brokerage:((f=n.brokerage)==null?void 0:f.trim())||void 0}});if(_){console.error("Trial signup error:",_),me.error(_.message||"Something went wrong. Please try again.");return}if(y!=null&&y.error){me.error(y.error);return}me.success("🎉 Welcome aboard! Check your email to claim your account."),t("/trial/success")}catch(y){console.error("Trial signup error:",y),me.error("Something went wrong. Please try again.")}finally{r(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(qh,{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:Loe,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(hn,{className:"h-4 w-4 text-yellow-400"}),e.jsx("span",{children:"7-Day Free Trial • No Credit Card Required"})]}),e.jsxs("h1",{className:"text-3xl md:text-4xl lg:text-5xl font-bold text-white leading-tight font-sans",children:["Take LevelUp for a"," ",e.jsx("span",{className:"italic",children:"Free Test Drive"})]}),e.jsxs("p",{className:"text-lg md:text-xl text-white/80 max-w-xl mx-auto lg:mx-0 font-sans",children:["The tools you need to get it done.",e.jsx("br",{}),e.jsx("em",{children:"The platform you need to keep it going."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center lg:justify-start",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/80",children:[e.jsx(ha,{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(ha,{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:d6t.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(Kn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},c))}),e.jsx("p",{className:"text-sm text-white/60",children:"Trusted by 3,000+ agents"})]})]})]}),e.jsx("div",{className:"lg:pl-8",children:e.jsx(Ee,{className:"bg-white shadow-2xl border-0",children:e.jsxs(Oe,{className:"p-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-[#4a6b6d] mb-4",children:e.jsx(o0,{className:"h-8 w-8 text-white"})}),e.jsx("h2",{className:"text-2xl font-bold text-foreground font-sans",children:"Start Your Free Trial"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Get instant access • No credit card needed"})]}),e.jsxs("form",{onSubmit:i,className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"name",children:"Full Name *"}),e.jsx(Fe,{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(_e,{htmlFor:"email",children:"Email Address *"}),e.jsx(Fe,{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(_e,{htmlFor:"phone",children:"Phone Number"}),e.jsx(Fe,{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(_e,{htmlFor:"brokerage",children:"Brokerage Name"}),e.jsx(Fe,{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(Ss,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(Ki,{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:h6t.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(It,{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(Ot,{className:"text-xl font-sans",children:c.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:c.description})})]},u))})]})}),e.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs("div",{className:"container mx-auto px-4 relative",children:[e.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/10 text-white text-sm font-medium mb-6",children:[e.jsx(hn,{className:"w-4 h-4"}),"Included with Your Trial"]}),e.jsxs("h2",{className:"text-3xl mb-6 text-white font-sans font-bold md:text-6xl",children:["Meet ",e.jsx("span",{className:"italic",children:"Agent OS"})]}),e.jsx("p",{className:"text-lg text-white/80",children:"Your relationship-first operating system. Never forget a follow-up, track every touchpoint, and turn your sphere into a referral machine."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 max-w-6xl mx-auto",children:m6t.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(It,{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(Ot,{className:"text-lg font-semibold text-white",children:c.title})]}),e.jsx(Oe,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:c.description})})]},u))})]})]}),e.jsx("section",{className:"py-20 bg-background",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsxs("div",{className:"text-center mb-16",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4 font-sans",children:"Loved by Top Producers"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"See what agents are saying about LevelUp"})]}),e.jsx("div",{className:"grid md:grid-cols-3 gap-8 max-w-5xl mx-auto",children:p6t.map((c,u)=>e.jsx(Ee,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(p=>e.jsx(Kn,{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(Bh,{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(wp,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Fast Setup"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Start in 2 minutes"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:e.jsx(mr,{className:"h-6 w-6 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Expert Support"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Real estate pros"})]})]})]})})}),e.jsx("section",{id:"free-trial",className:"py-20 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs(Ee,{className:"bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] border-0 shadow-2xl overflow-hidden relative",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsxs(Oe,{className:"p-12 text-center relative",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-4 font-sans",children:"Ready to Level Up Your Business?"}),e.jsx("p",{className:"text-xl text-white/80 mb-8 max-w-2xl mx-auto",children:"Join thousands of successful agents. Start your free 7-day trial today."}),e.jsxs(K,{onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),size:"lg",className:"h-14 px-8 text-lg font-semibold bg-white text-[#1e3a4c] hover:bg-white/90 shadow-2xl transition-all hover:scale-105 rounded-full",children:["Start Your Free Trial Now",e.jsx(Ki,{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:Ywe,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."})]})})})]})]})},g6t=()=>{const t=Pr();return e.jsxs(e.Fragment,{children:[e.jsx(qh,{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:Loe,alt:"LevelUp",className:"h-8 md:h-10"})}),e.jsx(K,{onClick:()=>t("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})}),e.jsxs("section",{className:"relative pt-24 pb-12 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden flex-1 flex items-center",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),e.jsx("div",{className:"container mx-auto px-4 relative",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(Ee,{className:"max-w-lg w-full bg-white shadow-2xl border-0",children:e.jsxs(Oe,{className:"p-8 md:p-12 text-center",children:[e.jsxs("div",{className:"relative inline-block mb-8",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] flex items-center justify-center",children:e.jsx(ha,{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(Zd,{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(br,{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(Ki,{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:Ywe,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},x6t=ZS({viewerName:uc().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:uc().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:uc().max(20,"Phone must be less than 20 characters").optional(),message:uc().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function y6t({shareToken:t,agentName:s,hasContact:r}){const[n,a]=C.useState(!1),[o,l]=C.useState(!1),[i,c]=C.useState(null),u=rue({resolver:nue(x6t),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),p=async f=>{a(!0),c(null);try{const{data:y,error:_}=await G.functions.invoke("video-reply-notify",{body:{shareToken:t,viewerName:f.viewerName,viewerEmail:f.viewerEmail,viewerPhone:f.viewerPhone||void 0,message:f.message}});if(_)throw new Error(_.message);if(!(y!=null&&y.success))throw new Error((y==null?void 0:y.error)||"Failed to send reply");l(!0)}catch(y){console.error("Failed to submit reply:",y),c(y.message||"Something went wrong. Please try again.")}finally{a(!1)}};return o?e.jsx(Ee,{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:e.jsxs(Oe,{className:"py-8 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/20 mb-4",children:e.jsx(ha,{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(It,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ec,{className:"h-5 w-5 text-primary"}),e.jsx(Ot,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(fr,{children:r?`Have a question or want to connect? Send ${s||"them"} a message.`:`Interested? Share your info and ${s||"your agent"} will be in touch.`})]}),e.jsx(Oe,{children:e.jsx(aue,{...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(Rc,{control:u.control,name:"viewerName",render:({field:f})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Your Name *"}),e.jsx(Sc,{children:e.jsx(Fe,{placeholder:"John Smith",...f})}),e.jsx(vm,{})]})}),e.jsx(Rc,{control:u.control,name:"viewerEmail",render:({field:f})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Email *"}),e.jsx(Sc,{children:e.jsx(Fe,{type:"email",placeholder:"john@example.com",...f})}),e.jsx(vm,{})]})})]}),!r&&e.jsx(Rc,{control:u.control,name:"viewerPhone",render:({field:f})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Phone (optional)"}),e.jsx(Sc,{children:e.jsx(Fe,{type:"tel",placeholder:"(555) 123-4567",...f})}),e.jsx(vm,{})]})}),e.jsx(Rc,{control:u.control,name:"message",render:({field:f})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Message *"}),e.jsx(Sc,{children:e.jsx(Ar,{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(vm,{})]})}),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(Ss,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oa,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const v6t=()=>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(Kn,{className:"absolute top-[5%] left-[8%] w-6 h-6 text-blue-600/30 fill-blue-600/20"}),e.jsx(Kn,{className:"absolute top-[15%] left-[20%] w-4 h-4 text-blue-600/25 fill-blue-600/15"}),e.jsx(Kn,{className:"absolute top-[8%] left-[28%] w-5 h-5 text-blue-600/30 fill-blue-600/20"}),e.jsx(Kn,{className:"absolute top-[25%] left-[12%] w-4 h-4 text-blue-600/20 fill-blue-600/10"}),e.jsx(Kn,{className:"absolute top-[20%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse"}),e.jsx(Xv,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),_6t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-500/5 via-transparent to-blue-500/5"}),e.jsxs("div",{className:"absolute top-[10%] left-[15%] w-32 h-32",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-red-400/20 animate-ping",style:{animationDuration:"3s"}}),e.jsx(hn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-8 text-red-400/40"})]}),e.jsxs("div",{className:"absolute top-[5%] right-[20%] w-24 h-24",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-blue-400/20 animate-ping",style:{animationDuration:"4s",animationDelay:"1s"}}),e.jsx(Kn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-6 h-6 text-blue-400/40 fill-blue-400/20"})]}),e.jsxs("div",{className:"absolute top-[20%] left-[50%] w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border border-white/10 animate-ping",style:{animationDuration:"3.5s",animationDelay:"0.5s"}}),e.jsx(hn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-5 h-5 text-amber-400/40"})]}),e.jsx(Kn,{className:"absolute bottom-[25%] left-[10%] w-6 h-6 text-blue-500/25 fill-blue-500/15 animate-pulse"}),e.jsx(Kn,{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(Xv,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),b6t=()=>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(Fx,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(Fx,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(Fx,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(Fx,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),e.jsx(Ii,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),e.jsx(Ii,{className:"absolute top-[25%] right-[25%] w-4 h-4 text-pink-300/40 fill-pink-300/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(Ii,{className:"absolute top-[10%] left-[60%] w-4 h-4 text-rose-400/30 fill-rose-400/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx("div",{className:"absolute top-[8%] left-[45%] w-8 h-8 rounded-full bg-pink-300/10 blur-sm"}),e.jsx("div",{className:"absolute bottom-[25%] right-[30%] w-6 h-6 rounded-full bg-rose-300/10 blur-sm"})]}),w6t=()=>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(fc,{className:"absolute top-[8%] left-[12%] w-12 h-12 text-blue-600/15"}),e.jsx(Kn,{className:"absolute top-[15%] left-[22%] w-5 h-5 text-amber-500/25 fill-amber-500/15"}),e.jsx(fc,{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(Kn,{className:"absolute bottom-[25%] left-[15%] w-6 h-6 text-blue-500/20 fill-blue-500/10 animate-pulse"}),e.jsx(Kn,{className:"absolute top-[20%] right-[22%] w-5 h-5 text-indigo-400/20 fill-indigo-400/10 animate-pulse",style:{animationDelay:"0.5s"}})]}),j6t=()=>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(Fx,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(Fx,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(cM,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),k6t=()=>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($4,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx($4,{className:"absolute top-[10%] right-[12%] w-12 h-12 text-purple-400/20 animate-pulse"}),e.jsxs("div",{className:"absolute bottom-[18%] left-[8%]",children:[e.jsx("div",{className:"w-14 h-12 rounded-full bg-orange-500/20"}),e.jsx("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 w-2 h-4 bg-green-600/25 rounded-t-full"})]}),e.jsxs("div",{className:"absolute bottom-[22%] right-[12%]",children:[e.jsx("div",{className:"w-12 h-10 rounded-full bg-orange-400/15"}),e.jsx("div",{className:"absolute -top-1.5 left-1/2 -translate-x-1/2 w-1.5 h-3 bg-green-600/20 rounded-t-full"})]}),e.jsx("div",{className:"absolute top-[15%] left-[40%] opacity-20",children:e.jsx("svg",{viewBox:"0 0 24 12",className:"w-10 h-5 text-slate-800 fill-current",children:e.jsx("path",{d:"M12 6c-2-4-6-6-12-6 4 2 6 4 6 6s-2 4-6 6c6 0 10-2 12-6zm0 0c2-4 6-6 12-6-4 2-6 4-6 6s2 4 6 6c-6 0-10-2-12-6z"})})}),e.jsx(hn,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx(hn,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),N6t=()=>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(Fb,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(Fb,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(Fb,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx(hb,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx(hb,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(hb,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(hb,{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(Kn,{className:"absolute top-[3%] left-[50%] -translate-x-1/2 w-10 h-10 text-amber-400/35 fill-amber-400/25"})]}),S6t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-900/10 via-amber-800/6 to-red-900/10"}),e.jsx("div",{className:"absolute top-[5%] left-[10%] w-10 h-8 rounded-full bg-orange-500/25 rotate-45"}),e.jsx("div",{className:"absolute top-[10%] right-[15%] w-8 h-6 rounded-full bg-red-500/20 -rotate-12"}),e.jsx("div",{className:"absolute top-[15%] left-[35%] w-7 h-5 rounded-full bg-amber-500/22 rotate-30"}),e.jsx("div",{className:"absolute bottom-[18%] left-[12%] w-10 h-7 rounded-full bg-yellow-600/18 -rotate-45"}),e.jsx("div",{className:"absolute bottom-[22%] right-[10%] w-9 h-6 rounded-full bg-orange-600/15 rotate-12"}),e.jsxs("div",{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2",children:[e.jsx("div",{className:"w-16 h-14 rounded-full bg-orange-400/15"}),e.jsx("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 w-2 h-5 bg-green-600/18 rounded-t-full"})]}),e.jsx(Ii,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),e.jsx(Ii,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),C6t=()=>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(Kn,{className:"absolute top-[5%] left-[15%] w-12 h-12 text-yellow-400/35 fill-yellow-400/25 animate-pulse"}),e.jsx(Kn,{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(Kn,{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(Kn,{className:"absolute top-[12%] right-[35%] w-8 h-8 text-amber-300/28 fill-amber-300/18 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[20%] left-[25%] w-4 h-4 rounded-full bg-pink-400/30"}),e.jsx("div",{className:"absolute top-[18%] right-[30%] w-3 h-3 rounded-full bg-sky-400/30"}),e.jsx("div",{className:"absolute top-[25%] left-[60%] w-2.5 h-2.5 rounded-full bg-emerald-400/30"}),e.jsx("div",{className:"absolute top-[22%] right-[42%] w-3 h-3 rounded-full bg-purple-400/30"}),e.jsx(hn,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),e.jsx(Zd,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),e.jsx(Zd,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),M6t=()=>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(Kn,{className:"absolute top-[8%] left-[50%] -translate-x-1/2 w-14 h-14 text-yellow-400/28 fill-yellow-400/18"}),e.jsx(hn,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx(hn,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),T6t=()=>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($v,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx($v,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx($v,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx($v,{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"})]})]})]}),A6t=()=>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(Kn,{className:"absolute top-[5%] left-[42%] w-10 h-10 text-amber-400/30 fill-amber-400/20"}),e.jsx(Kn,{className:"absolute top-[15%] right-[25%] w-7 h-7 text-yellow-400/25 fill-yellow-400/15"}),e.jsx(fc,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(fc,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(Xv,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),E6t=()=>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(xh,{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(Zd,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),e.jsx(bo,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),P6t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-rose-900/12 via-pink-900/8 to-red-900/12"}),e.jsx(Ii,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),e.jsx(Ii,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),e.jsx(Ii,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),e.jsx(Ii,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),e.jsx(Ii,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),e.jsx(Ii,{className:"absolute top-[20%] right-[35%] w-5 h-5 text-rose-300/35 fill-rose-300/20 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(Ii,{className:"absolute top-[12%] left-[55%] w-5 h-5 text-red-300/30 fill-red-300/15 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(Ii,{className:"absolute top-[25%] right-[25%] w-4 h-4 text-pink-400/30 fill-pink-400/15 animate-pulse",style:{animationDelay:"0.9s"}}),e.jsx("div",{className:"absolute top-[18%] left-[45%] w-8 h-8 rounded-full bg-rose-300/18 blur-sm"}),e.jsx("div",{className:"absolute bottom-[25%] right-[40%] w-6 h-6 rounded-full bg-pink-300/15 blur-sm"})]}),I6t=()=>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(Rb,{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(Rb,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx(hn,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(Rb,{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"})]}),L6t=()=>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(Rn,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(Rn,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),e.jsx(vp,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),e.jsx(vp,{className:"absolute bottom-[22%] left-[22%] w-8 h-8 text-yellow-400/22"}),e.jsx(Ii,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),e.jsx(Ii,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),e.jsx(hn,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),e.jsx(Zd,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),D6t=()=>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(Zd,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),e.jsx(Zd,{className:"absolute top-[8%] right-[10%] w-12 h-12 text-teal-400/22 -rotate-12"}),e.jsx(vp,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),e.jsx(Rn,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),e.jsx(hn,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx(hn,{className:"absolute top-[20%] right-[32%] w-7 h-7 text-cyan-400/30"}),e.jsx("div",{className:"absolute top-[25%] left-[55%] w-3 h-3 bg-amber-400/30 rounded-full"}),e.jsx("div",{className:"absolute top-[22%] right-[42%] w-2.5 h-2.5 bg-teal-400/30 rounded-full"}),e.jsx("div",{className:"absolute top-[28%] left-[35%] w-2 h-2 bg-emerald-400/30 rounded-full"})]}),O6t=()=>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(vp,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),e.jsx(vp,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),e.jsx(vp,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),e.jsx(Rn,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),e.jsx(Zd,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),e.jsx(hn,{className:"absolute top-[5%] right-[35%] w-8 h-8 text-yellow-400/35"}),e.jsx(Kn,{className:"absolute top-[18%] left-[28%] w-6 h-6 text-amber-400/25 fill-amber-400/15"})]}),R6t=()=>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(Rn,{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(vp,{className:"absolute top-[10%] right-[12%] w-10 h-10 text-amber-400/28"}),e.jsx(Ii,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),e.jsx(hn,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(Zv,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),$6e=()=>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"})]}),F6t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Ii,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),e.jsx(Ii,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),e.jsx(Ii,{className:"absolute top-4 left-[40%] w-2.5 h-2.5 text-rose-400/40 fill-rose-400/20 animate-pulse delay-300"}),e.jsx(Ii,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),z6t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Zv,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx(hn,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),e.jsx(Rn,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),B6t=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(z4,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(yM,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(z4,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),A6=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(hn,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),e.jsx(Zd,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),e.jsx(hn,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),q6e=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Rn,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),e.jsx(hn,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),e.jsx(Rn,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),a1e=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx(hn,{className:"h-5 w-5"}),category:"general",headerText:()=>"Video Message",subText:"A personal video just for you",gradientClasses:"from-background to-muted/30",accentColor:"primary"},{id:"thank_you",name:"Thank You",description:"Express your gratitude",icon:e.jsx(Ii,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thank You, ${t}!`:"Thank You!",subText:"Your support means the world to me",gradientClasses:"from-rose-50/70 via-pink-50/50 to-red-50/40 dark:from-rose-950/30 dark:via-pink-950/20 dark:to-red-950/20",accentColor:"rose",decorativeElement:e.jsx(F6t,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(PI,{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(A6,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(z4,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Hey ${t}!`:"Hey There!",subText:"Just checking in to see how you're doing",gradientClasses:"from-amber-50/70 via-orange-50/50 to-yellow-50/40 dark:from-amber-950/30 dark:via-orange-950/20 dark:to-yellow-950/20",accentColor:"amber",decorativeElement:e.jsx(B6t,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(xl,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Market Update for ${t}`:"Market Update",subText:"The latest insights from your local market",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue"},{id:"referral_thank_you",name:"Referral Thank You",description:"Thank someone for a referral",icon:e.jsx(mr,{className:"h-5 w-5"}),category:"general",headerText:t=>t?`Thank You for the Referral, ${t}!`:"Thank You for the Referral!",subText:"Your trust in me means everything",gradientClasses:"from-emerald-50/70 via-green-50/50 to-teal-50/40 dark:from-emerald-950/30 dark:via-green-950/20 dark:to-teal-950/20",accentColor:"emerald",decorativeElement:e.jsx(A6,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(fc,{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($6e,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(Ui,{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(q6e,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(yM,{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(A6,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:e.jsx(xh,{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(E6t,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:e.jsx(Ii,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Valentine's Day, ${t}!`:"Happy Valentine's Day!",subText:"A heartfelt message from your real estate professional",gradientClasses:"from-rose-50/80 via-pink-50/60 to-red-50/40 dark:from-rose-950/30 dark:via-pink-950/20 dark:to-red-950/20",accentColor:"rose",decorativeElement:e.jsx(P6t,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(Rb,{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(I6t,{})},{id:"new_years",name:"New Year's Day",description:"Ring in the new year",icon:e.jsx(Kn,{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(C6t,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(cM,{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(j6t,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(Fx,{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(b6t,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(fc,{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(w6t,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(Xv,{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(v6t,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:e.jsx(Fh,{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(_6t,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(fc,{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(A6t,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx($4,{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(k6t,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:e.jsx(Ii,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Thanksgiving, ${t}!`:"Happy Thanksgiving!",subText:"Grateful for you and your friendship",gradientClasses:"from-orange-50/70 via-amber-50/50 to-red-50/40 dark:from-orange-950/30 dark:via-amber-950/20 dark:to-red-950/20",accentColor:"orange",decorativeElement:e.jsx(S6t,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(Fb,{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(N6t,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx(hn,{className:"h-5 w-5"}),category:"holidays",headerText:t=>t?`Happy Hanukkah, ${t}!`:"Happy Hanukkah!",subText:"Wishing you eight nights of light and joy",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-sky-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-sky-950/20",accentColor:"blue",decorativeElement:e.jsx(M6t,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx($v,{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(T6t,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(Rn,{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(L6t,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:e.jsx(Zd,{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(D6t,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(on,{className:"h-5 w-5"}),category:"transactional",headerText:t=>t?`Exciting News, ${t}!`:"Just Listed!",subText:"A new property is now on the market",gradientClasses:"from-blue-50/70 via-indigo-50/50 to-violet-50/40 dark:from-blue-950/30 dark:via-indigo-950/20 dark:to-violet-950/20",accentColor:"blue",decorativeElement:e.jsx(q6e,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(Td,{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(A6,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(K4,{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(Zv,{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(z6t,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:e.jsx(vp,{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(O6t,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(Rn,{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(R6t,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(Gu,{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(A6,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(fc,{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($6e,{})}],$6t=[{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 q6t(t){return a1e.filter(s=>s.category===t)}function PM(t){return a1e.find(s=>s.id===t)||a1e[0]}function U6e(){const{shareToken:t,recipientToken:s}=Po(),[r,n]=C.useState(null),[a,o]=C.useState(null),[l,i]=C.useState(null),[c,u]=C.useState(!0),[p,f]=C.useState(null),[y,_]=C.useState(!0),b=C.useRef(null),w=C.useRef(0),j=C.useRef(0),N=(()=>{const se=new URLSearchParams(window.location.search);return s||se.get("rt")||null})(),S=C.useCallback((se,ee=!1)=>{if(!N||se<=0)return;const Q=Math.max(1,Math.round(se));if(Q<=j.current)return;const re=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(N)}&e=watch&ws=${Q}`;ee&&navigator.sendBeacon?navigator.sendBeacon(re):fetch(re,{method:"GET",keepalive:ee}).catch(()=>{}),j.current=Math.max(j.current,Q)},[N]);C.useEffect(()=>{var le;if(!y||!(r!=null&&r.playback_url)||!N)return;let se=!1;const ee=()=>{w.current>0&&S(w.current,!0)},Q=()=>{document.visibilityState==="hidden"&&ee()},de=()=>{ee()},re=()=>{var we;if(se||!b.current||!((we=window.playerjs)!=null&&we.Player))return;const he=new window.playerjs.Player(b.current);he.on("timeupdate",ye=>{const je=Math.floor(Number((ye==null?void 0:ye.seconds)??0));!Number.isFinite(je)||je<=0||(w.current=Math.max(w.current,je))}),he.on("pause",()=>{w.current>0&&S(w.current)}),he.on("ended",()=>{w.current>0&&S(w.current,!0)})},ne=document.querySelector('script[data-bunny-playerjs="true"]');if((le=window.playerjs)!=null&&le.Player)re();else if(ne)ne.addEventListener("load",re,{once:!0});else{const he=document.createElement("script");he.src="https://assets.mediadelivery.net/playerjs/playerjs-latest.min.js",he.async=!0,he.defer=!0,he.dataset.bunnyPlayerjs="true",he.onload=re,document.body.appendChild(he)}return document.addEventListener("visibilitychange",Q),window.addEventListener("beforeunload",de),()=>{se=!0,document.removeEventListener("visibilitychange",Q),window.removeEventListener("beforeunload",de),ee()}},[y,r==null?void 0:r.playback_url,N,S]),C.useEffect(()=>{w.current=0,j.current=0},[N,t]),C.useEffect(()=>{const se=()=>{['[id*="lc_text_widget"]','[class*="lc-text-widget"]','[id*="chat-widget"]','[class*="chat-widget"]','iframe[src*="widgets.leadconnectorhq"]','iframe[src*="msgsndr"]',"[data-chat-widget]"].forEach(re=>{document.querySelectorAll(re).forEach(ne=>{ne.style.display="none"})})};se();const ee=[setTimeout(se,500),setTimeout(se,1500),setTimeout(se,3e3)],Q=new MutationObserver(se);return Q.observe(document.body,{childList:!0,subtree:!0}),()=>{ee.forEach(clearTimeout),Q.disconnect()}},[]),C.useEffect(()=>{(async()=>{if(!t){f("Invalid share link"),u(!1);return}const{data:ee,error:Q}=await G.from("agent_videos").select("id, title, playback_url, thumbnail_url, preview_url, duration_seconds, share_token, owner_user_id, contact_id, page_template, recipient_name").eq("share_token",t).eq("is_deleted",!1).single();if(Q||!ee){f("Video not found or has been removed"),u(!1);return}n(ee);try{await G.rpc("log_video_view",{p_video_id:ee.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch(de){console.warn("Failed to log video view:",de)}if(ee.owner_user_id){const{data:de}=await G.from("profiles").select("id, name, email, phone").eq("id",ee.owner_user_id).single();if(de){o(de);try{const{data:re}=await G.storage.from("avatars").list(`${ee.owner_user_id}`);if(re&&re.length>0){const{data:ne}=G.storage.from("avatars").getPublicUrl(`${ee.owner_user_id}/${re[0].name}`);i(ne.publicUrl)}}catch{}}}u(!1)})()},[t]);const T=se=>{if(!se)return"0:00";const ee=Math.floor(se/60),Q=se%60;return`${ee}:${Q.toString().padStart(2,"0")}`},I=se=>se.includes("iframe.mediadelivery.net/play/")?se.replace("/play/","/embed/")+"?autoplay=true&responsive=true":se,L=se=>{if(!se)return"?";const ee=se.split(" ");return ee.length>=2?`${ee[0][0]}${ee[1][0]}`.toUpperCase():se.substring(0,2).toUpperCase()},R=PM((r==null?void 0:r.page_template)||"default"),$=(r==null?void 0:r.recipient_name)||null,q=R.headerText($),V=`https://dashboard.relevelup.com/share/video/${t}`;if(c)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsx(Ss,{className:"h-8 w-8 animate-spin text-primary"})});if(p||!r)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx(Ee,{className:"max-w-md w-full",children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Nn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Video Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:p||"This video is no longer available."})]})})});const X=R.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs(qh,{children:[e.jsx("title",{children:q}),e.jsx("meta",{name:"description",content:R.subText}),e.jsx("meta",{property:"og:title",content:q}),e.jsx("meta",{property:"og:description",content:R.subText}),e.jsx("meta",{property:"og:type",content:"video.other"}),e.jsx("meta",{property:"og:url",content:V}),r.preview_url&&e.jsx("meta",{property:"og:image",content:r.preview_url}),!r.preview_url&&r.thumbnail_url&&e.jsx("meta",{property:"og:image",content:r.thumbnail_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{property:"og:video",content:r.playback_url}),e.jsx("meta",{property:"og:video:type",content:"text/html"}),e.jsx("meta",{property:"og:video:width",content:"1280"}),e.jsx("meta",{property:"og:video:height",content:"720"})]}),e.jsx("meta",{name:"twitter:card",content:"player"}),e.jsx("meta",{name:"twitter:title",content:q}),e.jsx("meta",{name:"twitter:description",content:R.subText}),r.preview_url&&e.jsx("meta",{name:"twitter:image",content:r.preview_url}),r.playback_url&&e.jsxs(e.Fragment,{children:[e.jsx("meta",{name:"twitter:player",content:r.playback_url}),e.jsx("meta",{name:"twitter:player:width",content:"1280"}),e.jsx("meta",{name:"twitter:player:height",content:"720"})]})]}),e.jsxs("div",{className:At("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",R.gradientClasses),children:[X&&R.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[X&&e.jsxs("div",{className:"text-center py-4 animate-fade-in",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:At("w-14 h-14 rounded-full flex items-center justify-center shadow-sm",R.accentColor==="primary"&&"bg-primary/10 text-primary",R.accentColor==="amber"&&"bg-amber-100 text-amber-600 dark:bg-amber-900/50 dark:text-amber-400",R.accentColor==="teal"&&"bg-teal-100 text-teal-600 dark:bg-teal-900/50 dark:text-teal-400",R.accentColor==="rose"&&"bg-rose-100 text-rose-600 dark:bg-rose-900/50 dark:text-rose-400",R.accentColor==="emerald"&&"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/50 dark:text-emerald-400",R.accentColor==="yellow"&&"bg-yellow-100 text-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400",R.accentColor==="pink"&&"bg-pink-100 text-pink-600 dark:bg-pink-900/50 dark:text-pink-400",R.accentColor==="blue"&&"bg-blue-100 text-blue-600 dark:bg-blue-900/50 dark:text-blue-400",R.accentColor==="red"&&"bg-red-100 text-red-600 dark:bg-red-900/50 dark:text-red-400",R.accentColor==="orange"&&"bg-orange-100 text-orange-600 dark:bg-orange-900/50 dark:text-orange-400",R.accentColor==="green"&&"bg-green-100 text-green-600 dark:bg-green-900/50 dark:text-green-400",R.accentColor==="violet"&&"bg-violet-100 text-violet-600 dark:bg-violet-900/50 dark:text-violet-400",R.accentColor==="sky"&&"bg-sky-100 text-sky-600 dark:bg-sky-900/50 dark:text-sky-400"),children:e.jsx("div",{className:"scale-150",children:R.icon})})}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:q}),e.jsx("p",{className:"text-muted-foreground",children:R.subText})]}),a&&e.jsxs("div",{className:"flex items-center gap-4 p-4 bg-card/90 backdrop-blur-sm rounded-lg border shadow-sm",children:[e.jsxs(yn,{className:"h-14 w-14 border-2 border-primary/20",children:[e.jsx(Da,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(vn,{className:"bg-primary/10 text-primary font-semibold",children:L(a.name)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:X?"A special video from":"A personal video from"}),e.jsx("h2",{className:"text-lg font-semibold truncate",children:a.name||"Your Agent"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Real Estate Professional"})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[a.phone&&e.jsx(K,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:e.jsx("a",{href:`tel:${a.phone}`,"aria-label":"Call agent",children:e.jsx(ea,{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(br,{className:"h-4 w-4"})})})]})]}),e.jsx(Ee,{className:"overflow-hidden shadow-lg",children:y&&r.playback_url?e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:e.jsx("iframe",{ref:b,src:I(r.playback_url),title:r.title||"Video message",className:"absolute top-0 left-0 w-full h-full",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})}):e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>_(!0),children:[r.preview_url||r.thumbnail_url?e.jsx("img",{src:r.preview_url||r.thumbnail_url||"",alt:r.title?`${r.title} video preview`:"Video message preview",className:"w-full h-full object-cover",onError:se=>{var Q;se.currentTarget.style.display="none";const ee=(Q=se.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(Nn,{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(wl,{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:T(r.duration_seconds)})]})}),!X&&e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.title||"Video Message"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:y?"Enjoy the video!":"Click to play the video"})]}),!y&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(K,{size:"lg",onClick:()=>_(!0),className:"gap-2",children:[e.jsx(wl,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(y6t,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function U6t(){return C.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(yvt,{})}function V6t(){const{token:t}=Po();return C.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(Ss,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}const H6t={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},W6t={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},e5={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function G6t(){var Q,de,re,ne;const{slugOrId:t}=Po(),[s]=Xc(),{data:r,isLoading:n}=yWe(t||""),a=vWe(),o=ckt(),l=s.get("ref"),[i,c]=C.useState(""),[u,p]=C.useState(""),[f,y]=C.useState(""),[_,b]=C.useState(""),[w,j]=C.useState(!1),[N,S]=C.useState(!1),[T,I]=C.useState(null),[L,R]=C.useState(!1);C.useEffect(()=>{l&&o.mutate(l)},[l]);const $=le=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(le),q=async le=>{if(le.preventDefault(),!(!i.trim()||!f.trim()||!r)){j(!0);try{await a.mutateAsync({listingId:r.id,agentId:r.agent_id,firstName:i.trim(),lastName:u.trim(),email:f.trim(),phone:_.trim(),shareToken:l}),S(!0),me.success("Thanks! The agent will be in touch soon.")}catch(he){console.error("Lead submission error:",he),me.error(`Failed to submit: ${he.message||"Please try again"}`)}finally{j(!1)}}},U=(r==null?void 0:r.photos)||[],V=U.find(le=>le.is_primary)||U[0],X=()=>{T!==null&&I(T===0?U.length-1:T-1)},se=()=>{T!==null&&I(T===U.length-1?0:T+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(xs,{className:"h-8 w-32"})})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsx(xs,{className:"h-10 w-48 mb-6"}),e.jsx(xs,{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(xs,{className:"h-12 w-48"}),e.jsx(xs,{className:"h-6 w-full"}),e.jsx(xs,{className:"h-6 w-3/4"})]}),e.jsx(xs,{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(So,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:foe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Rn,{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(So,{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(qh,{children:[e.jsxs("title",{children:[ee," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${r.square_footage?r.square_footage.toLocaleString()+" sqft":""} ${e5[r.property_type]} in ${r.city}, ${r.state}. ${((Q=r.description)==null?void 0:Q.slice(0,150))||""}`}),e.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${r.slug||r.id}`}),e.jsx("meta",{property:"og:title",content:ee}),e.jsx("meta",{property:"og:description",content:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${e5[r.property_type]} in ${r.city}, ${r.state}. View photos, details, and contact the listing agent.`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:`https://listings.relevelup.com/${r.slug||r.id}`}),V&&e.jsx("meta",{property:"og:image",content:V.photo_url}),V&&e.jsx("meta",{property:"og:image:alt",content:`${r.property_address||r.city} - ${e5[r.property_type]} for sale`}),e.jsx("meta",{property:"og:site_name",content:"LevelUp Listings"}),e.jsx("meta",{property:"og:locale",content:"en_US"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:ee}),e.jsx("meta",{name:"twitter:description",content:`${$(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA in ${r.city}, ${r.state}`}),V&&e.jsx("meta",{name:"twitter:image",content:V.photo_url}),e.jsx("meta",{name:"robots",content:"index, follow"}),e.jsx("meta",{name:"geo.region",content:`US-${r.state}`}),e.jsx("meta",{name:"geo.placename",content:r.city}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"RealEstateListing",name:r.property_address||`${r.city}, ${r.state} Home`,description:r.description||`${e5[r.property_type]} for sale in ${r.city}, ${r.state}`,url:`https://listings.relevelup.com/${r.slug||r.id}`,datePosted:r.created_at,image:U.map(le=>le.photo_url),address:{"@type":"PostalAddress",streetAddress:r.property_address||void 0,addressLocality:r.city,addressRegion:r.state,addressCountry:"US"},geo:r.neighborhood?{"@type":"GeoCoordinates",name:r.neighborhood}:void 0,offers:{"@type":"Offer",price:r.price,priceCurrency:"USD",availability:r.status==="sold"?"https://schema.org/SoldOut":r.status==="under_contract"?"https://schema.org/LimitedAvailability":"https://schema.org/InStock"},numberOfRooms:r.bedrooms||void 0,numberOfBathroomsTotal:r.bathrooms||void 0,floorSize:r.square_footage?{"@type":"QuantitativeValue",value:r.square_footage,unitCode:"FTK"}:void 0,yearBuilt:r.year_built||void 0,broker:r.agent?{"@type":"RealEstateAgent",name:r.agent.name,email:r.agent.email,worksFor:(de=r.agent.brokerage)!=null&&de.name?{"@type":"RealEstateAgent",name:r.agent.brokerage.name}:void 0}:void 0})})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(So,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:foe,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs(So,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(di,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),U.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>I(0),children:e.jsx("img",{src:V==null?void 0:V.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${e5[r.property_type]} main photo`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:U.slice(1,5).map((le,he)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>I(he+1),children:[e.jsx("img",{src:le.photo_url,alt:`${r.property_address||r.city} - Photo ${he+2} of ${U.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),he===3&&U.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",U.length-5," more"]})]},le.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx(nt,{className:`${H6t[r.status]} text-white border-0`,children:W6t[r.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:$(r.price)}),r.property_address&&e.jsx("p",{className:"text-xl font-medium",children:r.property_address}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(Ui,{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(Kv,{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(n0,{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(c0,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.square_footage.toLocaleString()}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),r.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(on,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"text-xl font-semibold",children:r.year_built}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(nt,{variant:"secondary",children:[e.jsx(La,{className:"h-3 w-3 mr-1"}),e5[r.property_type]]}),r.lot_size&&e.jsxs(nt,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(nt,{variant:"secondary",children:"HOA"})]}),r.description&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})]}),r.agent_notes&&r.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.agent_notes})]}),r.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:r.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[r.video&&r.video.playback_url&&e.jsx(Ee,{className:"overflow-hidden bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:e.jsxs(Oe,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>R(!0),children:[r.video.thumbnail_url?e.jsx("img",{src:r.video.thumbnail_url,alt:"Video thumbnail",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gradient-to-br from-primary/20 to-primary/30",children:e.jsx(Nn,{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(wl,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs(K,{onClick:()=>R(!0),className:"w-full gap-2",size:"lg",children:[e.jsx(wl,{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(It,{children:e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(ro,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Oe,{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(It,{children:e.jsx(Ot,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Oe,{children:N?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:e.jsx(br,{className:"h-6 w-6 text-primary"})}),e.jsx("p",{className:"font-medium",children:"Thanks for your interest!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The listing agent will contact you soon."})]}):e.jsxs("form",{onSubmit:q,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"firstName",children:"First Name *"}),e.jsx(Fe,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:le=>c(le.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"lastName",children:"Last Name"}),e.jsx(Fe,{id:"lastName",type:"text",placeholder:"Doe",value:u,onChange:le=>p(le.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"email",children:"Email *"}),e.jsx(Fe,{id:"email",type:"email",placeholder:"you@example.com",value:f,onChange:le=>y(le.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"phone",children:"Phone"}),e.jsx(Fe,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:_,onChange:le=>b(le.target.value)})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:w,children:w?"Submitting...":"Get More Info"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),e.jsx(_s,{open:T!==null,onOpenChange:()=>I(null),children:e.jsxs(vs,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(Cs,{className:"sr-only",children:e.jsx(Ns,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>I(null),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Ur,{className:"h-5 w-5"})}),T!==null&&U[T]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:U[T].photo_url,alt:`Photo ${T+1}`,className:"w-full max-h-[80vh] object-contain"}),U.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:X,className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Xl,{className:"h-6 w-6"})}),e.jsx("button",{onClick:se,className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Xa,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 text-white bg-black/50 px-3 py-1 rounded-full text-sm",children:[T+1," / ",U.length]})]})]})]})}),e.jsx(_s,{open:L,onOpenChange:R,children:e.jsxs(vs,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(Cs,{className:"sr-only",children:e.jsx(Ns,{children:"Video Tour"})}),e.jsx("button",{onClick:()=>R(!1),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:e.jsx(Ur,{className:"h-5 w-5"})}),((ne=r==null?void 0:r.video)==null?void 0:ne.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 K6t(){var o;const{slug:t}=Po(),{data:s,isLoading:r,error:n}=jWe(t);if(C.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),C.useEffect(()=>{s!=null&&s.id&&ho(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(xs,{className:"h-28 w-28 rounded-full"}),e.jsx(xs,{className:"h-6 w-48"}),e.jsx(xs,{className:"h-4 w-36"})]}),e.jsx(xs,{className:"h-12 w-full"}),e.jsx(xs,{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(qh,{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(Qwe,{card:s})]})}function iYe({slugOverride:t}={}){var Se;const{slug:s}=Po(),r=t||s,[n]=Xc(),a=n.get("t"),[o,l]=C.useState(!0),[i,c]=C.useState(null),[u,p]=C.useState(null),f=C.useRef(null),y=C.useRef(null),[_,b]=C.useState(null),[w,j]=C.useState(null),[N,S]=C.useState(!1),[T,I]=C.useState(!1),[L,R]=C.useState(0),[$,q]=C.useState(!1),[U,V]=C.useState(""),[X,se]=C.useState(""),[ee,Q]=C.useState(""),[de,re]=C.useState(""),[ne,le]=C.useState(""),[he,we]=C.useState(""),[ye,je]=C.useState(""),[ke,We]=C.useState(""),[be,Me]=C.useState(""),[Ae,Re]=C.useState(""),[Te,qe]=C.useState(""),[ct,De]=C.useState("");C.useEffect(()=>{Rt()},[r,a]);const Rt=async()=>{if(!r)return;l(!0);const{data:it,error:$e}=await G.from("contact_intake_pages").select("*").eq("slug",r).eq("is_active",!0).maybeSingle();if($e||!it){q(!0),l(!1);return}p(it),y.current=it;const{data:ot}=await G.from("profiles").select("name, avatar_url, title, phone, email, brokerage_id").eq("id",it.user_id).single();if(ot){let Ue;if(ot.brokerage_id){const{data:He}=await G.from("brokerages").select("name").eq("id",ot.brokerage_id).single();Ue=(He==null?void 0:He.name)||void 0}let Ke=ot.avatar_url||null;if(!Ke){const{data:He}=G.storage.from("avatars").getPublicUrl(`${it.user_id}/avatar.jpg`);He!=null&&He.publicUrl&&(Ke=`${He.publicUrl}?t=${Date.now()}`)}const Xe={...ot,avatar_url:Ke,brokerage_name:Ue};c(Xe),f.current=Xe}if(a)try{console.log("[ConnectPage] Resolving token:",a,"for page:",it.id);const{data:Ue,error:Ke}=await G.functions.invoke("process-intake-submissions",{body:{action:"resolve_token",token:a,page_id:it.id}});if(console.log("[ConnectPage] Resolve result:",{resolved:Ue,resolveErr:Ke}),!Ke&&(Ue!=null&&Ue.contact_id)){j(Ue.contact_id);const Xe=Ue.contact;Xe&&(b(Xe),V(Xe.first_name||""),se(Xe.last_name||""),Q(Xe.email||""),re(Xe.phone||""),le(Xe.address||""),we(Xe.city||""),je(Xe.state||""),We(Xe.zip||""),Me(Xe.birthday||""),Re(Xe.home_anniversary||""))}}catch(Ue){console.error("Failed to resolve token:",Ue)}l(!1)},pe=async()=>{var it,$e;if(!U.trim()){me.error("Please enter your first name");return}if(!r){me.error("Invalid page. Please refresh.");return}I(!0);try{let ot=(it=y.current)==null?void 0:it.id,Ue=($e=y.current)==null?void 0:$e.user_id;if(!ot||!Ue){const{data:Xe}=await G.from("contact_intake_pages").select("id, user_id").eq("slug",r).eq("is_active",!0).maybeSingle();if(!Xe){me.error("This page is no longer active. Please contact the agent directly."),I(!1);return}ot=Xe.id,Ue=Xe.user_id}const{error:Ke}=await G.from("contact_intake_submissions").insert({intake_page_id:ot,agent_user_id:Ue,existing_contact_id:w,first_name:U.trim(),last_name:X.trim()||null,email:ee.trim()||null,phone:de.trim()||null,address:ne.trim()||null,city:he.trim()||null,state:ye.trim()||null,zip:ke.trim()||null,birthday:be||null,home_anniversary:Ae||null,real_estate_interest:Te||null,message:ct.trim()||null});if(console.log("[ConnectPage] Insert result:",{error:Ke}),Ke)throw Ke;a&&await G.from("contact_intake_tokens").update({used_at:new Date().toISOString()}).eq("token",a);try{const Xe=[U.trim(),X.trim()].filter(Boolean).join(" ");await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/connect-page-notify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentUserId:Ue,contactName:Xe,contactEmail:ee.trim()||null,contactPhone:de.trim()||null,slug:r})})}catch(Xe){console.warn("Connect page notification failed (non-blocking):",Xe)}S(!0)}catch(ot){console.error(ot),me.error("Something went wrong. Please try again.")}finally{I(!1)}};if(o)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsx(Ss,{className:"h-8 w-8 animate-spin text-slate-400"})});if($)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("h1",{className:"text-2xl font-semibold text-slate-700",children:"Page Not Found"}),e.jsx("p",{className:"text-slate-500",children:"This connect page doesn't exist or is no longer active."})]})});if(N)return e.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-slate-50 via-white to-blue-50 p-4",children:[e.jsx(qh,{children:e.jsxs("title",{children:["Thank You | ",i==null?void 0:i.name]})}),e.jsxs(wr.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"max-w-md w-full text-center space-y-6 p-8",children:[e.jsx(wr.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",delay:.2},className:"mx-auto w-20 h-20 rounded-full bg-emerald-100 flex items-center justify-center",children:e.jsx(ha,{className:"h-10 w-10 text-emerald-600"})}),e.jsx("h1",{className:"text-3xl font-bold text-slate-800",children:"Thank You!"}),e.jsxs("p",{className:"text-lg text-slate-600",children:[i==null?void 0:i.name," has received your info and will be in touch soon."]}),e.jsxs("div",{className:"flex items-center justify-center gap-1 text-sm text-slate-400 pt-4",children:[e.jsx(Ii,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})]})]});const Je=!!a&&!!_,lt=3,rt=[{title:Je?"Confirm Your Info":"Let's Get Connected",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"First Name *"}),e.jsx("input",{type:"text",value:U,onChange:it=>V(it.target.value),placeholder:"Jane",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Last Name"}),e.jsx("input",{type:"text",value:X,onChange:it=>se(it.target.value),placeholder:"Smith",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Email"}),e.jsx("input",{type:"email",value:ee,onChange:it=>Q(it.target.value),placeholder:"jane@email.com",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Phone"}),e.jsx("input",{type:"tel",value:de,onChange:it=>re(it.target.value),placeholder:"(555) 123-4567",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]})},{title:"A Little More About You",fields:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Street Address"}),e.jsx("input",{type:"text",value:ne,onChange:it=>le(it.target.value),placeholder:"123 Main St",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"grid grid-cols-5 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"City"}),e.jsx("input",{type:"text",value:he,onChange:it=>we(it.target.value),placeholder:"Austin",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"col-span-1",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"State"}),e.jsx("input",{type:"text",value:ye,onChange:it=>je(it.target.value),placeholder:"TX",maxLength:2,className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Zip"}),e.jsx("input",{type:"text",value:ke,onChange:it=>We(it.target.value),placeholder:"78701",className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Birthday"}),e.jsx("input",{type:"date",value:be,onChange:it=>Me(it.target.value),className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:"Home Anniversary"}),e.jsx("input",{type:"date",value:Ae,onChange:it=>Re(it.target.value),className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all"})]})]})]})},{title:"One Last Thing",fields:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-600 mb-3",children:["Are you thinking about making a move anytime soon? ",e.jsx("span",{className:"text-slate-400 font-normal",children:"(totally optional)"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{value:"buying",label:"🏠 Buying",desc:"Looking for a home"},{value:"selling",label:"📋 Selling",desc:"Thinking of selling"},{value:"both",label:"🔄 Both",desc:"Buy & sell"},{value:"not_now",label:"😊 Not right now",desc:"Just staying connected"}].map(it=>e.jsxs("button",{type:"button",onClick:()=>qe(Te===it.value?"":it.value),className:`p-3.5 rounded-xl border-2 text-left transition-all ${Te===it.value?"border-blue-500 bg-blue-50 shadow-sm":"border-slate-200 bg-white hover:border-slate-300"}`,children:[e.jsx("span",{className:"block text-sm font-medium text-slate-800",children:it.label}),e.jsx("span",{className:"block text-xs text-slate-500 mt-0.5",children:it.desc})]},it.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-600 mb-1.5",children:["Anything else you'd like to share? ",e.jsx("span",{className:"text-slate-400 font-normal",children:"(optional)"})]}),e.jsx("textarea",{value:ct,onChange:it=>De(it.target.value),placeholder:"Feel free to drop a note...",rows:3,className:"w-full px-4 py-3 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/40 focus:border-blue-400 transition-all resize-none"})]})]})}];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-blue-50",children:[e.jsxs(qh,{children:[e.jsxs("title",{children:["Connect with ",(i==null?void 0:i.name)||"Agent"]}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-8 sm:py-12",children:[e.jsxs(wr.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"text-center mb-8",children:[i!=null&&i.avatar_url?e.jsx("img",{src:i.avatar_url,alt:i.name,className:"w-24 h-24 rounded-full object-cover mx-auto mb-4 ring-4 ring-white shadow-lg"}):e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-blue-500 to-indigo-600 mx-auto mb-4 flex items-center justify-center ring-4 ring-white shadow-lg",children:e.jsx("span",{className:"text-3xl font-bold text-white",children:((Se=i==null?void 0:i.name)==null?void 0:Se.charAt(0))||"?"})}),e.jsx("h1",{className:"text-2xl font-bold text-slate-800",children:i==null?void 0:i.name}),(i==null?void 0:i.title)&&e.jsx("p",{className:"text-slate-500 mt-0.5",children:i.title}),(i==null?void 0:i.brokerage_name)&&e.jsx("p",{className:"text-sm text-slate-400",children:i.brokerage_name}),((i==null?void 0:i.phone)||(i==null?void 0:i.email))&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[(i==null?void 0:i.phone)&&e.jsx("a",{href:`tel:${i.phone}`,className:"flex items-center justify-center w-10 h-10 rounded-full bg-blue-50 hover:bg-blue-100 text-blue-600 transition-colors","aria-label":"Call agent",children:e.jsx(ea,{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(br,{className:"h-4.5 w-4.5"})})]})]}),e.jsx(wr.p,{initial:{opacity:0},animate:{opacity:1},transition:{delay:.2},className:"text-center text-slate-600 mb-8 px-4 leading-relaxed",children:(u==null?void 0:u.welcome_message)||"I'd love to stay connected! Fill in your info below."}),e.jsx("div",{className:"flex gap-2 mb-8 px-2",children:Array.from({length:lt}).map((it,$e)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-500 ${$e<=L?"bg-blue-500":"bg-slate-200"}`},$e))}),e.jsxs(wr.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},className:"bg-white rounded-2xl shadow-lg shadow-slate-200/50 border border-slate-100 p-6 sm:p-8",children:[e.jsx(qKe,{mode:"wait",children:e.jsxs(wr.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.25},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx(hn,{className:"h-5 w-5 text-blue-500"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-800",children:rt[L].title})]}),rt[L].fields]},L)}),e.jsxs("div",{className:"flex justify-between mt-8",children:[L>0?e.jsx("button",{type:"button",onClick:()=>R(it=>it-1),className:"px-5 py-2.5 text-sm font-medium text-slate-600 hover:text-slate-800 transition-colors",children:"Back"}):e.jsx("div",{}),L{if(L===0&&!U.trim()){me.error("Please enter your first name");return}R(it=>it+1)},className:"px-6 py-2.5 bg-blue-600 text-white text-sm font-medium rounded-xl hover:bg-blue-700 transition-colors shadow-sm",children:"Continue"}):e.jsx("button",{type:"button",onClick:()=>pe(),disabled:T,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:T?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):"Submit"})]}),L>0&&LR(it=>it+1),className:"text-xs text-slate-400 hover:text-slate-500 transition-colors",children:"Skip this step"})})]}),e.jsx("div",{className:"text-center mt-8",children:e.jsxs("div",{className:"flex items-center justify-center gap-1 text-xs text-slate-400",children:[e.jsx(Ii,{className:"h-3 w-3"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})})]})]})}function E6({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=C.useState(0),[o,l]=C.useState(!1),i=C.useCallback(()=>{a(f=>(f+1)%t.length)},[t.length]),c=C.useCallback(()=>{a(f=>(f-1+t.length)%t.length)},[t.length]),u=C.useCallback(f=>{a(f)},[]);if(C.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:At("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:At("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(Xl,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:At("absolute right-2 top-1/2 -translate-y-1/2 bg-black/30 hover:bg-black/50 text-white rounded-full","opacity-0 transition-opacity",o&&"opacity-100"),onClick:i,children:e.jsx(Xa,{className:"h-6 w-6"})})]}),t.length>1&&e.jsx("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex gap-2",children:t.map((f,y)=>e.jsx("button",{onClick:()=>u(y),className:At("w-2 h-2 rounded-full transition-all duration-300",y===n?"bg-white w-6":"bg-white/50 hover:bg-white/70"),"aria-label":`Go to slide ${y+1}`},y))})]}),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 Z6t(t){return"EST"}function B8(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=Z6t();return`${r} ${n}`}function IM(t){const s=new Date,r=new Date(t),n=R5(r,-15),a=R5(r,30);return s>a?"ended":Ax(s,{start:r,end:a})?"live":Ax(s,{start:n,end:r})?"starting_soon":"upcoming"}function ake(t){const s=IM(t);return s==="starting_soon"||s==="live"}const V6e=ake,Y6t=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=C.useState(new Date);C.useEffect(()=>{const _=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(_)},[]);const o=t.filter(_=>ake(_.event_date));if(o.length===0)return null;const l=o[0],i=IM(l.event_date),c=s.find(_=>_.event_id===l.id),u=(c==null?void 0:c.zoom_join_url)||l.zoom_link,p=!!c,f=i==="live",y=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 ${y.container} border`,children:[e.jsx("div",{className:`absolute inset-0 bg-gradient-to-r ${y.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 ${y.indicator} opacity-75`}),e.jsx("span",{className:`relative flex h-3 w-3 rounded-full ${y.indicator}`})]}),e.jsx("div",{className:`flex items-center gap-2 ${y.text} font-bold text-sm uppercase tracking-wider`,children:f?e.jsxs(e.Fragment,{children:[e.jsx(n1,{className:"h-4 w-4"}),"Live Now"]}):e.jsxs(e.Fragment,{children:[e.jsx(Tn,{className:"h-4 w-4"}),"Starting Soon"]})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-lg text-foreground line-clamp-1",children:l.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?`Started at ${B8(new Date(l.event_date))}`:`Starts at ${B8(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:`${y.button} text-white gap-2`,children:[e.jsx(rn,{className:"h-4 w-4"}),f?"Join Now":"Join When Live"]}):e.jsxs(K,{variant:"outline",onClick:r,className:`${y.outlineButton} gap-2`,children:[e.jsx(mr,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var ike="Progress",oke=100,[X6t]=Yc(ike),[Q6t,J6t]=X6t(ike),oYe=C.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=eIt,...l}=t;(a||a===0)&&!H6e(a)&&console.error(tIt(`${a}`,"Progress"));const i=H6e(a)?a:oke;n!==null&&!W6e(n,i)&&console.error(sIt(`${n}`,"Progress"));const c=W6e(n,i)?n:null,u=Boe(c)?o(c,i):void 0;return e.jsx(Q6t,{scope:r,value:c,max:i,children:e.jsx(Jr.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":Boe(c)?c:void 0,"aria-valuetext":u,role:"progressbar","data-state":dYe(c,i),"data-value":c??void 0,"data-max":i,...l,ref:s})})});oYe.displayName=ike;var lYe="ProgressIndicator",cYe=C.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=J6t(lYe,r);return e.jsx(Jr.div,{"data-state":dYe(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});cYe.displayName=lYe;function eIt(t,s){return`${Math.round(t/s*100)}%`}function dYe(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function Boe(t){return typeof t=="number"}function H6e(t){return Boe(t)&&!isNaN(t)&&t>0}function W6e(t,s){return Boe(t)&&!isNaN(t)&&t<=s&&t>=0}function tIt(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${oke}\`.`}function sIt(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 ${oke} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var uYe=oYe,rIt=cYe;const Oi=C.forwardRef(({className:t,value:s,...r},n)=>e.jsx(uYe,{ref:n,className:At("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(rIt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));Oi.displayName=uYe.displayName;function nIt(){const{user:t,isBrokerageManager:s}=Ws(),[r,n]=C.useState([]),[a,o]=C.useState([]),[l,i]=C.useState(!1),[c,u]=C.useState(!0),p=s?"brokerage_manager":"agent";C.useEffect(()=>{if(!(t!=null&&t.id)){u(!1);return}f()},[t==null?void 0:t.id,p]);const f=async()=>{if(t!=null&&t.id)try{const{data:I,error:L}=await G.from("onboarding_checklist_items").select("*").eq("target_role",p).eq("is_active",!0).order("sort_order");if(L)throw L;const{data:R,error:$}=await G.from("onboarding_checklist_progress").select("item_id, completed_at").eq("user_id",t.id);if($)throw $;const{data:q,error:U}=await G.from("onboarding_checklist_dismissed").select("id").eq("user_id",t.id).maybeSingle();if(U)throw U;n(I||[]),o(R||[]),i(!!q),I&&I.length>0&&await y(I,R||[])}catch(I){console.error("Error fetching checklist data:",I)}finally{u(!1)}},y=async(I,L)=>{var Re,Te;if(!(t!=null&&t.id))return;const R=L.map(qe=>qe.item_id),$=I.filter(qe=>!R.includes(qe.id));if($.length===0)return;const[q,U,V,X,se,ee,Q,de,re,ne,le,he,we,ye,je]=await Promise.all([G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle(),G.from("resource_shares").select("id",{count:"exact",head:!0}).eq("sender_id",t.id),G.from("community_posts").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("event_registrations").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","template"),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","academy_video"),G.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id).eq("resource_type","toolbox"),G.from("activity_logs").select("id",{count:"exact",head:!0}).eq("user_id",t.id),G.from("innercircle_contacts").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("agent_videos").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("contact_touch_logs").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("scorecard_transactions").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id),G.from("listings").select("id",{count:"exact",head:!0}).eq("agent_id",t.id),G.from("innercircle_contacts").select("id").eq("owner_user_id",t.id),G.from("deal_pipeline").select("id",{count:"exact",head:!0}).eq("owner_user_id",t.id)]),ke={},We=(Re=q.data)==null?void 0:Re.brokerage_id;ke.share_resource=(U.count||0)>0,ke.post_community=(V.count||0)>0,ke.register_event=(X.count||0)>0,ke.view_template=(se.count||0)>0,ke.watch_academy=(ee.count||0)>0,ke.use_toolbox=(Q.count||0)>0,ke.launch_app=(de.count||0)>0,ke.add_contact=(re.count||0)>0,ke.create_video=(ne.count||0)>0,ke.complete_touch=(le.count||0)>0,ke.add_transaction=(he.count||0)>0,ke.add_listing=(we.count||0)>0,ke.add_deal=(je.count||0)>0;const be=((Te=ye.data)==null?void 0:Te.map(qe=>qe.id))||[],Me=[];We?Me.push(G.from("profiles").select("id").eq("brokerage_id",We).neq("id",t.id).then(qe=>{var ct;ke.add_agent=(((ct=qe.data)==null?void 0:ct.length)||0)>0})):ke.add_agent=!1,be.length>0?(Me.push(G.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",be).then(qe=>{ke.add_plan=(qe.count||0)>0})),Me.push(G.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",be).then(qe=>{ke.schedule_popby=(qe.count||0)>0}))):(ke.add_plan=!1,ke.schedule_popby=!1),await Promise.all(Me);const Ae=$.filter(qe=>ke[qe.action_type]);if(Ae.length>0){const qe=Ae.map(De=>({user_id:t.id,item_id:De.id})),{error:ct}=await G.from("onboarding_checklist_progress").upsert(qe,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!ct){const De=Ae.map(Rt=>({item_id:Rt.id,completed_at:new Date().toISOString()}));o(Rt=>[...Rt,...De])}}},_=async I=>{if(t!=null&&t.id)try{const{error:L}=await G.from("onboarding_checklist_progress").insert({user_id:t.id,item_id:I});if(L)throw L;o(R=>[...R,{item_id:I,completed_at:new Date().toISOString()}])}catch(L){console.error("Error marking item complete:",L)}},b=async()=>{if(t!=null&&t.id)try{const{error:I}=await G.from("onboarding_checklist_dismissed").insert({user_id:t.id});if(I)throw I;i(!0)}catch(I){console.error("Error dismissing checklist:",I)}},w=a.length,j=r.length,N=j>0&&w>=j,S=j>0?w/j*100:0;return{items:r,progress:a,isDismissed:l,loading:c,completedCount:w,totalCount:j,isComplete:N,progressPercentage:S,isItemComplete:I=>a.some(L=>L.item_id===I),markComplete:_,dismiss:b,refetch:f}}const aIt={add_agent:e.jsx(mr,{className:"h-4 w-4"}),share_resource:e.jsx(Ad,{className:"h-4 w-4"}),post_community:e.jsx(po,{className:"h-4 w-4"}),register_event:e.jsx(on,{className:"h-4 w-4"}),view_template:e.jsx(Av,{className:"h-4 w-4"}),watch_academy:e.jsx(zh,{className:"h-4 w-4"}),use_toolbox:e.jsx(Kx,{className:"h-4 w-4"}),launch_app:e.jsx(NI,{className:"h-4 w-4"}),add_deal:e.jsx(i0,{className:"h-4 w-4"}),add_listing:e.jsx(Rn,{className:"h-4 w-4"})},iIt={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function oIt(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:c,dismiss:u}=nIt(),p=Pr(),[f,y]=C.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(It,{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(o0,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{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:()=>y(!f),className:"h-8 w-8 p-0",children:f?e.jsx(Hx,{className:"h-4 w-4"}):e.jsx(tl,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",children:e.jsx(Ur,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm mb-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Progress"}),e.jsxs("span",{className:"font-medium",children:[n," of ",a," complete"]})]}),e.jsx(Oi,{value:l,className:"h-2"})]})]}),f&&e.jsx(Oe,{className:"pt-0",children:e.jsx("div",{className:"space-y-3",children:t.map(_=>{const b=i(_.id);return e.jsxs("div",{className:At("flex items-start gap-3 p-3 rounded-lg transition-colors",b?"bg-muted/50":"bg-background hover:bg-muted/30 cursor-pointer"),onClick:()=>{if(b)return;const w=iIt[_.action_type];w?p(w):c(_.id)},children:[e.jsx("div",{className:"mt-0.5",children:b?e.jsx(ha,{className:"h-5 w-5 text-primary"}):e.jsx(pd,{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:aIt[_.action_type]||e.jsx(pd,{className:"h-4 w-4"})}),e.jsx("span",{className:At("font-medium",b&&"line-through text-muted-foreground"),children:_.title})]}),_.description&&e.jsx("p",{className:At("text-sm text-muted-foreground mt-1",b&&"line-through"),children:_.description})]})]},_.id)})})})]})}const Rg=()=>wt({queryKey:["relationship-types"],queryFn:async()=>{const{data:t,error:s}=await G.from("relationship_types").select("*").order("sort_order");if(s)throw s;return t}}),Fm=t=>{const s=ai(),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=G.from("innercircle_contacts").select(` *, lead_source_ref:lead_sources(id, name), tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("owner_user_id",s).order("created_at",{ascending:!1}).order("first_name");return await n(a)},enabled:!!s})},lIt=t=>wt({queryKey:["innercircle-contact",t],queryFn:async()=>{const{data:s,error:r}=await G.from("innercircle_contacts").select(` *, lead_source_ref:lead_sources(id, name), tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("id",t).maybeSingle();if(r)throw r;return s},enabled:!!t}),hYe=()=>{const t=ai();return wt({queryKey:["innercircle-contact-counts",t],queryFn:async()=>{const{data:s,error:r}=await G.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(r)throw r;const n={};return s==null||s.forEach(a=>{var o;(o=a.tags)==null||o.forEach(l=>{n[l.relationship_type_id]=(n[l.relationship_type_id]||0)+1})}),n},enabled:!!t})},uue=()=>{const t=ss(),s=ai();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 G.from("innercircle_contacts").insert(o).select().single();if(i)throw i;if(n&&n.length>0){const{error:c}=await G.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"]}),fn({title:"Contact created successfully"})},onError:r=>{fn({title:"Error creating contact",description:r.message,variant:"destructive"})}})},lke=()=>{const t=ss();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 G.from("innercircle_contacts").update(l).eq("id",s).select().single();if(c)throw c;if(n!==void 0&&(await G.from("innercircle_contact_tags").delete().eq("contact_id",s),n.length>0)){const{error:u}=await G.from("innercircle_contact_tags").insert(n.map(p=>({contact_id:s,relationship_type_id:p})));if(u)throw u}return i},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),fn({title:"Contact updated successfully"})},onError:s=>{fn({title:"Error updating contact",description:s.message,variant:"destructive"})}})},mYe=()=>{const t=ss();return Dt({mutationFn:async({contactId:s,spouseContactId:r})=>{if(r){const{error:n}=await G.from("innercircle_contacts").update({spouse_contact_id:r}).eq("id",s);if(n)throw n;const{error:a}=await G.from("innercircle_contacts").update({spouse_contact_id:s}).eq("id",r);if(a)throw a}else{const{data:n}=await G.from("innercircle_contacts").select("spouse_contact_id").eq("id",s).single(),a=n==null?void 0:n.spouse_contact_id,{error:o}=await G.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",s);if(o)throw o;if(a){const{error:l}=await G.from("innercircle_contacts").update({spouse_contact_id:null}).eq("id",a);if(l)throw l}}},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact"]}),t.invalidateQueries({queryKey:["innercircle-contact-spouse"]}),fn({title:"Spouse link updated"})},onError:s=>{fn({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},cke=()=>{const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("innercircle_contacts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),fn({title:"Contact deleted successfully"})},onError:s=>{fn({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},bO=()=>wt({queryKey:["action-types"],queryFn:async()=>{const{data:t,error:s}=await G.from("action_types").select("*").order("sort_order");if(s)throw s;return t}}),cIt=t=>wt({queryKey:["action-scripts",t],queryFn:async()=>{let s=G.from("action_scripts").select("*, action_type:action_types(*)");const{data:r,error:n}=await s;if(n)throw n;return r}}),dIt=()=>wt({queryKey:["touchpoint-plans"],queryFn:async()=>{const{data:t,error:s}=await G.from("touchpoint_plans").select(` *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) `).order("name");if(s)throw s;return t}}),uIt=()=>{const t=ss(),s=ai();return Dt({mutationFn:async({name:r,description:n})=>{const{data:a,error:o}=await G.from("touchpoint_plans").insert({name:r,description:n,owner_user_id:s,active:!0,is_template:!1}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),fn({title:"Plan created successfully"})},onError:r=>{fn({title:"Error creating plan",description:r.message,variant:"destructive"})}})},hIt=()=>{const t=ss(),s=ai();return Dt({mutationFn:async({sourcePlanId:r,newName:n})=>{const{data:a,error:o}=await G.from("touchpoint_plans").select(` *, items:touchpoint_plan_items(*) `).eq("id",r).single();if(o)throw o;if(!a)throw new Error("Source plan not found");const{data:l,error:i}=await G.from("touchpoint_plans").insert({name:n,description:a.description,owner_user_id:s,active:!0,is_template:!1}).select().single();if(i)throw i;if(a.items&&a.items.length>0){const 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 G.from("touchpoint_plan_items").insert(c);if(u)throw u}return l},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),fn({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{fn({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},mIt=()=>{const t=ss();return Dt({mutationFn:async({id:s,name:r,description:n})=>{const{data:a,error:o}=await G.from("touchpoint_plans").update({name:r,description:n}).eq("id",s).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),fn({title:"Plan updated successfully"})}})},pIt=()=>{const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("touchpoint_plans").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),fn({title:"Plan deleted successfully"})}})},fIt=()=>{const t=ss();return Dt({mutationFn:async({planId:s,items:r})=>{if(await G.from("touchpoint_plan_items").delete().eq("plan_id",s),r.length>0){const{error:n}=await G.from("touchpoint_plan_items").insert(r.map(a=>({plan_id:s,month_number:a.month_number,action_type_id:a.action_type_id,default_script_id:a.default_script_id||null,notes:a.notes})));if(n)throw n}},onSuccess:()=>{t.invalidateQueries({queryKey:["touchpoint-plans"]}),fn({title:"Plan schedule updated"})}})},gIt=()=>{const t=ss();return Dt({mutationFn:async({actionTypeId:s,title:r,scriptBody:n,emailSubject:a,tone:o})=>{const{data:{user:l}}=await G.auth.getUser(),{data:i,error:c}=await G.from("action_scripts").insert({action_type_id:s,title:r,script_body:n,email_subject:a||null,tone:o||null,active:!0,user_id:l==null?void 0:l.id}).select().single();if(c)throw c;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["action-scripts"]}),fn({title:"Script created successfully"})},onError:s=>{fn({title:"Error creating script",description:s.message,variant:"destructive"})}})},xIt=()=>{const t=ai();return wt({queryKey:["user-plan-enrollments",t],queryFn:async()=>{const{data:s,error:r}=await G.from("user_plan_enrollments").select(` *, plan:touchpoint_plans(*), relationship_type:relationship_types(*) `);if(r)throw r;return s},enabled:!!t})},yIt=()=>{const t=ss(),s=ai();return Dt({mutationFn:async({planId:r,relationshipTypeId:n,active:a})=>{const{data:o}=await G.from("user_plan_enrollments").select("id").eq("plan_id",r).eq("relationship_type_id",n).maybeSingle();if(o){const{error:l}=await G.from("user_plan_enrollments").update({active:a}).eq("id",o.id);if(l)throw l}else if(a){const{error:l}=await G.from("user_plan_enrollments").insert({owner_user_id:s,plan_id:r,relationship_type_id:n,active:!0,start_date:new Date().toISOString().split("T")[0]});if(l)throw l}},onSuccess:()=>{t.invalidateQueries({queryKey:["user-plan-enrollments"]}),fn({title:"Plan enrollment updated"})}})},wO=(t=7)=>{const s=ai();return wt({queryKey:["contact-touch-logs",s,t],queryFn:async()=>{const r=new Date;r.setDate(r.getDate()-t);const{data:n,error:a}=await G.from("contact_touch_logs").select(` *, contact:innercircle_contacts(*), action_type:action_types(*) `).eq("owner_user_id",s).gte("completed_at",r.toISOString()).order("completed_at",{ascending:!1});if(a)throw a;return n},enabled:!!s})},pYe=()=>{const t=ai();return wt({queryKey:["contacts-last-touch",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_touch_logs").select("contact_id, completed_at").eq("owner_user_id",t).order("completed_at",{ascending:!1});if(r)throw r;const n={};return s==null||s.forEach(a=>{n[a.contact_id]||(n[a.contact_id]=a.completed_at)}),n},enabled:!!t})},vIt=(t=90)=>{const{data:s}=Fm(),{data:r}=pYe();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=ss(),s=ai();return Dt({mutationFn:async({contactId:r,actionTypeId:n,scriptUsedId:a,notes:o,completedAt:l})=>{const{data:i,error:c}=await G.from("contact_touch_logs").insert({owner_user_id:s,contact_id:r,action_type_id:n,script_used_id:a,notes:o,completed_at:l||new Date().toISOString()}).select().single();if(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"]}),fn({title:"Action completed!"});try{const[l,i]=await Promise.all([G.from("innercircle_contacts").select("email").eq("id",n.contactId).single(),G.from("action_types").select("name").eq("id",n.actionTypeId).single()]),c=(a=l.data)==null?void 0:a.email,u=((o=i.data)==null?void 0:o.name)||"Touch";c&&G.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{}}})},fYe="agentos_weekly_touch_goal",G6e=20,$oe=()=>{if(typeof window>"u")return G6e;const t=localStorage.getItem(fYe);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return G6e},gYe=t=>{localStorage.setItem(fYe,t.toString())},uke=()=>{const{data:t}=wO(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=$oe();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},_It=()=>{const t=ai();return wt({queryKey:["contact-plan-cycles",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_plan_cycles").select(` *, contact:innercircle_contacts(*), plan:touchpoint_plans( *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) ) `);if(r)throw r;return s},enabled:!!t})},bIt=()=>{const t=ss();return ai(),Dt({mutationFn:async()=>{const{data:s}=await G.from("user_plan_enrollments").select("*").eq("active",!0);if(!s||s.length===0)return;const{data:r}=await G.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(!r)return;const{data:n}=await G.from("contact_plan_cycles").select("contact_id, plan_id"),a=new Set((n==null?void 0:n.map(l=>`${l.contact_id}-${l.plan_id}`))||[]),o=[];for(const l of r)for(const i of l.tags||[]){const 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 G.from("contact_plan_cycles").insert(o);if(l)throw l}return o.length},onSuccess:s=>{t.invalidateQueries({queryKey:["contact-plan-cycles"]}),s&&s>0&&fn({title:`${s} contact(s) enrolled in plans`})}})},xYe=()=>{const t=ai(),{data:s}=_It(),{data:r}=wO(30);return wt({queryKey:["today-actions",t,s==null?void 0:s.length,r==null?void 0:r.length],queryFn:async()=>{var b;if(!s||s.length===0)return[];const{data:n}=await G.from("contact_snoozes").select("contact_id").gte("snoozed_until",new Date().toISOString()),a=new Set((n==null?void 0:n.map(w=>w.contact_id))||[]),o=new Date,l=[],i=new Date(o.getFullYear(),o.getMonth(),1),c=new Set((r==null?void 0:r.filter(w=>new Date(w.completed_at)>=i).map(w=>`${w.contact_id}-${w.action_type_id}`))||[]);for(const w of s){if(!((b=w.plan)!=null&&b.items)||w.plan.items.length===0||!w.contact||a.has(w.contact_id))continue;const j=new Date(w.cycle_start_date),S=Math.floor((o.getTime()-j.getTime())/(30.44*24*60*60*1e3))%12+1,T=w.plan.items.find(I=>I.month_number===S);if(T&&T.action_type){const I=`${w.contact_id}-${T.action_type_id}`;if(!c.has(I)){const{data:L}=await G.from("relationship_types").select("name").eq("id",w.relationship_type_id).single();l.push({contact:w.contact,actionType:T.action_type,script:T.default_script||void 0,planName:w.plan.name,relationshipTypeName:(L==null?void 0:L.name)||"",monthNumber:S})}}}const u=5,p=o.getDate(),f=l.sort((w,j)=>w.contact.first_name.localeCompare(j.contact.first_name)),y=(p-1)%Math.max(1,f.length);return[...f.slice(y),...f.slice(0,y)].slice(0,u)},enabled:!!t&&!!s})};function wIt(){const t=Pr(),{data:s,isLoading:r}=xYe(),{data:n}=Fm(),a=uke(),[o,l]=C.useState($oe()),[i,c]=C.useState(""),[u,p]=C.useState(!1);C.useEffect(()=>{l($oe())},[]);const f=()=>{const R=parseInt(i,10);if(isNaN(R)||R<1){fn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(R),gYe(R),p(!1),fn({title:"Goal updated",description:`Weekly touch goal set to ${R}`})},y=()=>{c(o.toString()),p(!0)},_=Pm(new Date),b=kl(_,7),w=R=>{if(!R)return null;const $=R.split(/[-/T]/);if($.length<3)return null;const q=parseInt($[1],10)-1,U=parseInt($[2],10);return isNaN(q)||isNaN(U)?null:new Date(_.getFullYear(),q,U)},j=(n==null?void 0:n.map(R=>{const $=w(R.birthday),q=w(R.home_anniversary),U=[];return $&&$>=_&&$<=b&&U.push({contact:R,type:"birthday",date:$,isToday:_l($,_)}),q&&q>=_&&q<=b&&U.push({contact:R,type:"anniversary",date:q,isToday:_l(q,_)}),U}).flat().sort((R,$)=>R.date.getTime()-$.date.getTime()).slice(0,3))||[],N=(n==null?void 0:n.filter(R=>{const $=w(R.birthday),q=w(R.home_anniversary);return $&&_l($,_)||q&&_l(q,_)}).length)||0,S=(s==null?void 0:s.length)||0,T=N+S,I=(a==null?void 0:a.actionsThisWeek)||0,L=(a==null?void 0:a.streak)||0;return r?e.jsx(Ee,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-primary/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-primary/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-primary/10 rounded w-1/2"})]})]})})}):e.jsxs(Ee,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:[e.jsxs(It,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),e.jsx("div",{className:"flex items-center gap-2",children:L>0&&e.jsxs(nt,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx(Fh,{className:"h-3 w-3"}),L," day streak"]})})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[T>0?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-primary font-medium",children:[T," tasks"]})," for today"]}):"No tasks for today",I>0&&e.jsxs("span",{className:"ml-2",children:["• ",e.jsx("span",{className:"text-emerald-600 font-medium",children:I})," touches this week"]})]})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:R=>{R.stopPropagation(),t("/mission-control/contacts?new=true")},children:[e.jsx(Pc,{className:"h-3.5 w-3.5"}),"Add Contact"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:R=>{R.stopPropagation(),t("/mission-control")},children:[e.jsx(ea,{className:"h-3.5 w-3.5"}),"Log Touch"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-emerald-200 text-emerald-700 hover:bg-emerald-50 hover:text-emerald-800",onClick:R=>{R.stopPropagation(),t("/mission-control/video/record")},children:[e.jsx(Nn,{className:"h-3.5 w-3.5"}),"Quick Video"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:R=>{R.stopPropagation(),t("/mission-control/popbys")},children:[e.jsx(Ui,{className:"h-3.5 w-3.5"}),"Pop-by Map"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5 border-purple-200 text-purple-700 hover:bg-purple-50 hover:text-purple-800",onClick:R=>{R.stopPropagation(),t("/mission-control/pipeline")},children:[e.jsx(i0,{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(Am,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Weekly Goal"}),e.jsxs(_s,{open:u,onOpenChange:p,children:[e.jsx(Fi,{asChild:!0,children:e.jsx("button",{onClick:y,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Jl,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),e.jsxs(vs,{className:"sm:max-w-[360px]",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Set Weekly Goal"}),e.jsx(Zr,{children:"How many touches do you want to complete each week?"})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"weekly-goal",children:"Weekly touch goal"}),e.jsx(Fe,{id:"weekly-goal",type:"number",min:"1",value:i,onChange:R=>c(R.target.value),placeholder:"20",onKeyDown:R=>{R.key==="Enter"&&f()}})]}),e.jsx(K,{onClick:f,className:"w-full",children:"Save Goal"})]})]})]})]}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium text-primary",children:I}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",o," touches"]})]})]}),e.jsx(Oi,{value:Math.min(I/o*100,100),className:"h-2 bg-muted [&>div]:bg-primary"}),I>=o&&e.jsxs("p",{className:"text-xs text-emerald-600 mt-1.5 flex items-center gap-1",children:[e.jsx("span",{children:"🎉"})," Goal achieved! Keep the momentum going."]}),I0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5",children:[o-I," more to hit your weekly goal"]})]}),j.length>0&&e.jsxs("div",{className:"pt-3 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(xh,{className:"h-4 w-4 text-pink-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Upcoming Milestones"})]}),e.jsx("div",{className:"space-y-2",children:j.map((R,$)=>e.jsxs("div",{className:`flex items-center justify-between p-2 rounded-lg cursor-pointer transition-colors ${R.isToday?"bg-pink-500/10 hover:bg-pink-500/15":"bg-muted/50 hover:bg-muted"}`,onClick:q=>{q.stopPropagation(),t(`/mission-control/contacts/${R.contact.id}`)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[R.type==="birthday"?e.jsx(xh,{className:"h-3.5 w-3.5 text-pink-500"}):e.jsx(Rn,{className:"h-3.5 w-3.5 text-blue-500"}),e.jsxs("span",{className:"text-sm",children:[R.contact.first_name," ",R.contact.last_name]}),R.isToday&&e.jsx(nt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-pink-500/20 text-pink-600",children:"Today!"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:R.isToday?R.type==="birthday"?"🎂":"🏠":ys(R.date,"EEE, MMM d")}),e.jsx(Xa,{className:"h-3 w-3"})]})]},`${R.contact.id}-${R.type}-${$}`))})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full gap-1 text-muted-foreground hover:text-primary",onClick:()=>t("/mission-control"),children:["Open Agent OS",e.jsx(Ki,{className:"h-4 w-4"})]})]})]})}function jIt(t){return wt({queryKey:["brokerage-content-categories",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("brokerage_content_categories").select("*").eq("brokerage_id",t).order("sort_order");if(r)throw r;return s},enabled:!!t})}function kIt(t,s){return wt({queryKey:["brokerage-content",t,s],queryFn:async()=>{if(!t)return[];let r=G.from("brokerage_content").select("*, category:brokerage_content_categories(*)").eq("brokerage_id",t).order("created_at",{ascending:!1});s&&(r=r.eq("category_id",s));const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!t})}function NIt(t,s=4){return wt({queryKey:["brokerage-content-recent",t,s],queryFn:async()=>{if(!t)return[];const{data:r,error:n}=await G.from("brokerage_content").select("*, category:brokerage_content_categories(*)").eq("brokerage_id",t).order("created_at",{ascending:!1}).limit(s);if(n)throw n;return r},enabled:!!t})}function SIt(t){const s=ss();return Dt({mutationFn:async r=>{const{data:n,error:a}=await G.from("brokerage_content").insert(r).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content"]}),s.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function CIt(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("brokerage_content").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content"]}),t.invalidateQueries({queryKey:["brokerage-content-recent"]})}})}function MIt(t){const s=ss();return Dt({mutationFn:async r=>{const{data:n,error:a}=await G.from("brokerage_content_categories").insert({...r,brokerage_id:t}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function TIt(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("brokerage_content_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}function AIt(t){const s=ss();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 G.from("brokerage_content_categories").upsert(r,{onConflict:"brokerage_id,name"});if(n)throw n},onSuccess:()=>{s.invalidateQueries({queryKey:["brokerage-content-categories"]})}})}const EIt={video:wl,pdf:In,link:sl,event:on,graphic:Ql},PIt={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 IIt(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 LIt(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 DIt({item:t}){const s=Pr(),r=EIt[t.content_type]||sl,n=PIt[t.content_type]||"",[a,o]=C.useState(null),l=t.thumbnail_url||(t.content_type==="graphic"&&t.file_url?t.file_url:null)||(t.content_type==="video"?IIt(t.url):null);C.useEffect(()=>{l||!t.url||t.content_type!=="video"||!LIt(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(c=>c.ok?c.json():null).then(c=>{c!=null&&c.thumbnail_url&&o(c.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,l]);const i=l||a;return e.jsxs(Ee,{className:"group cursor-pointer overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",onClick:()=>s(`/brokerage-content/${t.id}`),children:[i?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:i,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/20 flex items-center justify-center",children:e.jsx(r,{className:"h-8 w-8 text-muted-foreground/30"})}),e.jsxs(Oe,{className:"p-3",children:[e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsxs(nt,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${n}`,children:[e.jsx(r,{className:"h-3 w-3 mr-0.5"}),t.content_type]})}),e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:t.title}),t.content_type==="event"&&t.event_date&&e.jsx("p",{className:"text-xs text-primary mt-1 font-medium",children:ys(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function OIt(){const{brokerageId:t}=Ws(),s=Pr(),{data:r=[],isLoading:n}=NIt(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(La,{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(Ki,{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(DIt,{item:a},a.id))})]})}const yYe=()=>wt({queryKey:["listing-exchange-enabled"],queryFn:async()=>{const{data:t,error:s}=await G.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").maybeSingle();if(s)throw s;return(t==null?void 0:t.enabled)??!1}}),vYe=t=>{const{user:s,brokerageId:r}=Ws();return wt({queryKey:["listings",t,r],queryFn:async()=>{let n=G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("is_public",!0);t!=null&&t.status&&(n=n.eq("status",t.status)),t!=null&&t.propertyType&&(n=n.eq("property_type",t.propertyType)),t!=null&&t.city&&(n=n.ilike("city",`%${t.city}%`)),t!=null&&t.minPrice&&(n=n.gte("price",t.minPrice)),t!=null&&t.maxPrice&&(n=n.lte("price",t.maxPrice)),t!=null&&t.openToReferrals&&(n=n.eq("open_to_referrals",!0));const{data:a,error:o}=await n;if(o)throw o;let l=a||[];if(r){const{data:i}=await G.from("profiles").select("id").eq("brokerage_id",r);if(i&&i.length>0){const c=i.map(f=>f.id);let u=G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).eq("is_approved",!0).eq("share_with_brokerage",!0).eq("is_public",!1).in("agent_id",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(_=>_.id)),y=p.filter(_=>!f.has(_.id));l=[...l,...y]}}}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}})},_Ye=()=>{const{user:t}=Ws();return wt({queryKey:["my-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("listings").select(` *, photos:listing_photos(*) `).eq("agent_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})},bYe=t=>{const{user:s}=Ws();return wt({queryKey:["listing",t],queryFn:async()=>{const{data:r,error:n}=await G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)), video:agent_videos!listings_video_id_fkey(id, playback_url, thumbnail_url, title, duration_seconds) `).eq("id",t).single();if(n)throw n;return s&&await G.from("listing_views").insert({listing_id:t,viewer_id:s.id}),r},enabled:!!t})},RIt=()=>{const t=ss(),{user:s}=Ws();return Dt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("listings").insert({...r,agent_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},FIt=()=>{const t=ss();return Dt({mutationFn:async({agentId:s,...r})=>{const{data:n,error:a}=await G.from("listings").insert({...r,agent_id:s}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]}),t.invalidateQueries({queryKey:["brokerage-listings"]})}})},zIt=()=>{const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("listings").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]}),t.invalidateQueries({queryKey:["listing",s.id]})}})},wYe=()=>{const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("listings").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["listings"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},BIt=()=>{const t=ss();return Dt({mutationFn:async({listingId:s,photoUrl:r,isPrimary:n=!1})=>{const{data:a,error:o}=await G.from("listing_photos").insert({listing_id:s,photo_url:r,is_primary:n}).select().single();if(o)throw o;return a},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s.listing_id]}),t.invalidateQueries({queryKey:["my-listings"]})}})},$It=()=>{const t=ss();return Dt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await G.from("listing_photos").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s]}),t.invalidateQueries({queryKey:["my-listings"]})}})},qIt=()=>{const t=ss();return Dt({mutationFn:async({photos:s})=>{var o;const r=s.map(l=>G.from("listing_photos").update({sort_order:l.sort_order,is_primary:l.is_primary}).eq("id",l.id)),a=(o=(await Promise.all(r)).find(l=>l.error))==null?void 0:o.error;if(a)throw a;return s},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["listing"]}),t.invalidateQueries({queryKey:["my-listings"]})}})},UIt=()=>{const t=ss();return Dt({mutationFn:async({photoId:s,listingId:r})=>{const{error:n}=await G.from("listing_photos").update({is_primary:!1}).eq("listing_id",r);if(n)throw n;const{error:a}=await G.from("listing_photos").update({is_primary:!0}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["listing",s]}),t.invalidateQueries({queryKey:["my-listings"]})}})},VIt=()=>{const{user:t}=Ws();return wt({queryKey:["saved-listings",t==null?void 0:t.id],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("listing_saves").select(` *, listing:listings( *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id) ) `).eq("agent_id",t.id);if(r)throw r;return s},enabled:!!t})},jYe=()=>{const t=ss(),{user:s}=Ws();return Dt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await G.from("listing_saves").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await G.from("listing_saves").delete().eq("id",n.id),{saved:!1}):(await G.from("listing_saves").insert({listing_id:r,agent_id:s.id}),{saved:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["saved-listings"]}),t.invalidateQueries({queryKey:["listings"]})}})},kYe=t=>{const{user:s}=Ws();return wt({queryKey:["listing-saved",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await G.from("listing_saves").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},HIt=()=>{const t=ss(),{user:s}=Ws();return Dt({mutationFn:async r=>{if(!s)throw new Error("Not authenticated");const{data:n}=await G.from("listing_follows").select("id").eq("listing_id",r).eq("agent_id",s.id).maybeSingle();return n?(await G.from("listing_follows").delete().eq("id",n.id),{following:!1}):(await G.from("listing_follows").insert({listing_id:r,agent_id:s.id}),{following:!0})},onSuccess:()=>{t.invalidateQueries({queryKey:["listing-following"]})}})},WIt=t=>{const{user:s}=Ws();return wt({queryKey:["listing-following",t,s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:r}=await G.from("listing_follows").select("id").eq("listing_id",t).eq("agent_id",s.id).maybeSingle();return!!r},enabled:!!s&&!!t})},GIt=()=>{const{user:t}=Ws();return Dt({mutationFn:async({listingId:s,shareType:r})=>{if(!t)throw new Error("Not authenticated");const{error:n}=await G.from("listing_shares").insert({listing_id:s,sharing_agent_id:t.id,share_type:r});if(n)throw n}})},KIt=()=>{const{user:t}=Ws();return wt({queryKey:["my-referrals",t==null?void 0:t.id],queryFn:async()=>{if(!t)return{sent:[],received:[]};const[s,r]=await Promise.all([G.from("listing_referrals").select(` *, listing:listings(*,photos:listing_photos(*)) `).eq("sender_agent_id",t.id).order("created_at",{ascending:!1}),G.from("listing_referrals").select(` *, sender:profiles!listing_referrals_sender_agent_id_fkey(id, name, email), listing:listings(*,photos:listing_photos(*)) `).eq("listing_agent_id",t.id).order("created_at",{ascending:!1})]);return{sent:s.data||[],received:r.data||[]}},enabled:!!t})},ZIt=()=>{const t=ss(),{user:s}=Ws();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 G.from("listing_referrals").insert({listing_id:r,sender_agent_id:s.id,listing_agent_id:n,buyer_name:a,buyer_type:o,notes:l}).select().single();if(c)throw c;return i},onSuccess:()=>{t.invalidateQueries({queryKey:["my-referrals"]})}})},YIt=()=>wt({queryKey:["listing-leaderboard"],queryFn:async()=>{const{data:t}=await G.from("listing_shares").select("sharing_agent_id, profiles!listing_shares_agent_id_fkey(name)").order("created_at",{ascending:!1}),s=new Map;t==null||t.forEach(l=>{var u;const i=l.sharing_agent_id;if(!i)return;const 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 G.from("listings").select("agent_id, agent:profiles!listings_agent_id_fkey(name)").eq("is_approved",!0),a=new Map;n==null||n.forEach(l=>{var 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}}}),XIt=()=>{const{user:t,brokerageId:s}=Ws();return wt({queryKey:["brokerage-listings",s],queryFn:async()=>{if(!t||!s)return[];const{data:r}=await G.from("profiles").select("id").eq("brokerage_id",s);if(!r||r.length===0)return[];const n=r.map(l=>l.id),{data:a,error:o}=await G.from("listings").select(` *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id, brokerage:brokerages(name)) `).in("agent_id",n).eq("is_approved",!0).order("created_at",{ascending:!1});if(o)throw o;return a},enabled:!!t&&!!s})},NYe=({className:t,variant:s="default"})=>e.jsx(nt,{variant:"outline",className:At("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"}),QIt={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"},JIt={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function eLt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function tLt(){const t=Pr(),{data:s,isLoading:r}=yYe(),{data:n,isLoading:a}=vYe({status:void 0,propertyType:void 0,sortBy:"newest"}),o=(n==null?void 0:n.filter(p=>p.is_approved&&p.is_public))||[],l=o.filter(p=>p.is_featured),i=o.filter(p=>!p.is_featured),c=[...l,...i].slice(0,6),u=r||a;return!u&&!s?null:u?e.jsx(Ee,{className:"bg-gradient-to-br from-emerald-500/5 via-emerald-500/10 to-emerald-500/5 border-emerald-500/20",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-emerald-500/20 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-emerald-500/20 rounded w-1/3"}),e.jsx("div",{className:"h-3 bg-emerald-500/10 rounded w-1/2"})]})]})})}):e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Listing Exchange"}),e.jsx(NYe,{})]}),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(Ki,{className:"h-4 w-4"})]})]}),c.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Rn,{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 y,_;const f=((y=p.photos)==null?void 0:y.find(b=>b.is_primary))||((_=p.photos)==null?void 0:_[0]);return e.jsxs("div",{onClick:()=>t(`/mission-control/listings/${p.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden relative",children:[f!=null&&f.photo_url?e.jsx("img",{src:f.photo_url,alt:`${p.city}, ${p.state}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Rn,{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(nt,{className:"gap-1 bg-amber-500 text-white border-0 text-[10px] px-1.5 py-0.5",children:[e.jsx(Kn,{className:"h-2.5 w-2.5 fill-current"}),"Featured"]})}),e.jsx("div",{className:"absolute top-1.5 right-1.5",children:e.jsx(nt,{className:`text-[10px] px-1.5 py-0.5 ${QIt[p.status]}`,children:JIt[p.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:eLt(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 SYe(t=10,s){return wt({queryKey:["event-leaderboard",t,s],queryFn:async()=>{const{data:r}=await G.from("user_roles").select("user_id").eq("role","admin"),n=new Set((r==null?void 0:r.map(y=>y.user_id))||[]);let a=null;if(s){const{data:y}=await G.from("profiles").select("id").eq("brokerage_id",s);a=new Set((y==null?void 0:y.map(_=>_.id))||[])}const{data:o,error:l}=await G.from("agent_attendance_stats").select("user_id, total_points, total_events_attended, current_streak").order("total_points",{ascending:!1}).limit(t+n.size+50);if(l)throw l;if(!o||o.length===0)return[];let i=o.filter(y=>!n.has(y.user_id));a&&(i=i.filter(y=>a.has(y.user_id)));const c=i.slice(0,t),u=c.map(y=>y.user_id),{data:p}=await G.from("profiles").select("id, name").in("id",u),f=new Map((p==null?void 0:p.map(y=>[y.id,{name:y.name}]))||[]);return c.map(y=>({user_id:y.user_id,total_points:y.total_points,total_events_attended:y.total_events_attended,current_streak:y.current_streak,profile:f.get(y.user_id)||null}))}})}function CYe(t){return wt({queryKey:["user-attendance-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("agent_attendance_stats").select("*").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return s},enabled:!!t})}function MYe(t){return wt({queryKey:["user-badges",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("agent_badges").select("*").eq("user_id",t).order("earned_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function TYe(t,s){return wt({queryKey:["user-rank",t,s],queryFn:async()=>{if(!t)return null;const{data:r}=await G.from("agent_attendance_stats").select("total_points").eq("user_id",t).single();if(!r)return null;const{data:n}=await G.from("user_roles").select("user_id").eq("role","admin"),a=new Set((n==null?void 0:n.map(c=>c.user_id))||[]),{data:o,error:l}=await G.from("agent_attendance_stats").select("user_id, total_points").gt("total_points",r.total_points);if(l)throw l;let i=(o==null?void 0:o.filter(c=>!a.has(c.user_id)))||[];if(s){const{data:c}=await G.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 sLt(){const{user:t,brokerageId:s,isAdmin:r}=Ws();Pr();const n=!!s,[a,o]=C.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:c}=SYe(5,l()),{data:u}=CYe(t==null?void 0:t.id),{data:p}=TYe(t==null?void 0:t.id,l()),{data:f}=MYe(t==null?void 0:t.id),y=r||n,_=()=>r?"Agent Leaderboard":n?a==="global"?"All LevelUp":"My Brokerage":"My Points";if(c)return e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(mo,{className:"h-4 w-4 text-yellow-500"}),_()]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:[...Array(y?5:3)].map((w,j)=>e.jsx(xs,{className:"h-10 w-full"},j))})})]});const b=w=>w===0?e.jsx(mo,{className:"h-4 w-4 text-yellow-500 mx-auto"}):w===1?e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):w===2?e.jsx("span",{className:"text-sm font-medium text-amber-600",children:"3"}):e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:w+1});if(y){const w=(i==null?void 0:i.slice(0,5))||[];return e.jsxs(Ee,{children:[e.jsxs(It,{className:"pb-2",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(mo,{className:"h-4 w-4 text-yellow-500"}),_()]}),!r&&n&&e.jsxs("div",{className:"flex gap-1 mt-2",children:[e.jsx(K,{variant:a==="brokerage"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("brokerage"),children:"My Brokerage"}),e.jsx(K,{variant:a==="global"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("global"),children:"All LevelUp"})]})]}),e.jsxs(Oe,{children:[!r&&u&&e.jsx("div",{className:"mb-3 p-2 rounded-lg bg-primary/5 border border-primary/10",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Your Rank:"}),e.jsxs("span",{className:"font-bold text-primary",children:["#",p||"-"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-primary",children:u.total_points})," pts"]}),e.jsxs("span",{children:[e.jsx("strong",{children:u.total_events_attended})," events"]})]})]})}),e.jsxs("div",{className:"space-y-2",children:[w.map((j,N)=>{var S,T,I;return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${j.user_id===(t==null?void 0:t.id)?"bg-primary/10 border border-primary/20":N===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:b(N)}),e.jsx(yn,{className:"h-6 w-6",children:e.jsx(vn,{className:"text-xs",children:((T=(S=j.profile)==null?void 0:S.name)==null?void 0:T.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((I=j.profile)==null?void 0:I.name)||"Unknown"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:j.total_points})]},j.user_id)}),w.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-2 text-sm",children:"No data yet"})]}),e.jsxs(So,{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(bo,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(Xa,{className:"h-4 w-4"})]})]})]})}return e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(mo,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),e.jsx(Oe,{children:u?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-primary/5 border border-primary/10 text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-primary",children:u.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Points"})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:u.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Events Attended"})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fh,{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(fc,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Badges"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[f.slice(0,4).map(w=>e.jsx("span",{className:"text-xs px-2 py-1 rounded-full bg-yellow-500/10 text-yellow-600 border border-yellow-500/20",children:w.badge_name},w.id)),f.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",f.length-4," more"]})]})]}),e.jsxs(So,{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(bo,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(Xa,{className:"h-4 w-4"})]})]}):e.jsxs("div",{className:"text-center text-muted-foreground py-4 text-sm",children:[e.jsx(Kn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{children:"Attend events to earn points!"}),e.jsxs(So,{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(bo,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(Xa,{className:"h-4 w-4"})]})]})})]})}const FA=()=>wt({queryKey:["lead-sources"],queryFn:async()=>{const{data:t,error:s}=await G.from("lead_sources").select("*").eq("is_active",!0).order("sort_order");if(s)throw s;return t}}),hke=()=>{const t=ss(),{user:s}=Ws();return Dt({mutationFn:async r=>{const{data:n}=await G.from("lead_sources").select("id, name").eq("is_active",!0).ilike("name",r.trim()),a=(n||[]).find(i=>i.name.toLowerCase()===r.trim().toLowerCase()&&!0);if(a)throw new Error(`Lead source "${a.name}" already exists`);const{data:o,error:l}=await G.from("lead_sources").insert({name:r,owner_user_id:s==null?void 0:s.id,sort_order:100}).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),me.success("Lead source added")},onError:r=>{me.error("Failed to add lead source"),console.error(r)}})},rLt=()=>{const t=ss();return Dt({mutationFn:async({id:s,name:r})=>{const{error:n}=await G.from("lead_sources").update({name:r}).eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),me.success("Lead source updated")},onError:s=>{me.error(s.message||"Failed to update lead source")}})},nLt=()=>{const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("lead_sources").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lead-sources"]}),me.success("Lead source removed")},onError:s=>{me.error(s.message||"Failed to remove lead source")}})},mke=(t,s)=>{const{user:r,isAdmin:n}=Ws(),a=n&&s?s:r==null?void 0:r.id;return wt({queryKey:["scorecard-transactions",t,a],queryFn:async()=>{let o=G.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).eq("owner_user_id",a).order("close_date",{ascending:!1});t&&(o=o.gte("close_date",`${t}-01-01`).lte("close_date",`${t}-12-31`));const{data:l,error:i}=await o;if(i)throw i;return l},enabled:!!a})},pke=t=>{const{user:s,isAdmin:r}=Ws(),n=r&&t?t:s==null?void 0:s.id;return wt({queryKey:["scorecard-transactions-all",n],queryFn:async()=>{const{data:a,error:o}=await G.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).eq("owner_user_id",n).order("close_date",{ascending:!1});if(o)throw o;return a},enabled:!!n})},hue=()=>{const t=ss(),{user:s}=Ws();return Dt({mutationFn:async r=>{const{data:n,error:a}=await G.from("scorecard_transactions").insert({...r,owner_user_id:s.id}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),me.success("Transaction added")},onError:r=>{me.error("Failed to add transaction"),console.error(r)}})},aLt=()=>{const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("scorecard_transactions").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),me.success("Transaction updated")},onError:s=>{me.error("Failed to update transaction"),console.error(s)}})},iLt=()=>{const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("scorecard_transactions").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-transactions"]}),t.invalidateQueries({queryKey:["scorecard-transactions-all"]}),me.success("Transaction deleted")},onError:s=>{me.error("Failed to delete transaction"),console.error(s)}})},AYe=(t,s)=>{const{user:r,isAdmin:n}=Ws(),a=n&&s?s:r==null?void 0:r.id;return wt({queryKey:["scorecard-goals",t,a],queryFn:async()=>{const{data:o,error:l}=await G.from("scorecard_goals").select("*").eq("owner_user_id",a).eq("year",t).maybeSingle();if(l)throw l;return o},enabled:!!a})},oLt=()=>{const t=ss(),{user:s}=Ws();return Dt({mutationFn:async r=>{const{data:n,error:a}=await G.from("scorecard_goals").upsert({...r,owner_user_id:s.id},{onConflict:"owner_user_id,year"}).select().single();if(a)throw a;return n},onSuccess:(r,n)=>{t.invalidateQueries({queryKey:["scorecard-goals",n.year]}),me.success("Goals saved")},onError:r=>{me.error("Failed to save goals"),console.error(r)}})},mue=()=>{const{user:t}=Ws();return wt({queryKey:["scorecard-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("scorecard_settings").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s},enabled:!!(t!=null&&t.id)})},lLt=()=>{const t=ss(),{user:s}=Ws();return Dt({mutationFn:async r=>{const{data:n,error:a}=await G.from("scorecard_settings").upsert({...r,user_id:s.id},{onConflict:"user_id"}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["scorecard-settings"]}),me.success("Settings saved")},onError:r=>{me.error("Failed to save settings"),console.error(r)}})},EYe=(t,s)=>{const{data:r,isLoading:n}=mke(t,s),{data:a,isLoading:o}=pke(s),{data:l}=mue(),i=(l==null?void 0:l.show_commission)??!0,c=u=>{if(!u||u.length===0)return{totalTransactions:0,buyerCount:0,sellerCount:0,totalVolume:0,averagePrice:0,totalCommission:0,totalNetToAgent:0,topLeadSource:null,transactionsByMonth:[],leadSourceBreakdown:[]};const p=u.filter(L=>L.transaction_type==="buyer").length,f=u.filter(L=>L.transaction_type==="seller").length,y=u.reduce((L,R)=>L+Number(R.sale_price),0),_=u.reduce((L,R)=>L+(Number(R.commission_amount)||0),0),b=u.reduce((L,R)=>{const $=Number(R.commission_amount)||0;if(!$)return L;let q=$;return R.brokerage_split_pct&&(q-=$*(R.brokerage_split_pct/100)),R.team_split_pct&&(q-=$*(R.team_split_pct/100)),R.franchise_fee_pct&&(q-=$*(R.franchise_fee_pct/100)),R.referral_fee_pct&&(q-=$*(R.referral_fee_pct/100)),R.transaction_fee&&(q-=R.transaction_fee),L+Math.max(0,q)},0),w={};u.forEach(L=>{var $;const R=(($=L.lead_source)==null?void 0:$.name)||"Unknown";w[R]=(w[R]||0)+1});const j=Object.entries(w).map(([L,R])=>({name:L,count:R})).sort((L,R)=>R.count-L.count),N=j[0]||null,S={};u.forEach(L=>{const R=Ml(L.close_date).toLocaleString("default",{month:"short"});S[R]=(S[R]||0)+1});const I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(L=>({month:L,count:S[L]||0}));return{totalTransactions:u.length,buyerCount:p,sellerCount:f,totalVolume:y,averagePrice:u.length>0?y/u.length:0,totalCommission:i?_:0,totalNetToAgent:i?b:0,topLeadSource:N,transactionsByMonth:I,leadSourceBreakdown:j}};return{yearStats:c(r),lifetimeStats:c(a),isLoading:n||o,showCommission:i}},cLt=()=>{const{isAdmin:t}=Ws();return wt({queryKey:["agents-with-transactions"],queryFn:async()=>{const{data:s,error:r}=await G.from("scorecard_transactions").select("owner_user_id").order("owner_user_id");if(r)throw r;const n=[...new Set(s.map(l=>l.owner_user_id))],{data:a,error:o}=await G.from("profiles").select("id, name, email").in("id",n);if(o)throw o;return a},enabled:t})},F_={recency:40,touchpoints:30,transactions:20},K6e={warm:70,cooling:40};function dLt(t){return t===null?0:t<=14?F_.recency:t<=30?F_.recency*.85:t<=60?F_.recency*.65:t<=90?F_.recency*.4:t<=180?F_.recency*.2:F_.recency*.05}function uLt(t){const s=Math.min(t/12,1);return Math.round(F_.touchpoints*s)}function hLt(t){return t?F_.transactions:0}function mLt(){return 0}function pLt(t){return t>=K6e.warm?"warm":t>=K6e.cooling?"cooling":"at-risk"}function pue(){const{data:t,isLoading:s}=Fm(),{data:r}=pYe(),{data:n}=wO(365),{data:a}=pke(),o=C.useMemo(()=>{if(!t)return[];const i=new Date,c=d4(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 y=(r==null?void 0:r[f.id])||null,_=y?ty(i,new Date(y)):null,b=u[f.id]||0,w=p.has(f.id),j=dLt(_),N=uLt(b),S=hLt(w),T=mLt(),I=Math.round(j+N+S+T),L={score:I,status:pLt(I),breakdown:{recency:Math.round(j),touchpoints:Math.round(N),transactions:Math.round(S),referrals:Math.round(T)},lastTouchDate:y,daysSinceTouch:_,touchCountLast12Months:b,hasTransaction:w};return{...f,relationshipScore:L}})},[t,r,n,a]),l=C.useMemo(()=>{const i=o.filter(y=>y.relationshipScore.status==="warm").length,c=o.filter(y=>y.relationshipScore.status==="cooling").length,u=o.filter(y=>y.relationshipScore.status==="at-risk").length,p=o.length,f=p>0?Math.round(o.reduce((y,_)=>y+_.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 PYe(){const t=Pr(),{stats:s,contactsWithScores:r,isLoading:n}=pue();if(n)return e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(xs,{className:"h-5 w-40"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(xs,{className:"h-20 w-full"}),e.jsx(xs,{className:"h-16 w-full"})]})]});if(s.total===0)return e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add contacts to see your relationship health scores."}),e.jsx(K,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>t("/mission-control/contacts?new=true"),children:"Add Your First Contact"})]})]});const a=Math.round(s.warm/s.total*100),o=Math.round(s.cooling/s.total*100),l=Math.round(s.atRisk/s.total*100),i=r.filter(c=>c.relationshipScore.status==="at-risk").sort((c,u)=>c.relationshipScore.score-u.relationshipScore.score).slice(0,3);return e.jsxs(Ee,{children:[e.jsxs(It,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(xc,{className:"h-5 w-5 text-emerald-500"}),"Relationship Health"]}),e.jsx("span",{className:"text-2xl font-bold",children:s.averageScore})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Average score across ",s.total," contacts"]})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-emerald-500"}),e.jsx("span",{children:"Warm"})]}),e.jsxs("span",{className:"font-medium",children:[s.warm," (",a,"%)"]})]}),e.jsx(Oi,{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(Oi,{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(Oi,{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(K4,{className:"h-4 w-4 text-red-500"}),e.jsx("span",{className:"text-sm font-medium",children:"Needs Attention"})]}),e.jsx("div",{className:"space-y-2",children:i.map(c=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-red-500/5 hover:bg-red-500/10 cursor-pointer transition-colors",onClick:()=>t(`/mission-control/contacts/${c.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),e.jsxs("span",{className:"text-sm",children:[c.first_name," ",c.last_name]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:c.relationshipScore.daysSinceTouch===null?"Never":`${c.relationshipScore.daysSinceTouch}d`}),e.jsx(Xa,{className:"h-3 w-3"})]})]},c.id))})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t("/mission-control/contacts?filter=at-risk"),children:["View All At-Risk Contacts",e.jsx(Xa,{className:"h-4 w-4 ml-1"})]})]})]})}const fLt=()=>{var re;const{user:t,isAdmin:s}=Ws(),r=Pr(),[n,a]=C.useState([]),[o,l]=C.useState([]),[i,c]=C.useState([]),[u,p]=C.useState([]),[f,y]=C.useState([]),[_,b]=C.useState([]),[w,j]=C.useState(new Set),[N,S]=C.useState([]),[T,I]=C.useState([]),[L,R]=C.useState([]),[$,q]=C.useState(null),[U,V]=C.useState(!0);C.useEffect(()=>{X()},[t]);const X=async()=>{var ne,le,he,we,ye;try{const[je,ke,We,be,Me,Ae,Re,Te,qe,ct,De]=await Promise.all([G.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),G.from("app_tiles").select("*").order("name"),G.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),G.from("events").select("*").order("event_date",{ascending:!0}),G.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",t==null?void 0:t.id),G.from("canva_templates").select("id, name, preview_image_url, publish_date").order("publish_date",{ascending:!1}).limit(4),G.from("resource_kits").select("id, name, description, featured_image_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.from("academy_videos").select("id, title, description, thumbnail_url, duration, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.from("additional_services").select("id, name, description, preview_image_url, signup_link_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),G.from("dashboard_banners").select("id, title, description, image_url, link_url, link_text, placement, section_after").eq("is_active",!0).order("sort_order"),G.from("profiles").select("name").eq("id",t==null?void 0:t.id).single()]);(ne=De.data)!=null&&ne.name&&q(De.data.name);const Rt=((le=je.data)==null?void 0:le.map(it=>it.tag))||[],pe=new Set(((he=We.data)==null?void 0:he.map(it=>it.app_id))||[]);j(pe);const lt=(((we=ke.data)==null?void 0:we.filter(it=>!it.required_tags||it.required_tags.length===0?!0:it.required_tags.some($e=>Rt.includes($e))))||[]).sort((it,$e)=>it.name==="LevelUp Members Portal"?-1:$e.name==="LevelUp Members Portal"?1:0);a(lt.slice(0,6));const rt=((ye=be.data)==null?void 0:ye.filter(it=>IM(it.event_date)!=="ended"))||[];l(rt.slice(0,4)),S(Me.data||[]),c(Ae.data||[]),p(Re.data||[]),y(Te.data||[]),b(qe.data||[]);const Se=ct.data||[];I(Se.filter(it=>it.placement==="top")),R(Se.filter(it=>it.placement==="between"))}catch(je){console.error("Error loading dashboard:",je),me.error("Failed to load dashboard data")}finally{V(!1)}},se=async ne=>{var he;const le=window.open("about:blank","_blank");try{await G.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:ne.app_id,app_name:ne.name,user_agent:navigator.userAgent});const{data:we,error:ye}=await G.functions.invoke("sso-launch",{body:{app_id:ne.app_id}});if(ye)throw ye;we!=null&&we.redirect_url?le&&!le.closed?(le.location.href=we.redirect_url,(he=le.focus)==null||he.call(le)):window.location.assign(we.redirect_url):(le==null||le.close(),me.error("Launch link unavailable"))}catch(we){le==null||le.close(),console.error("Error launching app:",we),me.error("Failed to launch app")}},ee=ne=>N==null?void 0:N.some(le=>le.event_id===ne),Q=ne=>{const le=N==null?void 0:N.find(he=>he.event_id===ne);return le==null?void 0:le.zoom_join_url};if(U)return e.jsx(Es,{title:"Dashboard",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading your dashboard..."})]})})});const de=ne=>L.filter(le=>le.section_after===ne);return e.jsxs(Es,{title:"Dashboard",children:[e.jsx(Y6t,{events:o,registrations:N,onNavigateToEvents:()=>r("/events")}),T.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(E6,{banners:T})}),e.jsx(oIt,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",($||((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(wIt,{}),e.jsx(PYe,{}),e.jsx(sLt,{})]}),e.jsx(OIt,{}),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(Ki,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(on,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming events"})]})})}):e.jsx("div",{className:"bg-card rounded-xl border border-border overflow-hidden divide-y divide-border max-w-full",children:o.map(ne=>{const le=ee(ne.id),he=Q(ne.id)||ne.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 ${V6e(ne.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[V6e(ne.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(n1,{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(ne.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(ne.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:ne.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(ne.event_date))," at ",B8(new Date(ne.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:le?e.jsxs(K,{size:"sm",variant:"default",className:"gap-1",onClick:we=>{we.stopPropagation(),window.open(he,"_blank")},children:[e.jsx(rn,{className:"h-3.5 w-3.5"}),"Join"]}):e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground group-hover:text-primary transition-colors",children:[e.jsx("span",{className:"text-sm",children:"Register"}),e.jsx(Xa,{className:"h-4 w-4"})]})})]},ne.id)})})]}),de("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(E6,{banners:de("events")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Academy Videos"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/academy"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ki,{className:"h-4 w-4"})]})]}),f.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(ap,{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(ne=>e.jsxs("div",{onClick:()=>r(`/academy/${ne.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:[ne.thumbnail_url?e.jsx("img",{src:ne.thumbnail_url,alt:ne.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(ap,{className:"h-8 w-8 text-muted-foreground/50"})}),ne.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:ne.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:ne.title})})]},ne.id))})]}),de("academy").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(E6,{banners:de("academy")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Resource Kits"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/toolbox"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ki,{className:"h-4 w-4"})]})]}),u.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Cm,{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(ne=>e.jsxs("div",{onClick:()=>r(`/toolbox/${ne.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:ne.featured_image_url?e.jsx("img",{src:ne.featured_image_url,alt:ne.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(Cm,{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:ne.name})})]},ne.id))})]}),de("toolbox").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(E6,{banners:de("toolbox")})}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"New Templates"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>r("/templates"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",e.jsx(Ki,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Eb,{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(ne=>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:ne.preview_image_url?e.jsx("img",{src:ne.preview_image_url,alt:ne.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(Eb,{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:ne.name})})]},ne.id))})]}),de("templates").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(E6,{banners:de("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(tLt,{})}),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(Ki,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ux,{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(ne=>{const le=w.has(ne.id);return e.jsxs("div",{onClick:()=>se(ne),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:ne.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:ne.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:ne.description})]}),le&&e.jsx(Ux,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},ne.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(Ki,{className:"h-4 w-4"})]})]}),_.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(hn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional services available"})]})})}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:_.map(ne=>e.jsxs("div",{onClick:()=>window.open(ne.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:ne.preview_image_url?e.jsx("img",{src:ne.preview_image_url,alt:ne.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(hn,{className:"h-8 w-8 text-muted-foreground/50"})})}),e.jsxs("div",{className:"p-3",children:[e.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:ne.name}),ne.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:ne.description})]})]},ne.id))})]})]})};var IYe="AlertDialog",[gLt]=Yc(IYe,[fHe]),E1=fHe(),LYe=t=>{const{__scopeAlertDialog:s,...r}=t,n=E1(s);return e.jsx(Pde,{...n,...r,modal:!0})};LYe.displayName=IYe;var xLt="AlertDialogTrigger",DYe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=E1(r);return e.jsx(Zwe,{...a,...n,ref:s})});DYe.displayName=xLt;var yLt="AlertDialogPortal",OYe=t=>{const{__scopeAlertDialog:s,...r}=t,n=E1(s);return e.jsx(Ide,{...n,...r})};OYe.displayName=yLt;var vLt="AlertDialogOverlay",RYe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=E1(r);return e.jsx(TA,{...a,...n,ref:s})});RYe.displayName=vLt;var LM="AlertDialogContent",[_Lt,bLt]=gLt(LM),wLt=QBe("AlertDialogContent"),FYe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=E1(r),l=C.useRef(null),i=Oa(s,l),c=C.useRef(null);return e.jsx(bjt,{contentName:LM,titleName:zYe,docsSlug:"alert-dialog",children:e.jsx(_Lt,{scope:r,cancelRef:c,children:e.jsxs(AA,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:Mr(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(wLt,{children:n}),e.jsx(kLt,{contentRef:l})]})})})});FYe.displayName=LM;var zYe="AlertDialogTitle",BYe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=E1(r);return e.jsx(dO,{...a,...n,ref:s})});BYe.displayName=zYe;var $Ye="AlertDialogDescription",qYe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=E1(r);return e.jsx(uO,{...a,...n,ref:s})});qYe.displayName=$Ye;var jLt="AlertDialogAction",UYe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=E1(r);return e.jsx(hO,{...a,...n,ref:s})});UYe.displayName=jLt;var VYe="AlertDialogCancel",HYe=C.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=bLt(VYe,r),o=E1(r),l=Oa(s,a);return e.jsx(hO,{...o,...n,ref:l})});HYe.displayName=VYe;var kLt=({contentRef:t})=>{const s=`\`${LM}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${LM}\` by passing a \`${$Ye}\` 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 \`${LM}\`. 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 C.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},NLt=LYe,SLt=DYe,CLt=OYe,WYe=RYe,GYe=FYe,KYe=UYe,ZYe=HYe,YYe=BYe,XYe=qYe;const gc=NLt,_m=SLt,MLt=CLt,QYe=C.forwardRef(({className:t,...s},r)=>e.jsx(WYe,{className:At("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}));QYe.displayName=WYe.displayName;const Ul=C.forwardRef(({className:t,...s},r)=>e.jsxs(MLt,{children:[e.jsx(QYe,{}),e.jsx(GYe,{ref:r,className:At("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})]}));Ul.displayName=GYe.displayName;const Vl=({className:t,...s})=>e.jsx("div",{className:At("flex flex-col space-y-2 text-center sm:text-left",t),...s});Vl.displayName="AlertDialogHeader";const Hl=({className:t,...s})=>e.jsx("div",{className:At("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Hl.displayName="AlertDialogFooter";const Wl=C.forwardRef(({className:t,...s},r)=>e.jsx(YYe,{ref:r,className:At("text-lg font-semibold",t),...s}));Wl.displayName=YYe.displayName;const Gl=C.forwardRef(({className:t,...s},r)=>e.jsx(XYe,{ref:r,className:At("text-sm text-muted-foreground",t),...s}));Gl.displayName=XYe.displayName;const Tl=C.forwardRef(({className:t,...s},r)=>e.jsx(KYe,{ref:r,className:At(A8(),t),...s}));Tl.displayName=KYe.displayName;const Kl=C.forwardRef(({className:t,...s},r)=>e.jsx(ZYe,{ref:r,className:At(A8({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));Kl.displayName=ZYe.displayName;const TLt=[{key:"contacts",label:"Contacts",icon:ea,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:U4,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:Cm,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:Nn,description:"View and upload videos"},{key:"listings",label:"Listings",icon:Rn,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:Ab,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:Ui,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:yg,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:gh,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:Gx,description:"Create and manage smart presentations"}];function ALt(){var $;const{user:t}=Ws(),[s,r]=C.useState([]),[n,a]=C.useState(!0),[o,l]=C.useState(!1),[i,c]=C.useState(!1),[u,p]=C.useState(null),[f,y]=C.useState({email:"",name:"",password:""}),[_,b]=C.useState("create"),[w,j]=C.useState(!1),[N,S]=C.useState(null);C.useEffect(()=>{t&&T()},[t]);const T=async()=>{if(t){a(!0);try{const{data:q,error:U}=await G.from("agent_assistant_assignments").select("id, assistant_id, permissions, created_at").eq("agent_id",t.id);if(U)throw U;if(q&&q.length>0){const V=q.map(ee=>ee.assistant_id),{data:X}=await G.from("profiles").select("id, name, email").in("id",V),se=q.map(ee=>{const Q=X==null?void 0:X.find(de=>de.id===ee.assistant_id);return{...ee,permissions:ee.permissions,assistant_profile:Q?{name:Q.name||"",email:Q.email||""}:void 0}});r(se)}else r([])}catch(q){console.error("Error loading assistants:",q)}finally{a(!1)}}},I=async()=>{if(t){if(_==="link"){if(!f.email.trim()){me.error("Please enter the assistant's email");return}j(!0);try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const{data:U,error:V}=await G.from("profiles").select("id, name, email").eq("email",f.email.trim().toLowerCase()).single();if(V||!U){me.error("No account found with that email. Try creating a new assistant instead.");return}const{data:X}=await G.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",U.id);if(X&&X.length>0){me.error("This assistant is already assigned to you");return}const se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:U.id,role:"assistant",action:"add",agentId:t.id})}),ee=await se.json();if(!se.ok)throw new Error(ee.error||"Failed to assign assistant role");const{error:Q}=await G.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:U.id,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(Q)throw Q;me.success(`${U.name||U.email} linked as your assistant`),l(!1),y({email:"",name:"",password:""}),T()}catch(q){console.error("Error linking assistant:",q),me.error(q.message||"Failed to link assistant")}finally{j(!1)}return}if(!f.email.trim()||!f.name.trim()||!f.password.trim()){me.error("Please fill in all fields");return}if(f.password.length<6){me.error("Password must be at least 6 characters");return}j(!0);try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const U=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({email:f.email.trim(),password:f.password,name:f.name.trim(),purpose:"assistant"})}),V=await U.json();if(!U.ok)throw new Error(V.error||"Failed to create assistant account");const X=V.userId||V.id;if(!X)throw new Error("No user ID returned");const se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:X,role:"assistant",action:"add",agentId:t.id})}),ee=await se.json();if(!se.ok)throw new Error(ee.error||"Failed to assign assistant role");const{error:Q}=await G.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:X,permissions:{contacts:!0,pipeline:!0,videos:!1,listings:!1,scorecard:!1,popbys:!1,digital_card:!1,client_portal:!1,guest_book:!1,presentations:!1}});if(Q)throw Q;me.success(`Assistant account created for ${f.name.trim()}`),l(!1),y({email:"",name:"",password:""}),T()}catch(q){console.error("Error adding assistant:",q),me.error(q.message||"Failed to add assistant")}finally{j(!1)}}},L=async()=>{if(!(!u||!t))try{const{data:{session:q}}=await G.auth.getSession();if(!q)throw new Error("Not authenticated");const{error:U}=await G.from("agent_assistant_assignments").delete().eq("id",u.id);if(U)throw U;const{data:V}=await G.from("agent_assistant_assignments").select("id").eq("assistant_id",u.assistant_id);(!V||V.length===0)&&await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:u.assistant_id,role:"assistant",action:"remove"})}),me.success("Assistant removed"),c(!1),p(null),T()}catch(q){console.error("Error removing assistant:",q),me.error(q.message||"Failed to remove assistant")}},R=async(q,U,V)=>{S(q);try{const X=s.find(Q=>Q.id===q);if(!X)return;const se={...X.permissions,[U]:V},{error:ee}=await G.from("agent_assistant_assignments").update({permissions:se}).eq("id",q);if(ee)throw ee;r(Q=>Q.map(de=>de.id===q?{...de,permissions:se}:de))}catch(X){console.error("Error updating permissions:",X),me.error("Failed to update permissions")}finally{S(null)}};return n?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(fr,{children:"Add assistants to help manage your Agent OS"})]}),e.jsxs(K,{size:"sm",onClick:()=>{b("create"),l(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Assistant"]})]})}),e.jsx(Oe,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No assistant assigned. Add one to help manage your contacts, deals, and more."}):e.jsx("div",{className:"space-y-4",children:s.map(q=>{var U,V,X,se;return e.jsxs("div",{className:"border rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(yn,{className:"h-10 w-10",children:e.jsx(vn,{children:((V=(U=q.assistant_profile)==null?void 0:U.name)==null?void 0:V.split(" ").map(ee=>ee[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((X=q.assistant_profile)==null?void 0:X.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((se=q.assistant_profile)==null?void 0:se.email)||""})]}),e.jsxs(nt,{variant:"secondary",className:"ml-2",children:[e.jsx(Bh,{className:"h-3 w-3 mr-1"}),"Assistant"]})]}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{p(q),c(!0)},children:e.jsx(jr,{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:TLt.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(Br,{checked:q.permissions[ee.key]||!1,onCheckedChange:de=>R(q.id,ee.key,de),disabled:N===q.id})]},ee.key)})})]})]},q.id)})})})]}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Add Assistant"}),e.jsx(Zr,{children:_==="create"?"Create a new account for your assistant.":"Link an existing assistant account by their email."})]}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsxs(K,{variant:_==="create"?"default":"outline",size:"sm",onClick:()=>b("create"),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(K,{variant:_==="link"?"default":"outline",size:"sm",onClick:()=>b("link"),children:[e.jsx(Vo,{className:"h-3 w-3 mr-1"}),"Link Existing"]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[_==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"assistant-name",children:"Name"}),e.jsx(Fe,{id:"assistant-name",value:f.name,onChange:q=>y({...f,name:q.target.value}),placeholder:"Assistant's full name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"assistant-email",children:"Email"}),e.jsx(Fe,{id:"assistant-email",type:"email",value:f.email,onChange:q=>y({...f,email:q.target.value}),placeholder:"assistant@email.com"})]}),_==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"assistant-password",children:"Temporary Password"}),e.jsx(Fe,{id:"assistant-password",type:"password",value:f.password,onChange:q=>y({...f,password:q.target.value}),placeholder:"Min 6 characters"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your assistant can change this after their first login."})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:I,disabled:w,children:[w&&e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),_==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(gc,{open:i,onOpenChange:c,children:e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Remove Assistant?"}),e.jsxs(Gl,{children:["This will remove ",($=u==null?void 0:u.assistant_profile)==null?void 0:$.name,"'s access to your Agent OS. Their account will remain active but they won't be able to manage your data."]})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:L,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function ch(t){this.content=t}ch.prototype={constructor:ch,find:function(t){for(var s=0;s>1}};ch.from=function(t){if(t instanceof ch)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new ch(s)};function JYe(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=JYe(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function eXe(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 Tr(n,a)}cutByIndex(s,r){return s==r?Tr.empty:s==0&&r==this.content.length?this:new Tr(this.content.slice(s,r))}replaceChild(s,r){let n=this.content[s];if(n==r)return this;let a=this.content.slice(),o=this.size+r.nodeSize-n.nodeSize;return a[s]=r,new Tr(a,o)}addToStart(s){return new Tr([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Tr(this.content.concat(s),this.size+s.nodeSize)}eq(s){if(this.content.length!=s.content.length)return!1;for(let r=0;rthis.size||s<0)throw new RangeError(`Position ${s} outside of fragment (${this})`);for(let r=0,n=0;;r++){let a=this.child(r),o=n+a.nodeSize;if(o>=s)return o==s?B7(r+1,o):B7(r,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(s=>s.toJSON()):null}static fromJSON(s,r){if(!r)return Tr.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Tr(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Tr.empty;let r,n=0;for(let a=0;athis.type.rank&&(r||(r=s.slice(0,a)),r.push(this),n=!0),r&&r.push(o)}}return r||(r=s.slice()),n||r.push(this),r}removeFromSet(s){for(let r=0;rn.type.rank-a.type.rank),r}};Sl.none=[];class Uoe extends Error{}class gn{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=sXe(this.content,s+this.openStart,r);return n&&new gn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new gn(tXe(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 gn.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 gn(Tr.fromJSON(s,r.content),n,a)}static maxOpen(s,r=!0){let n=0,a=0;for(let o=s.firstChild;o&&!o.isLeaf&&(r||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=s.lastChild;o&&!o.isLeaf&&(r||!o.type.spec.isolating);o=o.lastChild)a++;return new gn(s,n,a)}}gn.empty=new gn(Tr.empty,0,0);function tXe(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(tXe(o.content,s-a-1,r-a-1)))}function sXe(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=sXe(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function ELt(t,s,r){if(r.openStart>t.depth)throw new Uoe("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new Uoe("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 IL(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&&(Q4(t.nodeAfter,n),o++));for(let i=o;ia&&o1e(t,s,a+1),l=n.depth>a&&o1e(r,n,a+1),i=[];return IL(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(nXe(o,l),Q4(J4(o,aXe(t,s,r,n,a+1)),i)):(o&&Q4(J4(o,Voe(t,s,a+1)),i),IL(s,r,a,i),l&&Q4(J4(l,Voe(r,n,a+1)),i)),IL(n,null,a,i),new Tr(i)}function Voe(t,s,r){let n=[];if(IL(null,t,r,n),t.depth>r){let a=o1e(t,s,r+1);Q4(J4(a,Voe(t,s,r+1)),n)}return IL(s,null,r,n),new Tr(n)}function PLt(t,s){let r=s.depth-t.openStart,a=s.node(r).copy(t.content);for(let o=r-1;o>=0;o--)a=s.node(o).copy(Tr.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class $8{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 Hoe(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 $8(r,n,o)}static resolveCached(s,r){let n=Z6e.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()+")"),iXe(this.marks,s)}contentMatchAt(s){let r=this.type.contentMatch.matchFragment(this.content,0,s);if(!r)throw new Error("Called contentMatchAt on a node with invalid content");return r}canReplace(s,r,n=Tr.empty,a=0,o=n.childCount){let l=this.contentMatchAt(s).matchFragment(n,a,o),i=l&&l.matchFragment(this.content,r);if(!i||!i.validEnd)return!1;for(let 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=Tr.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};Hb.prototype.text=void 0;class Woe extends Hb{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):iXe(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 Woe(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new Woe(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 iXe(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class NS{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new OLt(s,r);if(n.next==null)return NS.empty;let a=oXe(n);n.next&&n.err("Unexpected trailing text");let o=ULt(qLt(a));return VLt(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(` `)}}NS.empty=new NS(!0);class OLt{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 oXe(t){let s=[];do s.push(RLt(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function RLt(t){let s=[];do s.push(FLt(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function FLt(t){let s=$Lt(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=zLt(t,s);else break;return s}function Y6e(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function zLt(t,s){let r=Y6e(t),n=r;return t.eat(",")&&(t.next!="}"?n=Y6e(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function BLt(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 $Lt(t){if(t.eat("(")){let s=oXe(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=BLt(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 qLt(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 NS(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:dXe(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Hb(this,this.computeAttrs(s),Tr.from(r),Sl.setFrom(n))}createChecked(s=null,r,n){return r=Tr.from(r),this.checkContent(r),new Hb(this,this.computeAttrs(s),r,Sl.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=Tr.from(r),r.size){let l=this.contentMatch.fillBefore(r);if(!l)return null;r=l.append(r)}let a=this.contentMatch.matchFragment(r),o=a&&a.fillBefore(Tr.empty,!0);return o?new Hb(this,s,r.append(o),Sl.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 mXe(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 HLt(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 WLt{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?HLt(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class fue{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=hXe(s,a.attrs),this.excluded=null;let o=cXe(this.attrs);this.instance=o?new Sl(this,o):null}create(s=null){return!s&&this.instance?this.instance:new Sl(this,dXe(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new fue(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class pXe{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=ch.from(s.nodes),r.marks=ch.from(s.marks||{}),this.nodes=Q6e.compile(this.spec.nodes,this),this.marks=fue.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]=NS.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?J6e(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==""?[]:J6e(this,l.split(" "))}this.nodeFromJSON=a=>Hb.fromJSON(this,a),this.markFromJSON=a=>Sl.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 Q6e){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 Woe(n,n.defaultAttrs,s,Sl.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 J6e(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 GLt(t){return t.tag!=null}function KLt(t){return t.style!=null}let LL=class c1e{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if(GLt(a))this.tags.push(a);else if(KLt(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 tIe(this,r,!1);return n.addAll(s,Sl.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new tIe(this,r,!0);return n.addAll(s,Sl.none,r.from,r.to),gn.maxOpen(n.finish())}matchTag(s,r,n){for(let a=n?this.tags.indexOf(n)+1:0;as.length&&(i.charCodeAt(s.length)!=61||i.slice(s.length+1)!=r))){if(l.getAttrs){let c=l.getAttrs(r);if(c===!1)continue;l.attrs=c||void 0}return l}}}static schemaRules(s){let r=[];function n(a){let o=a.priority==null?50:a.priority,l=0;for(;l{n(l=sIe(l)),l.mark||l.ignore||l.clearMark||(l.mark=a)})}for(let a in s.nodes){let o=s.nodes[a].spec.parseDOM;o&&o.forEach(l=>{n(l=sIe(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new c1e(s,c1e.schemaRules(s)))}};const fXe={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},ZLt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},gXe={ol:!0,ul:!0},q8=1,d1e=2,DL=4;function eIe(t,s,r){return s!=null?(s?q8:0)|(s==="full"?d1e:0):t&&t.whitespace=="pre"?q8|d1e:r&~DL}class $7{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=Sl.none,this.match=o||(l&DL?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Tr.from(s));if(r)this.match=this.type.contentMatch.matchFragment(r);else{let n=this.type.contentMatch,a;return(a=n.findWrapping(s.type))?(this.match=n,a):null}}return this.match.findWrapping(s.type)}finish(s){if(!(this.options&q8)){let n=this.content[this.content.length-1],a;if(n&&n.isText&&(a=/[ \t\r\n\u000c]+$/.exec(n.text))){let o=n;n.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-a[0].length))}}let r=Tr.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Tr.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r}inlineContext(s){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:s.parentNode&&!fXe.hasOwnProperty(s.parentNode.nodeName.toLowerCase())}}class tIe{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=eIe(null,r.preserveWhitespace,0)|(n?DL:0);a?o=new $7(a.type,a.attrs,Sl.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new $7(null,null,Sl.none,!0,null,l):o=new $7(s.schema.topNodeType,null,Sl.none,!0,null,l),this.nodes=[o],this.find=r.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(s,r){s.nodeType==3?this.addTextNode(s,r):s.nodeType==1&&this.addElement(s,r)}addTextNode(s,r){let n=s.nodeValue,a=this.top,o=a.options&d1e?"full":this.localPreserveWS||(a.options&q8)>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):rIe(u.type,s))?(c=u.addToSet(c),!1):!0),this.nodes.push(new $7(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|=q8)}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 YLt(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&gXe.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function XLt(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function sIe(t){let s={};for(let r in t)s[r]=t[r];return s}function rIe(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&&gie(Bge(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return gie(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new XS(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=nIe(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return nIe(s.marks)}}function nIe(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function Bge(t){return t.document||window.document}const aIe=new WeakMap;function QLt(t){let s=aIe.get(t);return s===void 0&&aIe.set(t,s=JLt(t)),s}function JLt(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 y=f.indexOf(" ");y>0?c.setAttributeNS(f.slice(0,y),f.slice(y+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:_,contentDOM:b}=gie(t,y,r,n);if(c.appendChild(_),b){if(i)throw new RangeError("Multiple content holes");i=b}}}return{dom:c,contentDOM:i}}const xXe=65535,yXe=Math.pow(2,16);function e8t(t,s){return t+s*yXe}function iIe(t){return t&xXe}function t8t(t){return(t-(t&xXe))/yXe}const vXe=1,_Xe=2,xie=4,bXe=8;class u1e{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&bXe)>0}get deletedBefore(){return(this.delInfo&(vXe|xie))>0}get deletedAfter(){return(this.delInfo&(_Xe|xie))>0}get deletedAcross(){return(this.delInfo&xie)>0}}class tf{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&tf.empty)return tf.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 y=u?s==c?-1:s==f?1:r:r,_=c+a+(y<0?0:p);if(n)return _;let b=s==(r<0?c:f)?null:e8t(i/3,s-c),w=s==c?_Xe:s==f?vXe:xie;return(r<0?s!=c:s!=f)&&(w|=bXe),new u1e(_,w,b)}a+=p-u}return n?s+a:new u1e(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 U8;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 Gd.fromReplace(s,this.from,this.to,o)}invert(){return new Jy(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 gb(r.pos,n.pos,this.mark)}merge(s){return s instanceof gb&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new gb(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 gb(r.from,r.to,s.markFromJSON(r.mark))}}Gh.jsonID("addMark",gb);class Jy extends Gh{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 gn(fke(r.content,a=>a.mark(this.mark.removeFromSet(a.marks)),s),r.openStart,r.openEnd);return Gd.fromReplace(s,this.from,this.to,n)}invert(){return new gb(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 Jy(r.pos,n.pos,this.mark)}merge(s){return s instanceof Jy&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new Jy(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 Jy(r.from,r.to,s.markFromJSON(r.mark))}}Gh.jsonID("removeMark",Jy);class xb extends Gh{constructor(s,r){super(),this.pos=s,this.mark=r}apply(s){let r=s.nodeAt(this.pos);if(!r)return Gd.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return Gd.fromReplace(s,this.pos,this.pos+1,new gn(Tr.from(n),0,r.isLeaf?0:1))}invert(s){let r=s.nodeAt(this.pos);if(r){let n=this.mark.addToSet(r.marks);if(n.length==r.marks.length){for(let a=0;an.pos?null:new Ku(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 Ku(r.from,r.to,r.gapFrom,r.gapTo,gn.fromJSON(s,r.slice),r.insert,!!r.structure)}}Gh.jsonID("replaceAround",Ku);function h1e(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 s8t(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 y=Math.max(u,s),_=Math.min(u+c.nodeSize,r),b=n.addToSet(f);for(let w=0;wt.step(c)),o.forEach(c=>t.step(c))}function r8t(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 fue){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 Jy(l.from,l.to,l.style)))}function gke(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 n8t(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function zA(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;b--)w||n.index(b)>0?(w=!0,p=Tr.from(n.node(b).copy(p)),f++):c--;let y=Tr.empty,_=0;for(let b=o,w=!1;b>r;b--)w||a.after(b+1)=0;l--){if(n.size){let i=r[l].type.contentMatch.matchFragment(n);if(!i||!i.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=Tr.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new Ku(a,o,a,o,new gn(n,0,0),r.length,!0))}function c8t(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)&&d8t(t.doc,t.mapping.slice(o).map(i),n)){let u=null;if(n.schema.linebreakReplacement){let _=n.whitespace=="pre",b=!!n.contentMatch.matchType(n.schema.linebreakReplacement);_&&!b?u=!1:!_&&b&&(u=!0)}u===!1&&jXe(t,l,i,o),gke(t,t.mapping.slice(o).map(i,1),n,void 0,u===null);let p=t.mapping.slice(o),f=p.map(i,1),y=p.map(i+l.nodeSize,1);return t.step(new Ku(f,y,f+1,y-1,new gn(Tr.from(n.create(c,null,l.marks)),0,0),1,!0)),u===!0&&wXe(t,l,i,o),!1}})}function wXe(t,s,r,n){s.forEach((a,o)=>{if(a.isText){let l,i=/\r?\n|\r/g;for(;l=i.exec(a.text);){let c=t.mapping.slice(n).map(r+1+o+l.index);t.replaceWith(c,c+1,s.type.schema.linebreakReplacement.create())}}})}function jXe(t,s,r,n){s.forEach((a,o)=>{if(a.type==a.type.schema.linebreakReplacement){let l=t.mapping.slice(n).map(r+1+o);t.replaceWith(l,l+1,s.type.schema.text(` `))}})}function d8t(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function u8t(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 Ku(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new gn(Tr.from(l),0,0),1,!0))}function o1(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),y=a.index(u);if(f.type.spec.isolating)return!1;let _=f.content.cutByIndex(y,f.childCount),b=n&&n[p+1];b&&(_=_.replaceChild(0,b.type.create(b.attrs)));let w=n&&n[p]||f;if(!f.canReplace(y+1,f.childCount)||!w.type.validContent(_))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 h8t(t,s,r=1,n){let a=t.doc.resolve(s),o=Tr.empty,l=Tr.empty;for(let i=a.depth,c=a.depth-r,u=r-1;i>c;i--,u--){o=Tr.from(a.node(i).copy(o));let p=n&&n[u];l=Tr.from(p?p.type.create(p.attrs,l):a.node(i).copy(l))}t.step(new qu(s,s,new gn(o.append(l),r,r),!0))}function C2(t,s){let r=t.resolve(s),n=r.index();return kXe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function m8t(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&&kXe(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 p8t(t,s,r){let n=null,{linebreakReplacement:a}=t.doc.type.schema,o=t.doc.resolve(s-r),l=o.node().type;if(a&&l.inlineContent){let p=l.whitespace=="pre",f=!!l.contentMatch.matchType(a);p&&!f?n=!1:!p&&f&&(n=!0)}let i=t.steps.length;if(n===!1){let p=t.doc.resolve(s+r);jXe(t,p.node(),p.before(),i)}l.inlineContent&&gke(t,s+r-1,l,o.node().contentMatchAt(o.index()),n==null);let c=t.mapping.slice(i),u=c.map(s-r);if(t.step(new qu(u,c.map(s+r,-1),gn.empty,!0)),n===!0){let p=t.doc.resolve(u);wXe(t,p.node(),p.before(),t.steps.length)}return t}function f8t(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 xue(t,s,r=s,n=gn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return SXe(a,o,n)?new qu(s,r,n):new g8t(a,o,n).fit()}function SXe(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class g8t{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Tr.empty;for(let a=0;a<=s.depth;a++){let o=s.node(a);this.frontier.push({type:o.type,match:o.contentMatchAt(s.indexAfter(a))})}for(let a=s.depth;a>0;a--)this.placed=Tr.from(s.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let s=this.mustMoveInline(),r=this.placed.size-this.depth-this.$from.depth,n=this.$from,a=this.close(s<0?this.$to:n.doc.resolve(s));if(!a)return null;let o=this.placed,l=n.depth,i=a.depth;for(;l&&i&&o.childCount==1;)o=o.firstChild.content,l--,i--;let c=new gn(o,l,i);return s>-1?new Ku(n.pos,s,this.$to.pos,this.$to.end(),c,r):c.size||n.pos!=this.$to.pos?new qu(n.pos,a.pos,c):null}findFittable(){let s=this.unplaced.openStart;for(let r=this.unplaced.content,n=0,a=this.unplaced.openEnd;n1&&(a=0),o.type.spec.isolating&&a<=n){s=n;break}r=o.content}for(let r=1;r<=2;r++)for(let n=r==1?s:this.unplaced.openStart;n>=0;n--){let a,o=null;n?(o=qge(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(Tr.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=qge(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new gn(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=qge(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new gn(aI(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new gn(aI(s,r,1),r,n)}placeNodes({sliceDepth:s,frontierDepth:r,parent:n,inject:a,wrap:o}){for(;this.depth>r;)this.closeFrontierNode();if(o)for(let w=0;w1||c==0||w.content.size)&&(f=j,p.push(CXe(w.mark(y.allowedMarks(w.marks)),u==1?c:0,u==i.childCount?_:-1)))}let b=u==i.childCount;b||(_=-1),this.placed=iI(this.placed,r,Tr.from(p)),this.frontier[r].match=f,b&&_<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,j=i;w<_;w++){let N=j.lastChild;this.frontier.push({type:N.type,match:N.contentMatchAt(N.childCount)}),j=N.content}this.unplaced=b?s==0?gn.empty:new gn(aI(l.content,s-1,1),s-1,_<0?l.openEnd:s-1):new gn(aI(l.content,s,u),l.openStart,l.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let s=this.frontier[this.depth],r;if(!s.type.isTextblock||!Uge(this.$to,this.$to.depth,s.type,s.match,!1)||this.$to.depth==this.depth&&(r=this.findCloseLevel(this.$to))&&r.depth==this.depth)return-1;let{depth:n}=this.$to,a=this.$to.after(n);for(;n>1&&a==this.$to.end(--n);)++a;return a}findCloseLevel(s){e:for(let r=Math.min(this.depth,s.depth);r>=0;r--){let{match:n,type:a}=this.frontier[r],o=r=0;i--){let{match:c,type:u}=this.frontier[i],p=Uge(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=iI(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=iI(this.placed,this.depth,Tr.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Tr.empty,!0);r.childCount&&(this.placed=iI(this.placed,this.frontier.length,r))}}function aI(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(aI(t.firstChild.content,s-1,r)))}function iI(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(iI(t.lastChild.content,s-1,r)))}function qge(t,s){for(let r=0;r1&&(n=n.replaceChild(0,CXe(n.firstChild,s-1,n.childCount==1?r-1:0))),s>0&&(n=t.type.contentMatch.fillBefore(n).append(n),r<=0&&(n=n.append(t.type.contentMatch.matchFragment(n).fillBefore(Tr.empty,!0)))),t.copy(n)}function Uge(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&&!x8t(r,o.content,l)?i:null}function x8t(t,s,r){for(let n=r;n0;y--,_--){let b=a.node(y).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;l.indexOf(y)>-1?i=y:a.before(y)==_&&l.splice(1,0,-y)}let c=l.indexOf(i),u=[],p=n.openStart;for(let y=n.content,_=0;;_++){let b=y.firstChild;if(u.push(b),_==n.openStart)break;y=b.content}for(let y=p-1;y>=0;y--){let _=u[y],b=y8t(_.type);if(b&&!_.sameMarkup(a.node(Math.abs(i)-1)))p=y;else if(b||!_.type.isTextblock)break}for(let y=n.openStart;y>=0;y--){let _=(y+p+1)%(n.openStart+1),b=u[_];if(b)for(let w=0;w=0&&(t.replace(s,r,n),!(t.steps.length>f));y--){let _=l[y];_<0||(s=a.before(_),r=o.after(_))}}function MXe(t,s,r,n,a){if(sn){let o=a.contentMatchAt(0),l=o.fillBefore(t).append(t);t=l.append(o.matchFragment(l).fillBefore(Tr.empty,!0))}return t}function _8t(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=f8t(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new gn(Tr.from(n),0,0))}function b8t(t,s,r){let n=t.doc.resolve(s),a=t.doc.resolve(r),o=TXe(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 TXe(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 DM extends Gh{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 Gd.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 Gd.fromReplace(s,this.pos,this.pos+1,new gn(Tr.from(a),0,r.isLeaf?0:1))}getMap(){return tf.empty}invert(s){return new DM(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 DM(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 DM(r.pos,r.attr,r.value)}}Gh.jsonID("attr",DM);class V8 extends Gh{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 Gd.ok(n)}getMap(){return tf.empty}invert(s){return new V8(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 V8(r.attr,r.value)}}Gh.jsonID("docAttr",V8);let NT=class extends Error{};NT=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};NT.prototype=Object.create(Error.prototype);NT.prototype.constructor=NT;NT.prototype.name="TransformError";class yke{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new U8}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new NT(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=gn.empty){let a=xue(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new gn(Tr.from(n),0,0))}delete(s,r){return this.replace(s,r,gn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return v8t(this,s,r,n),this}replaceRangeWith(s,r,n){return _8t(this,s,r,n),this}deleteRange(s,r){return b8t(this,s,r),this}lift(s,r){return a8t(this,s,r),this}join(s,r=1){return p8t(this,s,r),this}wrap(s,r){return l8t(this,s,r),this}setBlockType(s,r=s,n,a=null){return c8t(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return u8t(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new DM(s,r,n)),this}setDocAttribute(s,r){return this.step(new V8(s,r)),this}addNodeMark(s,r){return this.step(new xb(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 Sl)r.isInSet(n.marks)&&this.step(new SS(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new SS(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 h8t(this,s,r,n),this}addMark(s,r,n){return s8t(this,s,r,n),this}removeMark(s,r,n){return r8t(this,s,r,n),this}clearIncompatible(s,r,n){return gke(this,s,r,n),this}}const Vge=Object.create(null);class hi{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new AXe(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?_5(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):_5(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 hf(s.node(0))}static atStart(s){return _5(s,s,0,0,1)||new hf(s)}static atEnd(s){return _5(s,s,s.content.size,s.childCount,-1)||new hf(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Vge[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 Vge)throw new RangeError("Duplicate use of selection JSON ID "+s);return Vge[s]=r,r.prototype.jsonID=s,r}getBookmark(){return Ya.between(this.$anchor,this.$head).getBookmark()}}hi.prototype.visible=!0;class AXe{constructor(s,r){this.$from=s,this.$to=r}}let lIe=!1;function cIe(t){!lIe&&!t.parent.inlineContent&&(lIe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Ya extends hi{constructor(s,r=s){cIe(s),cIe(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 hi.near(n);let a=s.resolve(r.map(this.anchor));return new Ya(a.parent.inlineContent?a:n,n)}replace(s,r=gn.empty){if(super.replace(s,r),r==gn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof Ya&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new yue(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 Ya(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=hi.findFrom(r,n,!0)||hi.findFrom(r,-n,!0);if(o)r=o.$head;else return hi.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(hi.findFrom(s,-n,!0)||hi.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&&Ba.isSelectable(i))return Ba.create(t,r-(a<0?i.nodeSize:0))}else{let c=_5(t,i,r+a,a<0?i.childCount:0,a,o);if(c)return c}r+=i.nodeSize*a}return null}function dIe(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=p)}),t.setSelection(hi.near(t.doc.resolve(l),r))}const uIe=1,q7=2,hIe=4;class j8t extends yke{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|=q7,this}ensureMarks(s){return Sl.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&q7)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~q7,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)||Sl.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(hi.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|=hIe,this}get scrolledIntoView(){return(this.updated&hIe)>0}}function mIe(t,s){return!s||!t?t:t.bind(s)}class oI{constructor(s,r,n){this.name=s,this.init=mIe(r.init,n),this.apply=mIe(r.apply,n)}}const k8t=[new oI("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new oI("selection",{init(t,s){return t.selection||hi.atStart(s.doc)},apply(t){return t.selection}}),new oI("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new oI("scrollToSelection",{init(){return 0},apply(t,s){return t.scrolledIntoView?s+1:s}})];class Hge{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=k8t.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 oI(n.key,n.spec.state,n))})}}class $5{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 Hge(s.schema,s.plugins),o=new $5(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=Hb.fromJSON(s.schema,r.doc);else if(l.name=="selection")o.selection=hi.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 EXe(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=EXe(a,s,{})),r[n]=a}return r}class Nu{constructor(s){this.spec=s,this.props={},s.props&&EXe(s.props,this,this.props),this.key=s.key?s.key.key:PXe("plugin")}getState(s){return s[this.key]}}const Wge=Object.create(null);function PXe(t){return t in Wge?t+"$"+ ++Wge[t]:(Wge[t]=0,t+"$")}class Kh{constructor(s="key"){this.key=PXe(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const hh=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},ST=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let m1e=null;const Nv=function(t,s,r){let n=m1e||(m1e=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},N8t=function(){m1e=null},CS=function(t,s,r,n){return r&&(pIe(t,s,r,n,-1)||pIe(t,s,r,n,1))},S8t=/^(img|br|input|textarea|hr)$/i;function pIe(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:lg(t))){let l=t.parentNode;if(!l||l.nodeType!=1||jO(t)||S8t.test(t.nodeName)||t.contentEditable=="false")return!1;s=hh(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?lg(t):0}else return!1}}function lg(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function C8t(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=lg(t)}else if(t.parentNode&&!jO(t))s=hh(t),t=t.parentNode;else return null}}function M8t(t,s){for(;;){if(t.nodeType==3&&s2),tg=CT||(_0?/Mac/.test(_0.platform):!1),DXe=_0?/Win/.test(_0.platform):!1,qv=/Android \d/.test(M2),kO=!!fIe&&"webkitFontSmoothing"in fIe.documentElement.style,P8t=kO?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function I8t(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 pv(t,s){return typeof t=="number"?t:t[s]}function L8t(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 gIe(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=ST(l);continue}let i=l,c=i==o.body,u=c?I8t(o):L8t(i),p=0,f=0;if(s.topu.bottom-pv(n,"bottom")&&(f=s.bottom-s.top>u.bottom-u.top?s.top+pv(a,"top")-u.top:s.bottom-u.bottom+pv(a,"bottom")),s.leftu.right-pv(n,"right")&&(p=s.right-u.right+pv(a,"right")),p||f)if(c)o.defaultView.scrollBy(p,f);else{let _=i.scrollLeft,b=i.scrollTop;f&&(i.scrollTop+=f),p&&(i.scrollLeft+=p);let w=i.scrollLeft-_,j=i.scrollTop-b;s={left:s.left-w,top:s.top-j,right:s.right-w,bottom:s.bottom-j}}let y=c?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(y))break;l=y=="absolute"?l.offsetParent:ST(l)}}function D8t(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:OXe(t.dom)}}function OXe(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=ST(n));return s}function O8t({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;RXe(r,n==0?0:n-s)}function RXe(t,s){for(let r=0;r=i){l=Math.max(b.bottom,l),i=Math.min(b.top,i);let w=b.left>s.left?b.left-s.left:b.right=(b.left+b.right)/2?1:0));continue}}else b.top>s.top&&!c&&b.left<=s.left&&b.right>=s.left&&(c=p,u={left:Math.max(b.left,Math.min(b.right,s.left)),top:b.top});!r&&(s.left>=b.right&&s.top>=b.top||s.left>=b.left&&s.top>=b.bottom)&&(o=f+1)}}return!r&&c&&(r=c,a=u,n=0),r&&r.nodeType==3?F8t(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:FXe(r,a)}function F8t(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 _ke(t,s){return t.left>=s.left-1&&t.left<=s.right+1&&t.top>=s.top-1&&t.top<=s.bottom+1}function z8t(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 $8t(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 zXe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let u;kO&&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=$8t(t,n,a,s))}i==null&&(i=B8t(t,l,s));let c=t.docView.nearestDesc(l,!0);return{pos:i,inside:c?c.posAtStart-c.border:-1}}function xIe(t){return t.top=0&&a==n.nodeValue.length?(c--,p=1):r<0?c--:u++,P6(I_(Nv(n,c,u),p),p<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==lg(n))){let c=n.childNodes[a-1];if(c.nodeType==1)return Gge(c.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==lg(n))){let c=n.childNodes[a-1],u=c.nodeType==3?Nv(c,lg(c)-(l?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return P6(I_(u,1),!1)}if(o==null&&a=0)}function P6(t,s){if(t.width==0)return t;let r=s?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function Gge(t,s){if(t.height==0)return t;let r=s?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function $Xe(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 V8t(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return $Xe(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=BXe(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=Nv(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 H8t=/[\u0590-\u08ac]/;function W8t(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?!H8t.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:$Xe(t,s,()=>{let{focusNode:c,focusOffset:u,anchorNode:p,anchorOffset:f}=t.domSelectionRange(),y=i.caretBidiLevel;i.modify("move",r,"character");let _=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:b,focusOffset:w}=t.domSelectionRange(),j=b&&!_.contains(b.nodeType==1?b:b.parentNode)||c==b&&u==w;try{i.collapse(p,f),c&&(c!=p||u!=f)&&i.extend&&i.extend(c,u)}catch{}return y!=null&&(i.caretBidiLevel=y),j}):n.pos==n.start()||n.pos==n.end()}let yIe=null,vIe=null,_Ie=!1;function G8t(t,s,r){return yIe==s&&vIe==r?_Ie:(yIe=s,vIe=r,_Ie=r=="up"||r=="down"?V8t(t,s,r):W8t(t,s,r))}const Ng=0,bIe=1,p4=2,b0=3;class NO{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=Ng,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;rhh(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 UXe){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 qXe&&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?hh(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 y=this.children[f-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){a=hh(y.dom)+1;break}s-=y.size}a==-1&&(a=0)}if(a>-1&&(u>r||i==this.children.length-1)){r=u;for(let p=i+1;pb&&lr){let b=i;i=c,c=b}let _=document.createRange();_.setEnd(c.node,c.offset),_.setStart(i.node,i.offset),u.removeAllRanges(),u.addRange(_)}}ignoreMutation(s){return!this.contentDOM&&s.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(s,r){for(let n=0,a=0;a=n:sn){let i=n+o.border,c=l-o.border;if(s>=i&&r<=c){this.dirty=s==n||r==l?p4:bIe,s==i&&r==c&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=b0:o.markDirty(s-i,r-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?p4:b0}n=l}this.dirty=p4}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?p4:bIe;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==Ng&&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 K8t extends NO{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 MS extends NO{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=XS.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new MS(s,r,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&b0||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(s){return this.dirty!=b0&&this.mark.eq(s)}markDirty(s,r){if(super.markDirty(s,r),this.dirty!=Ng){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=y1e(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}=XS.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 y=p;return p=WXe(p,n,r),u?c=new Z8t(s,r,n,a,p,f||null,y,u,o,l+1):r.isText?new _ue(s,r,n,a,p,y,o):new Gb(s,r,n,a,p,f||null,y,o,l+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let s={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(s.preserveWhitespace="full"),!this.contentDOM)s.getContent=()=>this.node.content;else if(!this.contentLost)s.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let n=this.children[r];if(this.dom.contains(n.dom.parentNode)){s.contentElement=n.dom.parentNode;break}}s.contentElement||(s.getContent=()=>Tr.empty)}return s}matchesNode(s,r,n){return this.dirty==Ng&&s.eq(this.node)&&Goe(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 X8t(this,l&&l.node,s);eDt(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?Sl.none:this.node.child(p).marks,n,s),c.placeWidget(u,s,a)},(u,p,f,y)=>{c.syncToMarks(u.marks,n,s);let _;c.findNodeMatch(u,p,f,y)||i&&s.state.selection.from>a&&s.state.selection.to-1&&c.updateNodeAt(u,p,f,_,s)||c.updateNextNode(u,p,f,s,y,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==p4)&&(l&&this.protectLocalComposition(s,l),VXe(this.contentDOM,this.children,s),CT&&tDt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof Ya)||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=sDt(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 K8t(this,o,r,a);s.input.compositionNodes.push(l),this.children=y1e(this.children,n,n+a.length,s,l)}update(s,r,n,a){return this.dirty==b0||!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=Ng}updateOuterDeco(s){if(Goe(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=HXe(this.dom,this.nodeDOM,x1e(this.outerDeco,this.node,r),x1e(s,this.node,r)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=s}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function wIe(t,s,r,n,a){WXe(n,s,t);let o=new Gb(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class _ue extends Gb{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==b0||this.dirty!=Ng&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=Ng||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=Ng,!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 _ue(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=b0)}get domAtom(){return!1}isText(s){return this.node.text==s}}class UXe extends NO{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==Ng&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Z8t extends Gb{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==b0)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 VXe(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=MS.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 MS)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 J8t(t,s){return t.type.side-s.type.side}function eDt(t,s,r,n){let a=s.locals(t),o=0;if(a.length==0){for(let u=0;uo;)i.push(a[l++]);let b=o+y.nodeSize;if(y.isText){let j=b;l!j.inline):i.slice();n(y,w,s.forChild(o,y),_),o=b}}function tDt(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 sDt(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 y1e(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 bke(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(vue(r)){for(c=l;a&&!a.node;)a=a.parent;let f=a.node;if(a&&f.isAtom&&Ba.isSelectable(f)&&a.parent&&!(f.isInline&&T8t(r.focusNode,r.focusOffset,a.dom))){let y=a.posBefore;u=new Ba(l==y?i:n.resolve(y))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let f=l,y=l;for(let _=0;_{(r.anchorNode!=n||r.anchorOffset!=a)&&(s.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!GXe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function nDt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,hh(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&jp&&Wb<=11&&(r.disabled=!0,r.disabled=!1)}function KXe(t,s){if(s instanceof Ba){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&(CIe(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else CIe(t)}function CIe(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function wke(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||Ya.between(s,r,n)}function MIe(t){return t.editable&&!t.hasFocus()?!1:ZXe(t)}function ZXe(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 aDt(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return CS(s.node,s.offset,r.anchorNode,r.anchorOffset)}function v1e(t,s){let{$anchor:r,$head:n}=t.selection,a=s>0?r.max(n):r.min(n),o=a.parent.inlineContent?a.depth?t.doc.resolve(s>0?a.after():a.before()):null:a;return o&&hi.findFrom(o,s)}function z_(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function TIe(t,s,r){let n=t.state.selection;if(n instanceof Ya)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 z_(t,new Ya(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=v1e(t.state,s);return a&&a instanceof Ba?z_(t,a):!1}else if(!(tg&&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?Ba.isSelectable(o)?z_(t,new Ba(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):kO?z_(t,new Ya(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof Ba&&n.node.isInline)return z_(t,new Ya(s>0?n.$to:n.$from));{let a=v1e(t.state,s);return a?z_(t,a):!1}}}function Koe(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function RL(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function s5(t,s){return s<0?iDt(t):oDt(t)}function iDt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(kg&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(RL(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(YXe(r))break;{let i=r.previousSibling;for(;i&&RL(i,-1);)a=r.parentNode,o=hh(i),i=i.previousSibling;if(i)r=i,n=Koe(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?_1e(t,r,n):a&&_1e(t,a,o)}function oDt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=Koe(r),o,l;for(;;)if(n{t.state==a&&l1(t)},50)}function AIe(t,s){let r=t.state.doc.resolve(s);if(!(Vu||DXe)&&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 EIe(t,s,r){let n=t.state.selection;if(n instanceof Ya&&!n.empty||r.indexOf("s")>-1||tg&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=v1e(t.state,s);if(l&&l instanceof Ba)return z_(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof hf?hi.near(l,s):hi.findFrom(l,s);return i?z_(t,i):!1}return!1}function PIe(t,s){if(!(t.state.selection instanceof Ya))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 IIe(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function dDt(t){if(!Vh||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;IIe(t,n,"true"),setTimeout(()=>IIe(t,n,"false"),20)}return!1}function uDt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function hDt(t,s){let r=s.keyCode,n=uDt(s);if(r==8||tg&&r==72&&n=="c")return PIe(t,-1)||s5(t,-1);if(r==46&&!s.shiftKey||tg&&r==68&&n=="c")return PIe(t,1)||s5(t,1);if(r==13||r==27)return!0;if(r==37||tg&&r==66&&n=="c"){let a=r==37?AIe(t,t.state.selection.from)=="ltr"?-1:1:-1;return TIe(t,a,n)||s5(t,a)}else if(r==39||tg&&r==70&&n=="c"){let a=r==39?AIe(t,t.state.selection.from)=="ltr"?1:-1:1;return TIe(t,a,n)||s5(t,a)}else{if(r==38||tg&&r==80&&n=="c")return EIe(t,-1,n)||s5(t,-1);if(r==40||tg&&r==78&&n=="c")return dDt(t)||EIe(t,1,n)||s5(t,1);if(n==(tg?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function jke(t,s){t.someProp("transformCopied",_=>{s=_(s,t)});let r=[],{content:n,openStart:a,openEnd:o}=s;for(;a>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){a--,o--;let _=n.firstChild;r.push(_.type.name,_.attrs!=_.type.defaultAttrs?_.attrs:null),n=_.content}let l=t.someProp("clipboardSerializer")||XS.fromSchema(t.state.schema),i=sQe(),c=i.createElement("div");c.appendChild(l.serializeFragment(n,{document:i}));let u=c.firstChild,p,f=0;for(;u&&u.nodeType==1&&(p=tQe[u.nodeName.toLowerCase()]);){for(let _=p.length-1;_>=0;_--){let b=i.createElement(p[_]);for(;c.firstChild;)b.appendChild(c.firstChild);c.appendChild(b),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${a} ${o}${f?` -${f}`:""} ${JSON.stringify(r)}`);let y=t.someProp("clipboardTextSerializer",_=>_(s,t))||s.content.textBetween(0,s.content.size,` `);return{dom:c,text:y,slice:s}}function XXe(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",y=>{s=y(s,o||n,t)}),o)return i=new gn(Tr.from(t.state.schema.text(s.replace(/\r\n?/g,` `))),0,0),t.someProp("transformPasted",y=>{i=y(i,t,!0)}),i;let f=t.someProp("clipboardTextParser",y=>y(s,a,n,t));if(f)i=f;else{let y=a.marks(),{schema:_}=t.state,b=XS.fromSchema(_);l=document.createElement("div"),s.split(/(?:\r\n?|\n)+/).forEach(w=>{let j=l.appendChild(document.createElement("p"));w&&j.appendChild(b.serializeNode(_.text(w,y)))})}}else t.someProp("transformPastedHTML",f=>{r=f(r,t)}),l=gDt(r),kO&&xDt(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 y=l.firstChild;for(;y&&y.nodeType!=1;)y=y.nextSibling;if(!y)break;l=y}if(i||(i=(t.someProp("clipboardParser")||t.someProp("domParser")||LL.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(c||p),context:a,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!mDt.test(y.parentNode.nodeName)?{ignore:!0}:null}})),p)i=yDt(LIe(i,+p[1],+p[2]),p[4]);else if(i=gn.maxOpen(pDt(i.content,a),!0),i.openStart||i.openEnd){let f=0,y=0;for(let _=i.content.firstChild;f{i=f(i,t,c)}),i}const mDt=/^(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 pDt(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&&JXe(c,o,i,l[l.length-1],0))l[l.length-1]=u;else{l.length&&(l[l.length-1]=eQe(l[l.length-1],o.length));let p=QXe(i,c);l.push(p),a=a.matchType(p.type),o=c}}),l)return Tr.from(l)}return t}function QXe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Tr.from(t));return t}function JXe(t,s,r,n,a){if(a1&&(o=0),a=r&&(i=s<0?l.contentMatchAt(0).fillBefore(i,o<=a).append(i):i.append(l.contentMatchAt(l.childCount).fillBefore(Tr.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function LIe(t,s,r){return sr})),Zge.createHTML(t)):t}function gDt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=sQe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&tQe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=fDt(t),a)for(let o=0;o=0;i-=2){let c=r.nodes[n[i]];if(!c||c.hasRequiredAttrs())break;a=Tr.from(c.create(n[i+1],a)),o++,l++}return new gn(a,o,l)}const Im={},Lm={},vDt={touchstart:!0,touchmove:!0};class _Dt{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 bDt(t){for(let s in Im){let r=Im[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{jDt(t,n)&&!kke(t,n)&&(t.editable||!(n.type in Lm))&&r(t,n)},vDt[s]?{passive:!0}:void 0)}Vh&&t.dom.addEventListener("input",()=>null),w1e(t)}function yb(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function wDt(t){t.domObserver.stop();for(let s in t.input.eventHandlers)t.dom.removeEventListener(s,t.input.eventHandlers[s]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function w1e(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>kke(t,n))})}function kke(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function jDt(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 kDt(t,s){!kke(t,s)&&Im[s.type]&&(t.editable||!(s.type in Lm))&&Im[s.type](t,s)}Lm.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!nQe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(qv&&Vu&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),CT&&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,s4(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||hDt(t,r)?r.preventDefault():yb(t,"key")};Lm.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};Lm.keypress=(t,s)=>{let r=s;if(nQe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||tg&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof Ya)||!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 bue(t){return{left:t.clientX,top:t.clientY}}function NDt(t,s){let r=s.x-t.clientX,n=s.y-t.clientY;return r*r+n*n<100}function Nke(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 OM(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 SDt(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&Ba.isSelectable(n)?(OM(t,new Ba(r)),!0):!1}function CDt(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof Ba&&(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(Ba.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?(OM(t,Ba.create(t.state.doc,a)),!0):!1}function MDt(t,s,r,n,a){return Nke(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?CDt(t,r):SDt(t,r))}function TDt(t,s,r,n){return Nke(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function ADt(t,s,r,n){return Nke(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||EDt(t,r,n)}function EDt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(OM(t,Ya.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)OM(t,Ya.create(n,i+1,i+1+l.content.size));else if(Ba.isSelectable(l))OM(t,Ba.create(n,i));else continue;return!0}}function Ske(t){return Zoe(t)}const rQe=tg?"metaKey":"ctrlKey";Im.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=Ske(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&NDt(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(bue(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new PDt(t,l,r,!!n)):(o=="doubleClick"?TDt:ADt)(t,l.pos,l.inside,r)?r.preventDefault():yb(t,"pointer"))};class PDt{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 Ba&&u.from<=l&&u.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&kg&&!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)),yb(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(()=>l1(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(bue(s))),this.updateAllowDefault(s),this.allowDefault||!r?yb(this.view,"pointer"):MDt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||Vh&&this.mightDrag&&!this.mightDrag.node.isAtom||Vu&&!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)?(OM(this.view,hi.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):yb(this.view,"pointer")}move(s){this.updateAllowDefault(s),yb(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)}}Im.touchstart=t=>{t.input.lastTouch=Date.now(),Ske(t),yb(t,"pointer")};Im.touchmove=t=>{t.input.lastTouch=Date.now(),yb(t,"pointer")};Im.contextmenu=t=>Ske(t);function nQe(t,s){return t.composing?!0:Vh&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const IDt=qv?5e3:-1;Lm.compositionstart=Lm.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof Ya&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||Vu&&DXe&&LDt(t)))t.markCursor=t.state.storedMarks||r.marks(),Zoe(t,!0),t.markCursor=null;else if(Zoe(t,!s.selection.empty),kg&&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}aQe(t,IDt)};function LDt(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"}Lm.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++,aQe(t,20))};function aQe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>Zoe(t),s))}function iQe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=ODt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function DDt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=C8t(s.focusNode,s.focusOffset),n=M8t(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 ODt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Zoe(t,s=!1){if(!(qv&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),iQe(t),s||t.docView&&t.docView.dirty){let r=bke(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 RDt(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 H8=jp&&Wb<15||CT&&P8t<604;Im.copy=Lm.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=H8?null:r.clipboardData,l=n.content(),{dom:i,text:c}=jke(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",c)):RDt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function FDt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function zDt(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?W8(t,n.value,null,a,s):W8(t,n.textContent,n.innerHTML,a,s)},50)}function W8(t,s,r,n,a){let o=XXe(t,s,r,n,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,a,o||gn.empty)))return!0;if(!o)return!1;let l=FDt(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 oQe(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," "):""}Lm.paste=(t,s)=>{let r=s;if(t.composing&&!qv)return;let n=H8?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&W8(t,oQe(n),n.getData("text/html"),a,r)?r.preventDefault():zDt(t,r)};class lQe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const BDt=tg?"altKey":"ctrlKey";function cQe(t,s){let r=t.someProp("dragCopies",n=>!n(s));return r??!s[BDt]}Im.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(bue(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof Ba?a.to-1:a.to))){if(n&&n.mightDrag)l=Ba.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=Ba.create(t.state.doc,f.posBefore))}}let i=(l||t.state.selection).content(),{dom:c,text:u,slice:p}=jke(t,i);(!r.dataTransfer.files.length||!Vu||LXe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(H8?"Text":"text/html",c.innerHTML),r.dataTransfer.effectAllowed="copyMove",H8||r.dataTransfer.setData("text/plain",u),t.dragging=new lQe(p,cQe(t,r),l)};Im.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};Lm.dragover=Lm.dragenter=(t,s)=>s.preventDefault();Lm.drop=(t,s)=>{try{$Dt(t,s,t.dragging)}finally{t.dragging=null}};function $Dt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(bue(s));if(!n)return;let a=t.state.doc.resolve(n.pos),o=r&&r.slice;o?t.someProp("transformPasted",_=>{o=_(o,t,!1)}):o=XXe(t,oQe(s.dataTransfer),H8?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&cQe(t,s));if(t.someProp("handleDrop",_=>_(t,s,o||gn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?NXe(t.state.doc,a.pos,o):a.pos;i==null&&(i=a.pos);let c=t.state.tr;if(l){let{node:_}=r;_?_.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 y=c.doc.resolve(u);if(p&&Ba.isSelectable(o.content.firstChild)&&y.nodeAfter&&y.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new Ba(y));else{let _=c.mapping.map(i);c.mapping.maps[c.mapping.maps.length-1].forEach((b,w,j,N)=>_=N),c.setSelection(wke(t,y,c.doc.resolve(_)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}Im.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())&&l1(t)},20))};Im.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)};Im.beforeinput=(t,s)=>{if(Vu&&qv&&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,s4(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 Lm)Im[t]=Lm[t];function G8(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 Yoe{constructor(s,r){this.toDOM=s,this.spec=r||eS,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 bm(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof Yoe&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&G8(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class Kb{constructor(s,r){this.attrs=s,this.spec=r||eS}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 bm(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==Th||s.maps.length==0?this:this.mapInner(s,r,0,0,n||eS)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let u=c+n,p;if(p=uQe(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 Kb){let u=Math.max(o,c.from)-o,p=Math.min(l,c.to)-o;ua.map(s,r,eS));return Z_.from(n)}forChild(s,r){if(r.isLeaf)return od.empty;let n=[];for(let a=0;ar instanceof od)?s:s.reduce((r,n)=>r.concat(n instanceof od?n:n.members),[]))}}forEachSet(s){for(let r=0;r{let j=w-b-(_-y);for(let N=0;NS+p-f)continue;let T=i[N]+p-f;_>=T?i[N+1]=y<=T?-2:-1:y>=p&&j&&(i[N]+=j,i[N+1]+=j)}f+=j}),p=r.maps[u].map(p,-1)}let c=!1;for(let u=0;u=n.content.size){c=!0;continue}let y=r.map(t[u+1]+o,-1),_=y-a,{index:b,offset:w}=n.content.findIndex(f),j=n.maybeChild(b);if(j&&w==f&&w+j.nodeSize==_){let N=i[u+2].mapInner(r,j,p+1,t[u]+o+1,l);N!=Th?(i[u]=f,i[u+1]=_,i[u+2]=N):(i[u+1]=-2,c=!0)}else c=!0}if(c){let u=UDt(i,t,s,r,a,o,l),p=Xoe(u,n,0,l);s=p.local;for(let f=0;fr&&l.to{let u=uQe(t,i,c+r);if(u){o=!0;let p=Xoe(u,i,r+c+1,n);p!=Th&&a.push(c,c+i.nodeSize,p)}});let l=dQe(o?hQe(t):t,-r).sort(tS);for(let i=0;i0;)s++;t.splice(s,0,r)}function Yge(t){let s=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=Th&&s.push(n)}),t.cursorWrapper&&s.push(od.create(t.state.doc,[t.cursorWrapper.deco])),Z_.from(s)}const VDt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},HDt=jp&&Wb<=11;class WDt{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 GDt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new WDt,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()}),HDt&&(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,VDt)),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(MIe(this.view)){if(this.suppressingSelectionUpdates)return l1(this.view);if(jp&&Wb<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&CS(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=ST(o))r.add(o);for(let o=s.anchorNode;o;o=ST(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)&&MIe(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,y]=p;f.parentNode&&f.parentNode.parentNode==y.parentNode?y.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let y of p){let _=y.parentNode;_&&_.nodeName=="LI"&&(!f||YDt(s,f)!=_)&&y.remove()}}}else if((Vu||Vh)&&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),KDt(s)),this.handleDOMChange(o,l,i,c),s.docView&&s.docView.dirty?s.updateState(s.state):this.currentSelection.eq(n)||l1(s),this.currentSelection.set(n))}registerMutation(s,r){if(r.indexOf(s.target)>-1)return null;let n=this.view.docView.nearestDesc(s.target);if(s.type=="attributes"&&(n==this.view.docView||s.attributeName=="contenteditable"||s.attributeName=="style"&&!s.oldValue&&!s.target.getAttribute("style"))||!n||n.ignoreMutation(s))return null;if(s.type=="childList"){for(let p=0;pa;j--){let N=n.childNodes[j-1],S=N.pmViewDesc;if(N.nodeName=="BR"&&!S){o=j;break}if(!S||S.size)break}let f=t.state.doc,y=t.someProp("domParser")||LL.fromSchema(t.state.schema),_=f.resolve(l),b=null,w=y.parse(n,{topNode:_.parent,topMatch:_.parent.contentMatchAt(_.index()),topOpen:!0,from:a,to:o,preserveWhitespace:_.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:QDt,context:_});if(u&&u[0].pos!=null){let j=u[0].pos,N=u[1]&&u[1].pos;N==null&&(N=j),b={anchor:j+l,head:N+l}}return{doc:w,sel:b,from:l,to:i}}function QDt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Vh&&/^(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||Vh&&/^(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 JDt=/^(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 eOt(t,s,r,n,a){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,s<0){let $=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,q=bke(t,$);if(q&&!t.state.selection.eq(q)){if(Vu&&qv&&t.input.lastKeyCode===13&&Date.now()-100V(t,s4(13,"Enter"))))return;let U=t.state.tr.setSelection(q);$=="pointer"?U.setMeta("pointer",!0):$=="key"&&U.scrollIntoView(),o&&U.setMeta("composition",o),t.dispatch(U)}return}let l=t.state.doc.resolve(s),i=l.sharedDepth(r);s=l.before(i+1),r=t.state.doc.resolve(r).after(i+1);let c=t.state.selection,u=XDt(t,s,r),p=t.state.doc,f=p.slice(u.from,u.to),y,_;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||qv)&&a.some($=>$.nodeType==1&&!JDt.test($.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",$=>$(t,s4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(n&&c instanceof Ya&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))b={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let $=BIe(t,t.state.doc,u.sel);if($&&!$.eq(t.state.selection)){let q=t.state.tr.setSelection($);o&&q.setMeta("composition",o),t.dispatch(q)}}return}t.state.selection.fromt.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?b.start=t.state.selection.from:b.endA=t.state.selection.to-2&&t.state.selection.to<=u.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),jp&&Wb<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>u.from&&u.doc.textBetween(b.start-u.from-1,b.start-u.from+1)=="  "&&(b.start--,b.endA--,b.endB--);let w=u.doc.resolveNoCache(b.start-u.from),j=u.doc.resolveNoCache(b.endB-u.from),N=p.resolve(b.start),S=w.sameParent(j)&&w.parent.inlineContent&&N.end()>=b.endA;if((CT&&t.input.lastIOSEnter>Date.now()-225&&(!S||a.some($=>$.nodeName=="DIV"||$.nodeName=="P"))||!S&&w.pos$(t,s4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&sOt(p,b.start,b.endA,w,j)&&t.someProp("handleKeyDown",$=>$(t,s4(8,"Backspace")))){qv&&Vu&&t.domObserver.suppressSelectionUpdates();return}Vu&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),qv&&!S&&w.start()!=j.start()&&j.parentOffset==0&&w.depth==j.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==b.endA&&(b.endB-=2,j=u.doc.resolveNoCache(b.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function($){return $(t,s4(13,"Enter"))})},20));let T=b.start,I=b.endA,L=$=>{let q=$||t.state.tr.replace(T,I,u.doc.slice(b.start-u.from,b.endB-u.from));if(u.sel){let U=BIe(t,q.doc,u.sel);U&&!(Vu&&t.composing&&U.empty&&(b.start!=b.endB||t.input.lastChromeDeletel1(t),20));let $=L(t.state.tr.delete(T,I)),q=p.resolve(b.start).marksAcross(p.resolve(b.endA));q&&$.ensureMarks(q),t.dispatch($)}else if(b.endA==b.endB&&(R=tOt(w.parent.content.cut(w.parentOffset,j.parentOffset),N.parent.content.cut(N.parentOffset,b.endA-N.start())))){let $=L(t.state.tr);R.type=="add"?$.addMark(T,I,R.mark):$.removeMark(T,I,R.mark),t.dispatch($)}else if(w.parent.child(w.index()).isText&&w.index()==j.index()-(j.textOffset?0:1)){let $=w.parent.textBetween(w.parentOffset,j.parentOffset),q=()=>L(t.state.tr.insertText($,T,I));t.someProp("handleTextInput",U=>U(t,T,I,$,q))||t.dispatch(q())}else t.dispatch(L());else t.dispatch(L())}function BIe(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:wke(t,s.resolve(r.anchor),s.resolve(r.head))}function tOt(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||Xge(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 rOt(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 mQe{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 _Dt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(WIe),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=VIe(this),UIe(this),this.nodeViews=HIe(this),this.docView=wIe(this.state.doc,qIe(this),Yge(this),this.dom,this),this.domObserver=new GDt(this,(n,a,o,l)=>eOt(this,n,a,o,l)),this.domObserver.start(),bDt(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let s=this._props;this._props={};for(let r in s)this._props[r]=s[r];this._props.state=this.state}return this._props}update(s){s.handleDOMEvents!=this._props.handleDOMEvents&&w1e(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach(WIe),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&&(iQe(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 _=HIe(this);aOt(_,this.nodeViews)&&(this.nodeViews=_,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&w1e(this),this.editable=VIe(this),UIe(this);let c=Yge(this),u=qIe(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 y=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&D8t(this);if(l){this.domObserver.stop();let _=f&&(jp||Vu)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&nOt(a.selection,s.selection);if(f){let b=Vu?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=DDt(this)),(o||!this.docView.update(s.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=wIe(s.doc,u,c,this.dom,this)),b&&!this.trackWrites&&(_=!0)}_||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&aDt(this))?l1(this,_):(KXe(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():y&&O8t(y)}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 Ba){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&gIe(this,r.getBoundingClientRect(),s)}else gIe(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 lQe(s.slice,s.move,a<0?void 0:Ba.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 q8t(this,s)}coordsAtPos(s,r=1){return BXe(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 G8t(this,r||this.state,s)}pasteHTML(s,r){return W8(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return W8(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return jke(this,s)}destroy(){this.docView&&(wDt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Yge(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,N8t())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return kDt(this,s)}domSelectionRange(){let s=this.domSelection();return s?Vh&&this.root.nodeType===11&&A8t(this.dom.ownerDocument)==this.dom&&ZDt(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}mQe.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function qIe(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"),[bm.node(0,t.state.doc.content.size,s)]}function UIe(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:bm.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function VIe(t){return!t.someProp("editable",s=>s(t.state)===!1)}function nOt(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 HIe(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 aOt(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 WIe(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 d2={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:"'"},Qoe={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},iOt=typeof navigator<"u"&&/Mac/.test(navigator.platform),oOt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var mh=0;mh<10;mh++)d2[48+mh]=d2[96+mh]=String(mh);for(var mh=1;mh<=24;mh++)d2[mh+111]="F"+mh;for(var mh=65;mh<=90;mh++)d2[mh]=String.fromCharCode(mh+32),Qoe[mh]=String.fromCharCode(mh);for(var Qge in d2)Qoe.hasOwnProperty(Qge)||(Qoe[Qge]=d2[Qge]);function lOt(t){var s=iOt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||oOt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?Qoe:d2)[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 cOt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),dOt=typeof navigator<"u"&&/Win/.test(navigator.platform);function uOt(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 pQe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const fQe=(t,s,r)=>{let n=pQe(t,r);if(!n)return!1;let a=Eke(n);if(!a){let l=n.blockRange(),i=l&&zA(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(kQe(t,a,s,-1))return!0;if(n.parent.content.size==0&&(MT(o,"end")||Ba.isSelectable(o)))for(let l=n.depth;;l--){let i=xue(t.doc,n.before(l),n.after(l),gn.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},pOt=(t,s,r)=>{let n=pQe(t,r);if(!n)return!1;let a=Eke(n);return a?gQe(t,a,s):!1},fOt=(t,s,r)=>{let n=yQe(t,r);if(!n)return!1;let a=Pke(n);return a?gQe(t,a,s):!1};function gQe(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=xue(t.doc,o,c,gn.empty);if(!u||u.from!=o||u instanceof qu&&u.slice.size>=c-o)return!1;if(r){let p=t.tr.step(u);p.setSelection(Ya.create(p.doc,o)),r(p.scrollIntoView())}return!0}function MT(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=Eke(n)}let l=o&&o.nodeBefore;return!l||!Ba.isSelectable(l)?!1:(s&&s(t.tr.setSelection(Ba.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function Eke(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 yQe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=yQe(t,r);if(!n)return!1;let a=Pke(n);if(!a)return!1;let o=a.nodeAfter;if(kQe(t,a,s,1))return!0;if(n.parent.content.size==0&&(MT(o,"start")||Ba.isSelectable(o))){let l=xue(t.doc,n.before(),n.after(),gn.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 Ba,a;if(n){if(r.node.isTextblock||!C2(t.doc,r.from))return!1;a=r.from}else if(a=gue(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(Ba.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},xOt=(t,s)=>{let r=t.selection,n;if(r instanceof Ba){if(r.node.isTextblock||!C2(t.doc,r.to))return!1;n=r.to}else if(n=gue(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},yOt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&zA(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},bQe=(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 Ike(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=Ike(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(hi.near(c.doc.resolve(i),1)),s(c.scrollIntoView())}return!0},wQe=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof hf||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=Ike(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(o1(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&zA(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)};function _Ot(t){return(s,r)=>{let{$from:n,$to:a}=s.selection;if(s.selection instanceof Ba&&s.selection.node.isBlock)return!n.parentOffset||!o1(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 _=n.depth;;_--)if(n.node(_).isBlock){c=n.end(_)==n.pos+(n.depth-_),u=n.start(_)==n.pos-(n.depth-_),i=Ike(n.node(_-1).contentMatchAt(n.indexAfter(_-1))),o.unshift(c&&i?{type:i}:null),l=_;break}else{if(_==1)return!1;o.unshift(null)}let p=s.tr;(s.selection instanceof Ya||s.selection instanceof hf)&&p.deleteSelection();let f=p.mapping.map(n.pos),y=o1(p.doc,f,o.length,o);if(y||(o[0]=i?{type:i}:null,y=o1(p.doc,f,o.length,o)),!y)return!1;if(p.split(f,o.length,o),!c&&u&&n.node(l).type!=i){let _=p.mapping.map(n.before(l)),b=p.doc.resolve(_);i&&n.node(l-1).canReplaceWith(b.index(),b.index()+1,i)&&p.setNodeMarkup(p.mapping.map(n.before(l)),i)}return r&&r(p.scrollIntoView()),!0}}const bOt=_Ot(),wOt=(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(Ba.create(t.doc,a))),!0)};function jOt(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||C2(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function kQe(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,c=a.type.spec.isolating||o.type.spec.isolating;if(!c&&jOt(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 _=s.pos+o.nodeSize,b=Tr.empty;for(let N=l.length-1;N>=0;N--)b=Tr.from(l[N].create(null,b));b=Tr.from(a.copy(b));let w=t.tr.step(new Ku(s.pos-1,_,s.pos,_,new gn(b,1,0),l.length,!0)),j=w.doc.resolve(_+2*l.length);j.nodeAfter&&j.nodeAfter.type==a.type&&C2(w.doc,j.pos)&&w.join(j.pos),r(w.scrollIntoView())}return!0}let p=o.type.spec.isolating||n>0&&c?null:hi.findFrom(s,1),f=p&&p.$from.blockRange(p.$to),y=f&&zA(f);if(y!=null&&y>=s.depth)return r&&r(t.tr.lift(f,y).scrollIntoView()),!0;if(u&&MT(o,"start",!0)&&MT(a,"end")){let _=a,b=[];for(;b.push(_),!_.isTextblock;)_=_.lastChild;let w=o,j=1;for(;!w.isTextblock;w=w.firstChild)j++;if(_.canReplace(_.childCount,_.childCount,w.content)){if(r){let N=Tr.empty;for(let T=b.length-1;T>=0;T--)N=Tr.from(b[T].copy(N));let S=t.tr.step(new Ku(s.pos-b.length,s.pos+o.nodeSize,s.pos+j,s.pos+o.nodeSize-j,new gn(N,b.length,0),0,!0));r(S.scrollIntoView())}return!0}}return!1}function NQe(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(Ya.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const kOt=NQe(-1),NOt=NQe(1);function SOt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&xke(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function GIe(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 Hoe(c,c,s.depth),s.endIndex=0;p--)o=Tr.from(r[p].type.create(r[p].attrs,o));t.step(new Ku(s.start-(n?2:0),s.end,s.start,s.end,new gn(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?EOt(s,r,t,o):POt(s,r,o):!0:!1}}function EOt(t,s,r,n){let a=t.tr,o=n.end,l=n.$to.end(n.depth);ow;b--)_-=a.child(b).nodeSize,n.delete(_-1,_+1);let o=n.doc.resolve(r.start),l=o.nodeAfter;if(n.mapping.map(r.end)!=r.start+o.nodeAfter.nodeSize)return!1;let i=r.startIndex==0,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?Tr.empty:Tr.from(a))))return!1;let f=o.pos,y=f+l.nodeSize;return n.step(new Ku(f-(i?1:0),y+(c?1:0),f+1,y-1,new gn((i?Tr.empty:Tr.from(a.copy(Tr.empty))).append(c?Tr.empty:Tr.from(a.copy(Tr.empty))),i?0:1,c?0:1),i?0:1)),s(n.scrollIntoView()),!0}function IOt(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=Tr.from(u?t.create():null),f=new gn(Tr.from(t.create(null,Tr.from(i.type.create(null,p)))),u?3:1,0),y=o.start,_=o.end;r(s.tr.step(new Ku(y-(u?3:1),_,y,_,f,1,!0)).scrollIntoView())}return!0}}function wue(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 jue{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(y=>y===!0)),f={...Object.fromEntries(Object.entries(n).map(([y,_])=>[y,(...w)=>{const j=this.buildProps(u,r),N=_(...w)(j);return i.push(N),f}])),run:p};return f}createCan(s){const{rawCommands:r,state:n}=this,a=!1,o=s||n.tr,l=this.buildProps(o,a);return{...Object.fromEntries(Object.entries(r).map(([c,u])=>[c,(...p)=>u(...p)({...l,dispatch:void 0})])),chain:()=>this.createChain(o,a)}}buildProps(s,r=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i={tr:s,editor:a,view:l,state:wue({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 LOt=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 sa(t,s,r){return t.config[s]===void 0&&t.parent?sa(t.parent,s,r):typeof t.config[s]=="function"?t.config[s].bind({...r,parent:t.parent?sa(t.parent,s,r):null}):t.config[s]}function kue(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 SQe(t){const s=[],{nodeExtensions:r,markExtensions:n}=kue(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=sa(l,"addGlobalAttributes",i);if(!c)return;c().forEach(p=>{p.types.forEach(f=>{Object.entries(p.attributes).forEach(([y,_])=>{s.push({type:f,name:y,attribute:{...o,..._}})})})})}),a.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage},c=sa(l,"addAttributes",i);if(!c)return;const u=c();Object.entries(u).forEach(([p,f])=>{const y={...o,...f};typeof(y==null?void 0:y.default)=="function"&&(y.default=y.default()),y!=null&&y.isRequired&&(y==null?void 0:y.default)===void 0&&delete y.default,s.push({type:l.name,name:p,attribute:y})})}),s}function Xu(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 Zc(...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,y]=p.split(":").map(_=>_.trim());u.set(f,y)}),i.forEach(p=>{const[f,y]=p.split(":").map(_=>_.trim());u.set(f,y)}),n[a]=Array.from(u.entries()).map(([p,f])=>`${p}: ${f}`).join("; ")}else n[a]=o}),n},{})}function j1e(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)=>Zc(r,n),{})}function CQe(t){return typeof t=="function"}function Qi(t,s=void 0,...r){return CQe(t)?s?t.bind(s)(...r):t(...r):t}function DOt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function OOt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function KIe(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):OOt(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function ZIe(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&DOt(r)?!1:r!=null))}function ROt(t,s){var r;const n=SQe(t),{nodeExtensions:a,markExtensions:o}=kue(t),l=(r=a.find(u=>sa(u,"topNode")))===null||r===void 0?void 0:r.name,i=Object.fromEntries(a.map(u=>{const p=n.filter(N=>N.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},y=t.reduce((N,S)=>{const T=sa(S,"extendNodeSchema",f);return{...N,...T?T(u):{}}},{}),_=ZIe({...y,content:Qi(sa(u,"content",f)),marks:Qi(sa(u,"marks",f)),group:Qi(sa(u,"group",f)),inline:Qi(sa(u,"inline",f)),atom:Qi(sa(u,"atom",f)),selectable:Qi(sa(u,"selectable",f)),draggable:Qi(sa(u,"draggable",f)),code:Qi(sa(u,"code",f)),whitespace:Qi(sa(u,"whitespace",f)),linebreakReplacement:Qi(sa(u,"linebreakReplacement",f)),defining:Qi(sa(u,"defining",f)),isolating:Qi(sa(u,"isolating",f)),attrs:Object.fromEntries(p.map(N=>{var S;return[N.name,{default:(S=N==null?void 0:N.attribute)===null||S===void 0?void 0:S.default}]}))}),b=Qi(sa(u,"parseHTML",f));b&&(_.parseDOM=b.map(N=>KIe(N,p)));const w=sa(u,"renderHTML",f);w&&(_.toDOM=N=>w({node:N,HTMLAttributes:j1e(N,p)}));const j=sa(u,"renderText",f);return j&&(_.toText=j),[u.name,_]})),c=Object.fromEntries(o.map(u=>{const p=n.filter(j=>j.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},y=t.reduce((j,N)=>{const S=sa(N,"extendMarkSchema",f);return{...j,...S?S(u):{}}},{}),_=ZIe({...y,inclusive:Qi(sa(u,"inclusive",f)),excludes:Qi(sa(u,"excludes",f)),group:Qi(sa(u,"group",f)),spanning:Qi(sa(u,"spanning",f)),code:Qi(sa(u,"code",f)),attrs:Object.fromEntries(p.map(j=>{var N;return[j.name,{default:(N=j==null?void 0:j.attribute)===null||N===void 0?void 0:N.default}]}))}),b=Qi(sa(u,"parseHTML",f));b&&(_.parseDOM=b.map(j=>KIe(j,p)));const w=sa(u,"renderHTML",f);return w&&(_.toDOM=j=>w({mark:j,HTMLAttributes:j1e(j,p)})),[u.name,_]}));return new pXe({topNode:l,nodes:i,marks:c})}function exe(t,s){return s.nodes[t]||s.marks[t]||null}function YIe(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function Dke(t,s){const r=XS.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const FOt=(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 Oke(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class Nue{constructor(s){this.find=s.find,this.handler=s.handler}}const zOt=(t,s)=>{if(Oke(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 U7(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(y=>y.type.spec.code))return!1;let p=!1;const f=FOt(u)+o;return l.forEach(y=>{if(p)return;const _=zOt(f,y.find);if(!_)return;const b=c.state.tr,w=wue({state:c.state,transaction:b}),j={from:n-(_[0].length-o.length),to:a},{commands:N,chain:S,can:T}=new jue({editor:r,state:w});y.handler({state:w,range:j,match:_,commands:N,chain:S,can:T})===null||!b.steps.length||(b.setMeta(i,{transform:b,from:n,to:a,text:o}),c.dispatch(b),p=!0)}),p}function BOt(t){const{editor:s,rules:r}=t,n=new Nu({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=Dke(Tr.from(p),l.schema);const{from:f}=c,y=f+p.length;U7({editor:s,from:f,to:y,text:p,rules:r,plugin:n})}),a.selectionSet||a.docChanged?null:o}},props:{handleTextInput(a,o,l,i){return U7({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&U7({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?U7({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function $Ot(t){return Object.prototype.toString.call(t).slice(8,-1)}function V7(t){return $Ot(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Sue(t,s){const r={...t};return V7(t)&&V7(s)&&Object.keys(s).forEach(n=>{V7(s[n])&&V7(t[n])?r[n]=Sue(t[n],s[n]):r[n]=s[n]}),r}class w0{constructor(s={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Qi(sa(this,"addOptions",{name:this.name}))),this.storage=Qi(sa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new w0(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Sue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new w0(s);return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=Qi(sa(r,"addOptions",{name:r.name})),r.storage=Qi(sa(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 qOt(t){return typeof t=="number"}class UOt{constructor(s){this.find=s.find,this.handler=s.handler}}const VOt=(t,s,r)=>{if(Oke(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 HOt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:c,chain:u,can:p}=new jue({editor:s,state:r}),f=[];return r.doc.nodesBetween(n,a,(_,b)=>{if(!_.isTextblock||_.type.spec.code)return;const w=Math.max(n,b),j=Math.min(a,b+_.content.size),N=_.textBetween(w-b,j-b,void 0,"");VOt(N,o.find,l).forEach(T=>{if(T.index===void 0)return;const I=w+T.index+1,L=I+T[0].length,R={from:r.tr.mapping.map(I),to:r.tr.mapping.map(L)},$=o.handler({state:r,range:R,match:T,commands:c,chain:u,can:p,pasteEvent:l,dropEvent:i});f.push($)})}),f.every(_=>_!==null)}let H7=null;const WOt=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 GOt(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:y,rule:_,pasteEvt:b})=>{const w=p.tr,j=wue({state:p,transaction:w});if(!(!HOt({editor:s,state:j,from:Math.max(f-1,0),to:y.b-1,rule:_,pasteEvent:b,dropEvent:i})||!w.steps.length)){try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return r.map(p=>new Nu({view(f){const y=b=>{var w;n=!((w=f.dom.parentElement)===null||w===void 0)&&w.contains(b.target)?f.dom.parentElement:null,n&&(H7=s)},_=()=>{H7&&(H7=null)};return window.addEventListener("dragstart",y),window.addEventListener("dragend",_),{destroy(){window.removeEventListener("dragstart",y),window.removeEventListener("dragend",_)}}},props:{handleDOMEvents:{drop:(f,y)=>{if(o=n===f.dom.parentElement,i=y,!o){const _=H7;_!=null&&_.isEditable&&setTimeout(()=>{const b=_.state.selection;b&&_.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(f,y)=>{var _;const b=(_=y.clipboardData)===null||_===void 0?void 0:_.getData("text/html");return l=y,a=!!(b!=null&&b.includes("data-pm-slice")),!1}}},appendTransaction:(f,y,_)=>{const b=f[0],w=b.getMeta("uiEvent")==="paste"&&!a,j=b.getMeta("uiEvent")==="drop"&&!o,N=b.getMeta("applyPasteRules"),S=!!N;if(!w&&!j&&!S)return;if(S){let{text:L}=N;typeof L=="string"?L=L:L=Dke(Tr.from(L),_.schema);const{from:R}=N,$=R+L.length,q=WOt(L);return c({rule:p,state:_,from:R,to:{b:$},pasteEvt:q})}const T=y.doc.content.findDiffStart(_.doc.content),I=y.doc.content.findDiffEnd(_.doc.content);if(!(!qOt(T)||!I||T===I.b))return c({rule:p,state:_,from:T,to:I,pasteEvt:l})}}))}function KOt(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class q5{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=q5.resolve(s),this.schema=ROt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=q5.sort(q5.flatten(s)),n=KOt(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=sa(r,"addExtensions",n);return a?[r,...this.flatten(a())]:r}).flat(10)}static sort(s){return s.sort((n,a)=>{const o=sa(n,"priority")||100,l=sa(a,"priority")||100;return o>l?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:exe(r.name,this.schema)},a=sa(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=q5.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:exe(l.name,this.schema)},c=[],u=sa(l,"addKeyboardShortcuts",i);let p={};if(l.type==="mark"&&sa(l,"exitable",i)&&(p.ArrowRight=()=>w0.handleExit({editor:s,mark:l})),u){const w=Object.fromEntries(Object.entries(u()).map(([j,N])=>[j,()=>N({editor:s})]));p={...p,...w}}const f=mOt(p);c.push(f);const y=sa(l,"addInputRules",i);YIe(l,s.options.enableInputRules)&&y&&n.push(...y());const _=sa(l,"addPasteRules",i);YIe(l,s.options.enablePasteRules)&&_&&a.push(..._());const b=sa(l,"addProseMirrorPlugins",i);if(b){const w=b();c.push(...w)}return c}).flat();return[BOt({editor:s,rules:n}),...GOt({editor:s,rules:a}),...o]}get attributes(){return SQe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=kue(this.extensions);return Object.fromEntries(r.filter(n=>!!sa(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:Xu(n.name,this.schema)},l=sa(n,"addNodeView",o);if(!l)return[];const i=(c,u,p,f,y)=>{const _=j1e(c,a);return l()({node:c,view:u,getPos:p,decorations:f,innerDecorations:y,editor:s,extension:n,HTMLAttributes:_})};return[n.name,i]}))}setupExtensions(){this.extensions.forEach(s=>{var r;this.editor.extensionStorage[s.name]=s.storage;const n={name:s.name,options:s.options,storage:s.storage,editor:this.editor,type:exe(s.name,this.schema)};s.type==="mark"&&(!((r=Qi(sa(s,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(s.name);const a=sa(s,"onBeforeCreate",n),o=sa(s,"onCreate",n),l=sa(s,"onUpdate",n),i=sa(s,"onSelectionUpdate",n),c=sa(s,"onTransaction",n),u=sa(s,"onFocus",n),p=sa(s,"onBlur",n),f=sa(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 wh{constructor(s={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Qi(sa(this,"addOptions",{name:this.name}))),this.storage=Qi(sa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new wh(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Sue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new wh({...this.config,...s});return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=Qi(sa(r,"addOptions",{name:r.name})),r.storage=Qi(sa(r,"addStorage",{name:r.name,options:r.options})),r}}function MQe(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 y;c.isBlock&&u>n&&(i+=o);const _=l==null?void 0:l[c.type.name];if(_)return p&&(i+=_({node:c,pos:u,parent:p,index:f,range:s})),!1;c.isText&&(i+=(y=c==null?void 0:c.text)===null||y===void 0?void 0:y.slice(Math.max(n,u)-u,a-u))}),i}function TQe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const ZOt=wh.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Nu({key:new Kh("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=TQe(r);return MQe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),YOt=()=>({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),XOt=(t=!1)=>({commands:s})=>s.setContent("",t),QOt=()=>({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)),y=u.resolve(p.map(c+i.nodeSize)),_=f.blockRange(y);if(!_)return;const b=zA(_);if(i.type.isTextblock){const{defaultType:w}=f.parent.contentMatchAt(f.index());s.setNodeMarkup(_.start,w)}(b||b===0)&&s.lift(_,b)})}),!0},JOt=t=>s=>t(s),eRt=()=>({state:t,dispatch:s})=>wQe(t,s),tRt=(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 Ya(n.doc.resolve(Math.max(l-1,0)))),!0},sRt=()=>({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},rRt=t=>({tr:s,state:r,dispatch:n})=>{const a=Xu(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},nRt=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},aRt=()=>({state:t,dispatch:s})=>Ake(t,s),iRt=()=>({commands:t})=>t.keyboardShortcut("Enter"),oRt=()=>({state:t,dispatch:s})=>vOt(t,s);function Joe(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:Oke(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function AQe(t,s,r={}){return t.find(n=>n.type===s&&Joe(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function XIe(t,s,r={}){return!!AQe(t,s,r)}function Rke(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),!AQe([...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&&XIe([...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=T2(t,n.schema),{doc:l,selection:i}=r,{$from:c,from:u,to:p}=i;if(a){const f=Rke(c,o,s);if(f&&f.from<=u&&f.to>=p){const y=Ya.create(l,f.from,f.to);r.setSelection(y)}}return!0},cRt=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=()=>{(Fke()||dRt())&&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&&!EQe(r.state.selection))return l(),!0;const i=PQe(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},hRt=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),mRt=(t,s)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,s),IQe=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&&IQe(n)}return t};function W7(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return IQe(r)}function K8(t,s,r){if(t instanceof Hb||t instanceof Tr)return t;r={slice:!0,parseOptions:{},...r};const n=typeof t=="object"&&t!==null,a=typeof t=="string";if(n)try{if(Array.isArray(t)&&t.length>0)return Tr.fromArray(t.map(i=>s.nodeFromJSON(i)));const l=s.nodeFromJSON(t);return r.errorOnInvalidContent&&l.check(),l}catch(o){if(r.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),K8("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const c=new pXe({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?LL.fromSchema(c).parseSlice(W7(t),r.parseOptions):LL.fromSchema(c).parse(W7(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=LL.fromSchema(s);return r.slice?o.parseSlice(W7(t),r.parseOptions).content:o.parse(W7(t),r.parseOptions)}return K8("",s,r)}function pRt(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=p)}),t.setSelection(hi.near(t.doc.resolve(l),r))}const fRt=t=>!("type"in t),gRt=(t,s,r)=>({tr:n,dispatch:a,editor:o})=>{var l;if(a){r={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...r};let i;const c=j=>{o.emit("contentError",{editor:o,error:j,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{K8(s,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(j){c(j)}try{i=K8(s,o.schema,{parseOptions:u,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(j){return c(j),!1}let{from:p,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},y=!0,_=!0;if((fRt(i)?i:[i]).forEach(j=>{j.check(),y=y?j.isText&&j.marks.length===0:!1,_=_?j.isBlock:!1}),p===f&&_){const{parent:j}=n.doc.resolve(p);j.isTextblock&&!j.type.spec.code&&!j.childCount&&(p-=1,f+=1)}let w;if(y){if(Array.isArray(s))w=s.map(j=>j.text||"").join("");else if(s instanceof Tr){let j="";s.forEach(N=>{N.text&&(j+=N.text)}),w=j}else typeof s=="object"&&s&&s.text?w=s.text:w=s;n.insertText(w,p,f)}else w=i,n.replaceWith(p,f,w);r.updateSelection&&pRt(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:p,text:w}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:p,text:w})}return!0},xRt=()=>({state:t,dispatch:s})=>gOt(t,s),yRt=()=>({state:t,dispatch:s})=>xOt(t,s),vRt=()=>({state:t,dispatch:s})=>fQe(t,s),_Rt=()=>({state:t,dispatch:s})=>vQe(t,s),bRt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=gue(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},wRt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=gue(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},jRt=()=>({state:t,dispatch:s})=>pOt(t,s),kRt=()=>({state:t,dispatch:s})=>fOt(t,s);function LQe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function NRt(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=NRt(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 Z8(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?Xu(s,t.schema):null,i=[];t.doc.nodesBetween(n,a,(f,y)=>{if(f.isText)return;const _=Math.max(n,y),b=Math.min(a,y+f.nodeSize);i.push({node:f,from:_,to:b})});const c=a-n,u=i.filter(f=>l?l.name===f.node.type.name:!0).filter(f=>Joe(f.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((f,y)=>f+y.to-y.from,0)>=c}const CRt=(t,s={})=>({state:r,dispatch:n})=>{const a=Xu(t,r.schema);return Z8(r,a,s)?yOt(r,n):!1},MRt=()=>({state:t,dispatch:s})=>jQe(t,s),TRt=t=>({state:s,dispatch:r})=>{const n=Xu(t,s.schema);return AOt(n)(s,r)},ARt=()=>({state:t,dispatch:s})=>bQe(t,s);function Cue(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function QIe(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 ERt=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Cue(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=Xu(t,n.schema)),i==="mark"&&(l=T2(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,QIe(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(f=>{l===f.type&&r.addMark(p,p+u.nodeSize,l.create(QIe(f.attrs,s)))})})}),!0):!1},PRt=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),IRt=()=>({tr:t,dispatch:s})=>{if(s){const r=new hf(t.doc);t.setSelection(r)}return!0},LRt=()=>({state:t,dispatch:s})=>xQe(t,s),DRt=()=>({state:t,dispatch:s})=>_Qe(t,s),ORt=()=>({state:t,dispatch:s})=>wOt(t,s),RRt=()=>({state:t,dispatch:s})=>NOt(t,s),FRt=()=>({state:t,dispatch:s})=>kOt(t,s);function k1e(t,s,r={},n={}){return K8(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const zRt=(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=k1e(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 DQe(t,s){const r=T2(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 BRt(t,s){const r=new yke(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function $Rt(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function OQe(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 zke(t){return s=>OQe(s.$from,t)}function URt(t,s){const r={from:0,to:t.content.size};return MQe(t,r,s)}function VRt(t,s){const r=Xu(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 RQe(t,s){const r=Cue(typeof s=="string"?s:s.name,t.schema);return r==="node"?VRt(t,s):r==="mark"?DQe(t,s):{}}function HRt(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 WRt(t){const s=HRt(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 GRt(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),y=s.invert().map(p);n.push({oldRange:{from:f,to:y},newRange:{from:u,to:p}})})}),WRt(n)}function Bke(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=Rke(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 yie(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 N1e(t,s,r={}){const{empty:n,ranges:a}=t.selection,o=s?T2(s,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>Joe(f.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:f,$to:y})=>{const _=f.pos,b=y.pos;t.doc.nodesBetween(_,b,(w,j)=>{if(!w.isText&&!w.marks.length)return;const N=Math.max(_,j),S=Math.min(b,j+w.nodeSize),T=S-N;l+=T,i.push(...w.marks.map(I=>({mark:I,from:N,to:S})))})}),l===0)return!1;const c=i.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>Joe(f.mark.attrs,r,{strict:!1})).reduce((f,y)=>f+y.to-y.from,0),u=i.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,y)=>f+y.to-y.from,0);return(c>0?c+u:c)>=l}function KRt(t,s,r={}){if(!s)return Z8(t,null,r)||N1e(t,null,r);const n=Cue(s,t.schema);return n==="node"?Z8(t,s,r):n==="mark"?N1e(t,s,r):!1}function JIe(t,s){const{nodeExtensions:r}=kue(s),n=r.find(l=>l.name===t);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=Qi(sa(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function $ke(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&&($ke(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function ZRt(t){return t instanceof Ba}function YRt(t,s,r){var n;const{selection:a}=s;let o=null;if(EQe(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,y)=>{if(u)return!1;if(p.isInline){const _=!y||y.type.allowsMarkType(r),b=!!r.isInSet(p.marks)||!p.marks.some(w=>w.type.excludes(r));u=_&&b}return!u}),u})}const XRt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{const{selection:o}=r,{empty:l,ranges:i}=o,c=T2(t,n.schema);if(a)if(l){const u=DQe(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,(y,_)=>{const b=Math.max(_,p),w=Math.min(_+y.nodeSize,f);y.marks.find(N=>N.type===c)?y.marks.forEach(N=>{c===N.type&&r.addMark(b,w,c.create({...N.attrs,...s}))}):r.addMark(b,w,c.create(s))})});return YRt(n,r,c)},QRt=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),JRt=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=Xu(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})=>GIe(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>GIe(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},eFt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=g4(t,0,n.content.size),o=Ba.create(n,a);s.setSelection(o)}return!0},tFt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=Ya.atStart(n).from,i=Ya.atEnd(n).to,c=g4(a,l,i),u=g4(o,l,i),p=Ya.create(n,c,u);s.setSelection(p)}return!0},sFt=t=>({state:s,dispatch:r})=>{const n=Xu(t,s.schema);return IOt(n)(s,r)};function eLe(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 rFt=({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=yie(u,i.node().type.name,i.node().attrs);if(o instanceof Ba&&o.node.isBlock)return!i.parentOffset||!o1(l,i.pos)?!1:(n&&(t&&eLe(r,a.extensionManager.splittableMarks),s.split(i.pos).scrollIntoView()),!0);if(!i.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,y=i.depth===0?void 0:$Rt(i.node(-1).contentMatchAt(i.indexAfter(-1)));let _=f&&y?[{type:y,attrs:p}]:void 0,b=o1(s.doc,s.mapping.map(i.pos),1,_);if(!_&&!b&&o1(s.doc,s.mapping.map(i.pos),1,y?[{type:y}]:void 0)&&(b=!0,_=y?[{type:y,attrs:p}]:void 0),n){if(b&&(o instanceof Ya&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,_),y&&!f&&!i.parentOffset&&i.parent.type!==y)){const w=s.mapping.map(i.before()),j=s.doc.resolve(w);i.node(-1).canReplaceWith(j.index(),j.index()+1,y)&&s.setNodeMarkup(s.mapping.map(i.before()),y)}t&&eLe(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return b},nFt=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=Xu(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 y=o.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==i||c.index(-2)!==c.node(-2).childCount-1)return!1;if(a){let N=Tr.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let q=c.depth-S;q>=c.depth-3;q-=1)N=Tr.from(c.node(q).copy(N));const T=c.indexAfter(-1){if($>-1)return!1;q.isTextblock&&q.content.size===0&&($=U+1)}),$>-1&&r.setSelection(Ya.near(r.doc.resolve($))),r.scrollIntoView()}return!0}const _=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,b={...yie(y,f.type.name,f.attrs),...s},w={...yie(y,c.node().type.name,c.node().attrs),...s};r.delete(c.pos,u.pos);const j=_?[{type:i,attrs:b},{type:_,attrs:w}]:[{type:i,attrs:b}];if(!o1(r.doc,c.pos,2))return!1;if(a){const{selection:N,storedMarks:S}=n,{splittableMarks:T}=o.extensionManager,I=S||N.$to.parentOffset&&N.$from.marks();if(r.split(c.pos,2,j).scrollIntoView(),!I||!a)return!0;const L=I.filter(R=>T.includes(R.type.name));r.ensureMarks(L)}return!0},txe=(t,s)=>{const r=zke(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)&&C2(t.doc,r.pos)&&t.join(r.pos),!0},sxe=(t,s)=>{const r=zke(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)&&C2(t.doc,n)&&t.join(n),!0},aFt=(t,s,r,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:c,commands:u,can:p})=>{const{extensions:f,splittableMarks:y}=a.extensionManager,_=Xu(t,l.schema),b=Xu(s,l.schema),{selection:w,storedMarks:j}=l,{$from:N,$to:S}=w,T=N.blockRange(S),I=j||w.$to.parentOffset&&w.$from.marks();if(!T)return!1;const L=zke(R=>JIe(R.type.name,f))(w);if(T.depth>=1&&L&&T.depth-L.depth<=1){if(L.node.type===_)return u.liftListItem(b);if(JIe(L.node.type.name,f)&&_.validContent(L.node.content)&&i)return c().command(()=>(o.setNodeMarkup(L.pos,_),!0)).command(()=>txe(o,_)).command(()=>sxe(o,_)).run()}return!r||!I||!i?c().command(()=>p().wrapInList(_,n)?!0:u.clearNodes()).wrapInList(_,n).command(()=>txe(o,_)).command(()=>sxe(o,_)).run():c().command(()=>{const R=p().wrapInList(_,n),$=I.filter(q=>y.includes(q.type.name));return o.ensureMarks($),R?!0:u.clearNodes()}).wrapInList(_,n).command(()=>txe(o,_)).command(()=>sxe(o,_)).run()},iFt=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=T2(t,n.schema);return N1e(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},oFt=(t,s,r={})=>({state:n,commands:a})=>{const o=Xu(t,n.schema),l=Xu(s,n.schema),i=Z8(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})},lFt=(t,s={})=>({state:r,commands:n})=>{const a=Xu(t,r.schema);return Z8(r,a,s)?n.lift(a):n.wrapIn(a,s)},cFt=()=>({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},dFt=()=>({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},uFt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=s,{selection:i}=r,c=T2(t,n.schema),{$from:u,empty:p,ranges:f}=i;if(!a)return!0;if(p&&l){let{from:y,to:_}=i;const b=(o=u.marks().find(j=>j.type===c))===null||o===void 0?void 0:o.attrs,w=Rke(u,c,b);w&&(y=w.from,_=w.to),r.removeMark(y,_,c)}else f.forEach(y=>{r.removeMark(y.$from.pos,y.$to.pos,c)});return r.removeStoredMark(c),!0},hFt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Cue(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=Xu(t,n.schema)),i==="mark"&&(l=T2(t,n.schema)),a&&r.selection.ranges.forEach(c=>{const u=c.$from.pos,p=c.$to.pos;let f,y,_,b;r.selection.empty?n.doc.nodesBetween(u,p,(w,j)=>{o&&o===w.type&&(_=Math.max(j,u),b=Math.min(j+w.nodeSize,p),f=j,y=w)}):n.doc.nodesBetween(u,p,(w,j)=>{j=u&&j<=p&&(o&&o===w.type&&r.setNodeMarkup(j,void 0,{...w.attrs,...s}),l&&w.marks.length&&w.marks.forEach(N=>{if(l===N.type){const S=Math.max(j,u),T=Math.min(j+w.nodeSize,p);r.addMark(S,T,l.create({...N.attrs,...s}))}}))}),y&&(f!==void 0&&r.setNodeMarkup(f,void 0,{...y.attrs,...s}),l&&y.marks.length&&y.marks.forEach(w=>{l===w.type&&r.addMark(_,b,l.create({...w.attrs,...s}))}))}),!0):!1},mFt=(t,s={})=>({state:r,dispatch:n})=>{const a=Xu(t,r.schema);return SOt(a,s)(r,n)},pFt=(t,s={})=>({state:r,dispatch:n})=>{const a=Xu(t,r.schema);return COt(a,s)(r,n)};var fFt=Object.freeze({__proto__:null,blur:YOt,clearContent:XOt,clearNodes:QOt,command:JOt,createParagraphNear:eRt,cut:tRt,deleteCurrentNode:sRt,deleteNode:rRt,deleteRange:nRt,deleteSelection:aRt,enter:iRt,exitCode:oRt,extendMarkRange:lRt,first:cRt,focus:uRt,forEach:hRt,insertContent:mRt,insertContentAt:gRt,joinBackward:vRt,joinDown:yRt,joinForward:_Rt,joinItemBackward:bRt,joinItemForward:wRt,joinTextblockBackward:jRt,joinTextblockForward:kRt,joinUp:xRt,keyboardShortcut:SRt,lift:CRt,liftEmptyBlock:MRt,liftListItem:TRt,newlineInCode:ARt,resetAttributes:ERt,scrollIntoView:PRt,selectAll:IRt,selectNodeBackward:LRt,selectNodeForward:DRt,selectParentNode:ORt,selectTextblockEnd:RRt,selectTextblockStart:FRt,setContent:zRt,setMark:XRt,setMeta:QRt,setNode:JRt,setNodeSelection:eFt,setTextSelection:tFt,sinkListItem:sFt,splitBlock:rFt,splitListItem:nFt,toggleList:aFt,toggleMark:iFt,toggleNode:oFt,toggleWrap:lFt,undoInputRule:cFt,unsetAllMarks:dFt,unsetMark:uFt,updateAttributes:hFt,wrapIn:mFt,wrapInList:pFt});const gFt=wh.create({name:"commands",addCommands(){return{...fFt}}}),xFt=wh.create({name:"drop",addProseMirrorPlugins(){return[new Nu({key:new Kh("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),yFt=wh.create({name:"editable",addProseMirrorPlugins(){return[new Nu({key:new Kh("editable"),props:{editable:()=>this.editor.options.editable}})]}}),vFt=new Kh("focusEvents"),_Ft=wh.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Nu({key:vFt,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}}}})]}}),bFt=wh.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:y,parent:_}=f,b=f.parent.isTextblock&&y>0?i.doc.resolve(y-1):f,w=b.parent.type.spec.isolating,j=f.pos-f.parentOffset,N=w&&b.parent.childCount===1?j===f.pos:hi.atStart(u).from===y;return!p||!_.type.isTextblock||_.textContent.length||!N||N&&f.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),s=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:s,"Mod-Delete":s,"Mod-a":()=>this.editor.commands.selectAll()},a={...n},o={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":s,"Ctrl-Alt-Backspace":s,"Alt-Delete":s,"Alt-d":s,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Fke()||LQe()?o:a},addProseMirrorPlugins(){return[new Nu({key:new Kh("clearDocument"),appendTransaction:(t,s,r)=>{if(t.some(w=>w.getMeta("composition")))return;const n=t.some(w=>w.docChanged)&&!s.doc.eq(r.doc),a=t.some(w=>w.getMeta("preventClearDocument"));if(!n||a)return;const{empty:o,from:l,to:i}=s.selection,c=hi.atStart(s.doc).from,u=hi.atEnd(s.doc).to;if(o||!(l===c&&i===u)||!$ke(r.doc))return;const y=r.tr,_=wue({state:r,transaction:y}),{commands:b}=new jue({editor:this.editor,state:_});if(b.clearNodes(),!!y.steps.length)return y}})]}}),wFt=wh.create({name:"paste",addProseMirrorPlugins(){return[new Nu({key:new Kh("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),jFt=wh.create({name:"tabindex",addProseMirrorPlugins(){return[new Nu({key:new Kh("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class r4{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 r4(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 r4(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 r4(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 r4(i,this.editor,a,a?r:null);a&&(c.actualDepth=this.depth+1),s.push(new r4(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 kFt=`.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 NFt(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 SFt extends LOt{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=NFt(kFt,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=CQe(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?[yFt,ZOt.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),gFt,_Ft,bFt,jFt,xFt,wFt].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 q5(a,this)}createCommandManager(){this.commandManager=new jue({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=k1e(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=k1e(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=PQe(r,this.options.autofocus);this.view=new mQe(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:$5.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 RQe(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return KRt(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Dke(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return URt(this.state.doc,{blockSeparator:r,textSerializers:{...TQe(this.schema),...n}})}get isEmpty(){return $ke(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 r4(r,this)}get $doc(){return this.$pos(0)}}function TT(t){return new Nue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=Qi(t.getAttributes,void 0,n);if(a===!1||a===null)return null;const{tr:o}=s,l=n[n.length-1],i=n[0];if(l){const c=i.search(/\S/),u=r.from+i.indexOf(l),p=u+l.length;if(Bke(r.from,r.to,s.doc).filter(_=>_.mark.type.excluded.find(w=>w===t.type&&w!==_.mark.type)).filter(_=>_.to>u).length)return null;pr.from&&o.delete(r.from+c,u);const y=r.from+c+l.length;o.addMark(r.from+c,y,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}function FQe(t){return new Nue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=Qi(t.getAttributes,void 0,n)||{},{tr:o}=s,l=r.from;let i=r.to;const 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 S1e(t){return new Nue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=s.doc.resolve(r.from),o=Qi(t.getAttributes,void 0,n)||{};if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t.type))return null;s.tr.delete(r.from,r.to).setBlockType(r.from,r.from,t.type,o)}})}function Y8(t){return new Nue({find:t.find,handler:({state:s,range:r,match:n,chain:a})=>{const o=Qi(t.getAttributes,void 0,n)||{},l=s.tr.delete(r.from,r.to),c=l.doc.resolve(r.from).blockRange(),u=c&&xke(c,t.type,o);if(!u)return null;if(l.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:y}=s,{splittableMarks:_}=t.editor.extensionManager,b=y||f.$to.parentOffset&&f.$from.marks();if(b){const w=b.filter(j=>_.includes(j.type.name));l.ensureMarks(w)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(f,o).run()}const p=l.doc.resolve(r.from-1).nodeBefore;p&&p.type===t.type&&C2(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,p))&&l.join(r.from-1)}})}let Zh=class C1e{constructor(s={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...s},this.name=this.config.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Qi(sa(this,"addOptions",{name:this.name}))),this.storage=Qi(sa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new C1e(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Sue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new C1e(s);return r.parent=this,this.child=r,r.name=s.name?s.name:r.parent.name,s.defaultOptions&&Object.keys(s.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=Qi(sa(r,"addOptions",{name:r.name})),r.storage=Qi(sa(r,"addStorage",{name:r.name,options:r.options})),r}};function TS(t){return new UOt({find:t.find,handler:({state:s,range:r,match:n,pasteEvent:a})=>{const o=Qi(t.getAttributes,void 0,n,a);if(o===!1||o===null)return null;const{tr:l}=s,i=n[n.length-1],c=n[0];let u=r.to;if(i){const p=c.search(/\S/),f=r.from+c.indexOf(i),y=f+i.length;if(Bke(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>f).length)return null;yr.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 CFt(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof Ba){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 MFt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zQe={exports:{}},rxe={};/** * @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 tLe;function TFt(){if(tLe)return rxe;tLe=1;var t=ht;function s(f,y){return f===y&&(f!==0||1/f===1/y)||f!==f&&y!==y}var r=typeof Object.is=="function"?Object.is:s,n=t.useState,a=t.useEffect,o=t.useLayoutEffect,l=t.useDebugValue;function i(f,y){var _=y(),b=n({inst:{value:_,getSnapshot:y}}),w=b[0].inst,j=b[1];return o(function(){w.value=_,w.getSnapshot=y,c(w)&&j({inst:w})},[f,_,y]),a(function(){return c(w)&&j({inst:w}),f(function(){c(w)&&j({inst:w})})},[f]),l(_),_}function c(f){var y=f.getSnapshot;f=f.value;try{var _=y();return!r(f,_)}catch{return!0}}function u(f,y){return y()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:i;return rxe.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,rxe}zQe.exports=TFt();var qke=zQe.exports;const AFt=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},EFt=({contentComponent:t})=>{const s=qke.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return ht.createElement(ht.Fragment,null,Object.values(s))};function PFt(){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]:Q2e.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 IFt 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=PFt(),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:AFt(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&&ht.createElement(EFt,{contentComponent:s.contentComponent}))}}const LFt=C.forwardRef((t,s)=>{const r=ht.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ht.createElement(IFt,{key:r,innerRef:s,...t})}),BQe=ht.memo(LFt);var DFt=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},OFt=MFt(DFt),$Qe={exports:{}},nxe={};/** * @license React * use-sync-external-store-shim/with-selector.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var sLe;function RFt(){if(sLe)return nxe;sLe=1;var t=ht,s=qke;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 nxe.useSyncExternalStoreWithSelector=function(u,p,f,y,_){var b=o(null);if(b.current===null){var w={hasValue:!1,value:null};b.current=w}else w=b.current;b=i(function(){function N(R){if(!S){if(S=!0,T=R,R=y(R),_!==void 0&&w.hasValue){var $=w.value;if(_($,R))return I=$}return I=R}if($=I,n(T,R))return $;var q=y(R);return _!==void 0&&_($,q)?$:(T=R,I=q)}var S=!1,T,I,L=f===void 0?null:f;return[function(){return N(p())},L===null?void 0:function(){return N(L())}]},[p,f,y,_]);var j=a(u,b[0],b[1]);return l(function(){w.hasValue=!0,w.value=j},[j]),c(j),j},nxe}$Qe.exports=RFt();var FFt=$Qe.exports;const zFt=typeof window<"u"?C.useLayoutEffect:C.useEffect;class BFt{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 $Ft(t){var s;const[r]=C.useState(()=>new BFt(t.editor)),n=FFt.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:OFt);return zFt(()=>r.watch(t.editor),[t.editor,r]),C.useDebugValue(n),n}const qFt=!1,M1e=typeof window>"u",UFt=M1e||!!(typeof window<"u"&&window.next);class Uke{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?M1e||UFt?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 SFt(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?Uke.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 qQe(t={},s=[]){const r=C.useRef(t);r.current=t;const[n]=C.useState(()=>new Uke(r)),a=qke.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return C.useDebugValue(a),C.useEffect(n.onRender(s)),$Ft({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const VFt=C.createContext({editor:null});VFt.Consumer;const HFt=C.createContext({onDragStart:void 0}),WFt=()=>C.useContext(HFt);ht.forwardRef((t,s)=>{const{onDragStart:r}=WFt(),n=t.as||"div";return ht.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const GFt=/^\s*>\s$/,KFt=Zh.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",Zc(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[Y8({find:GFt,type:this.type})]}}),ZFt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,YFt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,XFt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,QFt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,JFt=w0.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",Zc(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[TT({find:ZFt,type:this.type}),TT({find:XFt,type:this.type})]},addPasteRules(){return[TS({find:YFt,type:this.type}),TS({find:QFt,type:this.type})]}}),e7t="listItem",rLe="textStyle",nLe=/^\s*([-+*])\s$/,t7t=Zh.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",Zc(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(e7t,this.editor.getAttributes(rLe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Y8({find:nLe,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Y8({find:nLe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(rLe),editor:this.editor})),[t]}}),s7t=/(^|[^`])`([^`]+)`(?!`)/,r7t=/(^|[^`])`([^`]+)`(?!`)/g,n7t=w0.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Zc(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[TT({find:s7t,type:this.type})]},addPasteRules(){return[TS({find:r7t,type:this.type})]}}),a7t=/^```([a-z]+)?[\s\n]$/,i7t=/^~~~([a-z]+)?[\s\n]$/,o7t=Zh.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",Zc(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(hi.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[S1e({find:a7t,type:this.type,getAttributes:t=>({language:t[1]})}),S1e({find:i7t,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Nu({key:new Kh("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(Ya.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),l7t=Zh.create({name:"doc",topNode:!0,content:"block+"});function c7t(t={}){return new Nu({view(s){return new d7t(s,t)}})}class d7t{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,y=s.nodeAfter;if(f||y){let _=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(_){let b=_.getBoundingClientRect(),w=f?b.bottom:b.top;f&&y&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let j=this.width/2*i;n={left:b.left,right:b.right,top:w-j,bottom:w+j}}}}if(!n){let f=this.editorView.coordsAtPos(this.cursorPos),y=this.width/2*l;n={left:f.left-y,right:f.left+y,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(),y=f.width/c.offsetWidth,_=f.height/c.offsetHeight;u=f.left-c.scrollLeft*y,p=f.top-c.scrollTop*_}this.element.style.left=(n.left-u)/l+"px",this.element.style.top=(n.top-p)/i+"px",this.element.style.width=(n.right-n.left)/l+"px",this.element.style.height=(n.bottom-n.top)/i+"px"}scheduleRemoval(s){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),s)}dragover(s){if(!this.editorView.editable)return;let r=this.editorView.posAtCoords({left:s.clientX,top:s.clientY}),n=r&&r.inside>=0&&this.editorView.state.doc.nodeAt(r.inside),a=n&&n.type.spec.disableDropCursor,o=typeof a=="function"?a(this.editorView,r,s):a;if(r&&!o){let l=r.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let i=NXe(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 u7t=wh.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[c7t(this.options)]}});class ld extends hi{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return ld.valid(n)?new ld(n):hi.near(n)}content(){return gn.empty}eq(s){return s instanceof ld&&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 ld(s.resolve(r.pos))}getBookmark(){return new Vke(this.anchor)}static valid(s){let r=s.parent;if(r.isTextblock||!h7t(s)||!m7t(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&&ld.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(ld.valid(c))return c}for(;;){let l=r>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!Ba.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(ld.valid(i))return i}return null}}}ld.prototype.visible=!1;ld.findFrom=ld.findGapCursorFrom;hi.jsonID("gapcursor",ld);class Vke{constructor(s){this.pos=s}map(s){return new Vke(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return ld.valid(r)?new ld(r):hi.near(r)}}function UQe(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function h7t(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||UQe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function m7t(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||UQe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function p7t(){return new Nu({props:{decorations:y7t,createSelectionBetween(t,s,r){return s.pos==r.pos&&ld.valid(r)?new ld(r):null},handleClick:g7t,handleKeyDown:f7t,handleDOMEvents:{beforeinput:x7t}}})}const f7t=Tke({ArrowLeft:G7("horiz",-1),ArrowRight:G7("horiz",1),ArrowUp:G7("vert",-1),ArrowDown:G7("vert",1)});function G7(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 Ya){if(!o.endOfTextblock(r)||i.depth==0)return!1;c=!1,i=n.doc.resolve(s>0?i.after():i.before())}let u=ld.findGapCursorFrom(i,s,c);return u?(a&&a(n.tr.setSelection(new ld(u))),!0):!1}}function g7t(t,s,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(s);if(!ld.valid(n))return!1;let a=t.posAtCoords({left:r.clientX,top:r.clientY});return a&&a.inside>-1&&Ba.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ld(n))),!0)}function x7t(t,s){if(s.inputType!="insertCompositionText"||!(t.state.selection instanceof ld))return!1;let{$from:r}=t.state.selection,n=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!n)return!1;let a=Tr.empty;for(let l=n.length-1;l>=0;l--)a=Tr.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new gn(a,0,0));return o.setSelection(Ya.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function y7t(t){if(!(t.selection instanceof ld))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",od.create(t.doc,[bm.widget(t.selection.head,s,{key:"gapcursor"})])}const v7t=wh.create({name:"gapCursor",addProseMirrorPlugins(){return[p7t()]},extendNodeSchema(t){var s;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(s=Qi(sa(t,"allowGapCursor",r)))!==null&&s!==void 0?s:null}}}),_7t=Zh.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",Zc(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(y=>i.includes(y.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),b7t=Zh.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]}`,Zc(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=>S1e({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var ele=200,Zu=function(){};Zu.prototype.append=function(s){return s.length?(s=Zu.from(s),!this.length&&s||s.length=r?Zu.empty:this.sliceInner(Math.max(0,s),Math.min(this.length,r))};Zu.prototype.get=function(s){if(!(s<0||s>=this.length))return this.getInner(s)};Zu.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)};Zu.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};Zu.from=function(s){return s instanceof Zu?s:s&&s.length?new VQe(s):Zu.empty};var VQe=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<=ele)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=ele)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}(Zu);Zu.empty=new VQe([]);var w7t=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}(Zu);const j7t=500;class Ox{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,y)=>{if(!f.step){a||(a=this.remapping(n,y+1),o=a.maps.length),o--,p.push(f);return}if(a){p.push(new zy(f.map));let _=f.step.map(a.slice(o)),b;_&&l.maybeStep(_).doc&&(b=l.mapping.maps[l.mapping.maps.length-1],u.push(new zy(b,void 0,void 0,u.length+p.length))),o--,b&&a.appendMap(b,o)}else l.maybeStep(f.step);if(f.selection)return i=a?f.selection.map(a.slice(o)):f.selection,c=new Ox(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;pN7t&&(i=k7t(i,u),l-=u),new Ox(i.append(o),l)}remapping(s,r){let n=new U8;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 Ox(this.items.append(s.map(r=>new zy(r))),this.eventCount)}rebased(s,r){if(!this.eventCount)return this;let n=[],a=Math.max(0,this.items.length-r),o=s.mapping,l=s.steps.length,i=this.eventCount;this.items.forEach(y=>{y.selection&&i--},a);let c=r;this.items.forEach(y=>{let _=o.getMirror(--c);if(_==null)return;l=Math.min(l,_);let b=o.maps[_];if(y.step){let w=s.steps[_].invert(s.docs[_]),j=y.selection&&y.selection.map(o.slice(c+1,_));j&&i++,n.push(new zy(b,w,j))}else n.push(new zy(b))},a);let u=[];for(let y=r;yj7t&&(f=f.compress(this.items.length-n.length)),f}emptyItemCount(){let s=0;return this.items.forEach(r=>{r.step||s++}),s}compress(s=this.items.length){let r=this.remapping(0,s),n=r.maps.length,a=[],o=0;return this.items.forEach((l,i)=>{if(i>=s)a.push(l),l.selection&&o++;else if(l.step){let c=l.step.map(r.slice(n)),u=c&&c.getMap();if(n--,u&&r.appendMap(u,n),c){let p=l.selection&&l.selection.map(r.slice(n));p&&o++;let f=new zy(u.invert(),c,p),y,_=a.length-1;(y=a.length&&a[_].merge(f))?a[_]=y:a.push(f)}}else l.map&&n--},this.items.length,0),new Ox(Zu.from(a.reverse()),o)}}Ox.empty=new Ox(Zu.empty,0);function k7t(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class zy{constructor(s,r,n,a){this.map=s,this.step=r,this.selection=n,this.mirrorOffset=a}merge(s){if(this.step&&s.step&&!s.selection){let r=s.step.merge(this.step);if(r)return new zy(r.getMap().invert(),r,this.selection)}}}class B_{constructor(s,r,n,a,o){this.done=s,this.undone=r,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const N7t=20;function S7t(t,s,r,n){let a=r.getMeta(sS),o;if(a)return a.historyState;r.getMeta(T7t)&&(t=new B_(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(sS))return l.getMeta(sS).redo?new B_(t.done.addTransform(r,void 0,n,vie(s)),t.undone,aLe(r.mapping.maps),t.prevTime,t.prevComposition):new B_(t.done,t.undone.addTransform(r,void 0,n,vie(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||!C7t(r,t.prevRanges)),u=l?axe(t.prevRanges,r.mapping):aLe(r.mapping.maps);return new B_(t.done.addTransform(r,c?s.selection.getBookmark():void 0,n,vie(s)),Ox.empty,u,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new B_(t.done.rebased(r,o),t.undone.rebased(r,o),axe(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new B_(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),axe(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function C7t(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 aLe(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 axe(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=sS.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=M7t(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const WQe=HQe(!1,!0),GQe=HQe(!0,!0),E7t=wh.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>WQe(t,s),redo:()=>({state:t,dispatch:s})=>GQe(t,s)}},addProseMirrorPlugins(){return[A7t(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()}}}),P7t=Zh.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Zc(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!CFt(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}):ZRt(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(Ya.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Ba.create(l.doc,u.pos)):l.setSelection(Ya.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(Ya.create(l.doc,p+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[FQe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),I7t=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,L7t=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,D7t=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,O7t=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,R7t=w0.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",Zc(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[TT({find:I7t,type:this.type}),TT({find:D7t,type:this.type})]},addPasteRules(){return[TS({find:L7t,type:this.type}),TS({find:O7t,type:this.type})]}}),F7t=Zh.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Zc(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)}}}),z7t="listItem",oLe="textStyle",lLe=/^(\d+)\.\s$/,B7t=Zh.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",Zc(this.options.HTMLAttributes,r),0]:["ol",Zc(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(z7t,this.editor.getAttributes(oLe)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Y8({find:lLe,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=Y8({find:lLe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(oLe)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),$7t=Zh.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Zc(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),q7t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,U7t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,V7t=w0.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",Zc(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[TT({find:q7t,type:this.type})]},addPasteRules(){return[TS({find:U7t,type:this.type})]}}),H7t=Zh.create({name:"text",group:"inline"}),KQe=wh.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(JFt.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(KFt.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(t7t.configure(this.options.bulletList)),this.options.code!==!1&&t.push(n7t.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(o7t.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(l7t.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(u7t.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(v7t.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(_7t.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(b7t.configure(this.options.heading)),this.options.history!==!1&&t.push(E7t.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(P7t.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(R7t.configure(this.options.italic)),this.options.listItem!==!1&&t.push(F7t.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(B7t.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push($7t.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(V7t.configure(this.options.strike)),this.options.text!==!1&&t.push(H7t.configure(this.options.text)),t}}),W7t="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",G7t="ελ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",T1e="numeric",A1e="ascii",E1e="alpha",FL="asciinumeric",lI="alphanumeric",P1e="domain",ZQe="emoji",K7t="scheme",Z7t="slashscheme",oxe="whitespace";function Y7t(t,s){return t in s||(s[t]=[]),s[t]}function x4(t,s,r){s[T1e]&&(s[FL]=!0,s[lI]=!0),s[A1e]&&(s[FL]=!0,s[E1e]=!0),s[FL]&&(s[lI]=!0),s[E1e]&&(s[lI]=!0),s[lI]&&(s[P1e]=!0),s[ZQe]&&(s[P1e]=!0);for(const n in s){const a=Y7t(n,r);a.indexOf(t)<0&&a.push(t)}}function X7t(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function op(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}op.groups={};op.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),Jc=(t,s,r,n,a)=>t.tr(s,r,n,a),cLe=(t,s,r,n,a)=>t.ts(s,r,n,a),Wr=(t,s,r,n,a)=>t.tt(s,r,n,a),bv="WORD",I1e="UWORD",YQe="ASCIINUMERICAL",XQe="ALPHANUMERICAL",X8="LOCALHOST",L1e="TLD",D1e="UTLD",_ie="SCHEME",w5="SLASH_SCHEME",Hke="NUM",O1e="WS",Wke="NL",zL="OPENBRACE",BL="CLOSEBRACE",tle="OPENBRACKET",sle="CLOSEBRACKET",rle="OPENPAREN",nle="CLOSEPAREN",ale="OPENANGLEBRACKET",ile="CLOSEANGLEBRACKET",ole="FULLWIDTHLEFTPAREN",lle="FULLWIDTHRIGHTPAREN",cle="LEFTCORNERBRACKET",dle="RIGHTCORNERBRACKET",ule="LEFTWHITECORNERBRACKET",hle="RIGHTWHITECORNERBRACKET",mle="FULLWIDTHLESSTHAN",ple="FULLWIDTHGREATERTHAN",fle="AMPERSAND",gle="APOSTROPHE",xle="ASTERISK",$_="AT",yle="BACKSLASH",vle="BACKTICK",_le="CARET",Y_="COLON",Gke="COMMA",ble="DOLLAR",By="DOT",wle="EQUALS",Kke="EXCLAMATION",Zf="HYPHEN",$L="PERCENT",jle="PIPE",kle="PLUS",Nle="POUND",qL="QUERY",Zke="QUOTE",QQe="FULLWIDTHMIDDLEDOT",Yke="SEMI",$y="SLASH",UL="TILDE",Sle="UNDERSCORE",JQe="EMOJI",Cle="SYM";var eJe=Object.freeze({__proto__:null,ALPHANUMERICAL:XQe,AMPERSAND:fle,APOSTROPHE:gle,ASCIINUMERICAL:YQe,ASTERISK:xle,AT:$_,BACKSLASH:yle,BACKTICK:vle,CARET:_le,CLOSEANGLEBRACKET:ile,CLOSEBRACE:BL,CLOSEBRACKET:sle,CLOSEPAREN:nle,COLON:Y_,COMMA:Gke,DOLLAR:ble,DOT:By,EMOJI:JQe,EQUALS:wle,EXCLAMATION:Kke,FULLWIDTHGREATERTHAN:ple,FULLWIDTHLEFTPAREN:ole,FULLWIDTHLESSTHAN:mle,FULLWIDTHMIDDLEDOT:QQe,FULLWIDTHRIGHTPAREN:lle,HYPHEN:Zf,LEFTCORNERBRACKET:cle,LEFTWHITECORNERBRACKET:ule,LOCALHOST:X8,NL:Wke,NUM:Hke,OPENANGLEBRACKET:ale,OPENBRACE:zL,OPENBRACKET:tle,OPENPAREN:rle,PERCENT:$L,PIPE:jle,PLUS:kle,POUND:Nle,QUERY:qL,QUOTE:Zke,RIGHTCORNERBRACKET:dle,RIGHTWHITECORNERBRACKET:hle,SCHEME:_ie,SEMI:Yke,SLASH:$y,SLASH_SCHEME:w5,SYM:Cle,TILDE:UL,TLD:L1e,UNDERSCORE:Sle,UTLD:D1e,UWORD:I1e,WORD:bv,WS:O1e});const fv=/[a-z]/,I6=new RegExp("\\p{L}","u"),lxe=new RegExp("\\p{Emoji}","u"),gv=/\d/,cxe=/\s/,dLe="\r",dxe=` `,Q7t="️",J7t="‍",uxe="";let K7=null,Z7=null;function ezt(t=[]){const s={};op.groups=s;const r=new op;K7==null&&(K7=uLe(W7t)),Z7==null&&(Z7=uLe(G7t)),Wr(r,"'",gle),Wr(r,"{",zL),Wr(r,"}",BL),Wr(r,"[",tle),Wr(r,"]",sle),Wr(r,"(",rle),Wr(r,")",nle),Wr(r,"<",ale),Wr(r,">",ile),Wr(r,"(",ole),Wr(r,")",lle),Wr(r,"「",cle),Wr(r,"」",dle),Wr(r,"『",ule),Wr(r,"』",hle),Wr(r,"<",mle),Wr(r,">",ple),Wr(r,"&",fle),Wr(r,"*",xle),Wr(r,"@",$_),Wr(r,"`",vle),Wr(r,"^",_le),Wr(r,":",Y_),Wr(r,",",Gke),Wr(r,"$",ble),Wr(r,".",By),Wr(r,"=",wle),Wr(r,"!",Kke),Wr(r,"-",Zf),Wr(r,"%",$L),Wr(r,"|",jle),Wr(r,"+",kle),Wr(r,"#",Nle),Wr(r,"?",qL),Wr(r,'"',Zke),Wr(r,"/",$y),Wr(r,";",Yke),Wr(r,"~",UL),Wr(r,"_",Sle),Wr(r,"\\",yle),Wr(r,"・",QQe);const n=Jc(r,gv,Hke,{[T1e]:!0});Jc(n,gv,n);const a=Jc(n,fv,YQe,{[FL]:!0}),o=Jc(n,I6,XQe,{[lI]:!0}),l=Jc(r,fv,bv,{[A1e]:!0});Jc(l,gv,a),Jc(l,fv,l),Jc(a,gv,a),Jc(a,fv,a);const i=Jc(r,I6,I1e,{[E1e]:!0});Jc(i,fv),Jc(i,gv,o),Jc(i,I6,i),Jc(o,gv,o),Jc(o,fv),Jc(o,I6,o);const c=Wr(r,dxe,Wke,{[oxe]:!0}),u=Wr(r,dLe,O1e,{[oxe]:!0}),p=Jc(r,cxe,O1e,{[oxe]:!0});Wr(r,uxe,p),Wr(u,dxe,c),Wr(u,uxe,p),Jc(u,cxe,p),Wr(p,dLe),Wr(p,dxe),Jc(p,cxe,p),Wr(p,uxe,p);const f=Jc(r,lxe,JQe,{[ZQe]:!0});Wr(f,"#"),Jc(f,lxe,f),Wr(f,Q7t,f);const y=Wr(f,J7t);Wr(y,"#"),Jc(y,lxe,f);const _=[[fv,l],[gv,a]],b=[[fv,null],[I6,i],[gv,o]];for(let w=0;ww[0]>j[0]?1:-1);for(let w=0;w=0?S[P1e]=!0:fv.test(j)?gv.test(j)?S[FL]=!0:S[A1e]=!0:S[T1e]=!0,cLe(r,j,j,S)}return cLe(r,"localhost",X8,{ascii:!0}),r.jd=new op(Cle),{start:r,tokens:Object.assign({groups:s},eJe)}}function tJe(t,s){const r=tzt(s.replace(/[A-Z]/g,i=>i.toLowerCase())),n=r.length,a=[];let o=0,l=0;for(;l=0&&(f+=r[l].length,y++),u+=r[l].length,o+=r[l].length,l++;o-=f,l-=y,u-=f,a.push({t:p.t,v:s.slice(o-u,o),s:o-u,e:o})}return a}function tzt(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 N_(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 Q8={defaultProtocol:"http",events:null,format:hLe,formatHref:hLe,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Xke(t,s=null){let r=Object.assign({},Q8);t&&(r=Object.assign(r,t instanceof Xke?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=Q8.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 Mue(t,s){class r extends sJe{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 mLe=Mue("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),pLe=Mue("text"),szt=Mue("nl"),Y7=Mue("url",{isLink:!0,toHref(t=Q8.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==X8&&t[1].t===Y_}}),qf=t=>new op(t);function rzt({groups:t}){const s=t.domain.concat([fle,xle,$_,yle,vle,_le,ble,wle,Zf,Hke,$L,jle,kle,Nle,$y,Cle,UL,Sle]),r=[gle,Y_,Gke,By,Kke,$L,qL,Zke,Yke,ale,ile,zL,BL,sle,tle,rle,nle,ole,lle,cle,dle,ule,hle,mle,ple],n=[fle,gle,xle,yle,vle,_le,ble,wle,Zf,zL,BL,$L,jle,kle,Nle,qL,$y,Cle,UL,Sle],a=qf(),o=Wr(a,UL);Xi(o,n,o),Xi(o,t.domain,o);const l=qf(),i=qf(),c=qf();Xi(a,t.domain,l),Xi(a,t.scheme,i),Xi(a,t.slashscheme,c),Xi(l,n,o),Xi(l,t.domain,l);const u=Wr(l,$_);Wr(o,$_,u),Wr(i,$_,u),Wr(c,$_,u);const p=Wr(o,By);Xi(p,n,o),Xi(p,t.domain,o);const f=qf();Xi(u,t.domain,f),Xi(f,t.domain,f);const y=Wr(f,By);Xi(y,t.domain,f);const _=qf(mLe);Xi(y,t.tld,_),Xi(y,t.utld,_),Wr(u,X8,_);const b=Wr(f,Zf);Wr(b,Zf,b),Xi(b,t.domain,f),Xi(_,t.domain,f),Wr(_,By,y),Wr(_,Zf,b);const w=Wr(_,Y_);Xi(w,t.numeric,mLe);const j=Wr(l,Zf),N=Wr(l,By);Wr(j,Zf,j),Xi(j,t.domain,l),Xi(N,n,o),Xi(N,t.domain,l);const S=qf(Y7);Xi(N,t.tld,S),Xi(N,t.utld,S),Xi(S,t.domain,l),Xi(S,n,o),Wr(S,By,N),Wr(S,Zf,j),Wr(S,$_,u);const T=Wr(S,Y_),I=qf(Y7);Xi(T,t.numeric,I);const L=qf(Y7),R=qf();Xi(L,s,L),Xi(L,r,R),Xi(R,s,L),Xi(R,r,R),Wr(S,$y,L),Wr(I,$y,L);const $=Wr(i,Y_),q=Wr(c,Y_),U=Wr(q,$y),V=Wr(U,$y);Xi(i,t.domain,l),Wr(i,By,N),Wr(i,Zf,j),Xi(c,t.domain,l),Wr(c,By,N),Wr(c,Zf,j),Xi($,t.domain,L),Wr($,$y,L),Wr($,qL,L),Xi(V,t.domain,L),Xi(V,s,L),Wr(V,$y,L);const X=[[zL,BL],[tle,sle],[rle,nle],[ale,ile],[ole,lle],[cle,dle],[ule,hle],[mle,ple]];for(let se=0;se=0&&y++,a++,p++;if(y<0)a-=p,a0&&(o.push(hxe(pLe,s,l)),l=[]),a-=y,p-=y;const _=f.t,b=r.slice(a-p,a);o.push(hxe(_,s,b))}}return l.length>0&&o.push(hxe(pLe,s,l)),o}function hxe(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 azt=typeof console<"u"&&console&&console.warn||(()=>{}),izt="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",dc={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function ozt(){return op.groups={},dc.scanner=null,dc.parser=null,dc.tokenQueue=[],dc.pluginQueue=[],dc.customSchemes=[],dc.initialized=!1,dc}function fLe(t,s=!1){if(dc.initialized&&azt(`linkifyjs: already initialized - will not register custom scheme "${t}" ${izt}`),!/^[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`);dc.customSchemes.push([t,s])}function lzt(){dc.scanner=ezt(dc.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=BRt(r.doc,[...s]);if(GRt(i).forEach(({newRange:u})=>{const p=qRt(n.doc,u,_=>_.isTextblock);let f,y;if(p.length>1)f=p[0],y=n.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(p.length){const _=n.doc.textBetween(u.from,u.to," "," ");if(!dzt.test(_))return;f=p[0],y=n.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&y){const _=y.split(czt).filter(Boolean);if(_.length<=0)return!1;const b=_[_.length-1],w=f.pos+y.lastIndexOf(b);if(!b)return!1;const j=Qke(b).map(N=>N.toObject(t.defaultProtocol));if(!hzt(j))return!1;j.filter(N=>N.isLink).map(N=>({...N,from:w+N.start+1,to:w+N.end+1})).filter(N=>n.schema.marks.code?!n.doc.rangeHasMark(N.from,N.to,n.schema.marks.code):!0).filter(N=>t.validate(N.value)).filter(N=>t.shouldAutoLink(N.value)).forEach(N=>{Bke(N.from,N.to,n.doc).some(S=>S.mark.type===t.type)||l.addMark(N.from,N.to,t.type.create({href:N.href}))})}}),!!l.steps.length)return l}})}function pzt(t){return new Nu({key:new Kh("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(y=>y.nodeName==="A"))return!1;const c=RQe(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 fzt(t){return new Nu({key:new Kh("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=rJe(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 Ew(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(uzt,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const nJe=w0.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"){fLe(t);return}fLe(t.scheme,t.optionalSlashes)})},onDestroy(){ozt()},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)=>!!Ew(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=>!!Ew(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=>!!Ew(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Zc(this.options.HTMLAttributes,t),0]:["a",Zc(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!Ew(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=>!!Ew(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[TS({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=rJe(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!Ew(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(mzt({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!Ew(a,s),protocols:s,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(pzt({type:this.type})),this.options.linkOnPaste&&t.push(fzt({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),aJe=wh.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")}}}),gzt=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}`)})},iJe=w0.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&gzt(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Zc(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}}}}),xzt=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,yzt=Zh.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",Zc(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[FQe({find:xzt,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let R1e,F1e;if(typeof WeakMap<"u"){let t=new WeakMap;R1e=s=>t.get(s),F1e=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;R1e=n=>{for(let a=0;a(r==10&&(r=0),t[r++]=n,t[r++]=a)}var cd=class{constructor(t,s,r,n){this.width=t,this.height=s,this.map=r,this.problems=n}findCell(t){for(let s=0;s=r){(o||(o=[])).push({type:"overlong_rowspan",pos:p,n:N-T});break}const I=a+T*s;for(let L=0;Ln&&(o+=u.attrs.colspan)}}for(let l=0;l1&&(r=!0)}s==-1?s=o:s!=o&&(s=Math.max(s,o))}return s}function bzt(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 jzt(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 ay(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 Tue(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=BA(s.$head)||kzt(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function kzt(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 z1e(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Nzt(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function eNe(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function oJe(t,s,r){const n=t.node(-1),a=cd.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 AS(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 lJe(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 y=o+p+1;return new AXe(i.resolve(y),i.resolve(y+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(z1e(n)&&z1e(a)&&eNe(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?wv.rowSelection(n,a):o&&this.isColSelection()?wv.colSelection(n,a):new wv(n,a)}return Ya.between(n,a)}content(){const s=this.$anchorCell.node(-1),r=cd.get(s),n=this.$anchorCell.start(-1),a=r.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},l=[];for(let c=a.top;c0||j>0){let N=b.attrs;if(w>0&&(N=AS(N,0,w)),j>0&&(N=AS(N,N.colspan-j,j)),_.lefta.bottom){const N={...b.attrs,rowspan:Math.min(_.bottom,a.bottom)-Math.max(_.top,a.top)};_.top0)return!1;const n=s+this.$anchorCell.nodeAfter.attrs.rowspan,a=r+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,a)==this.$headCell.node(-1).childCount}static colSelection(s,r=s){const n=s.node(-1),a=cd.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 wv&&s.$anchorCell.pos==this.$anchorCell.pos&&s.$headCell.pos==this.$headCell.pos}static rowSelection(s,r=s){const n=s.node(-1),a=cd.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(bm.node(n,n+r.nodeSize,{class:"selectedCell"}))}),od.create(t.doc,s)}function Tzt({$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 Azt({$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 Ezt(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof Ba&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=ec.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=ec.rowSelection(i,i)}else if(!r){const i=cd.get(n.node),c=n.from+1,u=c+i.map[i.width*i.height-1];o=ec.create(a,c+1,u)}}else n instanceof Ya&&Tzt(n)?o=Ya.create(a,n.from):n instanceof Ya&&Azt(n)&&(o=Ya.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const Pzt=new Kh("fix-tables");function dJe(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=Izt(t,a,o,r))};return s?s.doc!=t.doc&&dJe(s.doc,t.doc,0,n):t.doc.descendants(n),r}function Izt(t,s,r,n){const a=cd.get(s);if(!a.problems)return n;n||(n=t.tr);const o=[];for(let c=0;c0){let _="cell";p.firstChild&&(_=p.firstChild.type.spec.tableRole);const b=[];for(let j=0;j0?-1:0;Szt(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;Fzt(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 y=r.nodeAt(f).attrs;t.setNodeMarkup(t.mapping.slice(i).map(f+n),null,{...y,rowspan:y.rowspan-1}),u+=y.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=gLe(u)?c+1:p;o.replaceWith(f+n.tableStart,p+n.tableStart,i)}o.setSelection(new ec(o.doc.resolve(c+n.tableStart))),s(o)}return!0}function yLe(t,s){const r=Hh(t.schema);return Vzt(({node:n})=>r[n.type.spec.tableRole])(t,s)}function Vzt(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof ec){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=jzt(n.$from),!a)return!1;o=(l=BA(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=E0(s),f=s.tr;for(let _=0;_{l.attrs[t]!==s&&o.setNodeMarkup(i,null,{...l.attrs,[t]:s})}):o.setNodeMarkup(a.pos,null,{...a.nodeAfter.attrs,[t]:s}),n(o)}return!0}}function Wzt(t){return function(s,r){if(!ay(s))return!1;if(r){const n=Hh(s.schema),a=E0(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 _=y+o.tableStart,b=l.doc.nodeAt(_);b&&l.setNodeMarkup(_,f,b.attrs)}),n(l)}return!0}}J8("row",{useDeprecatedLogic:!0});J8("column",{useDeprecatedLogic:!0});const Gzt=J8("cell",{useDeprecatedLogic:!0});function Kzt(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 X7(t,s){const r=t.selection;if(!(r instanceof ec))return!1;if(s){const n=t.tr,a=Hh(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 gn(a,0,0))}),n.docChanged&&s(n)}return!0}function Yzt(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(Tr.empty),r[a]n&&(y=y.type.createChecked(AS(y.attrs,y.attrs.colspan,p+y.attrs.colspan-n),y.content)),u.push(y),p+=y.attrs.colspan;for(let _=1;_a&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,a-f.attrs.rowspan)},f.content)),c.push(f)}o.push(Tr.from(c))}r=o,s=a}return{width:t,height:s,rows:r}}function Jzt(t,s,r,n,a,o,l){const i=t.doc.type.schema,c=Hh(i);let u,p;if(a>s.width)for(let f=0,y=0;fs.height){const f=[];for(let b=0,w=(s.height-1)*s.width;b=s.width?!1:r.nodeAt(s.map[w+b]).type==c.header_cell;f.push(j?p||(p=c.header_cell.createAndFill()):u||(u=c.cell.createAndFill()))}const y=c.row.create(null,Tr.from(f)),_=[];for(let b=s.height;b{if(!a)return!1;const o=r.selection;if(o instanceof ec)return bie(r,n,hi.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=pJe(a,t,s);if(l==null)return!1;if(t=="horiz")return bie(r,n,hi.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),c=oJe(i,t,s);let u;return c?u=hi.near(c,1):s<0?u=hi.near(r.doc.resolve(i.before(-1)),-1):u=hi.near(r.doc.resolve(i.after(-1)),1),bie(r,n,u)}}}function J7(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof ec)l=o;else{const c=pJe(a,t,s);if(c==null)return!1;l=new ec(r.doc.resolve(c))}const i=oJe(l.$headCell,t,s);return i?bie(r,n,new ec(l.$anchorCell,i)):!1}}function t9t(t,s){const r=t.state.doc,n=BA(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new ec(n))),!0):!1}function s9t(t,s,r){if(!ay(t.state))return!1;let n=Yzt(r);const a=t.state.selection;if(a instanceof ec){n||(n={width:1,height:1,rows:[Tr.from(B1e(Hh(t.state.schema).cell,r))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=cd.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=Qzt(n,i.right-i.left,i.bottom-i.top),jLe(t.state,t.dispatch,l,i,n),!0}else if(n){const o=Tue(t.state),l=o.start(-1);return jLe(t.state,t.dispatch,l,cd.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function r9t(t,s){var r;if(s.ctrlKey||s.metaKey)return;const n=kLe(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof ec)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=BA(t.state.selection.$anchor))!=null&&((r=mxe(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=mxe(t,u);const f=X_.getState(t.state)==null;if(!p||!eNe(c,p))if(f)p=c;else return;const y=new ec(c,p);if(f||!t.state.selection.eq(y)){const _=t.state.tr.setSelection(y);f&&_.setMeta(X_,c.pos),t.dispatch(_)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),X_.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(X_,-1))}function i(c){const u=c,p=X_.getState(t.state);let f;if(p!=null)f=t.state.doc.resolve(p);else if(kLe(t,u.target)!=n&&(f=mxe(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 pJe(t,s,r){if(!(t.state.selection instanceof Ya))return null;const{$head:n}=t.state.selection;for(let a=n.depth-1;a>=0;a--){const o=n.node(a);if((r<0?n.index(a):n.indexAfter(a))!=(r<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=n.before(a),i=s=="vert"?r>0?"down":"up":r>0?"right":"left";return t.endOfTextblock(i)?l:null}}return null}function kLe(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function mxe(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 BA(t.state.doc.resolve(n))}var n9t=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")),$1e(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,$1e(s,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(s){return s.type=="attributes"&&(s.target==this.table||this.colgroup.contains(s.target))}};function $1e(t,s,r,n,a,o){let l=0,i=!0,c=s.firstChild;const u=t.firstChild;if(u){for(let f=0,y=0;fnew n(f,r,y)),new i9t(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=sf.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{o9t(l,i,t,a)},mouseleave:l=>{l9t(l)},mousedown:(l,i)=>{c9t(l,i,s,r)}},decorations:l=>{const i=sf.getState(l);if(i&&i.activeHandle>-1)return p9t(l,i.activeHandle)},nodeViews:{}}});return o}var i9t=class wie{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta(sf);if(n&&n.setHandle!=null)return new wie(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new wie(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return z1e(s.doc.resolve(a))||(a=-1),new wie(a,r.dragging)}return r}};function o9t(t,s,r,n){if(!t.editable)return;const a=sf.getState(t.state);if(a&&!a.dragging){const o=u9t(s.target);let l=-1;if(o){const{left:i,right:c}=o.getBoundingClientRect();s.clientX-i<=r?l=NLe(t,s,"left",r):c-s.clientX<=r&&(l=NLe(t,s,"right",r))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=t.state.doc.resolve(l),c=i.node(-1),u=cd.get(c),p=i.start(-1);if(u.colCount(i.pos-p)+i.nodeAfter.attrs.colspan-1==u.width-1)return}fJe(t,l)}}}function l9t(t){if(!t.editable)return;const s=sf.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&fJe(t,-1)}function c9t(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=sf.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),c=d9t(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(sf,{setDragging:{startX:s.clientX,startWidth:c}}));function u(f){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",p);const y=sf.getState(t.state);y!=null&&y.dragging&&(h9t(t,y.activeHandle,SLe(y.dragging,f,r)),t.dispatch(t.state.tr.setMeta(sf,{setDragging:null})))}function p(f){if(!f.which)return u(f);const y=sf.getState(t.state);if(y&&y.dragging){const _=SLe(y.dragging,f,r);CLe(t,y.activeHandle,_,n)}}return CLe(t,l.activeHandle,c,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",p),s.preventDefault(),!0}function d9t(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 v9t(t,s,r,n,a){const o=y9t(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!_9t(s))return!1;let r=0;const n=OQe(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},b9t=Zh.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:g9t,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}=x9t(t,this.options.cellMinWidth),o=["table",Zc(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=v9t(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(Ya.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>Lzt(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>Dzt(t,s),deleteColumn:()=>({state:t,dispatch:s})=>Rzt(t,s),addRowBefore:()=>({state:t,dispatch:s})=>zzt(t,s),addRowAfter:()=>({state:t,dispatch:s})=>Bzt(t,s),deleteRow:()=>({state:t,dispatch:s})=>qzt(t,s),deleteTable:()=>({state:t,dispatch:s})=>Zzt(t,s),mergeCells:()=>({state:t,dispatch:s})=>xLe(t,s),splitCell:()=>({state:t,dispatch:s})=>yLe(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>J8("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>J8("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>Gzt(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>xLe(t,s)?!0:yLe(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>Hzt(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>_Le(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>_Le(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&uJe(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=ec.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:ez,"Mod-Backspace":ez,Delete:ez,"Mod-Delete":ez}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[a9t({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],f9t({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:Qi(sa(t,"tableRole",s))}}}),w9t=Zh.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Zc(this.options.HTMLAttributes,t),0]}}),j9t=Zh.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",Zc(this.options.HTMLAttributes,t),0]}}),k9t=Zh.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",Zc(this.options.HTMLAttributes,t),0]}});function iy({content:t,onChange:s,placeholder:r="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=C.useState(!1),[i,c]=C.useState(""),[u,p]=C.useState(!0),f=qQe({extensions:[KQe,nJe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),aJe.configure({types:["heading","paragraph"]}),iJe,yzt.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),width:{default:null},height:{default:null},style:{default:null}}}}).configure({inline:!0,allowBase64:!0}),b9t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},cellpadding:{default:null},cellspacing:{default:null},border:{default:null}}}}).configure({resizable:!1}),w9t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null}}}}),j9t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1},valign:{default:null}}}}),k9t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1}}}})],content:t,onUpdate:({editor:w})=>{s(w.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":r},handlePaste:(w,j)=>{var S;const N=(S=j.clipboardData)==null?void 0:S.items;if(!N)return!1;for(const T of Array.from(N))if(T.type.startsWith("image/")){j.preventDefault();const I=T.getAsFile();if(!I)continue;const L=new FileReader;return L.onload=R=>{var q;const $=(q=R.target)==null?void 0:q.result;w.dispatch(w.state.tr.replaceSelectionWith(w.state.schema.nodes.image.create({src:$})))},L.readAsDataURL(I),!0}return!1}}});C.useEffect(()=>{f&&t!==f.getHTML()&&f.commands.setContent(t)},[t,f]);const y=()=>{if(!f)return;const w=f.getAttributes("link").href||"",j=f.getAttributes("link").target;c(w),p(j==="_blank"),l(!0)},_=()=>{f&&(i===""?f.chain().focus().extendMarkRange("link").unsetLink().run():f.chain().focus().extendMarkRange("link").setLink({href:i,target:u?"_blank":null,rel:u?"noopener noreferrer nofollow":null}).run(),l(!1),c(""))},b=()=>{f&&f.chain().focus().extendMarkRange("link").unsetLink().run()};return f?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>f.chain().focus().toggleHeading({level:1}).run(),className:f.isActive("heading",{level:1})?"bg-muted":"",title:"Heading 1",children:e.jsx(qI,{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(UI,{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(iM,{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(mM,{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(Mm,{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(Jv,{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(rM,{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(sM,{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(nM,{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:y,className:f.isActive("link")?"bg-muted":"",title:"Add Link",children:e.jsx(Vo,{className:"h-4 w-4"})}),f.isActive("link")&&e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:b,title:"Remove Link",children:e.jsx(Vo,{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(kM,{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(wM,{className:"h-4 w-4"})})]}),e.jsx(BQe,{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(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Insert Link"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"link-url",children:"URL"}),e.jsx(Fe,{id:"link-url",value:i,onChange:w=>c(w.target.value),placeholder:"https://example.com"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Br,{id:"link-new-tab",checked:u,onCheckedChange:p}),e.jsx(_e,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"button",onClick:_,children:i?"Apply Link":"Remove Link"})]})]})})]}):null}var N9t=Object.defineProperty,S9t=(t,s,r)=>s in t?N9t(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,jc=(t,s,r)=>S9t(t,typeof s!="symbol"?s+"":s,r);const Mle={x:0,y:0,width:0,height:0,unit:"px"},r5=(t,s,r)=>Math.min(Math.max(t,s),r),C9t=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),ALe=(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 M9t(t,s,r,n){const a=qy(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==="%"?q_(a,r,n):a}function T9t(t,s,r){const n=qy(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?q_(n,s,r):n}function q_(t,s,r){return t.unit==="%"?{...Mle,...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 qy(t,s,r){return t.unit?t.unit==="px"?{...Mle,...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}:{...Mle,...t,unit:"px"}}function ELe(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),y=Math.min(i,n),_=Math.min(c,a);s&&(s>1?(p=l?l*s:p,f=p/s,y=i*s):(f=o?o/s:f,p=f*s,_=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 b=n-(u.x+u.width);b<0&&(u.x=Math.min(u.x,n-p),u.width+=b);const w=a-(u.y+u.height);if(w<0&&(u.y=Math.min(u.y,a-f),u.height+=w),u.widthy&&((r==="sw"||r=="nw")&&(u.x-=y-u.width),u.width=y),u.height>_&&((r==="nw"||r=="ne")&&(u.y-=_-u.height),u.height=_),s){const j=u.width/u.height;if(js){const N=Math.max(u.height*s,p);(r==="sw"||r=="nw")&&(u.x-=N-u.width),u.width=N}}return u}function A9t(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 n5={capture:!0,passive:!1};let E9t=0;const L_=class bx extends C.PureComponent{constructor(){super(...arguments),jc(this,"docMoveBound",!1),jc(this,"mouseDownOnCrop",!1),jc(this,"dragStarted",!1),jc(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),jc(this,"componentRef",C.createRef()),jc(this,"mediaRef",C.createRef()),jc(this,"resizeObserver"),jc(this,"initChangeCalled",!1),jc(this,"instanceId",`rc-${E9t++}`),jc(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),jc(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=qy(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 y=s.clientX-a.x,_=s.clientY-a.y;let b=0,w=0;l==="ne"||l=="e"?(b=y-(o.x+o.width),w=_-o.y,p=o.x,f=o.y+o.height):l==="se"||l==="s"?(b=y-(o.x+o.width),w=_-(o.y+o.height),p=o.x,f=o.y):l==="sw"||l=="w"?(b=y-o.x,w=_-(o.y+o.height),p=o.x+o.width,f=o.y):(l==="nw"||l=="n")&&(b=y-o.x,w=_-o.y,p=o.x+o.width,f=o.y+o.height),c=p+a.x+b,u=f+a.y+w}this.evData={startClientX:c,startClientY:u,startCropX:p,startCropY:f,clientX:s.clientX,clientY:s.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),jc(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(qy(p,i.width,i.height),q_(p,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),jc(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(),ALe(r,c)||a(qy(c,l.width,l.height),q_(c,l.width,l.height))}),jc(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)?bx.nudgeStepLarge:s.shiftKey?bx.nudgeStepMedium:bx.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=r5(u.x,0,c.width-u.width),u.y=r5(u.y,0,c.height-u.height);const f=qy(u,c.width,c.height),y=q_(u,c.width,c.height);a(f,y),o&&o(f,y)}}),jc(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,y=this.getBox();if(o||!a)return;if(s.key==="ArrowUp"||s.key==="ArrowDown"||s.key==="ArrowLeft"||s.key==="ArrowRight")s.stopPropagation(),s.preventDefault();else return;const _=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?bx.nudgeStepLarge:s.shiftKey?bx.nudgeStepMedium:bx.nudgeStep,b=qy(a,y.width,y.height),w=A9t(b,s.key,_,r),j=ELe(w,n,r,y.width,y.height,l,i,c,u);if(!ALe(a,j)){const N=q_(j,y.width,y.height);p(j,N),f&&f(j,N)}}),jc(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(qy(r,l.width,l.height),q_(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),jc(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(qy(r,a,o),q_(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,n5),this.document.addEventListener("pointerup",this.onDocPointerDone,n5),this.document.addEventListener("pointercancel",this.onDocPointerDone,n5),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,n5),this.document.removeEventListener("pointerup",this.onDocPointerDone,n5),this.document.removeEventListener("pointercancel",this.onDocPointerDone,n5),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=r5(s.startCropX+a,0,r.width-n.width),n.y=r5(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,y=s.clientY-s.startClientY;(l&&p==="nw"||p==="w"||p==="sw")&&(f=Math.min(f,-l)),(i&&p==="nw"||p==="n"||p==="ne")&&(y=Math.min(y,-i));const _={unit:"px",x:0,y:0,width:0,height:0};u==="ne"?(_.x=s.startCropX,_.width=f,r?(_.height=_.width/r,_.y=s.startCropY-_.height):(_.height=Math.abs(y),_.y=s.startCropY-_.height)):u==="se"?(_.x=s.startCropX,_.y=s.startCropY,_.width=f,r?_.height=_.width/r:_.height=y):u==="sw"?(_.x=s.startCropX+f,_.y=s.startCropY,_.width=Math.abs(f),r?_.height=_.width/r:_.height=y):u==="nw"&&(_.x=s.startCropX+f,_.width=Math.abs(f),r?(_.height=_.width/r,_.y=s.startCropY-_.height):(_.height=Math.abs(y),_.y=s.startCropY+y));const b=ELe(_,r,u,o.width,o.height,l,i,n,a);return r||bx.xyOrds.indexOf(p)>-1?c=b:bx.xOrds.indexOf(p)>-1?(c.x=b.x,c.width=b.width):bx.yOrds.indexOf(p)>-1&&(c.y=b.y,c.height=b.height),c.x=r5(c.x,0,o.width-c.width),c.y=r5(c.y,0,o.height-c.height),c}renderCropSelection(){const{ariaLabels:s=bx.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={...Mle,...this.props.crop||{}};return qy(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,y=o?this.renderCropSelection():null,_=C9t("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:_,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,y)}};jc(L_,"xOrds",["e","w"]),jc(L_,"yOrds",["n","s"]),jc(L_,"xyOrds",["nw","ne","se","sw"]),jc(L_,"nudgeStep",1),jc(L_,"nudgeStepMedium",10),jc(L_,"nudgeStepLarge",100),jc(L_,"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 P9t=L_;var gJe=["PageUp","PageDown"],xJe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],yJe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},$A="Slider",[U1e,I9t,L9t]=XD($A),[vJe]=Yc($A,[L9t]),[D9t,Aue]=vJe($A),_Je=C.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:y=()=>{},inverted:_=!1,form:b,...w}=t,j=C.useRef(new Set),N=C.useRef(0),T=l==="horizontal"?O9t:R9t,[I=[],L]=Yu({prop:p,defaultProp:u,onChange:X=>{var ee;(ee=[...j.current][N.current])==null||ee.focus(),f(X)}}),R=C.useRef(I);function $(X){const se=q9t(I,X);V(X,se)}function q(X){V(X,N.current)}function U(){const X=R.current[N.current];I[N.current]!==X&&y(I)}function V(X,se,{commit:ee}={commit:!1}){const Q=W9t(o),de=G9t(Math.round((X-n)/o)*o+n,Q),re=I8(de,[n,a]);L((ne=[])=>{const le=B9t(ne,re,se);if(H9t(le,c*o)){N.current=le.indexOf(re);const he=String(le)!==String(ne);return he&&ee&&y(le),he?le:ne}else return ne})}return e.jsx(D9t,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:N,thumbs:j.current,values:I,orientation:l,form:b,children:e.jsx(U1e.Provider,{scope:t.__scopeSlider,children:e.jsx(U1e.Slot,{scope:t.__scopeSlider,children:e.jsx(T,{"aria-disabled":i,"data-disabled":i?"":void 0,...w,ref:s,onPointerDown:Mr(w.onPointerDown,()=>{i||(R.current=I)}),min:n,max:a,inverted:_,onSlideStart:i?void 0:$,onSlideMove:i?void 0:q,onSlideEnd:i?void 0:U,onHomeKeyDown:()=>!i&&V(n,0,{commit:!0}),onEndKeyDown:()=>!i&&V(a,I.length-1,{commit:!0}),onStepKeyDown:({event:X,direction:se})=>{if(!i){const de=gJe.includes(X.key)||X.shiftKey&&xJe.includes(X.key)?10:1,re=N.current,ne=I[re],le=o*de*se;V(ne+le,re,{commit:!0})}}})})})})});_Je.displayName=$A;var[bJe,wJe]=vJe($A,{startEdge:"left",endEdge:"right",size:"width",direction:1}),O9t=C.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:c,onStepKeyDown:u,...p}=t,[f,y]=C.useState(null),_=Oa(s,T=>y(T)),b=C.useRef(void 0),w=b2(a),j=w==="ltr",N=j&&!o||!j&&o;function S(T){const I=b.current||f.getBoundingClientRect(),L=[0,I.width],$=tNe(L,N?[r,n]:[n,r]);return b.current=I,$(T-I.left)}return e.jsx(bJe,{scope:t.__scopeSlider,startEdge:N?"left":"right",endEdge:N?"right":"left",direction:N?1:-1,size:"width",children:e.jsx(jJe,{dir:w,"data-orientation":"horizontal",...p,ref:_,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:T=>{const I=S(T.clientX);l==null||l(I)},onSlideMove:T=>{const I=S(T.clientX);i==null||i(I)},onSlideEnd:()=>{b.current=void 0,c==null||c()},onStepKeyDown:T=>{const L=yJe[N?"from-left":"from-right"].includes(T.key);u==null||u({event:T,direction:L?-1:1})}})})}),R9t=C.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:c,...u}=t,p=C.useRef(null),f=Oa(s,p),y=C.useRef(void 0),_=!a;function b(w){const j=y.current||p.current.getBoundingClientRect(),N=[0,j.height],T=tNe(N,_?[n,r]:[r,n]);return y.current=j,T(w-j.top)}return e.jsx(bJe,{scope:t.__scopeSlider,startEdge:_?"bottom":"top",endEdge:_?"top":"bottom",size:"height",direction:_?1:-1,children:e.jsx(jJe,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const j=b(w.clientY);o==null||o(j)},onSlideMove:w=>{const j=b(w.clientY);l==null||l(j)},onSlideEnd:()=>{y.current=void 0,i==null||i()},onStepKeyDown:w=>{const N=yJe[_?"from-bottom":"from-top"].includes(w.key);c==null||c({event:w,direction:N?-1:1})}})})}),jJe=C.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:c,...u}=t,p=Aue($A,r);return e.jsx(Jr.span,{...u,ref:s,onKeyDown:Mr(t.onKeyDown,f=>{f.key==="Home"?(l(f),f.preventDefault()):f.key==="End"?(i(f),f.preventDefault()):gJe.concat(xJe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:Mr(t.onPointerDown,f=>{const y=f.target;y.setPointerCapture(f.pointerId),f.preventDefault(),p.thumbs.has(y)?y.focus():n(f)}),onPointerMove:Mr(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Mr(t.onPointerUp,f=>{const y=f.target;y.hasPointerCapture(f.pointerId)&&(y.releasePointerCapture(f.pointerId),o(f))})})}),kJe="SliderTrack",NJe=C.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Aue(kJe,r);return e.jsx(Jr.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});NJe.displayName=kJe;var V1e="SliderRange",SJe=C.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Aue(V1e,r),o=wJe(V1e,r),l=C.useRef(null),i=Oa(s,l),c=a.values.length,u=a.values.map(y=>TJe(y,a.min,a.max)),p=c>1?Math.min(...u):0,f=100-Math.max(...u);return e.jsx(Jr.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:i,style:{...t.style,[o.startEdge]:p+"%",[o.endEdge]:f+"%"}})});SJe.displayName=V1e;var H1e="SliderThumb",CJe=C.forwardRef((t,s)=>{const r=I9t(t.__scopeSlider),[n,a]=C.useState(null),o=Oa(s,i=>a(i)),l=C.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(F9t,{...t,ref:o,index:l})}),F9t=C.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=Aue(H1e,r),i=wJe(H1e,r),[c,u]=C.useState(null),p=Oa(s,S=>u(S)),f=c?l.form||!!c.closest("form"):!0,y=eO(c),_=l.values[n],b=_===void 0?0:TJe(_,l.min,l.max),w=$9t(n,l.values.length),j=y==null?void 0:y[i.size],N=j?U9t(j,b,i.direction):0;return C.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(${b}% + ${N}px)`},children:[e.jsx(U1e.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(Jr.span,{role:"slider","aria-label":t["aria-label"]||w,"aria-valuemin":l.min,"aria-valuenow":_,"aria-valuemax":l.max,"aria-orientation":l.orientation,"data-orientation":l.orientation,"data-disabled":l.disabled?"":void 0,tabIndex:l.disabled?void 0:0,...o,ref:p,style:_===void 0?{display:"none"}:t.style,onFocus:Mr(t.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),f&&e.jsx(MJe,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:_},n)]})});CJe.displayName=H1e;var z9t="RadioBubbleInput",MJe=C.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=C.useRef(null),o=Oa(a,n),l=mO(s);return C.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(Jr.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});MJe.displayName=z9t;function B9t(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function TJe(t,s,r){const o=100/(r-s)*(t-s);return I8(o,[0,100])}function $9t(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function q9t(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 U9t(t,s,r){const n=t/2,o=tNe([0,50],[0,n]);return(n-o(s)*r)*r}function V9t(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function H9t(t,s){if(s>0){const r=V9t(t);return Math.min(...r)>=s}return!0}function tNe(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 W9t(t){return(String(t).split(".")[1]||"").length}function G9t(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var AJe=_Je,K9t=NJe,Z9t=SJe,Y9t=CJe;const Bx=C.forwardRef(({className:t,...s},r)=>e.jsxs(AJe,{ref:r,className:At("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(K9t,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(Z9t,{className:"absolute h-full bg-primary"})}),e.jsx(Y9t,{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"})]}));Bx.displayName=AJe.displayName;function X9t(t,s,r){return T9t(M9t({unit:"%",width:90},r,t,s),t,s)}const sNe=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=C.useRef(null),[l,i]=C.useState(),[c,u]=C.useState(),[p,f]=C.useState(1),[y,_]=C.useState(0),b=C.useCallback(N=>{const{width:S,height:T}=N.currentTarget;i(X9t(S,T,a))},[a]),w=C.useCallback(async()=>{const N=o.current;if(!N||!c)return;const S=document.createElement("canvas"),T=S.getContext("2d");if(!T)return;const I=N.naturalWidth/N.width,L=N.naturalHeight/N.height,R=400;S.width=R,S.height=R,T.imageSmoothingQuality="high";const $=c.x*I,q=c.y*L,U=c.width*I,V=c.height*L,X=y*Math.PI/180,se=S.width/2,ee=S.height/2;return T.save(),T.translate(se,ee),T.rotate(X),T.scale(p,p),T.translate(-se,-ee),T.drawImage(N,$,q,U,V,0,0,R,R),T.restore(),new Promise((Q,de)=>{S.toBlob(re=>{re?Q(re):de(new Error("Canvas is empty"))},"image/jpeg",.95)})},[c,p,y]),j=async()=>{try{const N=await w();N&&(n(N),s())}catch(N){console.error("Error cropping image:",N)}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Crop Your Photo"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative max-h-[400px] overflow-hidden rounded-lg bg-muted flex items-center justify-center",children:e.jsx(P9t,{crop:l,onChange:(N,S)=>i(S),onComplete:N=>u(N),aspect:a,circularCrop:!0,className:"max-h-[400px]",children:e.jsx("img",{ref:o,src:r,alt:"Crop preview",style:{transform:`scale(${p}) rotate(${y}deg)`,maxHeight:"400px",width:"auto"},onLoad:b})})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(NM,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Bx,{value:[p],min:.5,max:3,step:.1,onValueChange:([N])=>f(N),className:"flex-1"}),e.jsx(Bb,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(nL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Bx,{value:[y],min:-180,max:180,step:1,onValueChange:([N])=>_(N),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[y,"°"]})]})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(K,{onClick:j,children:"Save Photo"})]})]})})},Q9t=()=>{const{user:t}=Ws(),{toast:s}=Ra(),[r,n]=C.useState(!1),[a,o]=C.useState(!1),[l,i]=C.useState(null);C.useEffect(()=>{t&&c()},[t]);const c=async()=>{n(!0);try{const{data:f}=await G.from("profiles").select("subscription_status, subscription_product_id, subscription_end_date, is_grandfathered").eq("id",t==null?void 0:t.id).single();f&&i({status:f.subscription_status||"none",productId:f.subscription_product_id,endDate:f.subscription_end_date,isGrandfathered:f.is_grandfathered||!1})}catch(f){console.error("Error loading subscription:",f)}finally{n(!1)}},u=async()=>{o(!0);try{const{data:{session:f}}=await G.auth.getSession();if(!f)throw new Error("Not authenticated");const{data:y,error:_}=await G.functions.invoke("customer-portal",{headers:{Authorization:`Bearer ${f.access_token}`}});if(_)throw _;y!=null&&y.url&&window.open(y.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(nt,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(nt,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(nt,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(nt,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(nt,{variant:"secondary",children:"Canceled"});default:return e.jsx(nt,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(yg,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(yg,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(fr,{children:"Manage your subscription and billing"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Status"}),e.jsx("div",{className:"mt-1",children:p()})]}),(l==null?void 0:l.endDate)&&l.status==="active"&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Next billing date"}),e.jsx("p",{className:"font-medium",children:new Date(l.endDate).toLocaleDateString()})]})]}),l!=null&&l.isGrandfathered?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your account was upgraded from LevelUp 1.0. To update/manage your subscription please reach out to support."}):(l==null?void 0:l.status)==="active"||(l==null?void 0:l.status)==="trialing"?e.jsxs(e.Fragment,{children:[(l==null?void 0:l.status)==="trialing"&&(l==null?void 0:l.endDate)&&e.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["Your trial ends on ",new Date(l.endDate).toLocaleDateString(),". After the trial, you'll be charged automatically."]}),e.jsxs(K,{onClick:u,variant:"outline",disabled:a,children:[a?e.jsx(Ss,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(rn,{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."})]})]})},J9t=()=>{const{user:t}=Ws(),s=Pr(),{toast:r}=Ra(),[n]=Xc(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:c,subscribe:u,unsubscribe:p}=rYe(),[f,y]=C.useState(!1),[_,b]=C.useState(""),[w,j]=C.useState(!1),[N,S]=C.useState(!1),[T,I]=C.useState(""),[L,R]=C.useState({name:"",email:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[$,q]=C.useState(!1),[U,V]=C.useState(!1),[X,se]=C.useState({newPassword:"",confirmPassword:""});C.useEffect(()=>{t&&ee()},[t]),C.useEffect(()=>{o&&t&&setTimeout(()=>{var le;(le=document.getElementById("change-password-section"))==null||le.scrollIntoView({behavior:"smooth",block:"center"})},500)},[o,t]);const ee=async()=>{var le,he,we;if(!(t!=null&&t.id)){console.log("No user ID available yet");return}try{console.log("Loading profile for user:",t.id);const{data:ye,error:je}=await G.from("profiles").select("name, email, digest_opt_out, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url, email_signature, use_email_signature").eq("id",t.id).maybeSingle();if(je)throw console.error("Profile query error:",je),je;ye?(console.log("Profile loaded successfully:",ye),R({name:ye.name||"",email:ye.email||"",title:ye.title||"",bio:ye.bio||"",areas_served:ye.areas_served||"",years_experience:((le=ye.years_experience)==null?void 0:le.toString())||"",instagram_url:ye.instagram_url||"",facebook_url:ye.facebook_url||"",linkedin_url:ye.linkedin_url||"",email_signature:ye.email_signature||"",use_email_signature:ye.use_email_signature||!1}),q(ye.digest_opt_out||!1)):(console.warn("No profile found for user"),R({name:((he=t.user_metadata)==null?void 0:he.name)||((we=t.email)==null?void 0:we.split("@")[0])||"",email:t.email||"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}));const{data:ke}=await G.storage.from("avatars").list(`${t.id}`);if(ke&&ke.length>0){const{data:We}=G.storage.from("avatars").getPublicUrl(`${t.id}/${ke[0].name}`);b(We.publicUrl)}}catch(ye){console.error("Error loading profile:",ye),r({title:"Error",description:ye.message||"Failed to load profile",variant:"destructive"})}},Q=le=>{var ye;const he=(ye=le.target.files)==null?void 0:ye[0];if(!he)return;const we=new FileReader;we.onloadend=()=>{I(we.result),S(!0)},we.readAsDataURL(he),le.target.value=""},de=async le=>{if(t){j(!0);try{const{data:he}=await G.storage.from("avatars").list(`${t.id}`);he&&he.length>0&&await G.storage.from("avatars").remove(he.map(be=>`${t.id}/${be.name}`));const ye=`${t.id}/avatar.jpg`,{error:je}=await G.storage.from("avatars").upload(ye,le,{upsert:!0,contentType:"image/jpeg"});if(je)throw je;const{data:ke}=G.storage.from("avatars").getPublicUrl(ye),We=ke.publicUrl;b(`${We}?t=${Date.now()}`),await G.from("profiles").update({avatar_url:We}).eq("id",t.id),r({title:"Success",description:"Profile photo updated successfully"})}catch(he){console.error("Error uploading avatar:",he),r({title:"Error",description:he.message||"Failed to upload photo",variant:"destructive"})}finally{j(!1)}}},re=async()=>{if(!L.name.trim()||!L.email.trim()){r({title:"Error",description:"Name and email are required",variant:"destructive"});return}y(!0);try{const{error:le}=await G.from("profiles").update({name:L.name.trim(),email:L.email.trim(),title:L.title.trim()||null,bio:L.bio.trim()||null,areas_served:L.areas_served.trim()||null,years_experience:L.years_experience?parseInt(L.years_experience):null,instagram_url:L.instagram_url.trim()||null,facebook_url:L.facebook_url.trim()||null,linkedin_url:L.linkedin_url.trim()||null,email_signature:L.email_signature||"",use_email_signature:L.use_email_signature}).eq("id",t==null?void 0:t.id);if(le)throw le;r({title:"Success",description:"Profile updated successfully"})}catch(le){console.error("Error updating profile:",le),r({title:"Error",description:le.message||"Failed to update profile",variant:"destructive"})}finally{y(!1)}},ne=async()=>{if(!X.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(X.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(X.newPassword!==X.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}y(!0);try{const{error:le}=await G.auth.updateUser({password:X.newPassword});if(le)throw le;r({title:"Success",description:"Password updated successfully"}),se({newPassword:"",confirmPassword:""}),a&&setTimeout(()=>s("/dashboard"),1e3)}catch(le){console.error("Error updating password:",le),r({title:"Error",description:le.message||"Failed to update password",variant:"destructive"})}finally{y(!1)}};return e.jsx(Es,{title:a?"Complete Your Profile":o?"Reset Your Password":"Profile Settings",description:a?"Welcome! Please complete your profile setup":o?"Please set a new password for your account":"Manage your account information and password",children:e.jsxs("div",{className:"mx-auto max-w-4xl",children:[!a&&!o&&e.jsx("div",{className:"mb-6",children:e.jsxs(K,{variant:"outline",onClick:()=>{var le;(le=document.getElementById("change-password-section"))==null||le.scrollIntoView({behavior:"smooth",block:"center"})},className:"gap-2",children:[e.jsx(q4,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Profile Photo"}),e.jsx(fr,{children:"Upload a professional photo for your profile"})]}),e.jsxs(Oe,{className:"flex items-center gap-6",children:[e.jsxs(yn,{className:"h-24 w-24",children:[e.jsx(Da,{src:_}),e.jsx(vn,{className:"text-2xl",children:L.name.split(" ").map(le=>le[0]).join("").toUpperCase()||"U"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",id:"avatar-upload",accept:"image/*",className:"hidden",onChange:Q,disabled:w}),e.jsxs(K,{variant:"outline",onClick:()=>{var le;return(le=document.getElementById("avatar-upload"))==null?void 0:le.click()},disabled:w,children:[e.jsx(ni,{className:"mr-2 h-4 w-4"}),w?"Uploading...":"Upload Photo"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Upload an image and crop it to your liking."})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Personal Information"}),e.jsx(fr,{children:"Update your profile details"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"name",children:"Name"}),e.jsx(Fe,{id:"name",value:L.name,onChange:le=>R({...L,name:le.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"email",children:"Email"}),e.jsx(Fe,{id:"email",type:"email",value:L.email,onChange:le=>R({...L,email:le.target.value}),maxLength:255})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Job Title"}),e.jsx(Fe,{id:"title",value:L.title,onChange:le=>R({...L,title:le.target.value}),placeholder:"e.g., Broker Associate, Team Lead",maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"bio",children:"Bio"}),e.jsx(Ar,{id:"bio",value:L.bio,onChange:le=>R({...L,bio:le.target.value}),placeholder:"A short description about yourself",maxLength:500,className:"min-h-[120px] resize-y"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"areas_served",children:"Areas Served"}),e.jsx(Fe,{id:"areas_served",value:L.areas_served,onChange:le=>R({...L,areas_served:le.target.value}),placeholder:"e.g., Downtown, Suburbs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"years_experience",children:"Years Experience"}),e.jsx(Fe,{id:"years_experience",type:"number",min:"0",value:L.years_experience,onChange:le=>R({...L,years_experience:le.target.value}),placeholder:"e.g., 5"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Social Links"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsx(Fe,{value:L.linkedin_url,onChange:le=>R({...L,linkedin_url:le.target.value}),placeholder:"LinkedIn URL"}),e.jsx(Fe,{value:L.instagram_url,onChange:le=>R({...L,instagram_url:le.target.value}),placeholder:"Instagram URL"}),e.jsx(Fe,{value:L.facebook_url,onChange:le=>R({...L,facebook_url:le.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(K,{onClick:re,disabled:f,children:[e.jsx(Wu,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Ev,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(fr,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Use email signature in all emails"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:L.use_email_signature?"Your signature will be added to every email sent via Gmail":"Signature is currently disabled"})]}),e.jsx(Br,{checked:L.use_email_signature,onCheckedChange:le=>R({...L,use_email_signature:le})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Signature"}),e.jsx(iy,{content:L.email_signature,onChange:le=>R({...L,email_signature:le}),placeholder:"Paste your Gmail signature here or create one...",minHeight:"120px",compact:!0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tip: Copy your signature from Gmail Settings and paste it here — images and formatting will be preserved."})]}),e.jsxs(K,{onClick:re,disabled:f,children:[e.jsx(Wu,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(Ee,{id:"change-password-section",children:[e.jsxs(It,{children:[e.jsx(Ot,{children:a?"Set Your Password":"Change Password"}),e.jsx(fr,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"newPassword",children:"New Password"}),e.jsx(Fe,{id:"newPassword",type:"password",value:X.newPassword,onChange:le=>se({...X,newPassword:le.target.value}),placeholder:"Min 6 characters"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(Fe,{id:"confirmPassword",type:"password",value:X.confirmPassword,onChange:le=>se({...X,confirmPassword:le.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(K,{onClick:ne,disabled:f,children:[e.jsx(Wu,{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(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[i?e.jsx(gg,{className:"h-5 w-5"}):e.jsx(Mb,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(fr,{children:"Receive browser notifications when new content is added"})]}),e.jsx(Oe,{children:l?e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:i?"Notifications enabled":"Notifications disabled"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i?"You'll receive notifications about new templates, videos, and events":"Enable to get notified about new content"})]}),e.jsx(Br,{checked:i,onCheckedChange:le=>{le?u():p()},disabled: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(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[$?e.jsx(HI,{className:"h-5 w-5"}):e.jsx(br,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(fr,{children:"Manage your email subscription settings"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:$?"You won't receive weekly digest emails":"Receive a weekly summary of new content, events, and your progress"})]}),e.jsx(Br,{checked:!$,onCheckedChange:async le=>{V(!0);try{const{error:he}=await G.from("profiles").update({digest_opt_out:!le}).eq("id",t==null?void 0:t.id);if(he)throw he;q(!le),r({title:le?"Subscribed":"Unsubscribed",description:le?"You will now receive weekly digest emails":"You will no longer receive weekly digest emails"})}catch(he){r({title:"Error",description:he.message||"Failed to update preference",variant:"destructive"})}finally{V(!1)}},disabled:U})]})})]}),e.jsx(ALt,{}),e.jsx(Q9t,{})]}),e.jsx(sNe,{open:N,onClose:()=>S(!1),imageSrc:T,onCropComplete:de,aspectRatio:1})]})})};var eBt="AspectRatio",EJe=C.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(Jr.div,{...a,ref:s,style:{...n,position:"absolute",top:0,right:0,bottom:0,left:0}})})});EJe.displayName=eBt;var tBt=EJe;const sBt=tBt;function rBt(){const{user:t}=Ws(),s=ss(),[r,n]=C.useState(!1),[a,o]=C.useState(!1),{data:l,isLoading:i}=wt({queryKey:["calendar-token",t==null?void 0:t.id],queryFn:async()=>{const{data:b,error:w}=await G.from("profiles").select("calendar_token").eq("id",t==null?void 0:t.id).single();if(w)throw w;return b},enabled:!!t&&a}),c=Dt({mutationFn:async()=>{const b=new Uint8Array(12);crypto.getRandomValues(b);const w=btoa(String.fromCharCode(...b)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:j}=await G.from("profiles").update({calendar_token:w}).eq("id",t==null?void 0:t.id);if(j)throw j;return w},onSuccess:()=>{s.invalidateQueries({queryKey:["calendar-token",t==null?void 0:t.id]}),me.success("Calendar subscription URL generated!")},onError:b=>{me.error("Failed to generate calendar URL: "+b.message)}}),u=l!=null&&l.calendar_token?`https://dashboard.relevelup.com/api/calendar/${l.calendar_token}.ics`:null,p=async()=>{u&&(await navigator.clipboard.writeText(u),n(!0),me.success("Calendar URL copied to clipboard!"),setTimeout(()=>n(!1),2e3))},f=()=>{u&&(window.location.href=u.replace("https://","webcal://"))},y=()=>{if(u){const b=u.replace("https://","webcal://"),w=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(b)}`;window.open(w,"_blank")}},_=()=>{if(u){const b=`https://outlook.live.com/calendar/0/addfromweb?url=${encodeURIComponent(u)}&name=Level%20Up%20Events`;window.open(b,"_blank")}};return e.jsxs(_s,{open:a,onOpenChange:o,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-5 w-5 text-primary"}),"Subscribe to Events Calendar"]}),e.jsx(Zr,{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(Ss,{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(Fe,{value:u,readOnly:!0,className:"text-xs font-mono"}),e.jsx(K,{variant:"outline",size:"icon",onClick:p,children:r?e.jsx(ma,{className:"h-4 w-4 text-green-500"}):e.jsx(mi,{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(rn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:y,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(rn,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:_,children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M7.88 12.04q0 .45-.11.87-.1.41-.33.74-.22.33-.58.52-.37.2-.87.2t-.85-.2q-.35-.21-.57-.55-.22-.33-.33-.75-.1-.42-.1-.86t.1-.87q.1-.43.34-.76.22-.34.59-.54.36-.2.87-.2t.86.2q.35.21.57.55.22.34.31.77.1.43.1.88zM24 12v9.38q0 .46-.33.8-.33.32-.8.32H7.13q-.46 0-.8-.33-.32-.33-.32-.8V18H1q-.41 0-.7-.3-.3-.29-.3-.7V7q0-.41.3-.7Q.58 6 1 6h6.5V2.55q0-.44.3-.75.3-.3.75-.3h12.9q.44 0 .75.3.3.3.3.75V12zm-6-8.25v3h3v-3zm0 4.5v3h3v-3zm0 4.5v1.83l3.05-1.83zm-5.25-9v3h3.75v-3zm0 4.5v3h3.75v-3zm0 4.5v2.03l2.41 1.5 1.34-.81v-2.72zM9 3.75V6h2l.13.01.12.04v-2.3zM5.98 15.98q.9 0 1.6-.3.7-.32 1.19-.86.48-.55.73-1.28.25-.74.25-1.61 0-.83-.25-1.55-.24-.71-.71-1.24t-1.15-.83q-.68-.3-1.55-.3-.92 0-1.64.3-.71.3-1.2.85-.5.54-.75 1.3-.25.74-.25 1.63 0 .85.26 1.56.26.72.74 1.23.48.52 1.17.81.69.3 1.56.3zM7.5 21h12.39L12 16.08V17q0 .41-.3.7-.29.3-.7.3H7.5zm15-.13v-7.24l-5.9 3.54Z"})}),"Add to Outlook",e.jsx(rn,{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(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(on,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}var Eue="Tabs",[nBt]=Yc(Eue,[w2]),PJe=w2(),[aBt,rNe]=nBt(Eue),IJe=C.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:c="automatic",...u}=t,p=b2(i),[f,y]=Yu({prop:n,onChange:a,defaultProp:o??"",caller:Eue});return e.jsx(aBt,{scope:r,baseId:vu(),value:f,onValueChange:y,orientation:l,dir:p,activationMode:c,children:e.jsx(Jr.div,{dir:p,"data-orientation":l,...u,ref:s})})});IJe.displayName=Eue;var LJe="TabsList",DJe=C.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=rNe(LJe,r),l=PJe(r);return e.jsx(kde,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:n,children:e.jsx(Jr.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});DJe.displayName=LJe;var OJe="TabsTrigger",RJe=C.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=rNe(OJe,r),i=PJe(r),c=BJe(l.baseId,n),u=$Je(l.baseId,n),p=n===l.value;return e.jsx(Nde,{asChild:!0,...i,focusable:!a,active:p,children:e.jsx(Jr.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:Mr(t.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?l.onValueChange(n):f.preventDefault()}),onKeyDown:Mr(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&l.onValueChange(n)}),onFocus:Mr(t.onFocus,()=>{const f=l.activationMode!=="manual";!p&&!a&&f&&l.onValueChange(n)})})})});RJe.displayName=OJe;var FJe="TabsContent",zJe=C.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=rNe(FJe,r),c=BJe(i.baseId,n),u=$Je(i.baseId,n),p=n===i.value,f=C.useRef(p);return C.useEffect(()=>{const y=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(y)},[]),e.jsx(Id,{present:a||p,children:({present:y})=>e.jsx(Jr.div,{"data-state":p?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":c,hidden:!y,id:u,tabIndex:0,...l,ref:s,style:{...t.style,animationDuration:f.current?"0s":void 0},children:y&&o})})});zJe.displayName=FJe;function BJe(t,s){return`${t}-trigger-${s}`}function $Je(t,s){return`${t}-content-${s}`}var iBt=IJe,qJe=DJe,UJe=RJe,VJe=zJe;const Aa=iBt,ja=C.forwardRef(({className:t,...s},r)=>e.jsx(qJe,{ref:r,className:At("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));ja.displayName=qJe.displayName;const js=C.forwardRef(({className:t,...s},r)=>e.jsx(UJe,{ref:r,className:At("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}));js.displayName=UJe.displayName;const $s=C.forwardRef(({className:t,...s},r)=>e.jsx(VJe,{ref:r,className:At("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));$s.displayName=VJe.displayName;const oBt={first_timer:Kn,regular:e1,dedicated:fc,veteran:mo,streak_master:Fh,century:mo},lBt={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 PLe(t){return t===1?e.jsx(mo,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(e1,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(fc,{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 HJe({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=Ws(),{data:o,isLoading:l}=SYe(s?5:10,r),{data:i}=CYe(a==null?void 0:a.id),{data:c}=TYe(a==null?void 0:a.id),{data:u}=MYe(a==null?void 0:a.id);return l?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(mo,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((p,f)=>e.jsx(xs,{className:"h-12 w-full"},f))})})]}):e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(mo,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsxs(Oe,{children:[t&&i&&e.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-primary/5 border border-primary/10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Your Stats"}),c&&e.jsxs(nt,{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(Fh,{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=oBt[p.badge_type]||Kn;return e.jsxs(nt,{variant:"outline",className:`text-xs ${lBt[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(nt,{variant:"outline",className:"text-xs",children:["+",u.length-4," more"]})]})]}),e.jsxs(Aa,{defaultValue:"points",className:"w-full",children:[e.jsxs(ja,{className:"w-full mb-3",children:[e.jsx(js,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(js,{value:"events",className:"flex-1",children:"By Events"})]}),e.jsx($s,{value:"points",className:"mt-0",children:e.jsxs("div",{className:"space-y-2",children:[o==null?void 0:o.map((p,f)=>{var y,_,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:PLe(f+1)}),e.jsx(yn,{className:"h-8 w-8",children:e.jsx(vn,{className:"text-xs",children:((_=(y=p.profile)==null?void 0:y.name)==null?void 0:_.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((b=p.profile)==null?void 0:b.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_events_attended," events"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold text-primary",children:p.total_points}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"pts"})]})]},p.user_id)}),(!o||o.length===0)&&e.jsx("div",{className:"text-center text-muted-foreground py-4 text-sm",children:"No attendance data yet. Attend an event to get on the leaderboard!"})]})}),e.jsx($s,{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 y,_,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:PLe(f+1)}),e.jsx(yn,{className:"h-8 w-8",children:e.jsx(vn,{className:"text-xs",children:((_=(y=p.profile)==null?void 0:y.name)==null?void 0:_.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium text-sm truncate",children:[((b=p.profile)==null?void 0:b.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_points," points"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"font-bold",children:p.total_events_attended}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"events"})]})]},p.user_id)})})})]})]})]})}function cBt(){const t=Pr(),{user:s,isAdmin:r}=Ws(),n=ss(),{data:a,isLoading:o}=wt({queryKey:["public-events"],queryFn:async()=>{const{data:w,error:j}=await G.from("events").select("*").order("event_date",{ascending:!0});if(j)throw j;return w}}),{data:l}=wt({queryKey:["my-registrations"],queryFn:async()=>{if(!s)return[];const{data:w,error:j}=await G.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",s.id);if(j)throw j;return w},enabled:!!s}),{data:i}=wt({queryKey:["event-registration-counts"],queryFn:async()=>{let w=[],j=0;const N=1e3;for(;;){const{data:T,error:I}=await G.from("event_registrations").select("event_id").range(j,j+N-1);if(I)throw I;if(!T||T.length===0||(w=w.concat(T),T.length{S[T.event_id]=(S[T.event_id]||0)+1}),S}}),c=Dt({mutationFn:async w=>{await G.auth.refreshSession();const{data:j,error:N}=await G.functions.invoke("zoom-register",{body:{event_id:w}});if(N)throw N;if(j!=null&&j.error)throw new Error(j.error);return j},onSuccess:w=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),w!=null&&w.join_url?me.success("Successfully registered! You'll receive a Zoom confirmation email."):me.success("Successfully registered for the event!")},onError:w=>{me.error("Failed to register: "+w.message)}}),u=Dt({mutationFn:async w=>{const{data:j,error:N}=await G.functions.invoke("zoom-unregister",{body:{event_id:w}});if(N)throw N;if(j!=null&&j.error)throw new Error(j.error);return j},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),me.success("Registration cancelled and removed from Zoom")},onError:w=>{me.error("Failed to cancel: "+w.message)}}),p=w=>l==null?void 0:l.some(j=>j.event_id===w),f=w=>{const j=l==null?void 0:l.find(N=>N.event_id===w);return j==null?void 0:j.zoom_join_url},y=w=>w.capacity?((i==null?void 0:i[w.id])||0)>=w.capacity:!1,_=(a==null?void 0:a.filter(w=>IM(w.event_date)!=="ended"))||[],b=(a==null?void 0:a.filter(w=>IM(w.event_date)==="ended"))||[];return e.jsx(Es,{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(rBt,{}),r&&e.jsx(K,{variant:"outline",onClick:()=>t("/admin/events"),children:"Manage Events"})]})]}),e.jsxs("div",{className:`grid grid-cols-1 ${r?"lg:grid-cols-3":""} gap-6`,children:[e.jsxs("div",{className:r?"lg:col-span-2":"",children:[o?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading events..."}):_.length===0?e.jsx(Ee,{className:"text-center py-12",children:e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground",children:"No upcoming events at the moment. Check back soon!"})})}):e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:_.map(w=>{const j=IM(w.event_date),N=ake(w.event_date),S=j==="live",T=j==="starting_soon";return e.jsxs(Ee,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${S?"border-red-500 ring-2 ring-red-500/20":T?"border-amber-500 ring-2 ring-amber-500/20":"hover:border-primary/50"}`,onClick:()=>t(`/events/${w.id}`),children:[N&&e.jsxs("div",{className:`${S?"bg-red-500":"bg-amber-500"} text-white px-3 py-1.5 flex items-center gap-2 text-sm font-medium`,children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-white opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-white"})]}),S?e.jsxs(e.Fragment,{children:[e.jsx(n1,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):e.jsxs(e.Fragment,{children:[e.jsx(Tn,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),w.image_url&&e.jsx(sBt,{ratio:3/2,className:"overflow-hidden",children:e.jsx("img",{src:w.image_url,alt:w.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),e.jsxs(It,{children:[e.jsx(Ot,{className:"line-clamp-2",children:w.title}),w.description&&e.jsx(fr,{className:"line-clamp-2",children:w.description.replace(/<[^>]*>/g,"")})]}),e.jsxs(Oe,{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(on,{className:"h-4 w-4"}),new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(w.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Tn,{className:"h-4 w-4"}),B8(new Date(w.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(mr,{className:"h-4 w-4"}),(i==null?void 0:i[w.id])||0," registered",w.capacity&&` / ${w.capacity} spots`]})]}),e.jsx(jL,{className:"flex gap-2",onClick:I=>I.stopPropagation(),children:p(w.id)?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>u.mutate(w.id),disabled:u.isPending,children:[e.jsx(Ur,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(K,{className:"flex-1",onClick:()=>window.open(f(w.id)||w.zoom_link,"_blank"),children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(K,{className:"w-full",onClick:()=>c.mutate(w.id),disabled:c.isPending||y(w),children:y(w)?"Event Full":e.jsxs(e.Fragment,{children:[e.jsx(ma,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},w.id)})}),b.length>0&&e.jsxs("div",{className:"mt-12",children:[e.jsx("h3",{className:"text-xl font-semibold mb-4 text-muted-foreground",children:"Past Events"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:b.map(w=>e.jsx(Ee,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${w.id}`),children:e.jsxs(It,{children:[e.jsx(Ot,{className:"text-base line-clamp-1",children:w.title}),e.jsx(fr,{children:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(w.event_date))})]})},w.id))})]})]}),r&&e.jsx("div",{className:"lg:col-span-1",children:e.jsx(HJe,{showUserStats:!0})})]})]})})}const pxe=[{value:"all",label:"All Roles",icon:mr},{value:"newest",label:"Newest Members",icon:Tn},{value:"brokerage_manager",label:"Brokerage Managers",icon:gL},{value:"admin",label:"Admins",icon:Bh}];function dBt({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var qe,ct;const{user:o,isAdmin:l,isBrokerageManager:i}=Ws(),[c,u]=C.useState([]),[p,f]=C.useState([]),[y,_]=C.useState([]),[b,w]=C.useState([]),[j,N]=C.useState(""),[S,T]=C.useState(""),[I,L]=C.useState(""),[R,$]=C.useState(!1),[q,U]=C.useState(!1),[V,X]=C.useState("agents"),[se,ee]=C.useState("all"),[Q,de]=C.useState({}),re=l||i;C.useEffect(()=>{t&&o&&(l?ne():le())},[t,o,l]),C.useEffect(()=>{t||(_([]),w([]),N(""),T(""),L(""),X("agents"),ee("all"))},[t]);const ne=async()=>{if(o){$(!0);try{const{data:De,error:Rt}=await G.from("brokerages").select("id, name").order("name");if(Rt)throw Rt;const pe=1e3,Je={};let lt=0,rt=!0;for(;rt;){const{data:$e,error:ot}=await G.from("profiles").select("brokerage_id").range(lt*pe,(lt+1)*pe-1);if(ot)throw ot;$e==null||$e.forEach(Ue=>{Ue.brokerage_id&&(Je[Ue.brokerage_id]=(Je[Ue.brokerage_id]||0)+1)}),rt=($e==null?void 0:$e.length)===pe,lt++}f((De==null?void 0:De.map($e=>({...$e,agent_count:Je[$e.id]||0})))||[]);const Se=[];for(lt=0,rt=!0;rt;){const{data:$e,error:ot}=await G.from("profiles").select("id, name, email, brokerage_id, created_at, brokerages(name)").neq("id",o.id).order("name").range(lt*pe,(lt+1)*pe-1);if(ot)throw ot;$e&&Se.push(...$e),rt=($e==null?void 0:$e.length)===pe,lt++}const it={};for(lt=0,rt=!0;rt;){const{data:$e,error:ot}=await G.from("user_roles").select("user_id, role").range(lt*pe,(lt+1)*pe-1);if(ot)throw ot;$e==null||$e.forEach(Ue=>{it[Ue.user_id]||(it[Ue.user_id]=[]),it[Ue.user_id].push(Ue.role)}),rt=($e==null?void 0:$e.length)===pe,lt++}de(it),u(Se.map($e=>{var ot;return{id:$e.id,name:$e.name,email:$e.email,brokerage_name:((ot=$e.brokerages)==null?void 0:ot.name)||"No Brokerage",roles:it[$e.id]||[],created_at:$e.created_at}}))}catch(De){console.error("Error loading data:",De),me.error("Failed to load agents and brokerages")}finally{$(!1)}}},le=async()=>{if(o){$(!0);try{const{data:De}=await G.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(De!=null&&De.brokerage_id)){me.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:Rt,error:pe}=await G.from("profiles").select("id, name, email").eq("brokerage_id",De.brokerage_id).neq("id",o.id).order("name");if(pe)throw pe;u(Rt||[])}catch(De){console.error("Error loading agents:",De),me.error("Failed to load agents")}finally{$(!1)}}},he=c.filter(De=>{var pe;const Rt=De.name.toLowerCase().includes(j.toLowerCase())||De.email.toLowerCase().includes(j.toLowerCase())||((pe=De.brokerage_name)==null?void 0:pe.toLowerCase().includes(j.toLowerCase()));if(l&&se!=="all"&&se!=="newest"){const Je=Q[De.id]||[];return Rt&&Je.includes(se)}return Rt}).sort((De,Rt)=>se==="newest"?(Rt.created_at||"").localeCompare(De.created_at||""):0),we=p.filter(De=>De.name.toLowerCase().includes(S.toLowerCase())),ye=()=>{y.length===he.length?_([]):_(he.map(De=>De.id))},je=()=>{b.length===we.length?w([]):w(we.map(De=>De.id))},ke=De=>{if(!re){_([De]);return}_(Rt=>Rt.includes(De)?Rt.filter(pe=>pe!==De):[...Rt,De])},We=De=>{w(Rt=>Rt.includes(De)?Rt.filter(pe=>pe!==De):[...Rt,De])},be=async()=>{if(!(y.length>0||b.length>0)){me.error("Please select at least one agent or brokerage to share with");return}U(!0);try{const{data:Rt,error:pe}=await G.functions.invoke("send-share-notification",{body:{recipientIds:y,brokerageIds:b,resourceType:r,resourceId:n,resourceTitle:a,message:I.trim()||void 0}});if(pe)throw pe;const Je=(Rt==null?void 0:Rt.sharesCreated)||y.length;me.success(`Shared with ${Je} agent${Je!==1?"s":""}`),s(!1)}catch(Rt){console.error("Error sharing resource:",Rt),me.error("Failed to share resource")}finally{U(!1)}},Me=De=>De.split(" ").map(Rt=>Rt[0]).join("").toUpperCase().slice(0,2),Ae=De=>{const Rt=Q[De]||[];return Rt.includes("admin")?e.jsx(nt,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):Rt.includes("brokerage_manager")?e.jsx(nt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},Re=y.length+b.length,Te=se!=="all"&&se!=="newest"?he.length:null;return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{className:"flex-shrink-0",children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(oa,{className:"h-5 w-5 text-primary"}),"Share Resource"]}),e.jsxs(Zr,{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(Aa,{value:V,onValueChange:X,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(ja,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[e.jsxs(js,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),y.length>0&&e.jsx(nt,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:y.length})]}),e.jsxs(js,{value:"brokerages",className:"flex items-center gap-2",children:[e.jsx(La,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),b.length>0&&e.jsx(nt,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:b.length})]})]}),e.jsxs($s,{value:"agents",className:"flex-1 flex flex-col space-y-3 mt-3 overflow-hidden",children:[e.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name, email, or brokerage...",value:j,onChange:De=>N(De.target.value),className:"pl-9"})]}),e.jsxs(rr,{value:se,onValueChange:ee,children:[e.jsxs(tr,{className:"w-[180px]",children:[e.jsx(a0,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(nr,{placeholder:"Filter by role"})]}),e.jsx(sr,{children:pxe.map(De=>e.jsx(Tt,{value:De.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De.icon,{className:"h-4 w-4"}),e.jsx("span",{children:De.label})]})},De.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:ye,className:"text-xs h-8",disabled:he.length===0,children:[e.jsx(mr,{className:"h-3.5 w-3.5 mr-1.5"}),y.length===he.length&&he.length>0?"Deselect All":"Select All"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[Te!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[Te," ",(qe=pxe.find(De=>De.value===se))==null?void 0:qe.label]}),e.jsxs("span",{className:"font-medium",children:[y.length," selected"]})]})]}),e.jsx(Vi,{className:"h-[300px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):he.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(mr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:se!=="all"?`No ${(ct=pxe.find(De=>De.value===se))==null?void 0:ct.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:he.map(De=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${y.includes(De.id)?"bg-accent":""}`,onClick:()=>ke(De.id),children:[e.jsx(Yo,{checked:y.includes(De.id),onCheckedChange:()=>ke(De.id),className:"flex-shrink-0"}),e.jsx(yn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(vn,{className:"text-xs bg-primary/10 text-primary",children:Me(De.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:De.name}),Ae(De.id)]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[De.email,De.brokerage_name&&e.jsxs("span",{className:"ml-1 opacity-75",children:["• ",De.brokerage_name]})]})]})]},De.id))})})]}),e.jsxs($s,{value:"brokerages",className:"flex-1 flex flex-col space-y-3 mt-3 overflow-hidden",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search brokerages...",value:S,onChange:De=>T(De.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:je,className:"text-xs h-8",disabled:we.length===0,children:[e.jsx(La,{className:"h-3.5 w-3.5 mr-1.5"}),b.length===we.length&&we.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[b.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground px-1 flex-shrink-0",children:"Selecting a brokerage will send to all agents in that brokerage."}),e.jsx(Vi,{className:"h-[250px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):we.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[180px] text-muted-foreground",children:[e.jsx(La,{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:we.map(De=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${b.includes(De.id)?"bg-accent":""}`,onClick:()=>We(De.id),children:[e.jsx(Yo,{checked:b.includes(De.id),onCheckedChange:()=>We(De.id),className:"flex-shrink-0"}),e.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(La,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:De.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[De.agent_count," agent",De.agent_count!==1?"s":""]})]})]},De.id))})})]})]}):e.jsxs("div",{className:"flex-1 flex flex-col space-y-3 overflow-hidden",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search agents...",value:j,onChange:De=>N(De.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:ye,className:"text-xs h-8",disabled:he.length===0,children:[e.jsx(mr,{className:"h-3.5 w-3.5 mr-1.5"}),y.length===he.length&&he.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[y.length," selected"]})]}),e.jsx(Vi,{className:"h-[300px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):he.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(mr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:he.map(De=>e.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${y.includes(De.id)?"bg-accent":""}`,onClick:()=>ke(De.id),children:[e.jsx(Yo,{checked:y.includes(De.id),onCheckedChange:()=>ke(De.id),className:"flex-shrink-0"}),e.jsx(yn,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(vn,{className:"text-xs bg-primary/10 text-primary",children:Me(De.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:De.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:De.email})]})]},De.id))})})]}),e.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[e.jsx(_e,{htmlFor:"message",className:"text-sm font-medium",children:"Add a message (optional)"}),e.jsx(Ar,{id:"message",placeholder:"I thought you might find this useful...",value:I,onChange:De=>L(De.target.value),rows:2,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2 flex-shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:be,disabled:Re===0||q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oa,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function qA({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=C.useState(!1),{user:c}=Ws();return c?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[e.jsx(Ad,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsx(dBt,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function uBt(){const{eventId:t}=Po(),s=Pr(),{user:r}=Ws(),[n,a]=C.useState(null),[o,l]=C.useState(null),[i,c]=C.useState(0),[u,p]=C.useState(!0),[f,y]=C.useState(!1);C.useEffect(()=>{t&&_()},[t,r]);const _=async()=>{try{const{data:T,error:I}=await G.from("events").select("*").eq("id",t).single();if(I)throw I;a(T);const{count:L}=await G.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",t);if(c(L||0),r){const{data:R}=await G.from("event_registrations").select("id, zoom_join_url").eq("event_id",t).eq("user_id",r.id).maybeSingle();l(R)}}catch(T){console.error("Error loading event:",T),me.error("Failed to load event"),s("/events")}finally{p(!1)}},b=async()=>{if(!(!r||!n)){y(!0);try{const{error:T}=await G.auth.refreshSession();if(T){console.error("Session refresh failed:",T),me.error("Your session has expired. Please log in again.");return}if(o){const{error:I}=await G.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(I)throw I;me.success("Successfully cancelled registration"),l(null),c(L=>L-1)}else{const{data:I,error:L}=await G.functions.invoke("zoom-register",{body:{event_id:n.id}});if(L)throw L;me.success("Successfully registered for event!"),l({id:I.registration_id,zoom_join_url:I.zoom_join_url}),c(R=>R+1)}}catch(T){console.error("Registration error:",T),me.error(o?"Failed to cancel registration":"Failed to register for event")}finally{y(!1)}}},w=T=>{var I,L,R;if(T.includes("iframe.mediadelivery.net")||T.includes("video.bunnycdn.com")){const $=T.match(/embed\/(\d+)\/([a-f0-9-]+)/);if($)return`https://iframe.mediadelivery.net/embed/${$[1]}/${$[2]}?autoplay=false&preload=true`}if(T.includes("youtube.com")||T.includes("youtu.be")){const $=T.includes("youtu.be")?(I=T.split("youtu.be/")[1])==null?void 0:I.split("?")[0]:(L=T.split("v=")[1])==null?void 0:L.split("&")[0];if($)return`https://www.youtube.com/embed/${$}`}if(T.includes("vimeo.com")){const $=(R=T.split("vimeo.com/")[1])==null?void 0:R.split("?")[0];if($)return`https://player.vimeo.com/video/${$}`}return T};if(u)return e.jsx(Es,{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(Es,{title:"Event Not Found",children:e.jsxs("div",{className:"text-center py-16",children:[e.jsx("p",{className:"text-muted-foreground",children:"Event not found"}),e.jsx(K,{onClick:()=>s("/events"),className:"mt-4",children:"Back to Events"})]})});const j=u0(new Date(n.event_date)),N=n.capacity&&i>=n.capacity,S=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return e.jsx(Es,{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(di,{className:"h-4 w-4"}),"Back to Events"]}),n.image_url&&e.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden mb-6",children:[e.jsx("img",{src:n.image_url,alt:n.title,className:"w-full h-full object-cover"}),j&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(nt,{variant:"secondary",className:"text-lg px-4 py-2",children:"Event Ended"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:n.title}),e.jsx(qA,{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(ap,{className:"h-5 w-5"}),"Event Preview"]}),e.jsx("div",{className:"relative w-full aspect-video rounded-xl overflow-hidden border bg-muted",children:e.jsx("iframe",{src:w(n.video_url),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"Event Preview Video"})})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(on,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:new Intl.DateTimeFormat("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(n.event_date))}),e.jsx("p",{className:"text-sm text-muted-foreground",children:B8(new Date(n.event_date))})]})]}),n.capacity&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(mr,{className:"h-5 w-5 text-primary mt-0.5"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[i," / ",n.capacity]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Registered"})]})]}),o&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-500/10 rounded-lg",children:[e.jsx(vi,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-700",children:"You're registered!"})]}),e.jsxs("div",{className:"space-y-2 pt-2",children:[!j&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"w-full gap-2",onClick:()=>window.open(S,"_blank"),children:[e.jsx(rn,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:b,disabled:f,children:[f?e.jsx(Ss,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(K,{className:"w-full gap-2",onClick:b,disabled:f||(N??!1),children:f?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):N?"Event Full":"Register Now"})}),j&&o&&e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(rn,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const hBt=[{id:"quickvid",name:"QuickVid",description:"Record, manage, and share personalized video messages",icon:e.jsx(Nn,{className:"h-6 w-6"}),path:"/mission-control/video-library",category:"Marketing"},{id:"smart-card",name:"Smart Card",description:"Your digital business card — share your info with a single link",icon:e.jsx(yg,{className:"h-6 w-6"}),path:"/mission-control/my-card",category:"Marketing"},{id:"smart-presentations",name:"Smart Presentations",description:"Create beautiful listing and buyer presentations",icon:e.jsx(Gx,{className:"h-6 w-6"}),path:"/mission-control/presentations",category:"Marketing"},{id:"landing-pages",name:"Landing Pages",description:"Build custom landing pages to capture leads",icon:e.jsx(In,{className:"h-6 w-6"}),path:"/mission-control/landing-pages",category:"Marketing"},{id:"guest-book",name:"Guest Book",description:"Digital open house sign-in to capture visitor info",icon:e.jsx(gh,{className:"h-6 w-6"}),path:"/mission-control/guest-book",category:"Open House"},{id:"card-studio",name:"Card Studio",description:"Send beautiful animated digital cards for birthdays, anniversaries & milestones",icon:e.jsx(hn,{className:"h-6 w-6"}),path:"/mission-control/card-studio",category:"Marketing"},{id:"direct-mail",name:"Direct Mail",description:"Send professional postcards to your contacts via direct mail",icon:e.jsx(br,{className:"h-6 w-6"}),path:"/mission-control/direct-mail",category:"Marketing",adminOnly:!0,beta:!0},{id:"mass-emails",name:"Mass Emails",description:"Create and send bulk email campaigns to your contacts",icon:e.jsx(oa,{className:"h-6 w-6"}),path:"/admin/email-campaigns",category:"Marketing",beta:!0}],mBt=()=>{const{user:t,isAdmin:s}=Ws(),r=Pr(),[n,a]=C.useState([]),[o,l]=C.useState(!0),[i,c]=C.useState(""),[u,p]=C.useState("all"),[f,y]=C.useState(new Set);C.useEffect(()=>{_()},[t]);const _=async()=>{try{const{data:R}=await G.from("user_tags").select("tag").eq("user_id",t==null?void 0:t.id),$=(R==null?void 0:R.map(Q=>Q.tag))||[],{data:q,error:U}=await G.from("app_tiles").select("*").order("name");if(U)throw U;const{data:V}=await G.from("user_favorites").select("app_id").eq("user_id",t==null?void 0:t.id),X=new Set((V==null?void 0:V.map(Q=>Q.app_id))||[]);y(X);const ee=((q==null?void 0:q.filter(Q=>!Q.required_tags||Q.required_tags.length===0?!0:Q.required_tags.some(de=>$.includes(de))))||[]).sort((Q,de)=>Q.name==="LevelUp Members Portal"?-1:de.name==="LevelUp Members Portal"?1:0);a(ee)}catch(R){console.error("Error loading apps:",R),me.error("Failed to load apps")}finally{l(!1)}},b=async R=>{var q;const $=window.open("about:blank","_blank");try{const{data:U,error:V}=await G.auth.getSession();if(V||!U.session){$==null||$.close(),me.error("Session expired. Please refresh the page and try again.");return}const X=U.session.access_token;await G.from("activity_logs").insert({user_id:t==null?void 0:t.id,app_id:R.app_id,app_name:R.name,user_agent:navigator.userAgent});const{data:se,error:ee}=await G.functions.invoke("sso-launch",{body:{app_id:R.app_id},headers:{Authorization:`Bearer ${X}`}});if(ee)throw ee;se!=null&&se.redirect_url?$&&!$.closed?($.location.href=se.redirect_url,(q=$.focus)==null||q.call($)):window.location.assign(se.redirect_url):($==null||$.close(),me.error("Launch link unavailable"))}catch(U){$==null||$.close(),console.error("Error launching app:",U),me.error("Failed to launch app. Please try again.")}},w=async(R,$)=>{R.stopPropagation();const q=f.has($);try{if(q){const{error:U}=await G.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",$);if(U)throw U;y(V=>{const X=new Set(V);return X.delete($),X}),me.success("Removed from favorites")}else{const{error:U}=await G.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:$});if(U)throw U;y(V=>new Set(V).add($)),me.success("Added to favorites")}}catch(U){console.error("Error toggling favorite:",U),me.error("Failed to update favorites")}},j=n.filter(R=>{var q;const $=R.name.toLowerCase().includes(i.toLowerCase())||((q=R.description)==null?void 0:q.toLowerCase().includes(i.toLowerCase()));return u==="favorites"?$&&f.has(R.id):$}),N=hBt.filter(R=>R.adminOnly&&!s?!1:R.name.toLowerCase().includes(i.toLowerCase())||R.description.toLowerCase().includes(i.toLowerCase())),S=N.reduce((R,$)=>(R[$.category]||(R[$.category]=[]),R[$.category].push($),R),{}),T=[{id:"all",label:"All"},{id:"tools",label:"Built-in Tools"},{id:"apps",label:"Connected Apps"},{id:"favorites",label:"Favorites"}];if(o)return e.jsx(Es,{title:"Apps & Tools",children:e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading apps & tools..."})]})})});const I=u==="all"||u==="tools",L=u==="all"||u==="apps"||u==="favorites";return e.jsxs(Es,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search apps & tools...",className:"pl-10 bg-muted/50 border-0 focus-visible:ring-1",value:i,onChange:R=>c(R.target.value)})]})]}),e.jsx("div",{className:"flex gap-6 border-b border-border mb-8",children:T.map(R=>e.jsxs("button",{onClick:()=>p(R.id),className:At("pb-3 text-sm font-medium transition-colors relative",u===R.id?"text-primary":"text-muted-foreground hover:text-foreground"),children:[R.label,u===R.id&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]},R.id))}),I&&Object.keys(S).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(Kx,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Built-in Tools"})]}),Object.entries(S).map(([R,$])=>e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground bg-muted px-2.5 py-1 rounded-full",children:R})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:$.map(q=>e.jsxs("div",{onClick:()=>r(q.path),className:"group flex items-start gap-4 p-5 bg-card rounded-xl border border-border transition-all duration-200 hover:shadow-lg hover:border-primary/30 cursor-pointer",children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 text-primary flex items-center justify-center",children:q.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate flex items-center gap-2",children:[q.name,q.beta&&e.jsx("span",{className:"text-[10px] font-medium bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"Beta"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:q.description})]})]},q.id))})]},R))]}),L&&e.jsxs("div",{children:[u==="all"&&j.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(rn,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Connected Apps"})]}),j.length===0&&u!=="all"?e.jsx("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:u==="favorites"?e.jsxs(e.Fragment,{children:[e.jsx(Ux,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No favorites yet"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:"Click the bookmark icon on any app to add it to your favorites"})]}):e.jsxs(e.Fragment,{children:[e.jsx(vh,{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:j.map(R=>{const $=f.has(R.id),q=R.name.toLowerCase().includes("agent review")||R.app_id==="agent_review";return e.jsxs("div",{className:"group flex flex-col p-5 bg-card rounded-xl border border-border transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[e.jsxs("div",{className:"flex items-start gap-4 cursor-pointer",onClick:()=>b(R),children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-3xl",children:R.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:R.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:R.description})]}),e.jsx("button",{className:At("flex-shrink-0 p-1 transition-colors",$?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:U=>w(U,R.id),children:e.jsx(Ux,{className:At("h-5 w-5",$&&"fill-current")})})]}),q&&e.jsx("a",{href:"https://forms.gle/vXnrzgSnPbw7CKPV6",target:"_blank",rel:"noopener noreferrer",onClick:U=>U.stopPropagation(),className:"mt-3 text-sm text-primary hover:underline flex items-center gap-1",children:"Create your account with this link →"})]},R.id)})})]}),I&&L&&j.length===0&&N.length===0&&i&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:[e.jsx(xn,{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"})]})]})},pBt=()=>{const t=Pr(),[s,r]=C.useState(""),[n,a]=C.useState("all"),[o,l]=C.useState("all"),[i,c]=C.useState("grid"),{data:u=[]}=wt({queryKey:["template-categories"],queryFn:async()=>{const{data:N,error:S}=await G.from("template_categories").select("*").order("name");if(S)throw S;return N}}),{data:p=[]}=wt({queryKey:["template-types"],queryFn:async()=>{const{data:N,error:S}=await G.from("template_types").select("*").order("name");if(S)throw S;return N}}),{data:f=[],isLoading:y}=wt({queryKey:["canva-templates"],queryFn:async()=>{const{data:N,error:S}=await G.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:T,error:I}=await G.from("template_links").select("*").order("sort_order");if(I)throw I;const{data:L}=await G.from("template_likes").select("template_id"),{data:R}=await G.from("template_comments").select("template_id"),$=new Map;L==null||L.forEach(V=>{$.set(V.template_id,($.get(V.template_id)||0)+1)});const q=new Map;return R==null||R.forEach(V=>{q.set(V.template_id,(q.get(V.template_id)||0)+1)}),(N||[]).map(V=>({...V,links:(T||[]).filter(X=>X.template_id===V.id)||[],likesCount:$.get(V.id)||0,commentsCount:q.get(V.id)||0}))}}),_=f.filter(N=>{var L;const S=N.name.toLowerCase().includes(s.toLowerCase())||((L=N.description)==null?void 0:L.toLowerCase().includes(s.toLowerCase())),T=n==="all"||N.category_id===n,I=o==="all"||N.type_id===o;return S&&T&&I}),b=()=>{r(""),a("all"),l("all")},w=s||n!=="all"||o!=="all",j=N=>{t(`/templates/${N}`)};return e.jsx(Es,{title:"Canva Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-bold text-foreground text-5xl",children:"Canva Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Browse and use our collection of professionally designed templates"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search templates...",value:s,onChange:N=>r(N.target.value),className:"pl-9"})]}),e.jsxs(rr,{value:n,onValueChange:a,children:[e.jsx(tr,{className:"w-full sm:w-48",children:e.jsx(nr,{placeholder:"All Categories"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Categories"}),u.map(N=>e.jsx(Tt,{value:N.id,children:N.name},N.id))]})]}),e.jsxs(rr,{value:o,onValueChange:l,children:[e.jsx(tr,{className:"w-full sm:w-48",children:e.jsx(nr,{placeholder:"All Types"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Types"}),p.map(N=>e.jsx(Tt,{value:N.id,children:N.name},N.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[w&&e.jsx(K,{variant:"outline",size:"sm",onClick:b,children:"Clear Filters"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:i==="grid"?"secondary":"outline",size:"icon",onClick:()=>c("grid"),className:"rounded-full",children:e.jsx(lf,{className:"h-4 w-4"})}),e.jsx(K,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>c("list"),className:"rounded-full",children:e.jsx(Mm,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[_.length," template",_.length!==1?"s":""," found"]}),y&&e.jsx("div",{className:i==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(8)].map((N,S)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(xs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(xs,{className:"h-5 w-3/4 mb-2"}),e.jsx(xs,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(xs,{className:"h-5 w-16"}),e.jsx(xs,{className:"h-5 w-20"})]})]})},S))}),!y&&_.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:w?"No templates match your filters":"No templates available yet"}),w&&e.jsx(K,{variant:"outline",onClick:b,children:"Clear Filters"})]}),!y&&_.length>0&&e.jsx("div",{className:i==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:_.map(N=>e.jsxs(Ee,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>j(N.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[N.preview_image_url?e.jsx("img",{src:N.preview_image_url,alt:N.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),N.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(nt,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(Vo,{className:"h-3 w-3"}),N.links.length]})})]}),e.jsxs(Oe,{className:`p-4 flex flex-col ${i==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:N.name}),N.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:mde(N.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[N.category&&e.jsx(nt,{variant:"secondary",className:"text-xs",children:N.category.name}),N.type&&e.jsx(nt,{variant:"outline",className:"text-xs",children:N.type.name})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gu,{className:"h-3.5 w-3.5"}),N.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ec,{className:"h-3.5 w-3.5"}),N.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:S=>{S.stopPropagation(),j(N.id)},children:[e.jsx(rn,{className:"h-4 w-4"}),"View Template"]})]})]},N.id))})]})})};var fBt="Separator",ILe="horizontal",gBt=["horizontal","vertical"],WJe=C.forwardRef((t,s)=>{const{decorative:r,orientation:n=ILe,...a}=t,o=xBt(n)?n:ILe,i=r?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return e.jsx(Jr.div,{"data-orientation":o,...i,...a,ref:s})});WJe.displayName=fBt;function xBt(t){return gBt.includes(t)}var GJe=WJe;const Zl=C.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(GJe,{ref:a,decorative:r,orientation:s,className:At("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));Zl.displayName=GJe.displayName;const SO=()=>({trackEngagement:C.useCallback(async(s,r,n,a="view")=>{try{const{data:{user:o}}=await G.auth.getUser();if(!o)return;await G.from("content_engagement_logs").insert({user_id:o.id,resource_type:s,resource_id:r,resource_title:n,action_type:a})}catch(o){console.error("Error tracking engagement:",o)}},[])}),yBt=()=>{const{templateId:t}=Po(),s=Pr(),{user:r,isAdmin:n}=Ws(),{toast:a}=Ra(),o=ss(),{trackEngagement:l}=SO(),[i,c]=C.useState(""),{data:u,isLoading:p}=wt({queryKey:["template-detail",t],queryFn:async()=>{const{data:I,error:L}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("id",t).single();if(L)throw L;const{data:R}=await G.from("template_links").select("*").eq("template_id",t).order("sort_order"),{data:$}=await G.from("template_guides").select("*").eq("template_id",t).order("sort_order");return{...I,links:R||[],guides:$||[]}},enabled:!!t}),{data:f=[]}=wt({queryKey:["template-linked-toolkits",t],queryFn:async()=>{const{data:I,error:L}=await G.from("resource_kit_templates").select("kit_id, resource_kits:kit_id(id, name, featured_image_url)").eq("template_id",t);if(L)throw L;return(I||[]).map(R=>R.resource_kits).filter(Boolean)},enabled:!!t});C.useEffect(()=>{u&&l("template",u.id,u.name,"view")},[u==null?void 0:u.id]);const{data:y=[]}=wt({queryKey:["template-likes",t],queryFn:async()=>{const{data:I,error:L}=await G.from("template_likes").select("*").eq("template_id",t);if(L)throw L;return I},enabled:!!t}),{data:_=[]}=wt({queryKey:["template-comments",t],queryFn:async()=>{const{data:I,error:L}=await G.from("template_comments").select("*").eq("template_id",t).order("created_at",{ascending:!1});if(L)throw L;const R=[...new Set(I.map(U=>U.user_id))],{data:$}=await G.from("profiles").select("id, name").in("id",R),q=new Map(($==null?void 0:$.map(U=>[U.id,U.name]))||[]);return I.map(U=>({...U,user_name:q.get(U.user_id)||"Unknown User"}))},enabled:!!t}),b=Dt({mutationFn:async I=>{const{error:L}=await G.from("template_comments").insert({template_id:t,user_id:r.id,content:I});if(L)throw L},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),c(""),a({title:"Comment added!"})},onError:I=>{a({title:"Error adding comment",description:I.message,variant:"destructive"})}}),w=Dt({mutationFn:async I=>{const{error:L}=await G.from("template_comments").delete().eq("id",I);if(L)throw L},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),a({title:"Comment deleted"})}}),j=Dt({mutationFn:async()=>{const I=y.find(L=>L.user_id===(r==null?void 0:r.id));if(I){const{error:L}=await G.from("template_likes").delete().eq("id",I.id);if(L)throw L}else{const{error:L}=await G.from("template_likes").insert({template_id:t,user_id:r.id});if(L)throw L}},onSuccess:()=>{o.invalidateQueries({queryKey:["template-likes",t]})}}),N=y.some(I=>I.user_id===(r==null?void 0:r.id)),S=I=>I.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),T=I=>{I.preventDefault(),!(!i.trim()||!r)&&b.mutate(i.trim())};return p?e.jsx(Es,{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(Es,{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(So,{to:"/templates",children:[e.jsx(di,{className:"h-4 w-4"}),"Back to Templates"]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:u.name}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[u.category&&e.jsx(nt,{variant:"secondary",children:u.category.name}),u.type&&e.jsx(nt,{variant:"outline",children:u.type.name})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(K,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:e.jsxs(So,{to:`/admin/templates?edit=${u.id}`,children:[e.jsx($a,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(qA,{resourceType:"template",resourceId:u.id,resourceTitle:u.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:N?"default":"outline",className:"gap-2 rounded-full",onClick:()=>j.mutate(),disabled:!r||j.isPending,children:[e.jsx(Gu,{className:`h-4 w-4 ${N?"fill-current":""}`}),y.length," ",y.length===1?"Like":"Likes"]})]})]}),u.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert [&>p]:mb-4 [&>p:last-child]:mb-0 whitespace-pre-line",dangerouslySetInnerHTML:{__html:u.description}})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Vo,{className:"h-4 w-4"}),u.links.length===1?"Template Link":"Template Links"]}),e.jsx("div",{className:"grid gap-2",children:u.links.map(I=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_canva"),window.open(I.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:I.title}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),u.video_url&&e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsx("div",{className:"aspect-video w-full rounded-lg overflow-hidden",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})}),u.guides&&u.guides.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(In,{className:"h-4 w-4"}),"Guide Files"]}),e.jsx("div",{className:"grid gap-2",children:u.guides.map(I=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{l("template",u.id,u.name,"click_pdf"),window.open(I.file_url,"_blank")},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:I.name}),I.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(I.file_size/1024).toFixed(0)," KB)"]})]}),e.jsx(ki,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),f.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(bl,{className:"h-4 w-4"}),"Related Toolkits"]}),e.jsx("div",{className:"grid gap-2",children:f.map(I=>e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-3 h-auto py-3",onClick:()=>s(`/toolbox/${I.id}`),children:[I.featured_image_url?e.jsx("img",{src:I.featured_image_url,alt:"",className:"w-10 h-10 rounded object-cover flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(bl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"font-medium",children:I.name})]},I.id))})]})}),e.jsx(Zl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Ec,{className:"h-5 w-5"}),"Comments (",_.length,")"]}),r?e.jsxs("form",{onSubmit:T,className:"flex gap-2",children:[e.jsx(Ar,{placeholder:"Add a comment...",value:i,onChange:I=>c(I.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!i.trim()||b.isPending,children:e.jsx(oa,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:_.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):_.map(I=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(yn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(vn,{className:"text-sm",children:S(I.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:I.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Yd(new Date(I.created_at),{addSuffix:!0})}),I.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>w.mutate(I.id),children:e.jsx(jr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:I.content})]})]})})},I.id))})]})]})}):e.jsx(Es,{title:"Templates",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Vo,{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(So,{to:"/templates",children:"Back to Templates"})})]})})},vBt=()=>{const{user:t}=Ws(),[s,r]=C.useState(""),[n,a]=C.useState("all"),{data:o=[]}=wt({queryKey:["academy-categories"],queryFn:async()=>{const{data:y,error:_}=await G.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(_)throw _;return y}}),{data:l=[],isLoading:i}=wt({queryKey:["academy-videos"],queryFn:async()=>{const{data:y,error:_}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("is_published",!0).order("publish_date",{ascending:!1});if(_)throw _;const{data:b,error:w}=await G.from("academy_resources").select("*").order("sort_order");if(w)throw w;return y.map(N=>({...N,resources:(b==null?void 0:b.filter(S=>S.video_id===N.id))||[]}))}}),{data:c=[]}=wt({queryKey:["academy-video-likes"],queryFn:async()=>{const{data:y,error:_}=await G.from("academy_video_likes").select("video_id, user_id");if(_)throw _;return y}}),u=l.filter(y=>{var w;const _=s===""||y.title.toLowerCase().includes(s.toLowerCase())||((w=y.description)==null?void 0:w.toLowerCase().includes(s.toLowerCase())),b=n==="all"||y.category_id===n;return _&&b}),p=y=>c.filter(_=>_.video_id===y).length,f=y=>c.some(_=>_.video_id===y&&_.user_id===(t==null?void 0:t.id));return e.jsx(Es,{title:"Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Academy"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"On-demand training videos and resources"})]}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-4",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search videos...",value:s,onChange:y=>r(y.target.value),className:"pl-10"})]})}),e.jsx(Aa,{value:n,onValueChange:a,children:e.jsxs(ja,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[e.jsx(js,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(y=>e.jsx(js,{value:y.id,className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:y.name},y.id))]})}),i?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):u.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Nn,{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(y=>e.jsx(So,{to:`/academy/${y.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:[y.thumbnail_url?e.jsx("img",{src:y.thumbnail_url,alt:y.title,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Nn,{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(wl,{className:"h-8 w-8 text-primary-foreground ml-1"})})}),y.duration&&e.jsxs("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-2 py-1 rounded flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),y.duration]})]}),e.jsxs(It,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(Ot,{className:"text-lg line-clamp-2",children:y.title})}),y.category&&e.jsx(nt,{variant:"secondary",className:"w-fit",children:y.category.name})]}),e.jsxs(Oe,{className:"pt-0",children:[y.description&&e.jsx(fr,{className:"line-clamp-2",children:y.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(Gu,{className:`h-4 w-4 ${f(y.id)?"fill-primary text-primary":""}`}),p(y.id)]}),y.resources&&y.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-4 w-4"}),y.resources.length]})]})]})]})},y.id))})]})})};function KJe({resourceType:t,resourceId:s}){const{data:r=[]}=wt({queryKey:["linked-templates",t,s],queryFn:async()=>{if(t==="academy_video"){const{data:n,error:a}=await G.from("academy_video_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("video_id",s);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}else{const{data:n,error:a}=await G.from("resource_kit_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("kit_id",s);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}},enabled:!!s});return r.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-sm",children:[e.jsx(Ql,{className:"h-4 w-4"}),"Related Templates"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(n=>e.jsx(So,{to:`/templates/${n.id}`,children:e.jsxs(nt,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 transition-colors gap-1.5 px-3 py-1.5 text-xs font-medium rounded-full",children:[e.jsx(Ql,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const _Bt=(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},bBt=()=>{const{videoId:t}=Po();Pr();const{user:s,isAdmin:r}=Ws(),{toast:n}=Ra(),a=ss(),{trackEngagement:o}=SO(),[l,i]=C.useState(""),{data:c,isLoading:u}=wt({queryKey:["academy-video",t],queryFn:async()=>{const{data:T,error:I}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:L}=await G.from("academy_resources").select("*").eq("video_id",t).order("sort_order");return{...T,resources:L||[]}},enabled:!!t});C.useEffect(()=>{c&&o("academy_video",c.id,c.title,"view")},[c==null?void 0:c.id]);const{data:p=[]}=wt({queryKey:["academy-video-likes",t],queryFn:async()=>{const{data:T,error:I}=await G.from("academy_video_likes").select("*").eq("video_id",t);if(I)throw I;return T},enabled:!!t}),{data:f=[]}=wt({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:T,error:I}=await G.from("academy_video_comments").select("*").eq("video_id",t).order("created_at",{ascending:!1});if(I)throw I;const L=[...new Set(T.map(q=>q.user_id))],{data:R}=await G.from("profiles").select("id, name").in("id",L),$=new Map((R==null?void 0:R.map(q=>[q.id,q.name]))||[]);return T.map(q=>({...q,user_name:$.get(q.user_id)||"Unknown User"}))},enabled:!!t}),y=Dt({mutationFn:async T=>{const{error:I}=await G.from("academy_video_comments").insert({video_id:t,user_id:s.id,content:T});if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),i(""),n({title:"Comment added!"})},onError:T=>{n({title:"Error adding comment",description:T.message,variant:"destructive"})}}),_=Dt({mutationFn:async T=>{const{error:I}=await G.from("academy_video_comments").delete().eq("id",T);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),n({title:"Comment deleted"})}}),b=Dt({mutationFn:async()=>{const T=p.find(I=>I.user_id===(s==null?void 0:s.id));if(T){const{error:I}=await G.from("academy_video_likes").delete().eq("id",T.id);if(I)throw I}else{const{error:I}=await G.from("academy_video_likes").insert({video_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",t]})}}),w=p.some(T=>T.user_id===(s==null?void 0:s.id)),j=T=>{switch(T==null?void 0:T.toLowerCase()){case"pdf":return"📄";case"pptx":case"ppt":return"📊";case"xlsx":case"xls":return"📈";case"docx":case"doc":return"📝";case"zip":return"📦";default:return"📁"}},N=T=>T.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),S=T=>{T.preventDefault(),!(!l.trim()||!s)&&y.mutate(l.trim())};return u?e.jsx(Es,{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(Es,{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(So,{to:"/academy",children:[e.jsx(di,{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:_Bt(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(Nn,{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(rn,{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(nt,{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(So,{to:`/admin/academy?edit=${c.id}`,children:[e.jsx($a,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(qA,{resourceType:"academy_video",resourceId:c.id,resourceTitle:c.title}),e.jsxs(K,{variant:w?"default":"outline",className:"gap-2 w-fit",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(Gu,{className:`h-4 w-4 ${w?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),c.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:c.description}})]}),c.resources&&c.resources.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(In,{className:"h-4 w-4"}),"Resources"]}),e.jsx("div",{className:"grid gap-2",children:c.resources.map(T=>e.jsxs("a",{href:T.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-muted transition-colors",children:[e.jsx("span",{className:"text-2xl",children:j(T.file_type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:T.title}),e.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:T.file_type})]}),e.jsx(ki,{className:"h-4 w-4 text-muted-foreground"})]},T.id))})]})}),e.jsx(KJe,{resourceType:"academy_video",resourceId:c.id}),e.jsx(Zl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Ec,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Ar,{placeholder:"Add a comment...",value:l,onChange:T=>i(T.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()||y.isPending,children:e.jsx(oa,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:f.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(T=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(yn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(vn,{className:"text-sm",children:N(T.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:T.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Yd(new Date(T.created_at),{addSuffix:!0})}),T.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(T.id),children:e.jsx(jr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:T.content})]})]})})},T.id))})]})]})}):e.jsx(Es,{title:"Academy",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Nn,{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(So,{to:"/academy",children:"Back to Academy"})})]})})};function wBt(){const t=Pr(),[s,r]=C.useState(""),{data:n,isLoading:a}=wt({queryKey:["resource-kits-published"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kits").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(b)throw b;return _}}),{data:o}=wt({queryKey:["resource-kit-files-all"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(b)throw b;return _}}),{data:l}=wt({queryKey:["resource-kit-likes-all"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kit_likes").select("kit_id");if(b)throw b;return _}}),{data:i}=wt({queryKey:["resource-kit-comments-all"],queryFn:async()=>{const{data:_,error:b}=await G.from("resource_kit_comments").select("kit_id");if(b)throw b;return _}}),c=n==null?void 0:n.filter(_=>{var b;return _.name.toLowerCase().includes(s.toLowerCase())||((b=_.description)==null?void 0:b.toLowerCase().includes(s.toLowerCase()))}),u=_=>(o==null?void 0:o.filter(b=>b.kit_id===_))||[],p=_=>(l==null?void 0:l.filter(b=>b.kit_id===_).length)||0,f=_=>(i==null?void 0:i.filter(b=>b.kit_id===_).length)||0,y=_=>{t(`/toolbox/${_}`)};return e.jsx(Es,{title:"Toolbox",description:"Download resource kits and tools to help grow your business",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Toolbox"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Download resource kits and tools to help grow your business"})]}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search resource kits...",value:s,onChange:_=>r(_.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(Oe,{className:"p-4",children:[e.jsx(xs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(xs,{className:"h-5 w-3/4 mb-2"}),e.jsx(xs,{className:"h-4 w-full mb-4"}),e.jsx(xs,{className:"h-4 w-2/3"})]})},b))}):(c==null?void 0:c.length)===0?e.jsxs(Ee,{className:"p-12 text-center",children:[e.jsx(bl,{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(_=>{const b=u(_.id).length,w=p(_.id),j=f(_.id);return e.jsxs(Ee,{className:"group overflow-hidden cursor-pointer hover:shadow-lg transition-all duration-200",onClick:()=>y(_.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:_.featured_image_url?e.jsx("img",{src:_.featured_image_url,alt:_.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(bl,{className:"h-16 w-16 text-muted-foreground"})})}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:_.name}),_.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:mde(_.description)}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-4 w-4"}),b," file",b!==1?"s":""]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gu,{className:"h-3.5 w-3.5"}),w]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ec,{className:"h-3.5 w-3.5"}),j]})]})]})]})]},_.id)})})]})})}const jBt=()=>{const{kitId:t}=Po(),{user:s,isAdmin:r}=Ws(),{toast:n}=Ra(),a=ss(),{trackEngagement:o}=SO(),[l,i]=C.useState(""),{data:c,isLoading:u}=wt({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:T,error:I}=await G.from("resource_kits").select("*").eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:L}=await G.from("resource_kit_files").select("*").eq("kit_id",t).order("sort_order"),{data:R}=await G.from("resource_kit_links").select("*").eq("kit_id",t).order("sort_order");return{...T,files:L||[],links:R||[]}},enabled:!!t});C.useEffect(()=>{c&&o("toolbox",c.id,c.name,"view")},[c==null?void 0:c.id]);const{data:p=[]}=wt({queryKey:["resource-kit-likes",t],queryFn:async()=>{const{data:T,error:I}=await G.from("resource_kit_likes").select("*").eq("kit_id",t);if(I)throw I;return T},enabled:!!t}),{data:f=[]}=wt({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:T,error:I}=await G.from("resource_kit_comments").select("*").eq("kit_id",t).order("created_at",{ascending:!1});if(I)throw I;const L=[...new Set(T.map(q=>q.user_id))],{data:R}=await G.from("profiles").select("id, name").in("id",L),$=new Map((R==null?void 0:R.map(q=>[q.id,q.name]))||[]);return T.map(q=>({...q,user_name:$.get(q.user_id)||"Unknown User"}))},enabled:!!t}),y=Dt({mutationFn:async T=>{const{error:I}=await G.from("resource_kit_comments").insert({kit_id:t,user_id:s.id,content:T});if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),i(""),n({title:"Comment added!"})},onError:T=>{n({title:"Error adding comment",description:T.message,variant:"destructive"})}}),_=Dt({mutationFn:async T=>{const{error:I}=await G.from("resource_kit_comments").delete().eq("id",T);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),n({title:"Comment deleted"})}}),b=Dt({mutationFn:async()=>{const T=p.find(I=>I.user_id===(s==null?void 0:s.id));if(T){const{error:I}=await G.from("resource_kit_likes").delete().eq("id",T.id);if(I)throw I}else{const{error:I}=await G.from("resource_kit_likes").insert({kit_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",t]})}}),w=p.some(T=>T.user_id===(s==null?void 0:s.id)),j=T=>T.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),N=T=>T?T<1024?T+" B":T<1024*1024?(T/1024).toFixed(1)+" KB":(T/(1024*1024)).toFixed(1)+" MB":"",S=T=>{T.preventDefault(),!(!l.trim()||!s)&&y.mutate(l.trim())};return u?e.jsx(Es,{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(Es,{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(So,{to:"/toolbox",children:[e.jsx(di,{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(So,{to:`/admin/toolbox?edit=${c.id}`,children:[e.jsx($a,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(qA,{resourceType:"resource_kit",resourceId:c.id,resourceTitle:c.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:w?"default":"outline",className:"gap-2 rounded-full",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(Gu,{className:`h-4 w-4 ${w?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),c.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:c.description}})]}),c.files&&c.files.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(In,{className:"h-4 w-4"}),"Included Resources (",c.files.length,")"]}),e.jsx("div",{className:"grid gap-2",children:c.files.map(T=>e.jsxs("a",{href:T.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(In,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:T.name}),T.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:N(T.file_size)})]})]}),e.jsx(ki,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},T.id))})]})}),c.links&&c.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(rn,{className:"h-4 w-4"}),"Canva Templates (",c.links.length,")"]}),e.jsx("div",{className:"grid gap-2",children:c.links.map(T=>e.jsxs("a",{href:T.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(rn,{className:"h-4 w-4 text-purple-600"})}),e.jsx("div",{className:"font-medium text-sm",children:T.title})]}),e.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary transition-colors",children:"Open in Canva"})]},T.id))})]})}),e.jsx(KJe,{resourceType:"resource_kit",resourceId:c.id}),e.jsx(Zl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Ec,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[e.jsx(Ar,{placeholder:"Add a comment...",value:l,onChange:T=>i(T.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()||y.isPending,children:e.jsx(oa,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:f.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):f.map(T=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(yn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(vn,{className:"text-sm",children:j(T.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:T.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Yd(new Date(T.created_at),{addSuffix:!0})}),T.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(T.id),children:e.jsx(jr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:T.content})]})]})})},T.id))})]})]})}):e.jsx(Es,{title:"Toolbox",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(bl,{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(So,{to:"/toolbox",children:"Back to Toolbox"})})]})})},kBt=()=>{const t=Pr(),[s,r]=C.useState(""),[n,a]=C.useState("grid"),{data:o=[],isLoading:l}=wt({queryKey:["social-swag"],queryFn:async()=>{const{data:u,error:p}=await G.from("social_swag").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(p)throw p;const{data:f,error:y}=await G.from("social_swag_links").select("*").order("sort_order");if(y)throw y;const{data:_}=await G.from("social_swag_likes").select("swag_id"),{data:b}=await G.from("social_swag_comments").select("swag_id"),w=new Map;_==null||_.forEach(S=>{w.set(S.swag_id,(w.get(S.swag_id)||0)+1)});const j=new Map;return b==null||b.forEach(S=>{j.set(S.swag_id,(j.get(S.swag_id)||0)+1)}),(u||[]).map(S=>({...S,links:(f||[]).filter(T=>T.swag_id===S.id)||[],likesCount:w.get(S.id)||0,commentsCount:j.get(S.id)||0}))}}),i=o.filter(u=>{var f;return u.title.toLowerCase().includes(s.toLowerCase())||((f=u.description)==null?void 0:f.toLowerCase().includes(s.toLowerCase()))}),c=u=>{t(`/social-swag/${u}`)};return e.jsx(Es,{title:"Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Social Swag"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Browse our collection of social media content and graphics"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{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(lf,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Mm,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," item",i.length!==1?"s":""," found"]}),l&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(8)].map((u,p)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(xs,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),e.jsx(xs,{className:"h-5 w-3/4 mb-2"}),e.jsx(xs,{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(nt,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(Vo,{className:"h-3 w-3"}),u.links.length]})})]}),e.jsxs(Oe,{className:`p-4 flex flex-col ${n==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:u.title}),u.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:u.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gu,{className:"h-3.5 w-3.5"}),u.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ec,{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(rn,{className:"h-4 w-4"}),"View Details"]})]})]},u.id))})]})})};var yi=function(){return yi=Object.assign||function(s){for(var r,n=1,a=arguments.length;n1&&(c||!u),f=s>1&&(u||!c),y=function(){n&&o(n)},_=function(){a&&o(a)};return e.jsx(r$t,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:f,nextMonth:a,previousMonth:n,onPreviousClick:y,onNextClick:_})}function n$t(t){var s,r=tc(),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:XJe,u;return a?u=e.jsx(c,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?u=e.jsx(LLe,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(LLe,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(DLe,{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(DLe,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function a$t(t){var s=tc(),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 i$t(t,s,r){for(var n=r?b1(new Date):Uh(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=kl(n,o);a.push(l)}return a}function o$t(){var t=tc(),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=i$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 l$t(){var t,s=tc(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:o$t;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function c$t(t){var s=tc(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var nNe=C.createContext(void 0);function d$t(t){if(!CO(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(nNe.Provider,{value:s,children:t.children})}return e.jsx(u$t,{initialProps:t.initialProps,children:t.children})}function u$t(t){var s=t.initialProps,r=t.children,n=s.selected,a=s.min,o=s.max,l=function(u,p,f){var y,_;(y=s.onDayClick)===null||y===void 0||y.call(s,u,p,f);var b=!!(p.selected&&a&&(n==null?void 0:n.length)===a);if(!b){var w=!!(!p.selected&&o&&(n==null?void 0:n.length)===o);if(!w){var j=n?ZJe([],n):[];if(p.selected){var N=j.findIndex(function(S){return _l(u,S)});j.splice(N,1)}else j.push(u);(_=s.onSelect)===null||_===void 0||_.call(s,j,u,p,f)}}},i={disabled:[]};n&&i.disabled.push(function(u){var p=o&&n.length>o-1,f=n.some(function(y){return _l(y,u)});return!!(p&&!f)});var c={selected:n,onDayClick:l,modifiers:i};return e.jsx(nNe.Provider,{value:c,children:r})}function aNe(){var t=C.useContext(nNe);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function h$t(t,s){var r=s||{},n=r.from,a=r.to;return n&&a?_l(a,t)&&_l(n,t)?void 0:_l(a,t)?{from:a,to:void 0}:_l(n,t)?void 0:bS(n,t)?{from:t,to:a}:{from:n,to:t}:a?bS(t,a)?{from:a,to:t}:{from:t,to:a}:n?wS(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var iNe=C.createContext(void 0);function m$t(t){if(!MO(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(iNe.Provider,{value:s,children:t.children})}return e.jsx(p$t,{initialProps:t.initialProps,children:t.children})}function p$t(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,w){var j,N;(j=s.onDayClick)===null||j===void 0||j.call(s,_,b,w);var S=h$t(_,n);(N=s.onSelect)===null||N===void 0||N.call(s,S,_,b,w)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(p.range_start=[o],l?(p.range_end=[l],_l(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:aie(o,i-1),before:kl(o,i-1)}),o&&l&&p.disabled.push({after:o,before:kl(o,i-1)}),!o&&l&&p.disabled.push({after:aie(l,i-1),before:kl(l,i-1)})),c){if(o&&!l&&(p.disabled.push({before:kl(o,-c+1)}),p.disabled.push({after:kl(o,c-1)})),o&&l){var f=af(l,o)+1,y=c-f;p.disabled.push({before:aie(o,y)}),p.disabled.push({after:kl(l,y)})}!o&&l&&(p.disabled.push({before:kl(l,-c+1)}),p.disabled.push({after:kl(l,c-1)}))}return e.jsx(iNe.Provider,{value:{selected:n,onDayClick:u,modifiers:p},children:r})}function oNe(){var t=C.useContext(iNe);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function jie(t){return Array.isArray(t)?ZJe([],t):t!==void 0?[t]:[]}function f$t(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=jie(a)}),s}var sy;(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"})(sy||(sy={}));var g$t=sy.Selected,xv=sy.Disabled,x$t=sy.Hidden,y$t=sy.Today,fxe=sy.RangeEnd,gxe=sy.RangeMiddle,xxe=sy.RangeStart,v$t=sy.Outside;function _$t(t,s,r){var n,a=(n={},n[g$t]=jie(t.selected),n[xv]=jie(t.disabled),n[x$t]=jie(t.hidden),n[y$t]=[t.today],n[fxe]=[],n[gxe]=[],n[xxe]=[],n[v$t]=[],n);return t.fromDate&&a[xv].push({before:t.fromDate}),t.toDate&&a[xv].push({after:t.toDate}),CO(t)?a[xv]=a[xv].concat(s.modifiers[xv]):MO(t)&&(a[xv]=a[xv].concat(r.modifiers[xv]),a[xxe]=r.modifiers[xxe],a[gxe]=r.modifiers[gxe],a[fxe]=r.modifiers[fxe]),a}var eet=C.createContext(void 0);function b$t(t){var s=tc(),r=aNe(),n=oNe(),a=_$t(s,r,n),o=f$t(s.modifiers),l=yi(yi({},a),o);return e.jsx(eet.Provider,{value:l,children:t.children})}function tet(){var t=C.useContext(eet);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function w$t(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function j$t(t){return!!(t&&typeof t=="object"&&"from"in t)}function k$t(t){return!!(t&&typeof t=="object"&&"after"in t)}function N$t(t){return!!(t&&typeof t=="object"&&"before"in t)}function S$t(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function C$t(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=af(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=af(t,n)>=0&&af(a,t)>=0;return l}return a?_l(a,t):n?_l(n,t):!1}function M$t(t){return tje(t)}function T$t(t){return Array.isArray(t)&&t.every(tje)}function A$t(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(M$t(r))return _l(t,r);if(T$t(r))return r.includes(t);if(j$t(r))return C$t(t,r);if(S$t(r))return r.dayOfWeek.includes(t.getDay());if(w$t(r)){var n=af(r.before,t),a=af(r.after,t),o=n>0,l=a<0,i=bS(r.before,r.after);return i?l&&o:o||l}return k$t(r)?af(t,r.after)>0:N$t(r)?af(r.before,t)>0:typeof r=="function"?r(t):!1})}function lNe(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return A$t(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!Hde(t,r)&&(a.outside=!0),a}function E$t(t,s){for(var r=Mc(t[0]),n=eg(t[t.length-1]),a,o,l=r;l<=n;){var i=lNe(l,s),c=!i.disabled&&!i.hidden;if(!c){l=kl(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=kl(l,1)}return o||a}var P$t=365;function set(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,y={day:kl,week:c4,month:Em,year:vNt,startOfWeek:function(j){return a.ISOWeek?b1(j):Uh(j,{locale:f,weekStartsOn:c})},endOfWeek:function(j){return a.ISOWeek?$We(j):Ude(j,{locale:f,weekStartsOn:c})}},_=y[r](t,n==="after"?1:-1);n==="before"&&u?_=_Nt([u,_]):n==="after"&&p&&(_=bNt([p,_]));var b=!0;if(o){var w=lNe(_,o);b=!w.disabled&&!w.hidden}return b?_:i.count>P$t?i.lastFocused:set(_,{moveBy:r,direction:n,context:a,modifiers:o,retry:yi(yi({},i),{count:i.count+1})})}var ret=C.createContext(void 0);function I$t(t){var s=TO(),r=tet(),n=C.useState(),a=n[0],o=n[1],l=C.useState(),i=l[0],c=l[1],u=E$t(s.displayMonths,r),p=a??(i&&s.isDateDisplayed(i))?i:u,f=function(){c(a),o(void 0)},y=function(j){o(j)},_=tc(),b=function(j,N){if(a){var S=set(a,{moveBy:j,direction:N,context:_,modifiers:r});_l(a,S)||(s.goToDate(S,a),y(S))}},w={focusedDay:a,focusTarget:p,blur:f,focus:y,focusDayAfter:function(){return b("day","after")},focusDayBefore:function(){return b("day","before")},focusWeekAfter:function(){return b("week","after")},focusWeekBefore:function(){return b("week","before")},focusMonthBefore:function(){return b("month","before")},focusMonthAfter:function(){return b("month","after")},focusYearBefore:function(){return b("year","before")},focusYearAfter:function(){return b("year","after")},focusStartOfWeek:function(){return b("startOfWeek","before")},focusEndOfWeek:function(){return b("endOfWeek","after")}};return e.jsx(ret.Provider,{value:w,children:t.children})}function cNe(){var t=C.useContext(ret);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function L$t(t,s){var r=tet(),n=lNe(t,r,s);return n}var dNe=C.createContext(void 0);function D$t(t){if(!Pue(t.initialProps)){var s={selected:void 0};return e.jsx(dNe.Provider,{value:s,children:t.children})}return e.jsx(O$t,{initialProps:t.initialProps,children:t.children})}function O$t(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(dNe.Provider,{value:a,children:r})}function net(){var t=C.useContext(dNe);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function R$t(t,s){var r=tc(),n=net(),a=aNe(),o=oNe(),l=cNe(),i=l.focusDayAfter,c=l.focusDayBefore,u=l.focusWeekAfter,p=l.focusWeekBefore,f=l.blur,y=l.focus,_=l.focusMonthBefore,b=l.focusMonthAfter,w=l.focusYearBefore,j=l.focusYearAfter,N=l.focusStartOfWeek,S=l.focusEndOfWeek,T=function(ne){var le,he,we,ye;Pue(r)?(le=n.onDayClick)===null||le===void 0||le.call(n,t,s,ne):CO(r)?(he=a.onDayClick)===null||he===void 0||he.call(a,t,s,ne):MO(r)?(we=o.onDayClick)===null||we===void 0||we.call(o,t,s,ne):(ye=r.onDayClick)===null||ye===void 0||ye.call(r,t,s,ne)},I=function(ne){var le;y(t),(le=r.onDayFocus)===null||le===void 0||le.call(r,t,s,ne)},L=function(ne){var le;f(),(le=r.onDayBlur)===null||le===void 0||le.call(r,t,s,ne)},R=function(ne){var le;(le=r.onDayMouseEnter)===null||le===void 0||le.call(r,t,s,ne)},$=function(ne){var le;(le=r.onDayMouseLeave)===null||le===void 0||le.call(r,t,s,ne)},q=function(ne){var le;(le=r.onDayPointerEnter)===null||le===void 0||le.call(r,t,s,ne)},U=function(ne){var le;(le=r.onDayPointerLeave)===null||le===void 0||le.call(r,t,s,ne)},V=function(ne){var le;(le=r.onDayTouchCancel)===null||le===void 0||le.call(r,t,s,ne)},X=function(ne){var le;(le=r.onDayTouchEnd)===null||le===void 0||le.call(r,t,s,ne)},se=function(ne){var le;(le=r.onDayTouchMove)===null||le===void 0||le.call(r,t,s,ne)},ee=function(ne){var le;(le=r.onDayTouchStart)===null||le===void 0||le.call(r,t,s,ne)},Q=function(ne){var le;(le=r.onDayKeyUp)===null||le===void 0||le.call(r,t,s,ne)},de=function(ne){var le;switch(ne.key){case"ArrowLeft":ne.preventDefault(),ne.stopPropagation(),r.dir==="rtl"?i():c();break;case"ArrowRight":ne.preventDefault(),ne.stopPropagation(),r.dir==="rtl"?c():i();break;case"ArrowDown":ne.preventDefault(),ne.stopPropagation(),u();break;case"ArrowUp":ne.preventDefault(),ne.stopPropagation(),p();break;case"PageUp":ne.preventDefault(),ne.stopPropagation(),ne.shiftKey?w():_();break;case"PageDown":ne.preventDefault(),ne.stopPropagation(),ne.shiftKey?j():b();break;case"Home":ne.preventDefault(),ne.stopPropagation(),N();break;case"End":ne.preventDefault(),ne.stopPropagation(),S();break}(le=r.onDayKeyDown)===null||le===void 0||le.call(r,t,s,ne)},re={onClick:T,onFocus:I,onBlur:L,onKeyDown:de,onKeyUp:Q,onMouseEnter:R,onMouseLeave:$,onPointerEnter:q,onPointerLeave:U,onTouchCancel:V,onTouchEnd:X,onTouchMove:se,onTouchStart:ee};return re}function F$t(){var t=tc(),s=net(),r=aNe(),n=oNe(),a=Pue(t)?s.selected:CO(t)?r.selected:MO(t)?n.selected:void 0;return a}function z$t(t){return Object.values(sy).includes(t)}function B$t(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(z$t(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function $$t(t,s){var r=yi({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=yi(yi({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function q$t(t,s,r){var n,a,o,l=tc(),i=cNe(),c=L$t(t,s),u=R$t(t,c),p=F$t(),f=!!(l.onDayClick||l.mode!=="default");C.useEffect(function(){var R;c.outside||i.focusedDay&&f&&_l(i.focusedDay,t)&&((R=r.current)===null||R===void 0||R.focus())},[i.focusedDay,t,r,f,c.outside]);var y=B$t(l,c).join(" "),_=$$t(l,c),b=!!(c.outside&&!l.showOutsideDays||c.hidden),w=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:c$t,j=e.jsx(w,{date:t,displayMonth:s,activeModifiers:c}),N={style:_,className:y,children:j,role:"gridcell"},S=i.focusTarget&&_l(i.focusTarget,t)&&!c.outside,T=i.focusedDay&&_l(i.focusedDay,t),I=yi(yi(yi({},N),(n={disabled:c.disabled,role:"gridcell"},n["aria-selected"]=c.selected,n.tabIndex=T||S?0:-1,n)),u),L={isButton:f,isHidden:b,activeModifiers:c,selectedDays:p,buttonProps:I,divProps:N};return L}function U$t(t){var s=C.useRef(null),r=q$t(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(Tle,yi({name:"day",ref:s},r.buttonProps)):e.jsx("div",yi({},r.divProps))}function V$t(t){var s=t.number,r=t.dates,n=tc(),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}),y=function(_){a(s,r,_)};return e.jsx(Tle,{name:"week-number","aria-label":f,className:l.weeknumber,style:o.weeknumber,onClick:y,children:p})}function H$t(t){var s,r,n=tc(),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:U$t,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:V$t,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})},k4t(f))})]})}function OLe(t,s,r){for(var n=r!=null&&r.ISOWeek?$We(s):Ude(s,r),a=r!=null&&r.ISOWeek?b1(t):Uh(t,r),o=af(n,a),l=[],i=0;i<=o;i++)l.push(kl(a,i));var c=l.reduce(function(u,p){var f=r!=null&&r.ISOWeek?sje(p):nje(p,r),y=u.find(function(_){return _.weekNumber===f});return y?(y.dates.push(p),u):(u.push({weekNumber:f,dates:[p]}),u)},[]);return c}function W$t(t,s){var r=OLe(Mc(t),eg(t),s);if(s!=null&&s.useFixedWeeks){var n=S4t(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=c4(o,6-n),i=OLe(c4(o,1),l,s);r.push.apply(r,i)}}return r}function G$t(t){var s,r,n,a=tc(),o=a.locale,l=a.classNames,i=a.styles,c=a.hideHead,u=a.fixedWeeks,p=a.components,f=a.weekStartsOn,y=a.firstWeekContainsDate,_=a.ISOWeek,b=W$t(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:_,locale:o,weekStartsOn:f,firstWeekContainsDate:y}),w=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:l$t,j=(r=p==null?void 0:p.Row)!==null&&r!==void 0?r:H$t,N=(n=p==null?void 0:p.Footer)!==null&&n!==void 0?n:a$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(w,{}),e.jsx("tbody",{className:l.tbody,style:i.tbody,children:b.map(function(S){return e.jsx(j,{displayMonth:t.displayMonth,dates:S.dates,weekNumber:S.weekNumber},S.weekNumber)})}),e.jsx(N,{displayMonth:t.displayMonth})]})}function K$t(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Z$t=K$t()?C.useLayoutEffect:C.useEffect,yxe=!1,Y$t=0;function RLe(){return"react-day-picker-".concat(++Y$t)}function X$t(t){var s,r=t??(yxe?RLe():null),n=C.useState(r),a=n[0],o=n[1];return Z$t(function(){a===null&&o(RLe())},[]),C.useEffect(function(){yxe===!1&&(yxe=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function Q$t(t){var s,r,n=tc(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,c=TO().displayMonths,u=X$t(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],y=l.month,_=t.displayIndex===0,b=t.displayIndex===c.length-1,w=!_&&!b;a==="rtl"&&(s=[_,b],b=s[0],_=s[1]),_&&(f.push(o.caption_start),y=yi(yi({},y),l.caption_start)),b&&(f.push(o.caption_end),y=yi(yi({},y),l.caption_end)),w&&(f.push(o.caption_between),y=yi(yi({},y),l.caption_between));var j=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:n$t;return e.jsxs("div",{className:f.join(" "),style:y,children:[e.jsx(j,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(G$t,{id:p,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function J$t(t){var s=tc(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function eqt(t){var s,r,n=t.initialProps,a=tc(),o=cNe(),l=TO(),i=C.useState(!1),c=i[0],u=i[1];C.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=yi(yi({},a.styles.root),a.style),y=Object.keys(n).filter(function(b){return b.startsWith("data-")}).reduce(function(b,w){var j;return yi(yi({},b),(j={},j[w]=n[w],j))},{}),_=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:J$t;return e.jsx("div",yi({className:p.join(" "),style:f,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},y,{children:e.jsx(_,{children:l.displayMonths.map(function(b,w){return e.jsx(Q$t,{displayIndex:w,displayMonth:b},w)})})}))}function tqt(t){var s=t.children,r=NBt(t,["children"]);return e.jsx(VBt,{initialProps:r,children:e.jsx(e$t,{children:e.jsx(D$t,{initialProps:r,children:e.jsx(d$t,{initialProps:r,children:e.jsx(m$t,{initialProps:r,children:e.jsx(b$t,{children:e.jsx(I$t,{children:s})})})})})})})}function sqt(t){return e.jsx(tqt,yi({},t,{children:e.jsx(eqt,{initialProps:t})}))}function mf({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(sqt,{showOutsideDays:r,className:At("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:At(A8({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:At(A8({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(Xl,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(Xa,{className:"h-4 w-4"})},...n})}mf.displayName="Calendar";var Iue="Popover",[aet]=Yc(Iue,[M0]),AO=M0(),[rqt,A2]=aet(Iue),iet=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=AO(s),c=C.useRef(null),[u,p]=C.useState(!1),[f,y]=Yu({prop:n,defaultProp:a??!1,onChange:o,caller:Iue});return e.jsx(tO,{...i,children:e.jsx(rqt,{scope:s,contentId:vu(),triggerRef:c,open:f,onOpenChange:y,onOpenToggle:C.useCallback(()=>y(_=>!_),[y]),hasCustomAnchor:u,onCustomAnchorAdd:C.useCallback(()=>p(!0),[]),onCustomAnchorRemove:C.useCallback(()=>p(!1),[]),modal:l,children:r})})};iet.displayName=Iue;var oet="PopoverAnchor",nqt=C.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=A2(oet,r),o=AO(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return C.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(jA,{...o,...n,ref:s})});nqt.displayName=oet;var cet="PopoverTrigger",det=C.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=A2(cet,r),o=AO(r),l=Oa(s,a.triggerRef),i=e.jsx(Jr.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":fet(a.open),...n,ref:l,onClick:Mr(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(jA,{asChild:!0,...o,children:i})});det.displayName=cet;var uNe="PopoverPortal",[aqt,iqt]=aet(uNe,{forceMount:void 0}),uet=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=A2(uNe,s);return e.jsx(aqt,{scope:s,forceMount:r,children:e.jsx(Id,{present:r||o.open,children:e.jsx(vA,{asChild:!0,container:a,children:n})})})};uet.displayName=uNe;var AT="PopoverContent",het=C.forwardRef((t,s)=>{const r=iqt(AT,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=A2(AT,t.__scopePopover);return e.jsx(Id,{present:n||o.open,children:o.modal?e.jsx(lqt,{...a,ref:s}):e.jsx(cqt,{...a,ref:s})})});het.displayName=AT;var oqt=e2("PopoverContent.RemoveScroll"),lqt=C.forwardRef((t,s)=>{const r=A2(AT,t.__scopePopover),n=C.useRef(null),a=Oa(s,n),o=C.useRef(!1);return C.useEffect(()=>{const l=n.current;if(l)return Sde(l)},[]),e.jsx(oO,{as:oqt,allowPinchZoom:!0,children:e.jsx(met,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Mr(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Mr(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:Mr(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),cqt=C.forwardRef((t,s)=>{const r=A2(AT,t.__scopePopover),n=C.useRef(!1),a=C.useRef(!1);return e.jsx(met,{...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()}})}),met=C.forwardRef((t,s)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:p,...f}=t,y=A2(AT,r),_=AO(r);return jde(),e.jsx(aO,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(g2,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>y.onOpenChange(!1),children:e.jsx(sO,{"data-state":fet(y.open),role:"dialog",id:y.contentId,..._,...f,ref:s,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),pet="PopoverClose",dqt=C.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=A2(pet,r);return e.jsx(Jr.button,{type:"button",...n,ref:s,onClick:Mr(t.onClick,()=>a.onOpenChange(!1))})});dqt.displayName=pet;var uqt="PopoverArrow",hqt=C.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=AO(r);return e.jsx(rO,{...a,...n,ref:s})});hqt.displayName=uqt;function fet(t){return t?"open":"closed"}var mqt=iet,pqt=det,fqt=uet,get=het;const Lo=mqt,Do=pqt,Eo=C.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(fqt,{children:e.jsx(get,{ref:a,align:s,sideOffset:r,className:At("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})}));Eo.displayName=get.displayName;const gqt=HS("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"}}),hNe=C.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:At(gqt({variant:s}),t),...r}));hNe.displayName="Alert";const xqt=C.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:At("mb-1 font-medium leading-none tracking-tight",t),...s}));xqt.displayName="AlertTitle";const mNe=C.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:At("text-sm [&_p]:leading-relaxed",t),...s}));mNe.displayName="AlertDescription";function yqt({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=ss(),[c,u]=C.useState(a),[p,f]=C.useState([]),[y,_]=C.useState(null),[b,w]=C.useState("now"),[j,N]=C.useState(IEe(zEe(new Date),1)),[S,T]=C.useState("12"),[I,L]=C.useState("00"),[R,$]=C.useState("PM");C.useEffect(()=>{if(t){u(a),w("now"),f([]);const ke=IEe(zEe(new Date),1);N(ke);const We=ke.getHours();T(String(We>12?We-12:We===0?12:We)),L("00"),$(We>=12?"PM":"AM")}},[t,a]);const q=()=>{if(!j)return null;let ke=parseInt(S);const We=parseInt(I);return R==="PM"&&ke!==12&&(ke+=12),R==="AM"&&ke===12&&(ke=0),NL(kL(j,ke),We)},{data:U,isLoading:V}=wt({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:ke}}=await G.auth.getUser();if(!ke)return[];const{data:We,error:be}=await G.from("social_accounts").select("*").eq("user_id",ke.id).eq("is_active",!0).order("platform",{ascending:!0});if(be)throw be;return console.log("Fetched social accounts for posting:",We),We},enabled:t,staleTime:0}),X=Dt({mutationFn:async({accountId:ke,platform:We})=>{_(ke);const{data:be,error:Me}=await G.functions.invoke("social-post",{body:{platform:We,accountId:ke,imageUrl:r,caption:c}});if(Me)throw Me;if(be!=null&&be.error)throw new Error(be.error);return be},onSuccess:ke=>{const We=ke.platform==="facebook"?"Facebook":ke.platform==="instagram"?"Instagram":ke.platform==="linkedin"?"LinkedIn":"Google Business";me.success(`Posted to ${We}!`)},onError:ke=>{me.error(`Failed to post: ${ke.message}`)},onSettled:()=>{_(null)}}),se=Dt({mutationFn:async({accountId:ke,platform:We,scheduledFor:be})=>{const{data:{user:Me}}=await G.auth.getUser();if(!Me)throw new Error("Not authenticated");const{error:Ae}=await G.from("scheduled_posts").insert({user_id:Me.id,social_account_id:ke,platform:We,image_url:r,caption:c,swag_item_id:o||null,reel_id:l||null,scheduled_for:be.toISOString(),status:"scheduled"});if(Ae)throw Ae;return{platform:We}},onSuccess:ke=>{const We=ke.platform==="facebook"?"Facebook":ke.platform==="instagram"?"Instagram":"LinkedIn";me.success(`Post scheduled for ${We}!`)},onError:ke=>{me.error(`Failed to schedule: ${ke.message}`)}}),ee=async()=>{if(p.length===0){me.error("Please select at least one account");return}if(b==="schedule"){const ke=q();if(!ke||ke<=new Date){me.error("Please select a future date and time");return}for(const We of p){const be=U==null?void 0:U.find(Me=>Me.id===We);be&&await se.mutateAsync({accountId:We,platform:be.platform,scheduledFor:ke})}i.invalidateQueries({queryKey:["scheduled-posts"]}),me.success(`${p.length} post(s) scheduled for ${ys(ke,"PPp")}`)}else for(const ke of p){const We=U==null?void 0:U.find(be=>be.id===ke);We&&await X.mutateAsync({accountId:ke,platform:We.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),f([]),s(!1)},Q=ke=>{f(We=>We.includes(ke)?We.filter(be=>be!==ke):[...We,ke])},de=(U==null?void 0:U.filter(ke=>ke.platform==="facebook"))||[],re=(U==null?void 0:U.filter(ke=>ke.platform==="instagram"))||[],ne=(U==null?void 0:U.filter(ke=>ke.platform==="linkedin"))||[],le=(U==null?void 0:U.filter(ke=>ke.platform==="google_business"))||[],he=((U==null?void 0:U.length)||0)>0,we=X.isPending||se.isPending,ye=Array.from({length:12},(ke,We)=>String(We+1)),je=["00","15","30","45"];return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Create Social Post"}),e.jsx(Zr,{children:"Share this image to your connected social accounts"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"aspect-square w-full max-w-[200px] mx-auto overflow-hidden rounded-lg border",children:e.jsx("img",{src:r,alt:"Post preview",className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"caption",children:"Caption"}),e.jsx(Ar,{id:"caption",placeholder:"Write a caption for your post...",value:c,onChange:ke=>u(ke.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(_e,{children:"Publish Time"}),e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsx("button",{type:"button",onClick:()=>w("now"),className:At("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",b==="now"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Post Now"}),e.jsx("button",{type:"button",onClick:()=>w("schedule"),className:At("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",b==="schedule"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Schedule"})]})]}),b==="schedule"&&e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(Tn,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:At("justify-start text-left font-normal flex-1",!j&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),j?ys(j,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(Eo,{className:"w-auto p-0",align:"start",children:e.jsx(mf,{mode:"single",selected:j,onSelect:N,disabled:ke=>kee.jsx(Tt,{value:ke,children:ke},ke))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(rr,{value:I,onValueChange:L,children:[e.jsx(tr,{className:"w-[70px]",children:e.jsx(nr,{})}),e.jsx(sr,{children:je.map(ke=>e.jsx(Tt,{value:ke,children:ke},ke))})]}),e.jsxs(rr,{value:R,onValueChange:ke=>$(ke),children:[e.jsx(tr,{className:"w-[70px]",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"AM",children:"AM"}),e.jsx(Tt,{value:"PM",children:"PM"})]})]})]})]}),j&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",ys(q()||new Date,"PPP 'at' p")]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{children:"Post to"}),V&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin"})}),!V&&!he&&e.jsxs(hNe,{children:[e.jsx(yl,{className:"h-4 w-4"}),e.jsxs(mNe,{className:"flex flex-col gap-2",children:[e.jsx("span",{children:"No social accounts connected yet."}),e.jsxs(So,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[e.jsx(Jl,{className:"h-3.5 w-3.5"}),"Connect your Facebook, Instagram & LinkedIn"]})]})]}),de.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(xu,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),de.map(ke=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Yo,{checked:p.includes(ke.id),onCheckedChange:()=>Q(ke.id),disabled:y===ke.id}),e.jsxs(yn,{className:"h-8 w-8",children:[e.jsx(Da,{src:ke.profile_picture_url||""}),e.jsx(vn,{children:e.jsx(xu,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:ke.page_name||ke.platform_username}),y===ke.id&&e.jsx(Ss,{className:"h-4 w-4 animate-spin"})]},ke.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(yu,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),re.map(ke=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Yo,{checked:p.includes(ke.id),onCheckedChange:()=>Q(ke.id),disabled:y===ke.id}),e.jsxs(yn,{className:"h-8 w-8",children:[e.jsx(Da,{src:ke.profile_picture_url||""}),e.jsx(vn,{children:e.jsx(yu,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",ke.platform_username]}),y===ke.id&&e.jsx(Ss,{className:"h-4 w-4 animate-spin"})]},ke.id))]}),ne.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(_p,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),ne.map(ke=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Yo,{checked:p.includes(ke.id),onCheckedChange:()=>Q(ke.id),disabled:y===ke.id}),e.jsxs(yn,{className:"h-8 w-8",children:[e.jsx(Da,{src:ke.profile_picture_url||""}),e.jsx(vn,{children:e.jsx(_p,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:ke.platform_username}),y===ke.id&&e.jsx(Ss,{className:"h-4 w-4 animate-spin"})]},ke.id))]}),le.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Ui,{className:"h-4 w-4 text-red-600"})," Google Business"]}),le.map(ke=>e.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[e.jsx(Yo,{checked:p.includes(ke.id),onCheckedChange:()=>Q(ke.id),disabled:y===ke.id}),e.jsxs(yn,{className:"h-8 w-8",children:[e.jsx(Da,{src:ke.profile_picture_url||""}),e.jsx(vn,{children:e.jsx(Ui,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:ke.page_name||ke.platform_username}),y===ke.id&&e.jsx(Ss,{className:"h-4 w-4 animate-spin"})]},ke.id))]})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:ee,disabled:p.length===0||we,className:"gap-2",children:[we?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):b==="schedule"?e.jsx(on,{className:"h-4 w-4"}):e.jsx(oa,{className:"h-4 w-4"}),b==="schedule"?`Schedule ${p.length} post${p.length!==1?"s":""}`:`Post to ${p.length} account${p.length!==1?"s":""}`]})]})]})})}function vqt(){const t=ss(),[s,r]=C.useState(void 0),[n,a]=C.useState("all"),[o,l]=C.useState(null),[i,c]=C.useState(""),[u,p]=C.useState(void 0),[f,y]=C.useState("12"),[_,b]=C.useState("00"),[w,j]=C.useState("PM"),{data:N=[],isLoading:S}=wt({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:le,error:he}=await G.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(he)throw he;return le}}),T=N.filter(le=>{if(n!=="all"&&le.status!==n)return!1;if(s&&le.scheduled_for){const he=new Date(le.scheduled_for);if(!_l(he,s))return!1}return!0}),I=N.filter(le=>le.scheduled_for).map(le=>Pm(new Date(le.scheduled_for))),L=Dt({mutationFn:async le=>{const{error:he}=await G.from("scheduled_posts").update({caption:le.caption,scheduled_for:le.scheduled_for}).eq("id",le.id);if(he)throw he},onSuccess:()=>{me.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:le=>{me.error(`Failed to update: ${le.message}`)}}),R=Dt({mutationFn:async le=>{const{error:he}=await G.from("scheduled_posts").update({status:"cancelled"}).eq("id",le);if(he)throw he},onSuccess:()=>{me.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{me.error(`Failed to cancel: ${le.message}`)}}),$=Dt({mutationFn:async le=>{const{error:he}=await G.from("scheduled_posts").delete().eq("id",le);if(he)throw he},onSuccess:()=>{me.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{me.error(`Failed to delete: ${le.message}`)}}),q=Dt({mutationFn:async le=>{const{data:he,error:we}=await G.functions.invoke("social-post",{body:{platform:le.platform,accountId:le.social_account_id,imageUrl:le.image_url,caption:le.caption}});if(we)throw we;if(he!=null&&he.error)throw new Error(he.error);return await G.from("scheduled_posts").update({status:"posted",posted_at:new Date().toISOString(),post_id:he.postId}).eq("id",le.id),he},onSuccess:le=>{const he=le.platform==="facebook"?"Facebook":le.platform==="instagram"?"Instagram":"LinkedIn";me.success(`Posted to ${he}!`),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{me.error(`Failed to post: ${le.message}`)}}),U=le=>{if(l(le),c(le.caption||""),le.scheduled_for){const he=new Date(le.scheduled_for);p(he);const we=he.getHours();y(String(we>12?we-12:we===0?12:we)),b(String(he.getMinutes()).padStart(2,"0")),j(we>=12?"PM":"AM")}},V=()=>{if(!o||!u)return;let le=parseInt(f);const he=parseInt(_);w==="PM"&&le!==12&&(le+=12),w==="AM"&&le===12&&(le=0);const we=NL(kL(u,le),he);L.mutate({id:o.id,caption:i,scheduled_for:we.toISOString()})},X=le=>{switch(le){case"facebook":return e.jsx(xu,{className:"h-4 w-4 text-blue-600"});case"instagram":return e.jsx(yu,{className:"h-4 w-4 text-pink-600"});case"linkedin":return e.jsx(_p,{className:"h-4 w-4 text-blue-700"});default:return null}},se=le=>{switch(le){case"scheduled":return e.jsxs(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(nt,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(vi,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(nt,{variant:"destructive",className:"gap-1",children:[e.jsx($c,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(nt,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(yl,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(nt,{variant:"outline",children:le})}},ee=Array.from({length:12},(le,he)=>String(he+1)),Q=["00","15","30","45"],de=N.filter(le=>le.status==="scheduled").length,re=N.filter(le=>le.status==="posted").length,ne=N.filter(le=>le.status==="scheduled"&&le.scheduled_for&&C4t(new Date(le.scheduled_for))).length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:de}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Scheduled"})]}),e.jsxs(Ee,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:ne}),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:N.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total"})]})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[e.jsxs(Ee,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Md,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(mf,{mode:"single",selected:s,onSelect:r,className:At("pointer-events-auto"),modifiers:{hasPost:I},modifiersStyles:{hasPost:{fontWeight:"bold",backgroundColor:"hsl(var(--primary) / 0.1)",borderRadius:"50%"}}}),s&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>r(void 0),className:"w-full mt-2",children:"Clear date filter"})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a0,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:["all","scheduled","posted","failed","cancelled"].map(le=>e.jsx(K,{variant:n===le?"default":"outline",size:"sm",onClick:()=>a(le),className:"capitalize",children:le},le))})]}),S&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ss,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!S&&T.length===0&&e.jsxs(Ee,{className:"p-8 text-center",children:[e.jsx(on,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"font-medium mb-2",children:"No posts found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?`No posts scheduled for ${ys(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:T.map(le=>{var he,we;return e.jsx(Ee,{className:"overflow-hidden",children:e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[e.jsx("div",{className:"sm:w-32 h-32 sm:h-auto bg-muted flex-shrink-0",children:e.jsx("img",{src:le.image_url,alt:"Post preview",className:"w-full h-full object-cover"})}),e.jsxs(Oe,{className:"flex-1 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[X(le.platform),e.jsx("span",{className:"font-medium",children:((he=le.social_accounts)==null?void 0:he.page_name)||((we=le.social_accounts)==null?void 0:we.platform_username)||"Unknown"}),se(le.status)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[le.status==="scheduled"&&e.jsxs(x2,{children:[e.jsxs(hd,{children:[e.jsx(md,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>U(le),children:e.jsx($a,{className:"h-4 w-4"})})}),e.jsx(Uc,{children:"Edit post"})]}),e.jsxs(hd,{children:[e.jsx(md,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>q.mutate(le),disabled:q.isPending,children:q.isPending?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(oa,{className:"h-4 w-4"})})}),e.jsx(Uc,{children:"Post now"})]}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Cancel this scheduled post?"}),e.jsx(Gl,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Keep"}),e.jsx(Tl,{onClick:()=>R.mutate(le.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(Tl,{onClick:()=>$.mutate(le.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(le.status==="posted"||le.status==="cancelled"||le.status==="failed")&&e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Delete this post?"}),e.jsx(Gl,{children:"This will permanently remove this post from your history."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>$.mutate(le.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),le.caption&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:le.caption}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),le.status==="posted"&&le.posted_at?`Posted ${ys(new Date(le.posted_at),"PPp")}`:le.scheduled_for?`Scheduled for ${ys(new Date(le.scheduled_for),"PPp")}`:"Not scheduled"]}),le.status==="failed"&&le.error_message&&e.jsxs("p",{className:"text-xs text-destructive mt-2",children:["Error: ",le.error_message]})]})]})},le.id)})})]})]}),e.jsx(_s,{open:!!o,onOpenChange:le=>!le&&l(null),children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Edit Scheduled Post"}),e.jsx(Zr,{children:"Update the caption or reschedule this post"})]}),o&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"aspect-square w-32 mx-auto overflow-hidden rounded-lg border",children:e.jsx("img",{src:o.image_url,alt:"Post preview",className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Caption"}),e.jsx(Ar,{value:i,onChange:le=>c(le.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[e.jsx(_e,{children:"Schedule for"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:At("justify-start text-left font-normal flex-1",!u&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),u?ys(u,"PPP"):"Pick a date"]})}),e.jsx(Eo,{className:"w-auto p-0",align:"start",children:e.jsx(mf,{mode:"single",selected:u,onSelect:p,disabled:le=>lee.jsx(Tt,{value:le,children:le},le))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(rr,{value:_,onValueChange:b,children:[e.jsx(tr,{className:"w-[70px]",children:e.jsx(nr,{})}),e.jsx(sr,{children:Q.map(le=>e.jsx(Tt,{value:le,children:le},le))})]}),e.jsxs(rr,{value:w,onValueChange:le=>j(le),children:[e.jsx(tr,{className:"w-[70px]",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"AM",children:"AM"}),e.jsx(Tt,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{onClick:V,disabled:L.isPending,children:[L.isPending?e.jsx(Ss,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function tz(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 xet={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 tz=="function"&&tz;if(!p&&f)return f(u,!0);if(i)return i(u,!0);var y=new Error("Cannot find module '"+u+"'");throw y.code="MODULE_NOT_FOUND",y}var _=a[u]={exports:{}};n[u][0].call(_.exports,function(b){var w=n[u][1][b];return l(w||b)},_,_.exports,r,n,a,o)}return a[u].exports}for(var i=typeof tz=="function"&&tz,c=0;c>2,_=(3&u)<<4|p>>4,b=1>6:64,w=2>4,p=(15&y)<<4|(_=i.indexOf(c.charAt(w++)))>>2,f=(3&_)<<6|(b=i.indexOf(c.charAt(w++))),S[j++]=u,_!==64&&(S[j++]=p),b!==64&&(S[j++]=f);return S}},{"./support":30,"./utils":32}],2:[function(r,n,a){var o=r("./external"),l=r("./stream/DataWorker"),i=r("./stream/Crc32Probe"),c=r("./stream/DataLengthProbe");function u(p,f,y,_,b){this.compressedSize=p,this.uncompressedSize=f,this.crc32=y,this.compression=_,this.compressedContent=b}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,y){return p.pipe(new i).pipe(new c("uncompressedSize")).pipe(f.compressWorker(y)).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,y){var _=l,b=y+f;u^=-1;for(var w=y;w>>8^_[255&(u^p[w])];return-1^u}(0|c,i,i.length,0):function(u,p,f,y){var _=l,b=y+f;u^=-1;for(var w=y;w>>8^_[255&(u^p.charCodeAt(w))];return-1^u}(0|c,i,i.length,0):0}},{"./utils":32}],5:[function(r,n,a){a.base64=!1,a.binary=!1,a.dir=!1,a.createFolders=!0,a.date=null,a.compression=null,a.compressionOptions=null,a.comment=null,a.unixPermissions=null,a.dosPermissions=null},{}],6:[function(r,n,a){var o=null;o=typeof Promise<"u"?Promise:r("lie"),n.exports={Promise:o}},{lie:37}],7:[function(r,n,a){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",l=r("pako"),i=r("./utils"),c=r("./stream/GenericWorker"),u=o?"uint8array":"array";function p(f,y){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=y,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(y){f.push({data:y,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 w,j="";for(w=0;w>>=8;return j}function l(_,b,w,j,N,S){var T,I,L=_.file,R=_.compression,$=S!==u.utf8encode,q=i.transformTo("string",S(L.name)),U=i.transformTo("string",u.utf8encode(L.name)),V=L.comment,X=i.transformTo("string",S(V)),se=i.transformTo("string",u.utf8encode(V)),ee=U.length!==L.name.length,Q=se.length!==V.length,de="",re="",ne="",le=L.dir,he=L.date,we={crc32:0,compressedSize:0,uncompressedSize:0};b&&!w||(we.crc32=_.crc32,we.compressedSize=_.compressedSize,we.uncompressedSize=_.uncompressedSize);var ye=0;b&&(ye|=8),$||!ee&&!Q||(ye|=2048);var je=0,ke=0;le&&(je|=16),N==="UNIX"?(ke=798,je|=function(be,Me){var Ae=be;return be||(Ae=Me?16893:33204),(65535&Ae)<<16}(L.unixPermissions,le)):(ke=20,je|=function(be){return 63&(be||0)}(L.dosPermissions)),T=he.getUTCHours(),T<<=6,T|=he.getUTCMinutes(),T<<=5,T|=he.getUTCSeconds()/2,I=he.getUTCFullYear()-1980,I<<=4,I|=he.getUTCMonth()+1,I<<=5,I|=he.getUTCDate(),ee&&(re=o(1,1)+o(p(q),4)+U,de+="up"+o(re.length,2)+re),Q&&(ne=o(1,1)+o(p(X),4)+se,de+="uc"+o(ne.length,2)+ne);var We="";return We+=` \0`,We+=o(ye,2),We+=R.magic,We+=o(T,2),We+=o(I,2),We+=o(we.crc32,4),We+=o(we.compressedSize,4),We+=o(we.uncompressedSize,4),We+=o(q.length,2),We+=o(de.length,2),{fileRecord:f.LOCAL_FILE_HEADER+We+q+de,dirRecord:f.CENTRAL_FILE_HEADER+o(ke,2)+We+o(X.length,2)+"\0\0\0\0"+o(je,4)+o(j,4)+q+de+X}}var i=r("../utils"),c=r("../stream/GenericWorker"),u=r("../utf8"),p=r("../crc32"),f=r("../signature");function y(_,b,w,j){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=w,this.encodeFileName=j,this.streamFiles=_,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(y,c),y.prototype.push=function(_){var b=_.meta.percent||0,w=this.entriesCount,j=this._sources.length;this.accumulate?this.contentBuffer.push(_):(this.bytesWritten+=_.data.length,c.prototype.push.call(this,{data:_.data,meta:{currentFile:this.currentFile,percent:w?(b+100*(w-j-1))/w:100}}))},y.prototype.openedSource=function(_){this.currentSourceOffset=this.bytesWritten,this.currentFile=_.file.name;var b=this.streamFiles&&!_.file.dir;if(b){var w=l(_,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:w.fileRecord,meta:{percent:0}})}else this.accumulate=!0},y.prototype.closedSource=function(_){this.accumulate=!1;var b=this.streamFiles&&!_.file.dir,w=l(_,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(w.dirRecord),b)this.push({data:function(j){return f.DATA_DESCRIPTOR+o(j.crc32,4)+o(j.compressedSize,4)+o(j.uncompressedSize,4)}(_),meta:{percent:100}});else for(this.push({data:w.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},y.prototype.flush=function(){for(var _=this.bytesWritten,b=0;b=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 y=o.getTypeOf(f);return o.checkSupport(y),y!=="string"||l.uint8array?y==="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 y(b,w){return new p.Promise(function(j,N){var S=[],T=b._internalType,I=b._outputType,L=b._mimeType;b.on("data",function(R,$){S.push(R),w&&w($)}).on("error",function(R){S=[],N(R)}).on("end",function(){try{var R=function($,q,U){switch($){case"blob":return o.newBlob(o.transformTo("arraybuffer",q),U);case"base64":return c.encode(q);default:return o.transformTo($,q)}}(I,function($,q){var U,V=0,X=null,se=0;for(U=0;U"u")a.blob=!1;else{var o=new ArrayBuffer(0);try{a.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var l=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);l.append(o),a.blob=l.getBlob("application/zip").size===0}catch{a.blob=!1}}}try{a.nodestream=!!r("readable-stream").Readable}catch{a.nodestream=!1}},{"readable-stream":16}],31:[function(r,n,a){for(var o=r("./utils"),l=r("./support"),i=r("./nodejsUtils"),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 y(){c.call(this,"utf-8 encode")}a.utf8encode=function(_){return l.nodebuffer?i.newBufferFrom(_,"utf-8"):function(b){var w,j,N,S,T,I=b.length,L=0;for(S=0;S>>6:(j<65536?w[T++]=224|j>>>12:(w[T++]=240|j>>>18,w[T++]=128|j>>>12&63),w[T++]=128|j>>>6&63),w[T++]=128|63&j);return w}(_)},a.utf8decode=function(_){return l.nodebuffer?o.transformTo("nodebuffer",_).toString("utf-8"):function(b){var w,j,N,S,T=b.length,I=new Array(2*T);for(w=j=0;w>10&1023,I[j++]=56320|1023&N)}return I.length!==j&&(I.subarray?I=I.subarray(0,j):I.length=j),o.applyFromCharCode(I)}(_=o.transformTo(l.uint8array?"uint8array":"array",_))},o.inherits(f,c),f.prototype.processChunk=function(_){var b=o.transformTo(l.uint8array?"uint8array":"array",_.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var w=b;(b=new Uint8Array(w.length+this.leftOver.length)).set(this.leftOver,0),b.set(w,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var j=function(S,T){var I;for((T=T||S.length)>S.length&&(T=S.length),I=T-1;0<=I&&(192&S[I])==128;)I--;return I<0||I===0?T:I+u[S[I]]>T?I:T}(b),N=b;j!==b.length&&(l.uint8array?(N=b.subarray(0,j),this.leftOver=b.subarray(j,b.length)):(N=b.slice(0,j),this.leftOver=b.slice(j,b.length))),this.push({data:a.utf8decode(N),meta:_.meta})},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(y,c),y.prototype.processChunk=function(_){this.push({data:a.utf8encode(_.data),meta:_.meta})},a.Utf8EncodeWorker=y},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,n,a){var o=r("./support"),l=r("./base64"),i=r("./nodejsUtils"),c=r("./external");function u(w){return w}function p(w,j){for(var N=0;N>8;this.dir=!!(16&this.externalFileAttributes),_==0&&(this.dosPermissions=63&this.externalFileAttributes),_==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var _=o(this.extraFields[1].value);this.uncompressedSize===l.MAX_VALUE_32BITS&&(this.uncompressedSize=_.readInt(8)),this.compressedSize===l.MAX_VALUE_32BITS&&(this.compressedSize=_.readInt(8)),this.localHeaderOffset===l.MAX_VALUE_32BITS&&(this.localHeaderOffset=_.readInt(8)),this.diskNumberStart===l.MAX_VALUE_32BITS&&(this.diskNumberStart=_.readInt(4))}},readExtraFields:function(_){var b,w,j,N=_.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});_.index+4>>6:(_<65536?y[j++]=224|_>>>12:(y[j++]=240|_>>>18,y[j++]=128|_>>>12&63),y[j++]=128|_>>>6&63),y[j++]=128|63&_);return y},a.buf2binstring=function(f){return p(f,f.length)},a.binstring2buf=function(f){for(var y=new o.Buf8(f.length),_=0,b=y.length;_>10&1023,S[b++]=56320|1023&w)}return p(S,b)},a.utf8border=function(f,y){var _;for((y=y||f.length)>f.length&&(y=f.length),_=y-1;0<=_&&(192&f[_])==128;)_--;return _<0||_===0?y:_+c[f[_]]>y?_:y}},{"./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 y=u;y>>8^p[255&(l^i[y])];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,y=4,_=0,b=-2,w=-1,j=4,N=2,S=8,T=9,I=286,L=30,R=19,$=2*I+1,q=15,U=3,V=258,X=V+U+1,se=42,ee=113,Q=1,de=2,re=3,ne=4;function le(pe,Je){return pe.msg=p[Je],Je}function he(pe){return(pe<<1)-(4pe.avail_out&&(lt=pe.avail_out),lt!==0&&(l.arraySet(pe.output,Je.pending_buf,Je.pending_out,lt,pe.next_out),pe.next_out+=lt,Je.pending_out+=lt,pe.total_out+=lt,pe.avail_out-=lt,Je.pending-=lt,Je.pending===0&&(Je.pending_out=0))}function je(pe,Je){i._tr_flush_block(pe,0<=pe.block_start?pe.block_start:-1,pe.strstart-pe.block_start,Je),pe.block_start=pe.strstart,ye(pe.strm)}function ke(pe,Je){pe.pending_buf[pe.pending++]=Je}function We(pe,Je){pe.pending_buf[pe.pending++]=Je>>>8&255,pe.pending_buf[pe.pending++]=255&Je}function be(pe,Je){var lt,rt,Se=pe.max_chain_length,it=pe.strstart,$e=pe.prev_length,ot=pe.nice_match,Ue=pe.strstart>pe.w_size-X?pe.strstart-(pe.w_size-X):0,Ke=pe.window,Xe=pe.w_mask,He=pe.prev,Ye=pe.strstart+V,tt=Ke[it+$e-1],Et=Ke[it+$e];pe.prev_length>=pe.good_match&&(Se>>=2),ot>pe.lookahead&&(ot=pe.lookahead);do if(Ke[(lt=Je)+$e]===Et&&Ke[lt+$e-1]===tt&&Ke[lt]===Ke[it]&&Ke[++lt]===Ke[it+1]){it+=2,lt++;do;while(Ke[++it]===Ke[++lt]&&Ke[++it]===Ke[++lt]&&Ke[++it]===Ke[++lt]&&Ke[++it]===Ke[++lt]&&Ke[++it]===Ke[++lt]&&Ke[++it]===Ke[++lt]&&Ke[++it]===Ke[++lt]&&Ke[++it]===Ke[++lt]&&itUe&&--Se!=0);return $e<=pe.lookahead?$e:pe.lookahead}function Me(pe){var Je,lt,rt,Se,it,$e,ot,Ue,Ke,Xe,He=pe.w_size;do{if(Se=pe.window_size-pe.lookahead-pe.strstart,pe.strstart>=He+(He-X)){for(l.arraySet(pe.window,pe.window,He,He,0),pe.match_start-=He,pe.strstart-=He,pe.block_start-=He,Je=lt=pe.hash_size;rt=pe.head[--Je],pe.head[Je]=He<=rt?rt-He:0,--lt;);for(Je=lt=He;rt=pe.prev[--Je],pe.prev[Je]=He<=rt?rt-He:0,--lt;);Se+=He}if(pe.strm.avail_in===0)break;if($e=pe.strm,ot=pe.window,Ue=pe.strstart+pe.lookahead,Ke=Se,Xe=void 0,Xe=$e.avail_in,Ke=U)for(it=pe.strstart-pe.insert,pe.ins_h=pe.window[it],pe.ins_h=(pe.ins_h<=U&&(pe.ins_h=(pe.ins_h<=U)if(rt=i._tr_tally(pe,pe.strstart-pe.match_start,pe.match_length-U),pe.lookahead-=pe.match_length,pe.match_length<=pe.max_lazy_match&&pe.lookahead>=U){for(pe.match_length--;pe.strstart++,pe.ins_h=(pe.ins_h<=U&&(pe.ins_h=(pe.ins_h<=U&&pe.match_length<=pe.prev_length){for(Se=pe.strstart+pe.lookahead-U,rt=i._tr_tally(pe,pe.strstart-1-pe.prev_match,pe.prev_length-U),pe.lookahead-=pe.prev_length-1,pe.prev_length-=2;++pe.strstart<=Se&&(pe.ins_h=(pe.ins_h<pe.pending_buf_size-5&&(lt=pe.pending_buf_size-5);;){if(pe.lookahead<=1){if(Me(pe),pe.lookahead===0&&Je===f)return Q;if(pe.lookahead===0)break}pe.strstart+=pe.lookahead,pe.lookahead=0;var rt=pe.block_start+lt;if((pe.strstart===0||pe.strstart>=rt)&&(pe.lookahead=pe.strstart-rt,pe.strstart=rt,je(pe,!1),pe.strm.avail_out===0)||pe.strstart-pe.block_start>=pe.w_size-X&&(je(pe,!1),pe.strm.avail_out===0))return Q}return pe.insert=0,Je===y?(je(pe,!0),pe.strm.avail_out===0?re:ne):(pe.strstart>pe.block_start&&(je(pe,!1),pe.strm.avail_out),Q)}),new Te(4,4,8,4,Ae),new Te(4,5,16,8,Ae),new Te(4,6,32,32,Ae),new Te(4,4,16,16,Re),new Te(8,16,32,32,Re),new Te(8,16,128,128,Re),new Te(8,32,128,256,Re),new Te(32,128,258,1024,Re),new Te(32,258,258,4096,Re)],a.deflateInit=function(pe,Je){return Rt(pe,Je,S,15,8,0)},a.deflateInit2=Rt,a.deflateReset=De,a.deflateResetKeep=ct,a.deflateSetHeader=function(pe,Je){return pe&&pe.state?pe.state.wrap!==2?b:(pe.state.gzhead=Je,_):b},a.deflate=function(pe,Je){var lt,rt,Se,it;if(!pe||!pe.state||5>8&255),ke(rt,rt.gzhead.time>>16&255),ke(rt,rt.gzhead.time>>24&255),ke(rt,rt.level===9?2:2<=rt.strategy||rt.level<2?4:0),ke(rt,255&rt.gzhead.os),rt.gzhead.extra&&rt.gzhead.extra.length&&(ke(rt,255&rt.gzhead.extra.length),ke(rt,rt.gzhead.extra.length>>8&255)),rt.gzhead.hcrc&&(pe.adler=u(pe.adler,rt.pending_buf,rt.pending,0)),rt.gzindex=0,rt.status=69):(ke(rt,0),ke(rt,0),ke(rt,0),ke(rt,0),ke(rt,0),ke(rt,rt.level===9?2:2<=rt.strategy||rt.level<2?4:0),ke(rt,3),rt.status=ee);else{var $e=S+(rt.w_bits-8<<4)<<8;$e|=(2<=rt.strategy||rt.level<2?0:rt.level<6?1:rt.level===6?2:3)<<6,rt.strstart!==0&&($e|=32),$e+=31-$e%31,rt.status=ee,We(rt,$e),rt.strstart!==0&&(We(rt,pe.adler>>>16),We(rt,65535&pe.adler)),pe.adler=1}if(rt.status===69)if(rt.gzhead.extra){for(Se=rt.pending;rt.gzindex<(65535&rt.gzhead.extra.length)&&(rt.pending!==rt.pending_buf_size||(rt.gzhead.hcrc&&rt.pending>Se&&(pe.adler=u(pe.adler,rt.pending_buf,rt.pending-Se,Se)),ye(pe),Se=rt.pending,rt.pending!==rt.pending_buf_size));)ke(rt,255&rt.gzhead.extra[rt.gzindex]),rt.gzindex++;rt.gzhead.hcrc&&rt.pending>Se&&(pe.adler=u(pe.adler,rt.pending_buf,rt.pending-Se,Se)),rt.gzindex===rt.gzhead.extra.length&&(rt.gzindex=0,rt.status=73)}else rt.status=73;if(rt.status===73)if(rt.gzhead.name){Se=rt.pending;do{if(rt.pending===rt.pending_buf_size&&(rt.gzhead.hcrc&&rt.pending>Se&&(pe.adler=u(pe.adler,rt.pending_buf,rt.pending-Se,Se)),ye(pe),Se=rt.pending,rt.pending===rt.pending_buf_size)){it=1;break}it=rt.gzindexSe&&(pe.adler=u(pe.adler,rt.pending_buf,rt.pending-Se,Se)),it===0&&(rt.gzindex=0,rt.status=91)}else rt.status=91;if(rt.status===91)if(rt.gzhead.comment){Se=rt.pending;do{if(rt.pending===rt.pending_buf_size&&(rt.gzhead.hcrc&&rt.pending>Se&&(pe.adler=u(pe.adler,rt.pending_buf,rt.pending-Se,Se)),ye(pe),Se=rt.pending,rt.pending===rt.pending_buf_size)){it=1;break}it=rt.gzindexSe&&(pe.adler=u(pe.adler,rt.pending_buf,rt.pending-Se,Se)),it===0&&(rt.status=103)}else rt.status=103;if(rt.status===103&&(rt.gzhead.hcrc?(rt.pending+2>rt.pending_buf_size&&ye(pe),rt.pending+2<=rt.pending_buf_size&&(ke(rt,255&pe.adler),ke(rt,pe.adler>>8&255),pe.adler=0,rt.status=ee)):rt.status=ee),rt.pending!==0){if(ye(pe),pe.avail_out===0)return rt.last_flush=-1,_}else if(pe.avail_in===0&&he(Je)<=he(lt)&&Je!==y)return le(pe,-5);if(rt.status===666&&pe.avail_in!==0)return le(pe,-5);if(pe.avail_in!==0||rt.lookahead!==0||Je!==f&&rt.status!==666){var ot=rt.strategy===2?function(Ue,Ke){for(var Xe;;){if(Ue.lookahead===0&&(Me(Ue),Ue.lookahead===0)){if(Ke===f)return Q;break}if(Ue.match_length=0,Xe=i._tr_tally(Ue,0,Ue.window[Ue.strstart]),Ue.lookahead--,Ue.strstart++,Xe&&(je(Ue,!1),Ue.strm.avail_out===0))return Q}return Ue.insert=0,Ke===y?(je(Ue,!0),Ue.strm.avail_out===0?re:ne):Ue.last_lit&&(je(Ue,!1),Ue.strm.avail_out===0)?Q:de}(rt,Je):rt.strategy===3?function(Ue,Ke){for(var Xe,He,Ye,tt,Et=Ue.window;;){if(Ue.lookahead<=V){if(Me(Ue),Ue.lookahead<=V&&Ke===f)return Q;if(Ue.lookahead===0)break}if(Ue.match_length=0,Ue.lookahead>=U&&0Ue.lookahead&&(Ue.match_length=Ue.lookahead)}if(Ue.match_length>=U?(Xe=i._tr_tally(Ue,1,Ue.match_length-U),Ue.lookahead-=Ue.match_length,Ue.strstart+=Ue.match_length,Ue.match_length=0):(Xe=i._tr_tally(Ue,0,Ue.window[Ue.strstart]),Ue.lookahead--,Ue.strstart++),Xe&&(je(Ue,!1),Ue.strm.avail_out===0))return Q}return Ue.insert=0,Ke===y?(je(Ue,!0),Ue.strm.avail_out===0?re:ne):Ue.last_lit&&(je(Ue,!1),Ue.strm.avail_out===0)?Q:de}(rt,Je):o[rt.level].func(rt,Je);if(ot!==re&&ot!==ne||(rt.status=666),ot===Q||ot===re)return pe.avail_out===0&&(rt.last_flush=-1),_;if(ot===de&&(Je===1?i._tr_align(rt):Je!==5&&(i._tr_stored_block(rt,0,0,!1),Je===3&&(we(rt.head),rt.lookahead===0&&(rt.strstart=0,rt.block_start=0,rt.insert=0))),ye(pe),pe.avail_out===0))return rt.last_flush=-1,_}return Je!==y?_:rt.wrap<=0?1:(rt.wrap===2?(ke(rt,255&pe.adler),ke(rt,pe.adler>>8&255),ke(rt,pe.adler>>16&255),ke(rt,pe.adler>>24&255),ke(rt,255&pe.total_in),ke(rt,pe.total_in>>8&255),ke(rt,pe.total_in>>16&255),ke(rt,pe.total_in>>24&255)):(We(rt,pe.adler>>>16),We(rt,65535&pe.adler)),ye(pe),0=lt.w_size&&(it===0&&(we(lt.head),lt.strstart=0,lt.block_start=0,lt.insert=0),Ke=new l.Buf8(lt.w_size),l.arraySet(Ke,Je,Xe-lt.w_size,lt.w_size,0),Je=Ke,Xe=lt.w_size),$e=pe.avail_in,ot=pe.next_in,Ue=pe.input,pe.avail_in=Xe,pe.next_in=0,pe.input=Je,Me(lt);lt.lookahead>=U;){for(rt=lt.strstart,Se=lt.lookahead-(U-1);lt.ins_h=(lt.ins_h<>>=U=q>>>24,T-=U,(U=q>>>16&255)===0)de[p++]=65535&q;else{if(!(16&U)){if(!(64&U)){q=I[(65535&q)+(S&(1<>>=U,T-=U),T<15&&(S+=Q[c++]<>>=U=q>>>24,T-=U,!(16&(U=q>>>16&255))){if(!(64&U)){q=L[(65535&q)+(S&(1<>>=U,T-=U,(U=p-f)>3,S&=(1<<(T-=V<<3))-1,o.next_in=c,o.next_out=p,o.avail_in=c>>24&255)+(se>>>8&65280)+((65280&se)<<8)+((255&se)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function T(se){var ee;return se&&se.state?(ee=se.state,se.total_in=se.total_out=ee.total=0,se.msg="",ee.wrap&&(se.adler=1&ee.wrap),ee.mode=b,ee.last=0,ee.havedict=0,ee.dmax=32768,ee.head=null,ee.hold=0,ee.bits=0,ee.lencode=ee.lendyn=new o.Buf32(w),ee.distcode=ee.distdyn=new o.Buf32(j),ee.sane=1,ee.back=-1,y):_}function I(se){var ee;return se&&se.state?((ee=se.state).wsize=0,ee.whave=0,ee.wnext=0,T(se)):_}function L(se,ee){var Q,de;return se&&se.state?(de=se.state,ee<0?(Q=0,ee=-ee):(Q=1+(ee>>4),ee<48&&(ee&=15)),ee&&(ee<8||15=ne.wsize?(o.arraySet(ne.window,ee,Q-ne.wsize,ne.wsize,0),ne.wnext=0,ne.whave=ne.wsize):(de<(re=ne.wsize-ne.wnext)&&(re=de),o.arraySet(ne.window,ee,Q-de,re,ne.wnext),(de-=re)?(o.arraySet(ne.window,ee,Q-de,de,0),ne.wnext=de,ne.whave=ne.wsize):(ne.wnext+=re,ne.wnext===ne.wsize&&(ne.wnext=0),ne.whave>>8&255,Q.check=i(Q.check,it,2,0),je=ye=0,Q.mode=2;break}if(Q.flags=0,Q.head&&(Q.head.done=!1),!(1&Q.wrap)||(((255&ye)<<8)+(ye>>8))%31){se.msg="incorrect header check",Q.mode=30;break}if((15&ye)!=8){se.msg="unknown compression method",Q.mode=30;break}if(je-=4,pe=8+(15&(ye>>>=4)),Q.wbits===0)Q.wbits=pe;else if(pe>Q.wbits){se.msg="invalid window size",Q.mode=30;break}Q.dmax=1<>8&1),512&Q.flags&&(it[0]=255&ye,it[1]=ye>>>8&255,Q.check=i(Q.check,it,2,0)),je=ye=0,Q.mode=3;case 3:for(;je<32;){if(he===0)break e;he--,ye+=de[ne++]<>>8&255,it[2]=ye>>>16&255,it[3]=ye>>>24&255,Q.check=i(Q.check,it,4,0)),je=ye=0,Q.mode=4;case 4:for(;je<16;){if(he===0)break e;he--,ye+=de[ne++]<>8),512&Q.flags&&(it[0]=255&ye,it[1]=ye>>>8&255,Q.check=i(Q.check,it,2,0)),je=ye=0,Q.mode=5;case 5:if(1024&Q.flags){for(;je<16;){if(he===0)break e;he--,ye+=de[ne++]<>>8&255,Q.check=i(Q.check,it,2,0)),je=ye=0}else Q.head&&(Q.head.extra=null);Q.mode=6;case 6:if(1024&Q.flags&&(he<(be=Q.length)&&(be=he),be&&(Q.head&&(pe=Q.head.extra_len-Q.length,Q.head.extra||(Q.head.extra=new Array(Q.head.extra_len)),o.arraySet(Q.head.extra,de,ne,be,pe)),512&Q.flags&&(Q.check=i(Q.check,de,be,ne)),he-=be,ne+=be,Q.length-=be),Q.length))break e;Q.length=0,Q.mode=7;case 7:if(2048&Q.flags){if(he===0)break e;for(be=0;pe=de[ne+be++],Q.head&&pe&&Q.length<65536&&(Q.head.name+=String.fromCharCode(pe)),pe&&be>9&1,Q.head.done=!0),se.adler=Q.check=0,Q.mode=12;break;case 10:for(;je<32;){if(he===0)break e;he--,ye+=de[ne++]<>>=7&je,je-=7&je,Q.mode=27;break}for(;je<3;){if(he===0)break e;he--,ye+=de[ne++]<>>=1)){case 0:Q.mode=14;break;case 1:if(V(Q),Q.mode=20,ee!==6)break;ye>>>=2,je-=2;break e;case 2:Q.mode=17;break;case 3:se.msg="invalid block type",Q.mode=30}ye>>>=2,je-=2;break;case 14:for(ye>>>=7&je,je-=7&je;je<32;){if(he===0)break e;he--,ye+=de[ne++]<>>16^65535)){se.msg="invalid stored block lengths",Q.mode=30;break}if(Q.length=65535&ye,je=ye=0,Q.mode=15,ee===6)break e;case 15:Q.mode=16;case 16:if(be=Q.length){if(he>>=5,je-=5,Q.ndist=1+(31&ye),ye>>>=5,je-=5,Q.ncode=4+(15&ye),ye>>>=4,je-=4,286>>=3,je-=3}for(;Q.have<19;)Q.lens[$e[Q.have++]]=0;if(Q.lencode=Q.lendyn,Q.lenbits=7,lt={bits:Q.lenbits},Je=u(0,Q.lens,0,19,Q.lencode,0,Q.work,lt),Q.lenbits=lt.bits,Je){se.msg="invalid code lengths set",Q.mode=30;break}Q.have=0,Q.mode=19;case 19:for(;Q.have>>16&255,qe=65535&Se,!((Re=Se>>>24)<=je);){if(he===0)break e;he--,ye+=de[ne++]<>>=Re,je-=Re,Q.lens[Q.have++]=qe;else{if(qe===16){for(rt=Re+2;je>>=Re,je-=Re,Q.have===0){se.msg="invalid bit length repeat",Q.mode=30;break}pe=Q.lens[Q.have-1],be=3+(3&ye),ye>>>=2,je-=2}else if(qe===17){for(rt=Re+3;je>>=Re)),ye>>>=3,je-=3}else{for(rt=Re+7;je>>=Re)),ye>>>=7,je-=7}if(Q.have+be>Q.nlen+Q.ndist){se.msg="invalid bit length repeat",Q.mode=30;break}for(;be--;)Q.lens[Q.have++]=pe}}if(Q.mode===30)break;if(Q.lens[256]===0){se.msg="invalid code -- missing end-of-block",Q.mode=30;break}if(Q.lenbits=9,lt={bits:Q.lenbits},Je=u(p,Q.lens,0,Q.nlen,Q.lencode,0,Q.work,lt),Q.lenbits=lt.bits,Je){se.msg="invalid literal/lengths set",Q.mode=30;break}if(Q.distbits=6,Q.distcode=Q.distdyn,lt={bits:Q.distbits},Je=u(f,Q.lens,Q.nlen,Q.ndist,Q.distcode,0,Q.work,lt),Q.distbits=lt.bits,Je){se.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<=he&&258<=we){se.next_out=le,se.avail_out=we,se.next_in=ne,se.avail_in=he,Q.hold=ye,Q.bits=je,c(se,We),le=se.next_out,re=se.output,we=se.avail_out,ne=se.next_in,de=se.input,he=se.avail_in,ye=Q.hold,je=Q.bits,Q.mode===12&&(Q.back=-1);break}for(Q.back=0;Te=(Se=Q.lencode[ye&(1<>>16&255,qe=65535&Se,!((Re=Se>>>24)<=je);){if(he===0)break e;he--,ye+=de[ne++]<>ct)])>>>16&255,qe=65535&Se,!(ct+(Re=Se>>>24)<=je);){if(he===0)break e;he--,ye+=de[ne++]<>>=ct,je-=ct,Q.back+=ct}if(ye>>>=Re,je-=Re,Q.back+=Re,Q.length=qe,Te===0){Q.mode=26;break}if(32&Te){Q.back=-1,Q.mode=12;break}if(64&Te){se.msg="invalid literal/length code",Q.mode=30;break}Q.extra=15&Te,Q.mode=22;case 22:if(Q.extra){for(rt=Q.extra;je>>=Q.extra,je-=Q.extra,Q.back+=Q.extra}Q.was=Q.length,Q.mode=23;case 23:for(;Te=(Se=Q.distcode[ye&(1<>>16&255,qe=65535&Se,!((Re=Se>>>24)<=je);){if(he===0)break e;he--,ye+=de[ne++]<>ct)])>>>16&255,qe=65535&Se,!(ct+(Re=Se>>>24)<=je);){if(he===0)break e;he--,ye+=de[ne++]<>>=ct,je-=ct,Q.back+=ct}if(ye>>>=Re,je-=Re,Q.back+=Re,64&Te){se.msg="invalid distance code",Q.mode=30;break}Q.offset=qe,Q.extra=15&Te,Q.mode=24;case 24:if(Q.extra){for(rt=Q.extra;je>>=Q.extra,je-=Q.extra,Q.back+=Q.extra}if(Q.offset>Q.dmax){se.msg="invalid distance too far back",Q.mode=30;break}Q.mode=25;case 25:if(we===0)break e;if(be=We-we,Q.offset>be){if((be=Q.offset-be)>Q.whave&&Q.sane){se.msg="invalid distance too far back",Q.mode=30;break}Me=be>Q.wnext?(be-=Q.wnext,Q.wsize-be):Q.wnext-be,be>Q.length&&(be=Q.length),Ae=Q.window}else Ae=re,Me=le-Q.offset,be=Q.length;for(we$?(U=Me[Ae+j[ee]],je[ke+j[ee]]):(U=96,0),S=1<>le)+(T-=S)]=q<<24|U<<16|V|0,T!==0;);for(S=1<>=1;if(S!==0?(ye&=S-1,ye+=S):ye=0,ee++,--We[se]==0){if(se===de)break;se=f[y+j[ee]]}if(re>>7)]}function ke(Se,it){Se.pending_buf[Se.pending++]=255&it,Se.pending_buf[Se.pending++]=it>>>8&255}function We(Se,it,$e){Se.bi_valid>N-$e?(Se.bi_buf|=it<>N-Se.bi_valid,Se.bi_valid+=$e-N):(Se.bi_buf|=it<>>=1,$e<<=1,0<--it;);return $e>>>1}function Ae(Se,it,$e){var ot,Ue,Ke=new Array(j+1),Xe=0;for(ot=1;ot<=j;ot++)Ke[ot]=Xe=Xe+$e[ot-1]<<1;for(Ue=0;Ue<=it;Ue++){var He=Se[2*Ue+1];He!==0&&(Se[2*Ue]=Me(Ke[He]++,He))}}function Re(Se){var it;for(it=0;it>1;1<=$e;$e--)ct(Se,Ke,$e);for(Ue=Ye;$e=Se.heap[1],Se.heap[1]=Se.heap[Se.heap_len--],ct(Se,Ke,1),ot=Se.heap[1],Se.heap[--Se.heap_max]=$e,Se.heap[--Se.heap_max]=ot,Ke[2*Ue]=Ke[2*$e]+Ke[2*ot],Se.depth[Ue]=(Se.depth[$e]>=Se.depth[ot]?Se.depth[$e]:Se.depth[ot])+1,Ke[2*$e+1]=Ke[2*ot+1]=Ue,Se.heap[1]=Ue++,ct(Se,Ke,1),2<=Se.heap_len;);Se.heap[--Se.heap_max]=Se.heap[1],function(Et,qt){var ms,Xt,rs,ps,Ms,jt,As=qt.dyn_tree,Ps=qt.max_code,ar=qt.stat_desc.static_tree,Dn=qt.stat_desc.has_stree,Va=qt.stat_desc.extra_bits,pa=qt.stat_desc.extra_base,qa=qt.stat_desc.max_length,Kr=0;for(ps=0;ps<=j;ps++)Et.bl_count[ps]=0;for(As[2*Et.heap[Et.heap_max]+1]=0,ms=Et.heap_max+1;ms>=7;Ue<_;Ue++)for(he[Ue]=Ke<<7,it=0;it<1<>>=1)if(1&tt&&He.dyn_ltree[2*Ye]!==0)return l;if(He.dyn_ltree[18]!==0||He.dyn_ltree[20]!==0||He.dyn_ltree[26]!==0)return i;for(Ye=32;Ye>>3,(Ke=Se.static_len+3+7>>>3)<=Ue&&(Ue=Ke)):Ue=Ke=$e+5,$e+4<=Ue&&it!==-1?rt(Se,it,$e,ot):Se.strategy===4||Ke===Ue?(We(Se,2+(ot?1:0),3),De(Se,X,se)):(We(Se,4+(ot?1:0),3),function(He,Ye,tt,Et){var qt;for(We(He,Ye-257,5),We(He,tt-1,5),We(He,Et-4,4),qt=0;qt>>8&255,Se.pending_buf[Se.d_buf+2*Se.last_lit+1]=255&it,Se.pending_buf[Se.l_buf+Se.last_lit]=255&$e,Se.last_lit++,it===0?Se.dyn_ltree[2*$e]++:(Se.matches++,it--,Se.dyn_ltree[2*(Q[$e]+f+1)]++,Se.dyn_dtree[2*je(it)]++),Se.last_lit===Se.lit_bufsize-1},a._tr_align=function(Se){We(Se,2,3),be(Se,T,X),function(it){it.bi_valid===16?(ke(it,it.bi_buf),it.bi_buf=0,it.bi_valid=0):8<=it.bi_valid&&(it.pending_buf[it.pending++]=255&it.bi_buf,it.bi_buf>>=8,it.bi_valid-=8)}(Se)}},{"../utils/common":41}],53:[function(r,n,a){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(r,n,a){(function(o){(function(l,i){if(!l.setImmediate){var c,u,p,f,y=1,_={},b=!1,w=l.document,j=Object.getPrototypeOf&&Object.getPrototypeOf(l);j=j&&j.setTimeout?j:l,c={}.toString.call(l.process)==="[object process]"?function(I){process.nextTick(function(){S(I)})}:function(){if(l.postMessage&&!l.importScripts){var I=!0,L=l.onmessage;return l.onmessage=function(){I=!1},l.postMessage("","*"),l.onmessage=L,I}}()?(f="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",T,!1):l.attachEvent("onmessage",T),function(I){l.postMessage(f+I,"*")}):l.MessageChannel?((p=new MessageChannel).port1.onmessage=function(I){S(I.data)},function(I){p.port2.postMessage(I)}):w&&"onreadystatechange"in w.createElement("script")?(u=w.documentElement,function(I){var L=w.createElement("script");L.onreadystatechange=function(){S(I),L.onreadystatechange=null,u.removeChild(L),L=null},u.appendChild(L)}):function(I){setTimeout(S,0,I)},j.setImmediate=function(I){typeof I!="function"&&(I=new Function(""+I));for(var L=new Array(arguments.length-1),R=0;R"u"?o===void 0?this:o:self)}).call(this,typeof Fv<"u"?Fv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(xet);var _qt=xet.exports;const bqt=Co(_qt);function vxe(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 wqt=()=>{const{isAdmin:t}=Ws(),[s,r]=C.useState(null),[n,a]=C.useState(null),[o,l]=C.useState("all"),[i,c]=C.useState(new Set),[u,p]=C.useState(!1),[f,y]=C.useState(!1),[_,b]=C.useState("images"),[w,j]=C.useState(null),{data:N=[],isLoading:S}=wt({queryKey:["social-swag-2"],queryFn:async()=>{const{data:he,error:we}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(we)throw we;return he}}),{data:T=[]}=wt({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:he,error:we}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(we)throw we;return he}}),{data:I=[]}=wt({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:he,error:we}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(we)throw we;return he}}),{data:L=[]}=wt({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:he,error:we}=await G.from("social_accounts").select("id, platform").eq("is_active",!0);if(we)throw we;return he||[]}}),R=L.length>0,$=C.useMemo(()=>o==="all"?null:I.find(he=>he.month===o)||null,[o,I]),q=C.useMemo(()=>[...new Set(N.map(we=>we.month))].sort((we,ye)=>ye.localeCompare(we)),[N]);C.useEffect(()=>{q.length>0&&o==="all"&&l(q[0])},[q,o]);const U=he=>{try{const we=oje(he,"yyyy-MM",new Date);return ys(we,"MMMM yyyy")}catch{return he}},V=C.useMemo(()=>o==="all"?N:N.filter(he=>he.month===o),[o,N]),X=C.useMemo(()=>{var he;return o==="all"?null:((he=T.find(we=>we.month===o))==null?void 0:he.canva_link)||null},[o,T]),se=async he=>{try{await navigator.clipboard.writeText(he),me.success("Caption copied to clipboard!")}catch{me.error("Failed to copy caption")}},ee=async(he,we)=>{try{const je=await(await fetch(he)).blob(),ke=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),We=navigator.canShare&&navigator.canShare({files:[new File([je],"test.jpg",{type:"image/jpeg"})]});if(ke&&We){const be=new File([je],`social-swag-${we}.jpg`,{type:"image/jpeg"});await navigator.share({files:[be],title:"Social Swag Image"}),me.success("Image ready to save!")}else{const be=window.URL.createObjectURL(je),Me=document.createElement("a");Me.href=be,Me.download=`social-swag-${we}.jpg`,document.body.appendChild(Me),Me.click(),document.body.removeChild(Me),window.URL.revokeObjectURL(be),me.success("Image downloaded!")}}catch(ye){ye.name!=="AbortError"&&me.error("Failed to download image")}},Q=he=>{c(we=>{const ye=new Set(we);return ye.has(he)?ye.delete(he):ye.add(he),ye})},de=()=>{c(new Set(V.map(he=>he.id)))},re=()=>{c(new Set),p(!1)},ne=async()=>{const he=V.filter(we=>i.has(we.id));if(he.length===0){me.error("No images selected");return}y(!0),me.info(`Preparing ${he.length} images for download...`);try{const we=new bqt,ye=[...he].sort((Me,Ae)=>Me.sort_order-Ae.sort_order);for(let Me=0;Me{u?Q(he.id):r(he)};return e.jsx(Es,{title:"Social Swag 2.0",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary via-primary/80 to-info p-8 text-primary-foreground",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzMiAyIDIgNC0yIDQtMiA0LTItMi0yLTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsxs(nt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(hn,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(nt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(cl,{className:"h-3 w-3 mr-1"}),N.length," images"]})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3",children:"Social Swag 📸"}),e.jsx("p",{className:"text-lg text-primary-foreground/90 max-w-2xl",children:"Ready-to-post social media images delivered to you monthly. Just download, copy the caption, and share with your audience!"})]})]}),t?e.jsxs(Aa,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(ja,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(js,{value:"gallery",className:"gap-2",children:[e.jsx(cl,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(js,{value:"scheduled",className:"gap-2",children:[e.jsx(Md,{className:"h-4 w-4"}),"Scheduled"]})]}),e.jsxs($s,{value:"gallery",className:"space-y-6",children:[t?R?e.jsx(Ee,{className:"border rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-muted text-2xl",children:"📸"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Ready to post!"}),e.jsx("p",{className:"text-muted-foreground",children:'Click any image and use "Create Post" to share directly to your connected accounts.'})]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:e.jsx(So,{to:"/social-connections",children:"Manage Accounts"})})]})})}):e.jsx(Ee,{className:"border-2 border-dashed border-primary/30 bg-gradient-to-r from-pink-500/5 via-purple-500/5 to-blue-500/5 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(xu,{className:"h-5 w-5 text-blue-600"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(yu,{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(So,{to:"/social-connections",children:[e.jsx(sl,{className:"h-4 w-4"}),"Connect Accounts"]})})]})})}):e.jsx(Ee,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(Tn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(xu,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(yu,{className:"h-5 w-5 text-pink-400"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),e.jsx(nt,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(he=>e.jsx("button",{onClick:()=>l(he),className:At("px-4 py-2 rounded-full text-sm font-medium transition-all",o===he?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:U(he)},he))}),o!=="all"&&(X?e.jsxs("a",{href:X,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",U(o)," Images in Canva"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",U(o)," Images in Canva"]}))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[e.jsxs("button",{onClick:()=>{b("images"),re()},className:At("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(cl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),re()},className:At("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Fu,{className:"h-4 w-4"}),"Reels"]})]}),_==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:de,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:re,className:"gap-2",children:[e.jsx(Ur,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(K,{size:"sm",onClick:ne,disabled:f,className:"gap-2",children:[e.jsx(ki,{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(ma,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&_==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(he=>{const we=i.has(he.id);return e.jsx(Ee,{className:At("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&we&&"ring-2 ring-primary ring-offset-2"),onClick:()=>le(he),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:vxe(he.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"}),he.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:ys(new Date(he.post_date+"T00:00:00"),"MMM d")})}),u&&e.jsx("div",{className:At("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",we?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:we&&e.jsx(ma,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},he.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(cl,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&_==="reels"&&e.jsx(e.Fragment,{children:$?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Ee,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a($),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:vxe($.image_url,400,75),alt:"Reel preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105",loading:"lazy",decoding:"async"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(nt,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(Fu,{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(Fu,{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(_s,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(vs,{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:vxe(s.image_url,900,85),alt:"Social swag",className:"w-full h-full object-cover",decoding:"async"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground mb-4",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(on,{className:"h-4 w-4"}),ys(new Date(s.created_at),"MMMM d, yyyy")]}),s.post_date&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium rounded-full px-3 py-1 text-xs text-white",style:{background:"#406E71"},children:[e.jsx(on,{className:"h-3.5 w-3.5"}),"Post on ",ys(new Date(s.post_date+"T00:00:00"),"MMMM d, yyyy")]})]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col gap-3 mt-6",children:[t&&e.jsxs(K,{onClick:()=>{j({imageUrl:s.image_url,imageId:s.id,caption:s.caption})},className:"w-full gap-2 bg-gradient-to-r from-pink-500 via-purple-500 to-blue-500 hover:from-pink-600 hover:via-purple-600 hover:to-blue-600 text-white",children:[e.jsx(oa,{className:"h-4 w-4"}),"Create Post"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(K,{variant:"outline",onClick:()=>se(s.caption),className:"flex-1 gap-2",children:[e.jsx(mi,{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(ki,{className:"h-4 w-4"}),"Download"]})]})]})]})]})})})}),e.jsx(_s,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(vs,{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(Fu,{className:"h-4 w-4"}),"Monthly Reel"]}),n.caption&&e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[n.caption&&e.jsxs(K,{onClick:()=>se(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(mi,{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(rn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(yqt,{open:!!w,onOpenChange:he=>!he&&j(null),imageUrl:(w==null?void 0:w.imageUrl)||"",imageId:(w==null?void 0:w.imageId)||"",defaultCaption:(w==null?void 0:w.caption)||"",swagItemId:w==null?void 0:w.imageId})]}),e.jsx($s,{value:"scheduled",children:e.jsx(vqt,{})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-2 rounded-full bg-muted",children:e.jsx(Tn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(xu,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(yu,{className:"h-5 w-5 text-pink-400"})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),e.jsx(nt,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Soon you'll be able to connect your Facebook & Instagram accounts to post images with one click!"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(he=>e.jsx("button",{onClick:()=>l(he),className:At("px-4 py-2 rounded-full text-sm font-medium transition-all",o===he?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:U(he)},he))}),o!=="all"&&(X?e.jsxs("a",{href:X,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",U(o)," Images in Canva"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[e.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",U(o)," Images in Canva"]}))]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[e.jsxs("button",{onClick:()=>{b("images"),re()},className:At("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(cl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{b("reels"),re()},className:At("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",_==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(Fu,{className:"h-4 w-4"}),"Reels"]})]}),_==="images"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:u?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:de,className:"gap-2",children:["Select All (",V.length,")"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:re,className:"gap-2",children:[e.jsx(Ur,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(K,{size:"sm",onClick:ne,disabled:f,className:"gap-2",children:[e.jsx(ki,{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(ma,{className:"h-4 w-4"}),"Select Images"]})})]}),S&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!S&&_==="images"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:V.map(he=>{const we=i.has(he.id);return e.jsx(Ee,{className:At("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&we&&"ring-2 ring-primary ring-offset-2"),onClick:()=>le(he),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:he.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:At("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",we?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:we&&e.jsx(ma,{className:"h-4 w-4"})}),!u&&e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:e.jsx("span",{className:"text-white font-medium opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-primary px-4 py-2 rounded-full text-sm",children:"View Details"})})]})},he.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(cl,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!S&&_==="reels"&&e.jsx(e.Fragment,{children:$?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4",children:e.jsx(Ee,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a($),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:$.image_url,alt:"Reel preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs(nt,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(Fu,{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(Fu,{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(_s,{open:!!s,onOpenChange:()=>r(null),children:e.jsx(vs,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:e.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:s&&e.jsxs("div",{className:"flex flex-col md:flex-row",children:[e.jsx("div",{className:"md:w-1/2 bg-muted",children:e.jsx("div",{className:"aspect-[4/5]",children:e.jsx("img",{src:s.image_url,alt:"Social swag",className:"w-full h-full object-cover"})})}),e.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[e.jsx(on,{className:"h-4 w-4"}),ys(new Date(s.created_at),"MMMM d, yyyy")]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:s.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[e.jsxs(K,{variant:"outline",onClick:()=>se(s.caption),className:"flex-1 gap-2",children:[e.jsx(mi,{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(ki,{className:"h-4 w-4"}),"Download"]})]})]})]})})})}),e.jsx(_s,{open:!!n,onOpenChange:()=>a(null),children:e.jsx(vs,{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(Fu,{className:"h-4 w-4"}),"Monthly Reel"]}),n.caption&&e.jsxs("div",{className:"flex-1 min-h-0",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.caption})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[n.caption&&e.jsxs(K,{onClick:()=>se(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(mi,{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(rn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},jqt=()=>{const{swagId:t}=Po(),{user:s}=Ws(),{toast:r}=Ra(),n=ss(),{trackEngagement:a}=SO(),[o,l]=C.useState(""),{data:i,isLoading:c}=wt({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:N,error:S}=await G.from("social_swag").select("*").eq("id",t).single();if(S)throw S;const{data:T}=await G.from("social_swag_links").select("*").eq("swag_id",t).order("sort_order");return{...N,links:T||[]}},enabled:!!t});C.useEffect(()=>{i&&a("social_swag",i.id,i.title,"view")},[i==null?void 0:i.id]);const{data:u=[]}=wt({queryKey:["social-swag-likes",t],queryFn:async()=>{const{data:N,error:S}=await G.from("social_swag_likes").select("*").eq("swag_id",t);if(S)throw S;return N},enabled:!!t}),{data:p=[]}=wt({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:N,error:S}=await G.from("social_swag_comments").select("*").eq("swag_id",t).order("created_at",{ascending:!1});if(S)throw S;const T=[...new Set(N.map(R=>R.user_id))],{data:I}=await G.from("profiles").select("id, name").in("id",T),L=new Map((I==null?void 0:I.map(R=>[R.id,R.name]))||[]);return N.map(R=>({...R,user_name:L.get(R.user_id)||"Unknown User"}))},enabled:!!t}),f=Dt({mutationFn:async N=>{const{error:S}=await G.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:N});if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),l(""),r({title:"Comment added!"})},onError:N=>{r({title:"Error adding comment",description:N.message,variant:"destructive"})}}),y=Dt({mutationFn:async N=>{const{error:S}=await G.from("social_swag_comments").delete().eq("id",N);if(S)throw S},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),_=Dt({mutationFn:async()=>{const N=u.find(S=>S.user_id===(s==null?void 0:s.id));if(N){const{error:S}=await G.from("social_swag_likes").delete().eq("id",N.id);if(S)throw S}else{const{error:S}=await G.from("social_swag_likes").insert({swag_id:t,user_id:s.id});if(S)throw S}},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-likes",t]})}}),b=u.some(N=>N.user_id===(s==null?void 0:s.id)),w=N=>N.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),j=N=>{N.preventDefault(),!(!o.trim()||!s)&&f.mutate(o.trim())};return c?e.jsx(Es,{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(Es,{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(So,{to:"/social-swag",children:[e.jsx(di,{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(qA,{resourceType:"social_swag",resourceId:i.id,resourceTitle:i.title}),e.jsxs(K,{variant:b?"default":"outline",className:"gap-2 w-fit",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(Gu,{className:`h-4 w-4 ${b?"fill-current":""}`}),u.length," ",u.length===1?"Like":"Likes"]})]})]}),i.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:i.description}})]}),i.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Vo,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),e.jsx("div",{className:"grid gap-2",children:i.links.map(N=>e.jsxs(K,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{a("social_swag",i.id,i.title,"click_canva"),window.open(N.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:N.title}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground"})]},N.id))})]})}),e.jsx(Zl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(Ec,{className:"h-5 w-5"}),"Comments (",p.length,")"]}),s?e.jsxs("form",{onSubmit:j,className:"flex gap-2",children:[e.jsx(Ar,{placeholder:"Add a comment...",value:o,onChange:N=>l(N.target.value),className:"min-h-[80px] resize-none flex-1"}),e.jsx(K,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!o.trim()||f.isPending,children:e.jsx(oa,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),e.jsx("div",{className:"space-y-4",children:p.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):p.map(N=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(yn,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(vn,{className:"text-sm",children:w(N.user_name||"U")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium",children:N.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Yd(new Date(N.created_at),{addSuffix:!0})}),N.user_id===(s==null?void 0:s.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>y.mutate(N.id),children:e.jsx(jr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:N.content})]})]})})},N.id))})]})]})}):e.jsx(Es,{title:"Social Swag",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Vo,{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(So,{to:"/social-swag",children:"Back to Social Swag"})})]})})},kqt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=C.useState(!0),[i,c]=C.useState(!0),[u,p]=C.useState(!0),f=y=>y.split(" ").map(_=>_[0]).join("").toUpperCase().slice(0,2);return e.jsx("aside",{className:"w-64 shrink-0 hidden lg:block relative z-0",children:e.jsx("div",{className:"sticky top-4 space-y-4 max-h-[calc(100vh-8rem)] overflow-y-auto overscroll-contain",children:e.jsxs("div",{className:"space-y-2 pr-4",children:[e.jsxs(K,{variant:r==="all"?"secondary":"ghost",className:"w-full justify-start",onClick:()=>n("all"),children:[e.jsx(uM,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(bg,{open:o,onOpenChange:l,children:[e.jsx(wg,{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(tl,{className:"h-4 w-4"}):e.jsx(Xa,{className:"h-4 w-4"})]})}),e.jsx(jg,{className:"space-y-1 pl-2",children:t.map(y=>e.jsxs(K,{variant:r===y.id?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(y.id),children:[e.jsx("span",{className:"mr-2",children:y.icon||"📂"}),e.jsx("span",{className:"truncate",children:y.name})]},y.id))})]}),s.length>0&&e.jsxs(bg,{open:i,onOpenChange:c,children:[e.jsx(wg,{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(vh,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(tl,{className:"h-4 w-4"}):e.jsx(Xa,{className:"h-4 w-4"})]})}),e.jsx(jg,{className:"space-y-1 pl-2",children:s.map(y=>e.jsxs(K,{variant:r===`group:${y.id}`?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(`group:${y.id}`),children:[e.jsx("span",{className:"mr-2",children:y.icon||"🔒"}),e.jsx("span",{className:"truncate",children:y.name})]},y.id))})]}),e.jsxs(bg,{open:u,onOpenChange:p,children:[e.jsx(wg,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[e.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[e.jsx(mr,{className:"h-3 w-3"}),"Online Now",a.length>0&&e.jsx("span",{className:"ml-1 bg-green-500 text-white text-xs rounded-full px-1.5 py-0.5 min-w-[20px] text-center",children:a.length})]}),u?e.jsx(tl,{className:"h-4 w-4"}):e.jsx(Xa,{className:"h-4 w-4"})]})}),e.jsx(jg,{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(y=>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(yn,{className:"h-7 w-7",children:[e.jsx(Da,{src:y.avatarUrl}),e.jsx(vn,{className:"text-xs",children:f(y.name)})]}),e.jsx(pd,{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:y.name})]},y.id))})]})]})})})},Nqt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=C.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(y=>y.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(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:c()}),e.jsx(tl,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(Jd,{className:"w-56 bg-background border",children:[e.jsxs(Ta,{onClick:()=>n("all"),children:[e.jsx(uM,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(r2,{}),e.jsx(hve,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(u=>e.jsxs(Ta,{onClick:()=>n(u.id),children:[e.jsx("span",{className:"mr-2",children:u.icon||"📂"}),u.name]},u.id)),s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(r2,{}),e.jsxs(hve,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(vh,{className:"h-3 w-3"}),"Your Groups"]}),s.map(u=>e.jsxs(Ta,{onClick:()=>n(`group:${u.id}`),children:[e.jsx("span",{className:"mr-2",children:u.icon||"🔒"}),u.name]},u.id))]})]})]}),e.jsxs(DA,{open:o,onOpenChange:l,children:[e.jsx(Uje,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(mr,{className:"h-4 w-4"}),a.length>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-green-500 text-white text-xs rounded-full h-4 w-4 flex items-center justify-center",children:a.length})]})}),e.jsxs(YS,{children:[e.jsx(OA,{children:e.jsxs(RA,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(Vi,{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(yn,{className:"h-10 w-10",children:[e.jsx(Da,{src:u.avatarUrl}),e.jsx(vn,{children:i(u.name)})]}),e.jsx(pd,{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 _xe,Lue="HoverCard",[yet]=Yc(Lue,[M0]),Due=M0(),[Sqt,pNe]=yet(Lue),vet=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,c=Due(s),u=C.useRef(0),p=C.useRef(0),f=C.useRef(!1),y=C.useRef(!1),[_,b]=Yu({prop:n,defaultProp:a??!1,onChange:o,caller:Lue}),w=C.useCallback(()=>{clearTimeout(p.current),u.current=window.setTimeout(()=>b(!0),l)},[l,b]),j=C.useCallback(()=>{clearTimeout(u.current),!f.current&&!y.current&&(p.current=window.setTimeout(()=>b(!1),i))},[i,b]),N=C.useCallback(()=>b(!1),[b]);return C.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(p.current)},[]),e.jsx(Sqt,{scope:s,open:_,onOpenChange:b,onOpen:w,onClose:j,onDismiss:N,hasSelectionRef:f,isPointerDownOnContentRef:y,children:e.jsx(tO,{...c,children:r})})};vet.displayName=Lue;var _et="HoverCardTrigger",bet=C.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=pNe(_et,r),o=Due(r);return e.jsx(jA,{asChild:!0,...o,children:e.jsx(Jr.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Mr(t.onPointerEnter,Ele(a.onOpen)),onPointerLeave:Mr(t.onPointerLeave,Ele(a.onClose)),onFocus:Mr(t.onFocus,a.onOpen),onBlur:Mr(t.onBlur,a.onClose),onTouchStart:Mr(t.onTouchStart,l=>l.preventDefault())})})});bet.displayName=_et;var Cqt="HoverCardPortal",[C3s,Mqt]=yet(Cqt,{forceMount:void 0}),Ale="HoverCardContent",wet=C.forwardRef((t,s)=>{const r=Mqt(Ale,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=pNe(Ale,t.__scopeHoverCard);return e.jsx(Id,{present:n||o.open,children:e.jsx(Tqt,{"data-state":o.open?"open":"closed",...a,onPointerEnter:Mr(t.onPointerEnter,Ele(o.onOpen)),onPointerLeave:Mr(t.onPointerLeave,Ele(o.onClose)),ref:s})})});wet.displayName=Ale;var Tqt=C.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,c=pNe(Ale,r),u=Due(r),p=C.useRef(null),f=Oa(s,p),[y,_]=C.useState(!1);return C.useEffect(()=>{if(y){const b=document.body;return _xe=b.style.userSelect||b.style.webkitUserSelect,b.style.userSelect="none",b.style.webkitUserSelect="none",()=>{b.style.userSelect=_xe,b.style.webkitUserSelect=_xe}}},[y]),C.useEffect(()=>{if(p.current){const b=()=>{_(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var j;((j=document.getSelection())==null?void 0:j.toString())!==""&&(c.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",b),()=>{document.removeEventListener("pointerup",b),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),C.useEffect(()=>{p.current&&Pqt(p.current).forEach(w=>w.setAttribute("tabindex","-1"))}),e.jsx(g2,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Mr(o,b=>{b.preventDefault()}),onDismiss:c.onDismiss,children:e.jsx(sO,{...u,...i,onPointerDown:Mr(i.onPointerDown,b=>{b.currentTarget.contains(b.target)&&_(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:f,style:{...i.style,userSelect:y?"text":void 0,WebkitUserSelect:y?"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)"}})})}),Aqt="HoverCardArrow",Eqt=C.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Due(r);return e.jsx(rO,{...a,...n,ref:s})});Eqt.displayName=Aqt;function Ele(t){return s=>s.pointerType==="touch"?void 0:t()}function Pqt(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 Iqt=vet,Lqt=bet,jet=wet;const Dqt=Iqt,Oqt=Lqt,ket=C.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(jet,{ref:a,align:s,sideOffset:r,className:At("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}));ket.displayName=jet.displayName;const Rqt=[{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"}],Fqt=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),Net=({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(Dqt,{openDelay:200,closeDelay:100,children:[e.jsx(Oqt,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(ket,{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=Rqt.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(yn,{className:"h-6 w-6",children:[e.jsx(Da,{src:l.user_avatar||void 0}),e.jsx(vn,{className:"text-[10px]",children:Fqt(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 zqt({images:t,initialIndex:s=0,open:r,onOpenChange:n}){const[a,o]=C.useState(s),[l,i]=C.useState(!1);C.useEffect(()=>{r&&(o(s),i(!1))},[r,s]);const c=()=>{o(y=>y>0?y-1:t.length-1),i(!1)},u=()=>{o(y=>y{r&&(y.key==="ArrowLeft"&&c(),y.key==="ArrowRight"&&u(),y.key==="Escape"&&n(!1))},[r,t.length]);C.useEffect(()=>(window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)),[p]);const f=t[a];return e.jsx(_s,{open:r,onOpenChange:n,children:e.jsxs(vs,{className:"max-w-[95vw] max-h-[95vh] w-auto h-auto p-0 border-none bg-black/95 overflow-hidden",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 z-50 text-white hover:bg-white/20 h-10 w-10",onClick:()=>n(!1),children:e.jsx(Ur,{className:"h-6 w-6"})}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:c,children:e.jsx(Xl,{className:"h-8 w-8"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 z-50 text-white hover:bg-white/20 h-12 w-12",onClick:u,children:e.jsx(Xa,{className:"h-8 w-8"})})]}),t.length>1&&e.jsxs("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-50 text-white text-sm bg-black/50 px-3 py-1 rounded-full",children:[a+1," / ",t.length]}),(f==null?void 0:f.type)==="image"&&e.jsx(K,{variant:"ghost",size:"icon",className:"absolute top-2 left-2 z-50 text-white hover:bg-white/20 h-10 w-10",onClick:()=>i(!l),children:l?e.jsx(NM,{className:"h-5 w-5"}):e.jsx(Bb,{className:"h-5 w-5"})}),e.jsx("div",{className:At("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:y=>y.stopPropagation()}):e.jsx("img",{src:f==null?void 0:f.url,alt:"",className:At("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((y,_)=>e.jsx("button",{onClick:()=>{o(_),i(!1)},className:At("w-12 h-12 rounded overflow-hidden flex-shrink-0 border-2 transition-all",a===_?"border-white":"border-transparent opacity-60 hover:opacity-100"),children:y.type==="video"?e.jsx("video",{src:y.url,className:"w-full h-full object-cover"}):e.jsx("img",{src:y.url,alt:"",className:"w-full h-full object-cover"})},_))})]})})}const sz=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],Bqt=({commentId:t,reactions:s,currentUserId:r})=>{var u,p;const n=ss(),[a,o]=C.useState(!1),l=s.find(f=>f.user_id===r),i=Dt({mutationFn:async f=>{l?l.reaction_type===f?await G.from("community_comment_reactions").delete().eq("id",l.id):await G.from("community_comment_reactions").update({reaction_type:f}).eq("id",l.id):await G.from("community_comment_reactions").insert({comment_id:t,user_id:r,reaction_type:f})},onSuccess:()=>{n.invalidateQueries({queryKey:["community-posts"]}),o(!1)}}),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(Net,{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 y;return e.jsx("span",{className:"text-sm",children:(y=sz.find(_=>_.type===f))==null?void 0:y.emoji},f)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs(Lo,{open:a,onOpenChange:o,children:[e.jsx(Do,{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=sz.find(f=>f.type===l.reaction_type))==null?void 0:u.emoji," ",(p=sz.find(f=>f.type===l.reaction_type))==null?void 0:p.label]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ii,{className:"h-3 w-3"}),"Like"]})})}),e.jsx(Eo,{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:sz.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 fNe({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(So,{to:p?`/templates/${u}`:`/profile?user=${u}`,className:At("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(C.Fragment,{children:i},c))})}function Ple({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=C.useRef(null),f=C.useRef(null),[y,_]=C.useState(!1),[b,w]=C.useState("user"),[j,N]=C.useState(""),[S,T]=C.useState(null),[I,L]=C.useState(0),[R,$]=C.useState({top:0,left:0,width:0}),q=C.useRef(new Map),U=C.useRef(new Map),V=je=>{if(c==="plain"){const Me=[];return q.current.forEach((Re,Te)=>{je.includes(`@${Te}`)&&Me.push(Re)}),[...new Set(Me)]}const ke=/@\[([^\]]+)\]\(([^)]+)\)/g,We=[];let be;for(;(be=ke.exec(je))!==null;)We.push(be[2]);return[...new Set(We)]},X=je=>{if(c==="plain"){const Me=[];return U.current.forEach((Re,Te)=>{je.includes(`#${Te}`)&&Me.push(Re)}),[...new Set(Me)]}const ke=/#\[([^\]]+)\]\(([^)]+)\)/g,We=[];let be;for(;(be=ke.exec(je))!==null;)We.push(be[2]);return[...new Set(We)]};C.useEffect(()=>{if(o){const je=V(t);o(je)}if(l){const je=X(t);l(je)}},[t,o,l,c]);const{data:se=[],isLoading:ee}=wt({queryKey:["mention-users",j],queryFn:async()=>{const je=G.from("profiles").select("id, name").limit(8),ke=j.length>=1?je.ilike("name",`%${j}%`):je.order("name"),{data:We,error:be}=await ke;if(be)throw be;const Me=We.map(Re=>Re.id),Ae=await nZe(Me);return We.map(Re=>({id:Re.id,name:Re.name||"Unknown",avatar_url:Ae.get(Re.id)}))},enabled:y&&b==="user",staleTime:3e4}),{data:Q=[],isLoading:de}=wt({queryKey:["mention-templates",j],queryFn:async()=>{let je=G.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);j.length>=1&&(je=je.ilike("name",`%${j}%`));const{data:ke,error:We}=await je;if(We)throw We;return ke||[]},enabled:y&&b==="template"&&u,staleTime:3e4}),re=b==="user"?ee:de,ne=b==="user"?se:Q,le=je=>je.split(" ").map(ke=>ke[0]).join("").toUpperCase().slice(0,2),he=je=>{const ke=je.target.value,We=je.target.selectionStart;s(ke);const be=ke.substring(0,We),Me=be.lastIndexOf("@"),Ae=u?be.lastIndexOf("#"):-1;let Re=-1,Te="user";if(Me>Ae?(Re=Me,Te="user"):Ae>Me&&u&&(Re=Ae,Te="template"),Re!==-1){const qe=be.substring(Re+1),ct=qe.includes(" "),De=qe.includes(` `);if(!ct&&!De&&qe.length<=30){T(Re),N(qe),w(Te),_(!0),L(0);return}}_(!1),T(null)},we=je=>{if(S===null)return;const ke=t.substring(0,S),We=t.substring(S+j.length+1),be=b==="user"?"@":"#",Me=c==="plain"?`${be}${je.name} `:`${be}[${je.name}](${je.id}) `;c==="plain"&&(b==="user"?q.current.set(je.name,je.id):U.current.set(je.name,je.id));const Ae=ke+Me+We;s(Ae),_(!1),T(null),N(""),setTimeout(()=>{if(p.current){const Re=ke.length+Me.length;p.current.focus(),p.current.setSelectionRange(Re,Re)}},0)},ye=je=>{if(!(!y||ne.length===0))switch(je.key){case"ArrowDown":je.preventDefault(),L(ke=>(ke+1)%ne.length);break;case"ArrowUp":je.preventDefault(),L(ke=>(ke-1+ne.length)%ne.length);break;case"Enter":ne[I]&&(je.preventDefault(),we(ne[I]));break;case"Escape":je.preventDefault(),_(!1);break;case"Tab":ne[I]&&(je.preventDefault(),we(ne[I]));break}};return C.useEffect(()=>{const je=ke=>{f.current&&!f.current.contains(ke.target)&&p.current&&!p.current.contains(ke.target)&&_(!1)};return document.addEventListener("mousedown",je),()=>document.removeEventListener("mousedown",je)},[]),C.useEffect(()=>{if(!y)return;const je=()=>{const ke=p.current;if(!ke)return;const We=ke.getBoundingClientRect();$({top:We.bottom+4,left:We.left,width:We.width})};return je(),window.addEventListener("resize",je),window.addEventListener("scroll",je,!0),()=>{window.removeEventListener("resize",je),window.removeEventListener("scroll",je,!0)}},[y,t]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ar,{ref:p,value:t,onChange:he,onKeyDown:je=>{ye(je),je.defaultPrevented||i==null||i(je)},placeholder:r,className:At("resize-none",n),style:{minHeight:a}}),y&&cp.createPortal(e.jsxs("div",{ref:f,className:"fixed z-[1000] max-h-[220px] overflow-hidden rounded-lg border bg-popover shadow-lg",style:{top:R.top,left:R.left,width:R.width,maxWidth:"320px"},children:[e.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground border-b bg-muted/30",children:b==="user"?"👤 Mention a person":"📋 Link a template"}),re?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):ne.length===0?e.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:j.length<1?`Type to search ${b==="user"?"people":"templates"}...`:`No ${b==="user"?"users":"templates"} found`}):e.jsx("ul",{className:"py-1 max-h-[180px] overflow-y-auto",children:ne.map((je,ke)=>e.jsx("li",{className:At("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",ke===I?"bg-accent":"hover:bg-accent/50"),onClick:()=>we(je),onMouseEnter:()=>L(ke),children:b==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(yn,{className:"h-6 w-6",children:[e.jsx(Da,{src:je.avatar_url}),e.jsx(vn,{className:"text-xs",children:le(je.name)})]}),e.jsx("span",{className:"text-sm font-medium truncate",children:je.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:je.preview_image_url?e.jsx("img",{src:je.preview_image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(Ql,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate",children:je.name})]})},je.id))})]}),document.body)]})}function $qt(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const FLe=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function Cet({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=ss(),[c,u]=C.useState(!1),[p,f]=C.useState(""),[y,_]=C.useState([]),b=Dt({mutationFn:async({content:S,parentCommentId:T})=>{const{data:I,error:L}=await G.from("community_comments").insert({post_id:s,user_id:r,content:S,parent_comment_id:T}).select("id").single();if(L)throw L;const R=y;if(R.length>0&&I){const $=R.filter(q=>q!==r).map(q=>({comment_id:I.id,mentioned_user_id:q,mentioned_by_user_id:r}));$.length>0&&await G.from("community_comment_mentions").insert($)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),f(""),_([]),u(!1)}}),w=Dt({mutationFn:async S=>{const{error:T}=await G.from("community_comments").delete().eq("id",S);if(T)throw T},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),j=()=>{p.trim()&&b.mutate({content:p,parentCommentId:t.id})};return e.jsxs("div",{className:l>0?"ml-8 border-l-2 border-muted pl-3":"",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(yn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Da,{src:t.user_avatar||void 0}),e.jsx(vn,{className:"text-xs",children:FLe(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(fNe,{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:Yd(new Date(t.created_at),{addSuffix:!0})}),e.jsx(Bqt,{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(rL,{className:"h-3 w-3"}),"Reply"]}),(t.user_id===r||o)&&e.jsx("button",{onClick:()=>w.mutate(t.id),className:"hover:text-destructive",children:t.user_id!==r?"Remove":"Delete"})]}),c&&r&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsxs(yn,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx(Da,{src:n||void 0}),e.jsx(vn,{className:"text-xs",children:FLe((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(Ple,{placeholder:`Reply to ${t.user_name}...`,value:p,onChange:f,onMentionsChange:_,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:j,disabled:!p.trim()||b.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx(oa,{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(Cet,{comment:S,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},S.id))})]})}const rz=[{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"}],qqt=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=Ws(),{avatarUrl:a}=rZe(t==null?void 0:t.id),{onlineUsers:o}=aYe(),{toast:l}=Ra(),i=ss(),c=C.useRef(null),[u,p]=C.useState("all"),[f,y]=C.useState(""),[_,b]=C.useState(""),[w,j]=C.useState(""),[N,S]=C.useState([]),[T,I]=C.useState([]),[L,R]=C.useState(""),[$,q]=C.useState(!1),[U,V]=C.useState(null),[X,se]=C.useState(""),[ee,Q]=C.useState(new Set),[de,re]=C.useState({}),[ne,le]=C.useState({}),[he,we]=C.useState([]),[ye,je]=C.useState([]),[ke,We]=C.useState({open:!1,images:[],index:0});C.useEffect(()=>{if(u.startsWith("group:")){const tt=u.replace("group:","");j(tt),b("")}else u!=="all"?(b(u),j("")):(b(""),j(""))},[u]);const{data:be=[]}=wt({queryKey:["community-categories"],queryFn:async()=>{const{data:tt,error:Et}=await G.from("community_categories").select("*").order("sort_order");if(Et)throw Et;return tt}}),{data:Me=[]}=wt({queryKey:["community-private-groups"],queryFn:async()=>{const{data:tt,error:Et}=await G.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(Et)throw Et;return tt}}),Ae=20,{data:Re,isLoading:Te,hasNextPage:qe,fetchNextPage:ct,isFetchingNextPage:De}=S0t({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:tt})=>{var ze;const Et=tt*Ae,qt=Et+Ae;let ms=G.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(Et,qt);if(u.startsWith("group:")){const Qe=u.replace("group:","");ms=ms.eq("private_group_id",Qe)}else u==="all"||(ms=ms.eq("category_id",u).is("private_group_id",null));const{data:Xt,error:rs}=await ms;if(rs)throw rs;const ps=((Xt==null?void 0:Xt.length)||0)>Ae,Ms=(Xt||[]).slice(0,Ae);if(Ms.length===0)return{posts:[],hasMore:!1,nextPage:tt+1};const jt=Ms.map(Qe=>Qe.id),As=[...new Set(Ms.filter(Qe=>Qe.category_id).map(Qe=>Qe.category_id))].filter(Boolean),[Ps,ar,Dn,Va,pa]=await Promise.all([As.length?G.from("community_categories").select("*").in("id",As):Promise.resolve({data:[]}),G.from("community_post_media").select("*").in("post_id",jt).order("sort_order"),G.from("community_reactions").select("*").in("post_id",jt),G.from("community_comments").select("*").in("post_id",jt).order("created_at",{ascending:!0}),G.from("community_post_resources").select("*").in("post_id",jt)]),qa=Ps==null?void 0:Ps.data,Kr=ar==null?void 0:ar.data,Yn=Dn==null?void 0:Dn.data,mn=Va==null?void 0:Va.data,Gn=pa==null?void 0:pa.data,Zt=(mn||[]).map(Qe=>Qe.id),[$r,es]=await Promise.all([Zt.length?G.from("community_comment_reactions").select("*").in("comment_id",Zt):Promise.resolve({data:[]}),(()=>{const Qe=(Gn||[]).filter(Ct=>Ct.resource_type==="template").map(Ct=>Ct.resource_id);return Qe.length===0?Promise.resolve({data:[]}):G.from("canva_templates").select("id, name, preview_image_url").in("id",Qe)})()]),an=($r==null?void 0:$r.data)||[],Ha=(es==null?void 0:es.data)||[],Xn=new Map(Ha.map(Qe=>[Qe.id,{name:Qe.name,preview_image_url:Qe.preview_image_url}])),Ir=Array.from(new Set([...Ms.map(Qe=>Qe.user_id),...(Yn||[]).map(Qe=>Qe.user_id),...(mn||[]).map(Qe=>Qe.user_id),...an.map(Qe=>Qe.user_id)])),[_i,rl]=await Promise.all([Ir.length?G.from("profiles").select("id, name").in("id",Ir):Promise.resolve({data:[]}),nZe(Ir)]),Ni=new Map(((ze=_i==null?void 0:_i.data)==null?void 0:ze.map(Qe=>[Qe.id,Qe.name]))||[]),sc=new Map((qa||[]).map(Qe=>[Qe.id,Qe])),Vt=Qe=>{const Ct=new Map,Nt=[];return Qe.forEach(zt=>{Ct.set(zt.id,{...zt,user_name:Ni.get(zt.user_id)||"Unknown User",user_avatar:rl.get(zt.user_id),reactions:an.filter(Kt=>Kt.comment_id===zt.id).map(Kt=>({...Kt,user_name:Ni.get(Kt.user_id)||"Unknown User",user_avatar:rl.get(Kt.user_id)})),replies:[]})}),Qe.forEach(zt=>{const Kt=Ct.get(zt.id);if(zt.parent_comment_id&&Ct.has(zt.parent_comment_id)){const $t=Ct.get(zt.parent_comment_id);$t.replies=$t.replies||[],$t.replies.push(Kt)}else Nt.push(Kt)}),Nt};return{posts:Ms.map(Qe=>{const Ct=(Gn||[]).filter(Nt=>Nt.post_id===Qe.id).map(Nt=>{let zt="",Kt=null;if(Nt.resource_type==="template"){const $t=Xn.get(Nt.resource_id);zt=($t==null?void 0:$t.name)||"Unknown Template",Kt=($t==null?void 0:$t.preview_image_url)||null}return{id:Nt.id,resource_type:Nt.resource_type,resource_id:Nt.resource_id,resource_name:zt,resource_preview_url:Kt}});return{...Qe,user_name:Ni.get(Qe.user_id)||"Unknown User",user_avatar:rl.get(Qe.user_id),category:Qe.category_id?sc.get(Qe.category_id):null,media:(Kr||[]).filter(Nt=>Nt.post_id===Qe.id),reactions:((Yn||[]).filter(Nt=>Nt.post_id===Qe.id)||[]).map(Nt=>({...Nt,user_name:Ni.get(Nt.user_id)||"Unknown User",user_avatar:rl.get(Nt.user_id)})),comments:Vt((mn||[]).filter(Nt=>Nt.post_id===Qe.id)),resources:Ct}}),hasMore:ps,nextPage:tt+1}},getNextPageParam:tt=>tt.hasMore?tt.nextPage:void 0}),Rt=C.useMemo(()=>(Re==null?void 0:Re.pages.flatMap(tt=>tt.posts))??[],[Re]),pe=Dt({mutationFn:async()=>{q(!0);const{data:tt,error:Et}=await G.from("community_posts").insert({user_id:t.id,category_id:w?null:_||null,private_group_id:w||null,content:f,link_url:L||null}).select().single();if(Et)throw Et;for(let ms=0;ms0){const ms=he.filter(Xt=>Xt!==t.id).map(Xt=>({post_id:tt.id,mentioned_user_id:Xt,mentioned_by_user_id:t.id}));ms.length>0&&await G.from("community_post_mentions").insert(ms)}const qt=$qt(f);if(qt.length>0){const ms=qt.map(Xt=>({post_id:tt.id,resource_type:"template",resource_id:Xt}));await G.from("community_post_resources").insert(ms)}return tt},onSuccess:async tt=>{var Et;i.invalidateQueries({queryKey:["community-posts"]}),y(""),we([]),je([]),b(""),j(""),S([]),I([]),R(""),l({title:"Post created!"});try{const qt=((Et=t==null?void 0:t.user_metadata)==null?void 0:Et.name)||"Someone",ms=f.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),Xt=ms.length>50?ms.substring(0,50)+"...":ms;await G.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${qt}: ${Xt}`,url:"/community"}})}catch(qt){console.error("Failed to send push notification:",qt)}},onError:tt=>{l({title:"Error creating post",description:tt.message,variant:"destructive"})},onSettled:()=>q(!1)}),Je=Dt({mutationFn:async({postId:tt,content:Et})=>{const{error:qt}=await G.from("community_posts").update({content:Et}).eq("id",tt);if(qt)throw qt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),V(null),se(""),l({title:"Post updated!"})}}),lt=Dt({mutationFn:async tt=>{const{error:Et}=await G.from("community_posts").delete().eq("id",tt);if(Et)throw Et},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),rt=Dt({mutationFn:async({postId:tt,isPinned:Et})=>{const{error:qt}=await G.from("community_posts").update({is_pinned:!Et,pinned_at:Et?null:new Date().toISOString(),pinned_by:Et?null:t==null?void 0:t.id}).eq("id",tt);if(qt)throw qt},onSuccess:(tt,{isPinned:Et})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:Et?"Post unpinned":"Post pinned to top"})}}),Se=Dt({mutationFn:async({postId:tt,reactionType:Et})=>{var ms;const qt=(ms=Rt.find(Xt=>Xt.id===tt))==null?void 0:ms.reactions.find(Xt=>Xt.user_id===(t==null?void 0:t.id));qt?qt.reaction_type===Et?await G.from("community_reactions").delete().eq("id",qt.id):await G.from("community_reactions").update({reaction_type:Et}).eq("id",qt.id):await G.from("community_reactions").insert({post_id:tt,user_id:t.id,reaction_type:Et})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),it=Dt({mutationFn:async({postId:tt,content:Et})=>{const{data:qt,error:ms}=await G.from("community_comments").insert({post_id:tt,user_id:t.id,content:Et}).select("id").single();if(ms)throw ms;const Xt=ne[tt]||[];if(Xt.length>0&&qt){const rs=Xt.filter(ps=>ps!==t.id).map(ps=>({comment_id:qt.id,mentioned_user_id:ps,mentioned_by_user_id:t.id}));rs.length>0&&await G.from("community_comment_mentions").insert(rs)}},onSuccess:(tt,{postId:Et})=>{i.invalidateQueries({queryKey:["community-posts"]}),re(qt=>({...qt,[Et]:""})),le(qt=>({...qt,[Et]:[]}))}});Dt({mutationFn:async tt=>{const{error:Et}=await G.from("community_comments").delete().eq("id",tt);if(Et)throw Et},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const $e=tt=>{const Et=Array.from(tt.target.files||[]);if(Et.length+N.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}S(qt=>[...qt,...Et]),Et.forEach(qt=>{const ms=new FileReader;ms.onloadend=()=>{I(Xt=>[...Xt,ms.result])},ms.readAsDataURL(qt)})},ot=tt=>{S(Et=>Et.filter((qt,ms)=>ms!==tt)),I(Et=>Et.filter((qt,ms)=>ms!==tt))},Ue=tt=>tt.split(" ").map(Et=>Et[0]).join("").toUpperCase().slice(0,2),Ke=tt=>{const Et={};return tt.forEach(qt=>{Et[qt.reaction_type]=(Et[qt.reaction_type]||0)+1}),Et},Xe=tt=>{var Et;return(Et=tt.find(qt=>qt.user_id===(t==null?void 0:t.id)))==null?void 0:Et.reaction_type},He=tt=>tt.reduce((Et,qt)=>Et+1+(qt.replies?He(qt.replies):0),0),Ye=tt=>{if(n)return!0;if(!s||!tt.private_group_id)return!1;const Et=Me.find(qt=>qt.id===tt.private_group_id);return Et!=null&&Et.brokerage_id?r.some(qt=>qt.id===Et.brokerage_id):!1};return e.jsx(Es,{title:"Community",children:e.jsxs("div",{className:"flex gap-6 w-full isolate z-0",children:[e.jsx(kqt,{categories:be,privateGroups:Me,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(Nqt,{categories:be,privateGroups:Me,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(yn,{className:"h-10 w-10",children:[e.jsx(Da,{src:a||void 0}),e.jsx(vn,{children:t!=null&&t.email?Ue(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(Ple,{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:y,onMentionsChange:we,onTemplatesChange:je,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),T.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:T.map((tt,Et)=>{var qt;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(qt=N[Et])!=null&&qt.type.startsWith("video/")?e.jsx("video",{src:tt,className:"w-full h-full object-cover"}):e.jsx("img",{src:tt,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:()=>ot(Et),children:e.jsx(Ur,{className:"h-3 w-3"})})]},Et)})}),L&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{value:L,onChange:tt=>R(tt.target.value),placeholder:"https://...",className:"flex-1"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>R(""),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsx("input",{type:"file",ref:c,onChange:$e,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var tt;return(tt=c.current)==null?void 0:tt.click()},children:[e.jsx(cl,{className:"h-4 w-4 mr-1"}),"Photo"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var tt;return(tt=c.current)==null?void 0:tt.click()},children:[e.jsx(Nn,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>R("https://"),children:[e.jsx(Vo,{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:[Me.length>0?e.jsxs(rr,{value:w||_||"none",onValueChange:tt=>{tt==="none"?(b(""),j("")):tt.startsWith("group:")?(j(tt.replace("group:","")),b("")):(b(tt),j(""))},children:[e.jsx(tr,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(nr,{placeholder:"Select..."})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"No category"}),be.map(tt=>e.jsxs(Tt,{value:tt.id,children:[tt.icon," ",tt.name]},tt.id)),Me.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"}),Me.map(tt=>e.jsxs(Tt,{value:`group:${tt.id}`,children:[tt.icon||"🔒"," ",tt.name]},tt.id))]})]})]}):e.jsxs(rr,{value:_,onValueChange:b,children:[e.jsx(tr,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx(nr,{placeholder:"Category"})}),e.jsx(sr,{children:be.map(tt=>e.jsxs(Tt,{value:tt.id,children:[tt.icon," ",tt.name]},tt.id))})]}),e.jsxs(K,{size:"sm",onClick:()=>pe.mutate(),disabled:!f.trim()||$,children:[e.jsx(oa,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),Te?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((tt,Et)=>e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(xs,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(xs,{className:"h-4 w-32"}),e.jsx(xs,{className:"h-4 w-full"}),e.jsx(xs,{className:"h-4 w-3/4"})]})]})})},Et))}):Rt.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Ec,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No posts yet"}),e.jsx("p",{className:"text-muted-foreground",children:"Be the first to start a conversation!"})]})}):e.jsxs("div",{className:"space-y-4",children:[Rt.map(tt=>{var Et,qt,ms,Xt;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex gap-3 min-w-0",children:[e.jsxs(yn,{className:"h-10 w-10",children:[e.jsx(Da,{src:tt.user_avatar||void 0}),e.jsx(vn,{children:Ue(tt.user_name||"U")})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold break-words",children:tt.user_name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:Yd(new Date(tt.created_at),{addSuffix:!0})}),tt.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(nt,{variant:"secondary",className:"text-xs",children:[tt.category.icon," ",tt.category.name]})]})]})]})]}),(tt.user_id===(t==null?void 0:t.id)||Ye(tt))&&e.jsxs(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(ig,{className:"h-4 w-4"})})}),e.jsxs(Jd,{align:"end",children:[Ye(tt)&&tt.private_group_id&&e.jsx(Ta,{onClick:()=>rt.mutate({postId:tt.id,isPinned:tt.is_pinned}),children:tt.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(QI,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ob,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),tt.user_id===(t==null?void 0:t.id)&&e.jsxs(Ta,{onClick:()=>{V(tt),se(tt.content)},children:[e.jsx($a,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ta,{className:"text-destructive",onClick:()=>lt.mutate(tt.id),children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),tt.user_id!==(t==null?void 0:t.id)?"Remove (Moderate)":"Delete"]})]})]})]}),tt.is_pinned&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-primary",children:[e.jsx(Ob,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:"Pinned"})]}),e.jsx("div",{className:"mb-3",children:e.jsx(fNe,{content:tt.content})}),tt.media.length>0&&e.jsx("div",{className:`grid gap-2 mb-3 ${tt.media.length===1?"grid-cols-1":tt.media.length===2?"grid-cols-2":tt.media.length===3?"grid-cols-3":"grid-cols-2"}`,children:tt.media.slice(0,4).map((rs,ps)=>{const Ms=ps===3&&tt.media.length>4,jt=tt.media.length-4;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden bg-muted cursor-pointer group ${tt.media.length===1?"max-h-[500px]":tt.media.length===2?"aspect-[4/3]":"aspect-square"}`,onClick:()=>We({open:!0,images:tt.media.map(As=>({url:As.media_url,type:As.media_type==="video"?"video":"image"})),index:ps}),children:[rs.media_type==="video"?e.jsx("video",{src:rs.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:rs.media_url,alt:"",className:"w-full h-full object-cover transition-transform group-hover:scale-105"}),e.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors flex items-center justify-center",children:e.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-white",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})})})}),Ms&&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:["+",jt]})})]},rs.id)})}),tt.link_url&&e.jsxs("a",{href:tt.link_url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg border hover:bg-muted transition-colors mb-3 overflow-hidden",children:[tt.link_image&&e.jsx("div",{className:"aspect-video bg-muted",children:e.jsx("img",{src:tt.link_image,alt:tt.link_title||"Link preview",className:"w-full h-full object-cover",onError:rs=>{rs.currentTarget.style.display="none"}})}),e.jsx("div",{className:"p-3",children:tt.link_title?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-foreground line-clamp-2",children:tt.link_title}),tt.link_description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:tt.link_description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 truncate",children:new URL(tt.link_url).hostname})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary",children:[e.jsx(Vo,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:tt.link_url})]})})]}),tt.reactions.length>0&&e.jsx(Net,{reactions:tt.reactions,children:e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:[e.jsx("div",{className:"flex -space-x-1",children:Object.entries(Ke(tt.reactions)).slice(0,3).map(([rs])=>{var ps;return e.jsx("span",{className:"text-base",children:(ps=rz.find(Ms=>Ms.type===rs))==null?void 0:ps.emoji},rs)})}),e.jsx("span",{children:tt.reactions.length})]})}),e.jsxs("div",{className:"flex items-center gap-1 border-t border-b py-1 my-2",children:[e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",children:[Xe(tt.reactions)?e.jsx("span",{className:"mr-1",children:(Et=rz.find(rs=>rs.type===Xe(tt.reactions)))==null?void 0:Et.emoji}):e.jsx(Gu,{className:"h-4 w-4 mr-1"}),Xe(tt.reactions)?(qt=rz.find(rs=>rs.type===Xe(tt.reactions)))==null?void 0:qt.label:"Like"]})}),e.jsx(Eo,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:rz.map(rs=>e.jsx("button",{onClick:()=>Se.mutate({postId:tt.id,reactionType:rs.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:rs.label,children:rs.emoji},rs.type))})})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>Q(rs=>{const ps=new Set(rs);return ps.has(tt.id)?ps.delete(tt.id):ps.add(tt.id),ps}),children:[e.jsx(Ec,{className:"h-4 w-4 mr-1"}),(()=>{const rs=He(tt.comments);return rs>0?`Comment (${rs})`:"Comment"})()]})]}),ee.has(tt.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[tt.comments.map(rs=>e.jsx(Cet,{comment:rs,postId:tt.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:Ye(tt)},rs.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(yn,{className:"h-8 w-8",children:[e.jsx(Da,{src:a||void 0}),e.jsx(vn,{className:"text-xs",children:Ue(((ms=t.email)==null?void 0:ms.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(Ple,{placeholder:"Write a comment... (use @ to mention)",value:de[tt.id]||"",onChange:rs=>re(ps=>({...ps,[tt.id]:rs})),onMentionsChange:rs=>le(ps=>({...ps,[tt.id]:rs})),mentionFormat:"plain",onKeyDown:rs=>{var ps;rs.defaultPrevented||rs.key==="Enter"&&!rs.shiftKey&&((ps=de[tt.id])!=null&&ps.trim())&&(rs.preventDefault(),it.mutate({postId:tt.id,content:de[tt.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{var rs;(rs=de[tt.id])!=null&&rs.trim()&&it.mutate({postId:tt.id,content:de[tt.id]})},disabled:!((Xt=de[tt.id])!=null&&Xt.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(oa,{className:"h-4 w-4"})})]})]})]})]})},tt.id)}),qe&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(K,{variant:"outline",onClick:()=>ct(),disabled:De,children:De?"Loading…":"Load more posts"})})]}),e.jsx(_s,{open:!!U,onOpenChange:()=>V(null),children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Edit Post"})}),e.jsx(Ar,{value:X,onChange:tt=>se(tt.target.value),className:"min-h-[120px]"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>V(null),children:"Cancel"}),e.jsx(K,{onClick:()=>{U&&Je.mutate({postId:U.id,content:X})},disabled:!X.trim(),children:"Save Changes"})]})]})}),e.jsx(zqt,{images:ke.images,initialIndex:ke.index,open:ke.open,onOpenChange:tt=>We(Et=>({...Et,open:tt}))})]})]})})},a5={open:{label:"Open",icon:Tn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:Ec,color:"bg-blue-500"},resolved:{label:"Resolved",icon:vi,color:"bg-green-500"},closed:{label:"Closed",icon:$c,color:"bg-muted-foreground"}},zLe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function Uqt(){const{user:t}=Ws(),s=ss(),[r,n]=C.useState(null),[a,o]=C.useState(""),{data:l=[],isLoading:i}=wt({queryKey:["support-tickets"],queryFn:async()=>{const{data:f,error:y}=await G.from("support_tickets").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(y)throw y;return f},enabled:!!t}),{data:c=[]}=wt({queryKey:["ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:f,error:y}=await G.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(y)throw y;return f},enabled:!!r}),u=Dt({mutationFn:async f=>{if(!r||!t)throw new Error("Missing data");const{error:y}=await G.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:f,is_admin_reply:!1});if(y)throw y},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=a5[r.status].icon;return e.jsx(Es,{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(di,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(nt,{variant:"secondary",children:zLe[r.category]}),e.jsxs(nt,{className:a5[r.status].color,children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),a5[r.status].label]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(fr,{children:["Created on ",ys(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Vi,{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(y=>{var _;return e.jsxs("div",{className:`p-4 rounded-lg ${y.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:y.is_admin_reply?"Support Team":((_=y.profiles)==null?void 0:_.name)||"You"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(new Date(y.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:y.content})]},y.id)})})}),r.status!=="closed"&&e.jsxs(e.Fragment,{children:[e.jsx(Zl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ar,{placeholder:"Type your reply...",value:a,onChange:y=>o(y.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:p,disabled:!a.trim()||u.isPending,className:"self-end",children:e.jsx(oa,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{className:"bg-gradient-to-br from-primary/10 via-primary/5 to-background border-primary/20",children:e.jsx(Oe,{className:"p-6 sm:p-8",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-6",children:[e.jsx("div",{className:"p-4 bg-primary/20 rounded-full",children:e.jsx(Mv,{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(t1e,{trigger:e.jsxs(K,{size:"lg",className:"gap-2",children:[e.jsx(Zs,{className:"h-5 w-5"}),"Submit a Ticket"]})}),e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-muted rounded-lg",children:[e.jsx(ea,{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(t1e,{trigger:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"New Ticket"]})})]}),i?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):l.length===0?e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx(Ec,{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 y=a5[f.status].icon;return e.jsx(Ee,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(f),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:f.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(nt,{variant:"outline",className:"text-xs",children:zLe[f.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(new Date(f.created_at),"MMM d, yyyy")})]})]}),e.jsxs(nt,{className:a5[f.status].color,children:[e.jsx(y,{className:"h-3 w-3 mr-1"}),a5[f.status].label]})]})})},f.id)})})]})})}function Vqt({open:t,onOpenChange:s}){return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Cs,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(on,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ns,{children:"Schedule Agent Onboarding"}),e.jsx(Zr,{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 Hqt({open:t,onOpenChange:s}){const{brokerageId:r}=Ws(),[n,a]=C.useState(""),[o,l]=C.useState([]),[i,c]=C.useState(!1),{data:u,isLoading:p}=wt({queryKey:["brokerage-agents-for-onboarding",r],queryFn:async()=>{if(!r)return[];const{data:w,error:j}=await G.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name",{ascending:!0});if(j)throw j;return w},enabled:t&&!!r}),f=u==null?void 0:u.filter(w=>w.name.toLowerCase().includes(n.toLowerCase())||w.email.toLowerCase().includes(n.toLowerCase())),y=w=>{l(j=>j.includes(w)?j.filter(N=>N!==w):[...j,w])},_=async()=>{if(o.length===0){me.error("Please select at least one agent");return}c(!0);try{const{data:w,error:j}=await G.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(j)throw j;me.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),s(!1)}catch(w){console.error("Error sending onboarding link:",w),me.error(w.message||"Failed to send onboarding link")}finally{c(!1)}},b=w=>{w||(l([]),a("")),s(w)};return e.jsx(_s,{open:t,onOpenChange:b,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(oa,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ns,{children:"Send Onboarding Link"}),e.jsx(Zr,{children:"Select agents to receive the onboarding booking link"})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search agents...",value:n,onChange:w=>a(w.target.value),className:"pl-10"})]}),p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):(f==null?void 0:f.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(mr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(Vi,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:f==null?void 0:f.map(w=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>y(w.id),children:[e.jsx(Yo,{checked:o.includes(w.id),onCheckedChange:()=>y(w.id)}),e.jsx(yn,{className:"h-8 w-8",children:e.jsx(vn,{className:"text-xs",children:w.name.split(" ").map(j=>j[0]).join("").toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:w.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:w.email})]})]},w.id))})}),o.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," agent",o.length>1?"s":""," selected"]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{onClick:_,disabled:o.length===0||i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oa,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function Wqt(){const[t,s]=C.useState(!1),[r,n]=C.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(mr,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{children:"Agent Onboarding"}),e.jsx(fr,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Schedule Agent Onboarding"]}),e.jsxs(K,{variant:"outline",onClick:()=>n(!0),className:"flex items-center gap-2",children:[e.jsx(oa,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(Vqt,{open:t,onOpenChange:s}),e.jsx(Hqt,{open:r,onOpenChange:n})]})}function Gqt({open:t,onOpenChange:s}){return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[e.jsx(Cs,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(o0,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ns,{children:"Schedule Launch Meeting"}),e.jsx(Zr,{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 Kqt(){const[t,s]=C.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"mb-8",children:[e.jsx(It,{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(o0,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{children:"Launch or ReLaunch Meeting"}),e.jsx(fr,{children:"Schedule a private LevelUp information session for your brokerage. Have one of our staff host a meeting to help your team get the most out of all our trainings, tools, and resources."})]})]})}),e.jsx(Oe,{children:e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(o0,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(Gqt,{open:t,onOpenChange:s})]})}function Zqt(){const t=Pr(),[s,r]=C.useState(""),[n,a]=C.useState(null),{data:o,isLoading:l}=wt({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:w,error:j}=await G.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(j)throw j;return w}}),{data:i}=wt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:w,error:j}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(j)throw j;return w}}),{data:c}=wt({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:w,error:j}=await G.from("brokerage_resource_pdfs").select("resource_id");if(j)throw j;return w}}),{data:u}=wt({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:w,error:j}=await G.from("brokerage_resource_videos").select("resource_id");if(j)throw j;return w}}),{data:p}=wt({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:w,error:j}=await G.from("brokerage_resource_links").select("resource_id");if(j)throw j;return w}}),f=o==null?void 0:o.filter(w=>{var S;const j=w.title.toLowerCase().includes(s.toLowerCase())||((S=w.description)==null?void 0:S.toLowerCase().includes(s.toLowerCase())),N=!n||w.category_id===n;return j&&N}),y=i==null?void 0:i.filter(w=>o==null?void 0:o.some(j=>j.category_id===w.id)),_=w=>{const j=(c==null?void 0:c.filter(T=>T.resource_id===w).length)||0,N=(u==null?void 0:u.filter(T=>T.resource_id===w).length)||0,S=(p==null?void 0:p.filter(T=>T.resource_id===w).length)||0;return{pdfCount:j,videoCount:N,linkCount:S}},b=w=>{t(`/brokerage-resources/${w}`)};return e.jsx(Es,{title:"Brokerage Resources",description:"Access exclusive resources for brokerage managers",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Wqt,{}),e.jsx(Kqt,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search resources...",value:s,onChange:w=>r(w.target.value),className:"pl-10"})]}),y&&y.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(nt,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),y.map(w=>e.jsx(nt,{variant:n===w.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(w.id),children:w.name},w.id))]}),!l&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(f==null?void 0:f.length)||0," resource",(f==null?void 0:f.length)!==1?"s":""," available"]}),l?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[...Array(6)].map((w,j)=>e.jsxs(Ee,{children:[e.jsx(xs,{className:"h-40 w-full"}),e.jsx(It,{children:e.jsx(xs,{className:"h-5 w-3/4"})}),e.jsxs(Oe,{children:[e.jsx(xs,{className:"h-4 w-full mb-2"}),e.jsx(xs,{className:"h-4 w-2/3"})]})]},j))}):(f==null?void 0:f.length)===0?e.jsxs(Ee,{className:"p-12 text-center",children:[e.jsx(Rh,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resources found"}),e.jsx("p",{className:"text-muted-foreground",children:s||n?"Try adjusting your filters":"Check back later for new resources"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:f==null?void 0:f.map(w=>{const{pdfCount:j,videoCount:N,linkCount:S}=_(w.id),T=i==null?void 0:i.find(I=>I.id===w.category_id);return e.jsxs(Ee,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>b(w.id),children:[w.preview_image_url?e.jsx("img",{src:w.preview_image_url,alt:w.title,className:"w-full h-40 object-cover"}):e.jsx("div",{className:"w-full h-40 bg-muted flex items-center justify-center",children:e.jsx(Rh,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(Ot,{className:"text-lg line-clamp-1",children:w.title}),T&&e.jsx(nt,{variant:"secondary",className:"shrink-0 text-xs",children:T.name})]})}),e.jsxs(Oe,{children:[w.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:w.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[j>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-4 w-4"}),j]}),N>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nn,{className:"h-4 w-4"}),N]}),S>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vo,{className:"h-4 w-4"}),S]})]})]})]},w.id)})})]})})}const Yqt=()=>{const{resourceId:t}=Po(),{data:s,isLoading:r}=wt({queryKey:["brokerage-resource-detail",t],queryFn:async()=>{const{data:a,error:o}=await G.from("brokerage_resources").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;const{data:l}=await G.from("brokerage_resource_pdfs").select("*").eq("resource_id",t).order("sort_order"),{data:i}=await G.from("brokerage_resource_videos").select("*").eq("resource_id",t).order("sort_order"),{data:c}=await G.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(Es,{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(Es,{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(So,{to:"/brokerage-resources",children:[e.jsx(di,{className:"h-4 w-4"}),"Back to Resources"]})}),s.preview_image_url&&e.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:s.preview_image_url,alt:s.title,className:"w-full max-h-[400px] object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),s.description&&e.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:s.description}})]}),s.videos&&s.videos.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Nn,{className:"h-4 w-4"}),"Videos (",s.videos.length,")"]}),e.jsx("div",{className:"space-y-4",children:s.videos.map(a=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:a.title}),e.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:a.video_url,className:"absolute top-0 left-0 w-full h-full rounded-lg border",allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})]},a.id))})]})}),s.pdfs&&s.pdfs.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(In,{className:"h-4 w-4"}),"Documents (",s.pdfs.length,")"]}),e.jsx("div",{className:"grid gap-2",children:s.pdfs.map(a=>e.jsxs("a",{href:a.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between p-3 rounded-lg border hover:bg-muted transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(In,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:a.name}),a.file_size&&e.jsx("div",{className:"text-xs text-muted-foreground",children:n(a.file_size)})]})]}),e.jsx(ki,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})}),s.links&&s.links.length>0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(rn,{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(rn,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})})]})}):e.jsx(Es,{title:"Brokerage Resources",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Rh,{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(So,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function Xqt(){const{onlineUsers:t,totalOnline:s}=aYe();return e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(nt,{variant:"secondary",className:"bg-green-100 text-green-700",children:[e.jsx(pd,{className:"h-2 w-2 fill-green-500 text-green-500 mr-1"}),s," online"]})]})}),e.jsx(Oe,{children:t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No other users online right now"}):e.jsx(Vi,{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(yn,{className:"h-9 w-9",children:[e.jsx(Da,{src:r.avatarUrl,alt:r.name}),e.jsx(vn,{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 ",Yd(new Date(r.onlineSince),{addSuffix:!1})]})]})]},r.id)})})})})]})}const BLe={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:mr,path:"/admin/members",color:"bg-blue-500/10 text-blue-600"},{title:"Invite Codes",description:"Create and manage signup invite codes",icon:pL,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:yg,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:OI,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:Tm,path:"/admin/discounts",color:"bg-red-500/10 text-red-600"},{title:"Referral Program",description:"Track brokerage referrals and discounts",icon:Ad,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:mr,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:Am,path:"/admin/prospector",color:"bg-gradient-to-br from-orange-500/20 to-amber-500/10 text-orange-600"},{title:"Recruiting",description:"Manage agent recruit pipeline and outreach",icon:Pc,path:"/admin/recruiting",color:"bg-gradient-to-br from-emerald-500/20 to-green-500/10 text-emerald-600"}]},content:{label:"Content",sections:[{title:"Manage Templates",description:"Upload and organize Canva templates",icon:Ql,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:zh,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:Kx,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:hn,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:hn,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:s1,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:Md,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:Rh,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:Rh,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:br,path:"/admin/agent-email-templates",color:"bg-rose-500/10 text-rose-600"}]},platform:{label:"Platform",sections:[{title:"Dashboard Management",description:"Configure banners and dashboard modules",icon:U4,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:Yf,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:br,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:bp,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:lM,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:l0,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:bo,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:mo,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:sl,path:"/admin/integrations",color:"bg-blue-500/10 text-blue-600"},{title:"Agent Cards",description:"Manage digital business cards for agents",icon:mr,path:"/admin/agent-cards",color:"bg-gradient-to-br from-violet-500/20 to-purple-500/10 text-violet-600"},{title:"Notification Settings",description:"Test and manage push notifications",icon:bp,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:po,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:fM,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:Ib,path:"/admin/wishlist",color:"bg-yellow-500/10 text-yellow-600"},{title:"Membership Reviews",description:"View member feedback and ratings",icon:Kn,path:"/admin/membership-reviews",color:"bg-amber-500/10 text-amber-600"},{title:"Weekly Digest",description:"Configure automated weekly email digests",icon:br,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:xl,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:gh,path:"/admin/brokerage-content-activity",color:"bg-sky-500/10 text-sky-600"}]},lms:{label:"LevelUp U",sections:[{title:"Manage Courses",description:"Create and manage LMS training courses, modules, and access",icon:zh,path:"/admin/lms",color:"bg-gradient-to-br from-primary/20 to-primary/10 text-primary"}]},"agent-os":{label:"Agent OS",sections:[{title:"Agent OS Control Center",description:"Manage InnerCircle feature: relationship types, action types, scripts, plans & feature flags",icon:Ii,path:"/admin/agent-os",color:"bg-gradient-to-br from-rose-500/20 to-pink-500/10 text-rose-600"},{title:"Listing Exchange",description:"Approve, feature, and moderate community listings",icon:Rn,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:Gx,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:gh,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:cl,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:br,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:Pb,path:"/admin/beta/homereel",color:"bg-gradient-to-br from-violet-500/20 to-indigo-500/10 text-violet-600"}]}};function Qqt(){const t=Pr();return e.jsx(Es,{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(Xqt,{})})]}),e.jsxs(Aa,{defaultValue:"users",className:"w-full",children:[e.jsx(ja,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1 overflow-x-auto",children:Object.entries(BLe).map(([s,r])=>e.jsx(js,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(BLe).map(([s,r])=>e.jsx($s,{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(It,{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(Ot,{className:"text-base",children:n.title})]}),e.jsx(Oe,{className:"pt-0",children:e.jsx(fr,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const An=C.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:At("w-full caption-bottom text-sm",t),...s})}));An.displayName="Table";const En=C.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:At("[&_tr]:border-b",t),...s}));En.displayName="TableHeader";const Pn=C.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:At("[&_tr:last-child]:border-0",t),...s}));Pn.displayName="TableBody";const Jqt=C.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:At("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));Jqt.displayName="TableFooter";const ks=C.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:At("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));ks.displayName="TableRow";const bt=C.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:At("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));bt.displayName="TableHead";const dt=C.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:At("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));dt.displayName="TableCell";const eUt=C.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:At("mt-4 text-sm text-muted-foreground",t),...s}));eUt.displayName="TableCaption";const tUt=()=>{const{isAdmin:t}=Ws(),s=Pr(),[r,n]=C.useState([]),[a,o]=C.useState(!0),[l,i]=C.useState(!1),[c,u]=C.useState(null);C.useEffect(()=>{if(!t){s("/dashboard");return}p()},[t]);const p=async()=>{try{const{data:w,error:j}=await G.from("app_tiles").select("*").order("name");if(j)throw j;n(w||[])}catch(w){console.error("Error loading apps:",w),me.error("Failed to load apps")}finally{o(!1)}},f=async w=>{w.preventDefault();const j=new FormData(w.currentTarget),N={name:j.get("name"),description:j.get("description"),icon:j.get("icon"),app_id:j.get("app_id"),target_url:j.get("target_url"),required_tags:j.get("required_tags").split(",").map(S=>S.trim()).filter(Boolean)};try{if(c){const{error:S}=await G.from("app_tiles").update(N).eq("id",c.id);if(S)throw S;me.success("App updated successfully")}else{const{error:S}=await G.from("app_tiles").insert([N]);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")}},y=async w=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:j}=await G.from("app_tiles").delete().eq("id",w);if(j)throw j;me.success("App deleted successfully"),p()}catch(j){console.error("Error deleting app:",j),me.error("Failed to delete app")}},_=w=>{u(w),i(!0)},b=()=>{u(null),i(!0)};return a?e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"border-b bg-card",children:e.jsx("div",{className:"container mx-auto px-4 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s("/dashboard"),children:[e.jsx(di,{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(_s,{open:l,onOpenChange:i,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{onClick:b,children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Add App"]})}),e.jsxs(vs,{className:"max-w-2xl",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:c?"Edit App":"Create New App"}),e.jsx(Zr,{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(_e,{htmlFor:"name",children:"App Name"}),e.jsx(Fe,{id:"name",name:"name",defaultValue:c==null?void 0:c.name,required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"app_id",children:"App ID"}),e.jsx(Fe,{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(_e,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{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(_e,{htmlFor:"icon",children:"Icon (emoji)"}),e.jsx(Fe,{id:"icon",name:"icon",defaultValue:c==null?void 0:c.icon,placeholder:"🚀",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"target_url",children:"Target URL"}),e.jsx(Fe,{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(_e,{htmlFor:"required_tags",children:"Required Tags (comma-separated)"}),e.jsx(Fe,{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(It,{children:[e.jsx(Ot,{children:"Application Tiles"}),e.jsx(fr,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx(Oe,{children:r.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsxs(K,{onClick:b,children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Icon"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"App ID"}),e.jsx(bt,{children:"Target URL"}),e.jsx(bt,{children:"Tags"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:r.map(w=>e.jsxs(ks,{children:[e.jsx(dt,{className:"text-2xl",children:w.icon}),e.jsx(dt,{className:"font-medium",children:w.name}),e.jsx(dt,{className:"font-mono text-sm",children:w.app_id}),e.jsx(dt,{className:"text-sm text-muted-foreground max-w-xs truncate",children:w.target_url}),e.jsx(dt,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:w.required_tags.map(j=>e.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:j},j))})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>_(w),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>y(w.id),children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},w.id))})]})})]})})]})};function Ju({title:t,description:s,children:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(So,{to:"/admin",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(di,{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 $Le=({expiresAt:t,className:s})=>{const r=new Date().getTime(),n=new Date(t).getTime(),a=Math.ceil((n-r)/(1e3*60*60*24));return a<=0?e.jsxs(nt,{variant:"destructive",className:At("gap-1",s),children:[e.jsx(uh,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(nt,{variant:"destructive",className:At("gap-1",s),children:[e.jsx(Tn,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(nt,{className:At("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(Tn,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(nt,{variant:"secondary",className:At("gap-1",s),children:[e.jsx(Tn,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},Met=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=Ra(),l=C.useRef(null),[i,c]=C.useState([]),[u,p]=C.useState(""),[f,y]=C.useState(!1),[_,b]=C.useState("upload"),[w,j]=C.useState(null),N=()=>{c([]),p(""),b("upload"),j(null),l.current&&(l.current.value="")},S=()=>{N(),s(!1)},T=q=>{const U=q.split(` `).map(Q=>Q.trim()).filter(Q=>Q);if(U.length===0)return[];const V=U[0].toLowerCase(),se=V.includes("first")||V.includes("last")||V.includes("email")||V.includes("name")||V.includes("phone")||V.includes("sms")||V.includes("consent")?U.slice(1):U,ee=[];for(const Q of se){const re=(Q.includes(" ")?Q.split(" "):Q.split(",")).map(ne=>ne.trim().replace(/^["']|["']$/g,""));if(re.length>=2){let ne="",le="",he="",we="",ye;if(re.length===2){const We=re[0].split(" ");ne=We[0]||"",le=We.slice(1).join(" ")||"",he=re[1]}else if(re.length===3)ne=re[0],le=re[1],he=re[2];else if(re.length===4)ne=re[0],le=re[1],he=re[2],we=re[3];else if(re.length>=5){ne=re[0],le=re[1],he=re[2],we=re[3];const We=re[4].toLowerCase();ye=We==="true"||We==="yes"||We==="1"||We==="y"}const ke=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(he);ee.push({firstName:ne.trim(),lastName:le.trim(),email:he.trim().toLowerCase(),phone:we.trim()||void 0,smsConsent:ye,isValid:ke&&ne.trim().length>0,error:ke?ne.trim()?void 0:"Missing name":"Invalid email"})}}return ee},I=q=>{var X;const U=(X=q.target.files)==null?void 0:X[0];if(!U)return;const V=new FileReader;V.onload=se=>{var de;const ee=(de=se.target)==null?void 0:de.result,Q=T(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),b("preview")},V.readAsText(U)},L=async()=>{const q=i.filter(V=>V.isValid);if(q.length===0){o({title:"No valid users",description:"There are no valid users to import.",variant:"destructive"});return}const U=n||u||null;y(!0);try{const{data:{session:V}}=await G.auth.getSession(),X=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/bulk-create-users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${V==null?void 0:V.access_token}`},body:JSON.stringify({users:q.map(ee=>({firstName:ee.firstName,lastName:ee.lastName,email:ee.email,phone:ee.phone,smsConsent:ee.smsConsent})),brokerageId:U})}),se=await X.json();if(!X.ok)throw new Error(se.error||"Failed to import users");j(se),b("result"),se.created>0&&a(),o({title:"Import Complete",description:`${se.created} user(s) created successfully.${se.failed>0?` ${se.failed} failed.`:""}`})}catch(V){console.error("Import error:",V),o({title:"Import Failed",description:V.message||"Failed to import users",variant:"destructive"})}finally{y(!1)}},R=i.filter(q=>q.isValid).length,$=i.filter(q=>!q.isValid).length;return e.jsx(_s,{open:t,onOpenChange:S,children:e.jsxs(vs,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Yv,{className:"h-5 w-5"}),"Import Agents from CSV"]}),e.jsx(Zr,{children:"Upload a CSV file with agent information. Each row should contain First Name, Last Name, and Email."})]}),_==="upload"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx("input",{type:"file",accept:".csv,.txt",ref:l,onChange:I,className:"hidden"}),e.jsx(ni,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),e.jsx(K,{onClick:()=>{var q;return(q=l.current)==null?void 0:q.click()},children:"Select CSV File"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[e.jsx("p",{className:"font-medium mb-2",children:"Expected CSV Format:"}),e.jsxs("code",{className:"text-xs block bg-background p-2 rounded",children:["First Name, Last Name, Email, Phone, SMS Consent",e.jsx("br",{}),"John, Doe, john@example.com, 555-123-4567, yes",e.jsx("br",{}),"Jane, Smith, jane@example.com, 555-987-6543, true"]}),e.jsx("p",{className:"text-muted-foreground mt-2 text-xs",children:"Phone and SMS Consent columns are optional. SMS Consent accepts: yes/no, true/false, 1/0, y/n."})]})]}),_==="preview"&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[!n&&r&&r.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Assign to Brokerage (optional)"}),e.jsxs(rr,{value:u||"none",onValueChange:q=>p(q==="none"?"":q),children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select a brokerage..."})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"No brokerage"}),r.map(q=>e.jsx(Tt,{value:q.id,children:q.name},q.id))]})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ha,{className:"h-4 w-4 text-green-500"}),e.jsxs("span",{children:[R," valid"]})]}),$>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(yl,{className:"h-4 w-4"}),e.jsxs("span",{children:[$," invalid"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{className:"bg-muted/30",children:[e.jsx(bt,{children:"First Name"}),e.jsx(bt,{children:"Last Name"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Phone"}),e.jsx(bt,{children:"SMS"}),e.jsx(bt,{children:"Status"})]})}),e.jsx(Pn,{children:i.slice(0,100).map((q,U)=>e.jsxs(ks,{children:[e.jsx(dt,{children:q.firstName}),e.jsx(dt,{children:q.lastName}),e.jsx(dt,{children:q.email}),e.jsx(dt,{className:"text-muted-foreground",children:q.phone||"-"}),e.jsx(dt,{className:"text-muted-foreground",children:q.smsConsent===!0?"✓":q.smsConsent===!1?"✗":"-"}),e.jsx(dt,{children:q.isValid?e.jsx(nt,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(nt,{variant:"destructive",children:q.error||"Invalid"})})]},U))})]}),i.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",i.length," users"]})]})]}),_==="result"&&w&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(ha,{className:"h-12 w-12 mx-auto text-green-500 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:[w.created," agent(s) created and invited"]}),w.failed>0&&e.jsxs("p",{className:"text-destructive mt-1",children:[w.failed," failed to create"]})]}),w.errors.length>0&&e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 max-h-40 overflow-auto",children:[e.jsx("p",{className:"font-medium text-destructive text-sm mb-2",children:"Errors:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[w.errors.slice(0,10).map((q,U)=>e.jsxs("li",{children:["• ",q]},U)),w.errors.length>10&&e.jsxs("li",{children:["...and ",w.errors.length-10," more"]})]})]})]}),e.jsxs(Vn,{children:[_==="upload"&&e.jsx(K,{variant:"outline",onClick:S,children:"Cancel"}),_==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:N,children:"Back"}),e.jsx(K,{onClick:L,disabled:f||R===0,children:f?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${R} Agent${R!==1?"s":""}`})]}),_==="result"&&e.jsx(K,{onClick:S,children:"Done"})]})]})})};function dl({sortKey:t,currentSortKey:s,currentDirection:r,onSort:n,children:a,className:o,...l}){const i=s===t;return e.jsx(bt,{className:At("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(gu,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Oh,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ud,{className:"h-3.5 w-3.5 shrink-0 opacity-40"})]})})}function EO(t=null,s=null){const[r,n]=C.useState(t),[a,o]=C.useState(s),l=C.useCallback(c=>{r===c?a==="asc"?o("desc"):a==="desc"?(n(null),o(null)):o("asc"):(n(c),o("asc"))},[r,a]),i=C.useCallback((c,u)=>{if(!r||!a||!u[r])return c;const p=u[r];return[...c].sort((f,y)=>{const _=p(f),b=p(y);if(_==null&&b==null)return 0;if(_==null)return 1;if(b==null)return-1;let w;return typeof _=="string"&&typeof b=="string"?w=_.localeCompare(b,void 0,{sensitivity:"base"}):w=_-b,a==="asc"?w:-w})},[r,a]);return{sortKey:r,sortDirection:a,handleSort:l,sortData:i}}const sUt=[{type:"custom",title:"Great job!",message:"Keep up the amazing work!",icon:Kn},{type:"custom",title:"You're on fire!",message:"Your dedication is inspiring!",icon:mo},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:Zd}];function Tet({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=C.useState("custom"),[l,i]=C.useState(""),[c,u]=C.useState(""),p=pjt(),f=_=>{o(_.type),i(_.title),u(_.message)},y=async _=>{if(_.preventDefault(),!l.trim()){fn({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}),fn({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{fn({title:"Error",description:"Failed to send celebration",variant:"destructive"})}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Zd,{className:"h-5 w-5 text-primary"}),"Send Celebration to ",n]}),e.jsx(Zr,{children:"They'll see confetti and this message next time they log in!"})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(_e,{className:"text-sm text-muted-foreground mb-2 block",children:"Quick presets:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:sUt.map((_,b)=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>f(_),className:"text-xs",children:[e.jsx(_.icon,{className:"h-3 w-3 mr-1"}),_.title]},b))})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"type",children:"Celebration Type"}),e.jsxs(rr,{value:a,onValueChange:_=>o(_),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"custom",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Kn,{className:"h-4 w-4"})," Custom"]})}),e.jsx(Tt,{value:"points_earned",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mo,{className:"h-4 w-4"})," Points Earned"]})}),e.jsx(Tt,{value:"listing_created",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rn,{className:"h-4 w-4"})," Listing Created"]})}),e.jsx(Tt,{value:"deal_closed",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Td,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Fe,{id:"title",value:l,onChange:_=>i(_.target.value),placeholder:"e.g., Congratulations!",maxLength:100})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"message",children:"Message (optional)"}),e.jsx(Ar,{id:"message",value:c,onChange:_=>u(_.target.value),placeholder:"Add a personal message...",rows:3,maxLength:500})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:p.isPending,children:[e.jsx(Zd,{className:"h-4 w-4 mr-2"}),p.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const bxe={points_earned:{label:"Points Earned",icon:mo,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:Rn,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:Td,color:"bg-green-500"},custom:{label:"Custom",icon:hn,color:"bg-purple-500"}};function rUt(){const[t,s]=C.useState(""),[r,n]=C.useState("all"),[a,o]=C.useState("all"),{data:l=[],isLoading:i}=wt({queryKey:["admin-celebrations"],queryFn:async()=>{const{data:p,error:f}=await G.from("celebration_queue").select("*").order("created_at",{ascending:!1}).limit(500);if(f)throw f;const y=[...new Set([...p.map(w=>w.user_id),...p.map(w=>w.created_by).filter(Boolean)])],{data:_}=await G.from("profiles").select("id, name, email").in("id",y),b=new Map((_==null?void 0:_.map(w=>[w.id,w]))||[]);return p.map(w=>{var j,N,S;return{...w,user_name:((j=b.get(w.user_id))==null?void 0:j.name)||"Unknown",user_email:((N=b.get(w.user_id))==null?void 0:N.email)||"",creator_name:w.created_by?((S=b.get(w.created_by))==null?void 0:S.name)||"System":"Auto-triggered"}})}}),c=l.filter(p=>{var b,w;const f=((b=p.user_name)==null?void 0:b.toLowerCase().includes(t.toLowerCase()))||((w=p.user_email)==null?void 0:w.toLowerCase().includes(t.toLowerCase()))||p.title.toLowerCase().includes(t.toLowerCase()),y=r==="all"||p.celebration_type===r,_=a==="all"||a==="seen"&&p.seen_at||a==="unseen"&&!p.seen_at;return f&&y&&_}),u={total:l.length,seen:l.filter(p=>p.seen_at).length,unseen:l.filter(p=>!p.seen_at).length,byType:Object.keys(bxe).reduce((p,f)=>(p[f]=l.filter(y=>y.celebration_type===f).length,p),{})};return i?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ss,{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(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:u.total})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:u.seen})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:u.unseen})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:u.byType.custom||0})})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Zd,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(fr,{children:"View all celebrations awarded to agents"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by agent name, email, or title...",value:t,onChange:p=>s(p.target.value),className:"pl-9"})]}),e.jsxs(rr,{value:r,onValueChange:n,children:[e.jsx(tr,{className:"w-[180px]",children:e.jsx(nr,{placeholder:"Filter by type"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Types"}),Object.entries(bxe).map(([p,f])=>e.jsx(Tt,{value:p,children:f.label},p))]})]}),e.jsxs(rr,{value:a,onValueChange:o,children:[e.jsx(tr,{className:"w-[140px]",children:e.jsx(nr,{placeholder:"Status"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Status"}),e.jsx(Tt,{value:"seen",children:"Seen"}),e.jsx(Tt,{value:"unseen",children:"Pending"})]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Type"}),e.jsx(bt,{children:"Agent"}),e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Points"}),e.jsx(bt,{children:"Created By"}),e.jsx(bt,{children:"Created"}),e.jsx(bt,{children:"Status"})]})}),e.jsx(Pn,{children:c.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):c.map(p=>{const f=bxe[p.celebration_type],y=f.icon;return e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(y,{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(nt,{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:ys(new Date(p.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(dt,{children:p.seen_at?e.jsx(nt,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(nt,{variant:"outline",className:"bg-orange-50 text-orange-700 border-orange-200",children:"Pending"})})]},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 nUt=()=>{const{user:t}=Ws(),{toast:s}=Ra(),[r,n]=C.useState([]),[a,o]=C.useState(!0),[l,i]=C.useState(!1),[c,u]=C.useState("all"),[p,f]=C.useState("all"),[y,_]=C.useState("new"),[b,w]=C.useState(new Set),j=C.useCallback(async()=>{try{o(!0);const{data:ee,error:Q}=await G.from("profiles").select("id, name, email, phone, is_trial, trial_started_at, trial_expires_at, subscription_status, subscription_end_date, converted_from_trial_at, created_at").or("is_trial.eq.true,subscription_status.eq.trialing,converted_from_trial_at.not.is.null");if(Q)throw Q;const{data:de,error:re}=await G.from("trial_email_exports").select("user_id");if(re)throw re;const ne=new Set((de||[]).map(he=>he.user_id)),le=(ee||[]).map(he=>({...he,converted_from_trial_at:he.converted_from_trial_at??null,already_exported:ne.has(he.id)}));le.sort((he,we)=>new Date(we.created_at).getTime()-new Date(he.created_at).getTime()),n(le)}catch(ee){console.error("Error loading trial users:",ee),s({title:"Error",description:"Failed to load trial users",variant:"destructive"})}finally{o(!1)}},[s]);C.useEffect(()=>{j()},[j]);const N=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,T=ee=>ee.converted_from_trial_at!==null,I=ee=>{if(T(ee))return!1;const Q=S(ee);return Q?new Date(Q).getTime()<=Date.now():!1},L=r.filter(ee=>!(c!=="all"&&N(ee)!==c||p==="active"&&(I(ee)||T(ee))||p==="expired"&&!I(ee)||p==="converted"&&!T(ee)||y==="new"&&ee.already_exported||y==="exported"&&!ee.already_exported)),R=()=>{b.size===L.length?w(new Set):w(new Set(L.map(ee=>ee.id)))},$=ee=>{const Q=new Set(b);Q.has(ee)?Q.delete(ee):Q.add(ee),w(Q)},q=async()=>{if(b.size===0){s({title:"No users selected",description:"Select users to export",variant:"destructive"});return}i(!0);try{const ee=r.filter(ye=>b.has(ye.id)),Q="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",de=ee.map(ye=>{const je=(ye.name||"").split(" "),ke=je[0]||"",We=je.slice(1).join(" ")||"",be=N(ye)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Me=T(ye)?"Converted":I(ye)?"Expired":"Active",Ae=ye.created_at?new Date(ye.created_at).toLocaleDateString():"",Re=S(ye)?new Date(S(ye)).toLocaleDateString():"";return`"${ke}","${We}","${ye.email}","${ye.phone||""}","${be}","${Me}","${Ae}","${Re}"`}),re=[Q,...de].join(` `),ne=new Blob([re],{type:"text/csv"}),le=URL.createObjectURL(ne),he=document.createElement("a");he.href=le,he.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,he.click(),URL.revokeObjectURL(le);const we=ee.filter(ye=>!ye.already_exported).map(ye=>({user_id:ye.id,exported_by:t.id}));if(we.length>0){const{error:ye}=await G.from("trial_email_exports").upsert(we,{onConflict:"user_id"});ye&&console.error("Error marking exports:",ye)}s({title:"Export complete",description:`Downloaded ${ee.length} trial user(s). ${we.length} newly marked as exported.`}),w(new Set),j()}catch(ee){console.error("Export error:",ee),s({title:"Error",description:"Failed to export",variant:"destructive"})}finally{i(!1)}},U=r.filter(ee=>!ee.already_exported).length,V=r.filter(ee=>ee.already_exported).length,X=r.filter(ee=>T(ee)).length,se=r.filter(ee=>!I(ee)&&!T(ee)).length;return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ss,{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(It,{className:"pb-2",children:[e.jsx(fr,{children:"Total"}),e.jsx(Ot,{className:"text-2xl",children:r.length})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(fr,{children:"New (Not Exported)"}),e.jsx(Ot,{className:"text-2xl text-green-600",children:U})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(fr,{children:"Active Trials"}),e.jsx(Ot,{className:"text-2xl",children:se})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(fr,{children:"Converted 🎉"}),e.jsx(Ot,{className:"text-2xl text-primary",children:X})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(fr,{children:"Already Exported"}),e.jsx(Ot,{className:"text-2xl text-muted-foreground",children:V})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(rr,{value:y,onValueChange:ee=>_(ee),children:[e.jsx(tr,{className:"w-[160px]",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Users"}),e.jsx(Tt,{value:"new",children:"New Only"}),e.jsx(Tt,{value:"exported",children:"Already Exported"})]})]}),e.jsxs(rr,{value:c,onValueChange:ee=>u(ee),children:[e.jsx(tr,{className:"w-[180px]",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Trial Types"}),e.jsx(Tt,{value:"stripe",children:"Credit Card Trial"}),e.jsx(Tt,{value:"ghl",children:"Free Trial (No CC)"})]})]}),e.jsxs(rr,{value:p,onValueChange:ee=>f(ee),children:[e.jsx(tr,{className:"w-[160px]",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Statuses"}),e.jsx(Tt,{value:"active",children:"Active Trial"}),e.jsx(Tt,{value:"expired",children:"Expired"}),e.jsx(Tt,{value:"converted",children:"Converted ✓"})]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs(K,{onClick:q,disabled:l||b.size===0,children:[l?e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ki,{className:"h-4 w-4 mr-2"}),"Export Selected (",b.size,")"]})})]}),e.jsx("div",{className:"border rounded-lg",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(bt,{className:"w-[40px]",children:e.jsx(Yo,{checked:L.length>0&&b.size===L.length,onCheckedChange:R})}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Trial Type"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Signup Date"}),e.jsx(bt,{children:"Expires / Renews"}),e.jsx(bt,{children:"Exported"})]})}),e.jsx(Pn,{children:L.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):L.map(ee=>{const Q=N(ee),de=T(ee),re=I(ee),ne=S(ee);return e.jsxs(ks,{className:`hover:bg-muted/30 ${de?"bg-primary/5":""}`,children:[e.jsx(dt,{children:e.jsx(Yo,{checked:b.has(ee.id),onCheckedChange:()=>$(ee.id)})}),e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ee.name,de&&e.jsx(xc,{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(nt,{variant:"outline",className:"gap-1",children:[e.jsx(yg,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(br,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(dt,{children:de?e.jsxs(nt,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(xc,{className:"h-3 w-3"}),"Converted"]}):re?e.jsx(nt,{variant:"destructive",children:"Expired"}):e.jsx(nt,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),e.jsx(dt,{className:"text-sm",children:ee.created_at?new Date(ee.created_at).toLocaleDateString():"—"}),e.jsx(dt,{className:"text-sm",children:de&&ne?e.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(ne).toLocaleDateString()]}):ne?new Date(ne).toLocaleDateString():"—"}),e.jsx(dt,{children:ee.already_exported?e.jsx(ha,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(nt,{variant:"outline",className:"text-green-600 border-green-300",children:"New"})})]},ee.id)})})]})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",L.length," of ",r.length," trial users · ",X," converted to paid"]})]})},aUt=()=>{const[t,s]=C.useState([]),[r,n]=C.useState(!0);return C.useEffect(()=>{(async()=>{const{data:o,error:l}=await G.from("user_deletion_log").select("*").order("created_at",{ascending:!1});!l&&o&&s(o),n(!1)})()},[]),r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(jr,{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(It,{children:e.jsx(Ot,{className:"text-lg",children:"User Deletion History"})}),e.jsx(Oe,{children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Date"}),e.jsx(bt,{children:"User"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Brokerage"}),e.jsx(bt,{children:"Type"}),e.jsx(bt,{children:"Deleted By"})]})}),e.jsx(Pn,{children:t.map(a=>e.jsxs(ks,{children:[e.jsx(dt,{className:"whitespace-nowrap text-sm",children:ys(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(nt,{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))})]})})]})},QS=t=>{const{user:s}=Ws(),r=ss(),n=wt({queryKey:["teams",t],queryFn:async()=>{let f=G.from("teams").select("*").order("created_at",{ascending:!1});t&&(f=f.eq("brokerage_id",t));const{data:y,error:_}=await f;if(_)throw _;return y||[]},enabled:!!s}),a=f=>wt({queryKey:["team-members",f],queryFn:async()=>{const{data:y,error:_}=await G.from("team_members").select("*").eq("team_id",f).order("role",{ascending:!0});if(_)throw _;const b=(y||[]).map(N=>N.user_id),{data:w}=await G.from("profiles").select("id, name, email, avatar_url").in("id",b),j=new Map((w||[]).map(N=>[N.id,N]));return(y||[]).map(N=>({...N,profile:j.get(N.user_id)||null}))},enabled:!!f}),o=Dt({mutationFn:async f=>{const y={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&&(y.brokerage_id=f.brokerage_id);const{data:_,error:b}=await G.from("teams").insert(y).select().single();if(b)throw b;return _},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,...y})=>{const{data:_,error:b}=await G.from("teams").update(y).eq("id",f).select().single();if(b)throw b;return _},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:y}=await G.from("teams").delete().eq("id",f);if(y)throw y},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:y,error:_}=await G.from("team_members").insert({team_id:f.team_id,user_id:f.user_id,role:f.role||"team_member"}).select().single();if(_)throw _.message.includes("duplicate")||_.message.includes("unique")?new Error("This agent is already on a team. They must be removed from their current team first."):_;return y},onSuccess:(f,y)=>{r.invalidateQueries({queryKey:["team-members",y.team_id]}),me.success("Member added to team")},onError:f=>{me.error(f.message)}}),u=Dt({mutationFn:async f=>{const{error:y}=await G.from("team_members").delete().eq("id",f.member_id);if(y)throw y},onSuccess:(f,y)=>{r.invalidateQueries({queryKey:["team-members",y.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:y}=await G.from("team_members").update({role:f.role}).eq("id",f.member_id);if(y)throw y},onSuccess:(f,y)=>{r.invalidateQueries({queryKey:["team-members",y.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}},iUt=()=>{const{user:t}=Ws();return wt({queryKey:["team-contacts",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.rpc("get_team_contacts",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},Aet=t=>{const{user:s}=Ws(),r=ss(),n=wt({queryKey:["lead-pond",t],queryFn:async()=>{const{data:i,error:c}=await G.from("team_lead_pond").select("*").eq("team_id",t).order("created_at",{ascending:!1});if(c)throw c;if(!i||i.length===0)return[];const u=i.map(N=>N.contact_id),p=[...new Set(i.map(N=>N.added_by))],f=i.filter(N=>N.claimed_by).map(N=>N.claimed_by),y=[...new Set([...p,...f])],[_,b]=await Promise.all([G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",u),G.from("profiles").select("id, name, avatar_url").in("id",y)]),w=new Map((_.data||[]).map(N=>[N.id,N])),j=new Map((b.data||[]).map(N=>[N.id,N]));return i.map(N=>({...N,status:N.claimed_by?"claimed":"available",contact:w.get(N.contact_id)||null,contributor:j.get(N.added_by)||null,claimer:N.claimed_by&&j.get(N.claimed_by)||null}))},enabled:!!t&&!!s}),a=Dt({mutationFn:async i=>{const{data:c,error:u}=await G.rpc("add_to_lead_pond",{_contact_id:i.contact_id,_team_id:i.team_id,_notes:i.notes||null});if(u)throw u;return 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 G.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 G.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}},oUt=()=>{const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.rpc("transfer_contact",{_contact_id:s.contactId,_to_user_id:s.toUserId,_notes:s.notes||null});if(n)throw n;const a=r;if(!a.success)throw new Error(a.error);return a},onSuccess:()=>{t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["team-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),me.success("Contact transferred successfully")},onError:s=>{me.error(s.message||"Failed to transfer contact")}})};function Eet({open:t,onOpenChange:s,contactIds:r,contactNames:n=[],onComplete:a}){var L;const{user:o}=Ws(),{data:l}=Lg(),{useTeamMembers:i}=QS(),{data:c=[]}=i((l==null?void 0:l.teamId)||""),u=oUt(),[p,f]=C.useState(null),[y,_]=C.useState(""),[b,w]=C.useState(!1),j=c.filter(R=>R.user_id!==(o==null?void 0:o.id)),N=async()=>{if(p){w(!0);try{for(const R of r)await u.mutateAsync({contactId:R,toUserId:p,notes:y||void 0});s(!1),f(null),_(""),a==null||a()}catch{}finally{w(!1)}}},S=j.find(R=>R.user_id===p),T=r.length>1,I=n.length>0?T?`${n.length} contacts`:n[0]:T?`${r.length} contacts`:"this contact";return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Gv,{className:"h-5 w-5"}),"Transfer ",I]}),e.jsxs(Zr,{children:["Select a team member to transfer ",T?"these contacts":"this contact"," to. The contact will be removed from the current owner's CRM and added to the selected member's."]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium mb-2 block",children:"Transfer to:"}),e.jsx("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:j.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No other team members available"}):j.map(R=>{var $,q,U;return e.jsxs("button",{onClick:()=>f(R.user_id),className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${p===R.user_id?"bg-primary/10 border border-primary/30":"hover:bg-accent border border-transparent"}`,children:[e.jsxs(yn,{className:"h-8 w-8",children:[e.jsx(Da,{src:(($=R.profile)==null?void 0:$.avatar_url)||""}),e.jsx(vn,{className:"text-xs",children:(((q=R.profile)==null?void 0:q.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:((U=R.profile)==null?void 0:U.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:R.role.replace("_"," ")})]})]},R.user_id)})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),e.jsx(Ar,{id:"transfer-notes",value:y,onChange:R=>_(R.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:N,disabled:!p||b,children:[b?e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Gv,{className:"h-4 w-4 mr-2"}),"Transfer",S?` to ${(L=S.profile)==null?void 0:L.name}`:""]})]})]})})}const gNe=()=>{const t=Pr(),{data:s,isLoading:r}=iUt(),{data:n}=Lg(),[a,o]=C.useState(""),[l,i]=C.useState("all"),[c,u]=C.useState(null),[p,f]=C.useState(""),y=(n==null?void 0:n.role)==="team_leader",_=C.useMemo(()=>{if(!s)return[];const w=new Map;return s.forEach(j=>{w.has(j.owner_user_id)||w.set(j.owner_user_id,{id:j.owner_user_id,name:j.owner_name||"Unknown",avatar:j.owner_avatar_url})}),Array.from(w.values())},[s]),b=C.useMemo(()=>{if(!s)return[];let w=s;if(l!=="all"&&(w=w.filter(j=>j.owner_user_id===l)),a.trim()){const j=a.toLowerCase();w=w.filter(N=>{var S,T,I;return(N.first_name+" "+(N.last_name||"")).toLowerCase().includes(j)||((S=N.email)==null?void 0:S.toLowerCase().includes(j))||((T=N.phone)==null?void 0:T.includes(j))||((I=N.owner_name)==null?void 0:I.toLowerCase().includes(j))})}return w},[s,a,l]);return r?e.jsxs("div",{className:"space-y-4",children:[e.jsx(xs,{className:"h-10 w-full"}),e.jsx(xs,{className:"h-64 w-full"})]}):!s||s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(mr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Team Contacts"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Team contact sharing is not enabled, or you're not on a team. Ask your manager about contact visibility settings."})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name, email, phone, or agent...",value:a,onChange:w=>o(w.target.value),className:"pl-9"})]}),e.jsxs(rr,{value:l,onValueChange:i,children:[e.jsx(tr,{className:"w-[200px]",children:e.jsx(nr,{placeholder:"Filter by agent"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Team Members"}),_.map(w=>e.jsx(Tt,{value:w.id,children:w.name},w.id))]})]})]})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[b.length," contact",b.length!==1?"s":""," from ",_.length," teammate",_.length!==1?"s":""]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(An,{className:"min-w-[800px]",children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Agent"}),e.jsx(bt,{children:"Contact Info"}),e.jsx(bt,{children:"Address"}),e.jsx(bt,{children:"Lead Source"}),e.jsx(bt,{children:"Date Added"}),y&&e.jsx(bt,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(Pn,{children:b.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:y?7:6,className:"text-center py-8 text-muted-foreground",children:a||l!=="all"?"No contacts match your filters":"No team contacts available"})}):b.map(w=>e.jsxs(ks,{className:`hover:bg-accent/50 ${y?"cursor-pointer":""}`,onClick:y?()=>t(`/mission-control/contacts/${w.id}`):void 0,children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("span",{className:y?"hover:text-primary hover:underline transition-colors":"",children:[w.first_name," ",w.last_name||""]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(yn,{className:"h-6 w-6",children:[e.jsx(Da,{src:w.owner_avatar_url||""}),e.jsx(vn,{className:"text-[10px]",children:(w.owner_name||"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:w.owner_name||"Unknown"})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[w.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(br,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:w.email})]}),w.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(ea,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:w.phone})]}),!w.email&&!w.phone&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),e.jsx(dt,{children:w.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(Ui,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:w.address})]}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(dt,{children:w.lead_source?e.jsx(nt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:w.lead_source}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:ys(new Date(w.created_at),"MMM d, yyyy")})}),y&&e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:j=>{j.stopPropagation(),u(w.id),f(`${w.first_name} ${w.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(Gv,{className:"h-4 w-4"})})})]},w.id))})]})})}),e.jsx(Eet,{open:!!c,onOpenChange:w=>{w||u(null)},contactIds:c?[c]:[],contactNames:p?[p]:[],onComplete:()=>u(null)})]})},xNe=({teamId:t})=>{const{user:s}=Ws(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=Aet(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(xs,{className:"h-20 w-full"},c))});if(r.length===0)return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Wx,{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,y,_,b,w;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=c.contact)==null?void 0:u.first_name," ",((p=c.contact)==null?void 0:p.last_name)||""]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 mt-1",children:[((f=c.contact)==null?void 0:f.email)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(br,{className:"h-3 w-3"})," ",c.contact.email]}),((y=c.contact)==null?void 0:y.phone)&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(ea,{className:"h-3 w-3"})," ",c.contact.phone]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs(yn,{className:"h-4 w-4",children:[e.jsx(Da,{src:((_=c.contributor)==null?void 0:_.avatar_url)||""}),e.jsx(vn,{className:"text-[8px]",children:(((b=c.contributor)==null?void 0:b.name)||"?").charAt(0)})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["from ",((w=c.contributor)==null?void 0:w.name)||"Unknown"]})]})]}),e.jsxs(K,{size:"sm",onClick:()=>a.mutate(c.id),disabled:a.isPending,children:[e.jsx(zI,{className:"mr-1 h-3 w-3"}),"Claim"]})]})},c.id)})})]}),i.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Claimed (",i.length,")"]}),e.jsx("div",{className:"space-y-2",children:i.map(c=>{var u,p,f;return e.jsx(Ee,{className:"opacity-75",children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(u=c.contact)==null?void 0:u.first_name," ",((p=c.contact)==null?void 0:p.last_name)||""]}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs(nt,{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(a1,{className:"mr-1 h-3 w-3"}),"Return"]})]})},c.id)})})]})]})},Pet=({teamId:t})=>{const{useTeamMembers:s}=QS(),{data:r=[]}=s(t),n=r.map(_=>_.user_id),a=new Map(r.map(_=>[_.user_id,_.profile])),{data:o=[],isLoading:l}=wt({queryKey:["team-shared-presentations",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.from("smart_presentations").select("id, owner_user_id, title, client_name, status, view_count, cta_clicked_count, share_token, created_at, published_at").in("owner_user_id",n).neq("status","archived").order("created_at",{ascending:!1});if(b)throw b;return _||[]},enabled:n.length>0}),{data:i=[],isLoading:c}=wt({queryKey:["team-shared-open-houses",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.from("open_houses").select("id, agent_id, property_address, city, state, event_date, is_active, visitor_count, slug, created_at").in("agent_id",n).order("event_date",{ascending:!1});if(b)throw b;return _||[]},enabled:n.length>0}),{data:u=[],isLoading:p}=wt({queryKey:["team-shared-videos",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:b}=await G.from("agent_videos").select("id, owner_user_id, title, recipient_name, status, view_count, touch_type, share_token, created_at").in("owner_user_id",n).eq("is_deleted",!1).order("created_at",{ascending:!1}).limit(50);if(b)throw b;return _||[]},enabled:n.length>0});if(l||c||p)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(_=>e.jsx(xs,{className:"h-20 w-full"},_))});const y=_=>{const b=a.get(_);return{name:(b==null?void 0:b.name)||"Unknown",avatar:(b==null?void 0:b.avatar_url)||"",initials:((b==null?void 0:b.name)||"?").charAt(0).toUpperCase()}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-3",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(Gx,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:o.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Presentations"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(Rn,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:i.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Guest Books"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsx(Nn,{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(Aa,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(ja,{children:[e.jsxs(js,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(js,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(js,{value:"videos",children:["Videos (",u.length,")"]})]}),e.jsx($s,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx(wxe,{icon:e.jsx(Gx,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(_=>{const b=y(_.owner_user_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(yn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Da,{src:b.avatar}),e.jsx(vn,{className:"text-xs",children:b.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:_.title||"Untitled"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.name," · ",ys(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(nt,{variant:_.status==="published"?"default":"secondary",className:"text-xs capitalize",children:_.status}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(va,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})}),e.jsx($s,{value:"guest-books",className:"space-y-2",children:i.length===0?e.jsx(wxe,{icon:e.jsx(Rn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(_=>{const b=y(_.agent_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(yn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Da,{src:b.avatar}),e.jsx(vn,{className:"text-xs",children:b.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:_.property_address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.name," · ",ys(new Date(_.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[_.is_active?e.jsx(nt,{className:"text-xs",children:"Active"}):e.jsx(nt,{variant:"secondary",className:"text-xs",children:"Inactive"}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(mr,{className:"h-3 w-3"}),_.visitor_count||0]})]})]})},_.id)})}),e.jsx($s,{value:"videos",className:"space-y-2",children:u.length===0?e.jsx(wxe,{icon:e.jsx(Nn,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(_=>{const b=y(_.owner_user_id);return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(yn,{className:"h-8 w-8 shrink-0",children:[e.jsx(Da,{src:b.avatar}),e.jsx(vn,{className:"text-xs",children:b.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:_.title||_.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.name," · ",ys(new Date(_.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(nt,{variant:"secondary",className:"text-xs capitalize",children:_.touch_type}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(va,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})})]})]})},wxe=({icon:t,label:s})=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center text-muted-foreground",children:[t,e.jsx("p",{className:"mt-2 text-sm",children:s})]})}),Iet=({team:t,brokerageAgents:s,onBack:r,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:c,isAddingMember:u})=>{var $,q;const{useTeamMembers:p}=QS(),{data:f=[],isLoading:y}=p(t.id),[_,b]=C.useState(!1),[w,j]=C.useState(""),[N,S]=C.useState("team_member"),{data:T}=wt({queryKey:["agents-on-other-teams",t.id],queryFn:async()=>{const{data:U}=await G.from("team_members").select("user_id, team_id, teams:team_id(name)").neq("team_id",t.id),V=new Map;return(U||[]).forEach(X=>{var se;V.set(X.user_id,((se=X.teams)==null?void 0:se.name)||"another team")}),V}}),I=new Set(f.map(U=>U.user_id)),L=s.filter(U=>!I.has(U.id)),R=async()=>{w&&(await a(w,N),j(""),S("team_member"),b(!1))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(K,{variant:"ghost",onClick:r,className:"mb-2",children:"← Back to Teams"}),e.jsxs(Aa,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(ja,{children:[e.jsx(js,{value:"members",children:"Members"}),e.jsxs(js,{value:"contacts",children:[e.jsx(B4,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(js,{value:"lead-pond",children:[e.jsx(Wx,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(js,{value:"shared-assets",children:[e.jsx(Cm,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(js,{value:"settings",children:"Settings"})]}),e.jsxs($s,{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(_s,{open:_,onOpenChange:b,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Pc,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Add Team Member"}),e.jsxs(Zr,{children:["Select an agent from your brokerage to add to ",t.name,"."]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Agent"}),e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[w&&((($=L.find(U=>U.id===w))==null?void 0:$.name)||((q=L.find(U=>U.id===w))==null?void 0:q.email))||"Select an agent",e.jsx(xg,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Eo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Mg,{children:[e.jsx(Tg,{placeholder:"Search agents..."}),e.jsxs(Ag,{children:[e.jsx(Eg,{children:"No agents found."}),e.jsx(Pg,{children:L.map(U=>{const V=T==null?void 0:T.get(U.id);return e.jsxs(up,{value:U.name||U.email||U.id,disabled:!!V,onSelect:()=>j(U.id),children:[e.jsx(ma,{className:At("mr-2 h-4 w-4",w===U.id?"opacity-100":"opacity-0")}),U.name||U.email,V&&e.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",V,")"]})]},U.id)})})]})]})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Role"}),e.jsxs(rr,{value:N,onValueChange:S,children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"team_leader",children:"Team Leader"}),e.jsx(Tt,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{onClick:R,disabled:!w||u,children:u?"Adding...":"Add to Team"})]})]})]})]}),y?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(U=>e.jsx(xs,{className:"h-16 w-full"},U))}):f.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(mr,{className:"h-10 w-10 text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No members yet. Add agents to this team."})]})}):e.jsx("div",{className:"space-y-2",children:f.map(U=>{var V,X,se,ee,Q;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(yn,{className:"h-10 w-10",children:[e.jsx(Da,{src:((V=U.profile)==null?void 0:V.avatar_url)||""}),e.jsx(vn,{children:(((X=U.profile)==null?void 0:X.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((se=U.profile)==null?void 0:se.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(ee=U.profile)==null?void 0:ee.email})]}),U.role==="team_leader"?e.jsxs(nt,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(Sm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(nt,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(rr,{value:U.role,onValueChange:de=>l(U.id,de),children:[e.jsx(tr,{className:"w-[140px]",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"team_leader",children:"Team Leader"}),e.jsx(Tt,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx(xL,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Remove Member?"}),e.jsxs(Gl,{children:["Remove ",((Q=U.profile)==null?void 0:Q.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>o(U.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})]})]})},U.id)})})]}),e.jsx($s,{value:"contacts",className:"space-y-4",children:e.jsx(gNe,{})}),t.lead_pond_enabled&&e.jsx($s,{value:"lead-pond",className:"space-y-4",children:e.jsx(xNe,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx($s,{value:"shared-assets",className:"space-y-4",children:e.jsx(Pet,{teamId:t.id})}),e.jsxs($s,{value:"settings",className:"space-y-4",children:[e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{className:"text-lg",children:"Team Settings"}),e.jsx(fr,{children:"Configure how this team operates."})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Team Name"}),e.jsx(Fe,{defaultValue:t.name,onBlur:U=>{U.target.value!==t.name&&n({name:U.target.value})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Ar,{defaultValue:t.description||"",onBlur:U=>{U.target.value!==(t.description||"")&&n({description:U.target.value||null})},rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Contact Visibility"}),e.jsxs(rr,{defaultValue:t.contact_visibility,onValueChange:U=>n({contact_visibility:U}),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"private",children:"Private — Members keep their contacts private"}),e.jsx(Tt,{value:"leader_only",children:"Leader Only — Only team leaders can see member contacts"}),e.jsx(Tt,{value:"full_team",children:"Full Team — All team members can see shared contacts"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls whether team leaders and members can view each other's contacts."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Lead Pond"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable a shared lead pool where leaders can drop leads for members to claim."})]}),e.jsx(Br,{checked:t.lead_pond_enabled,onCheckedChange:U=>n({lead_pond_enabled:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Shared Assets"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow team members to access shared presentations, guest books, and videos."})]}),e.jsx(Br,{checked:t.shared_assets_enabled,onCheckedChange:U=>n({shared_assets_enabled:U})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Shared Video Library"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Let team members browse and use each other's videos from the Video Library."})]}),e.jsx(Br,{checked:t.shared_videos_enabled??!1,onCheckedChange:U=>n({shared_videos_enabled:U})})]})]})]}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsxs(K,{variant:"destructive",size:"sm",children:[e.jsx(jr,{className:"mr-2 h-4 w-4"}),"Delete Team"]})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Delete Team?"}),e.jsxs(Gl,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},Let=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[c,u]=C.useState(1),[p,f]=C.useState(""),[y,_]=C.useState(""),[b,w]=C.useState(""),[j,N]=C.useState(""),[S,T]=C.useState([]),I=()=>{u(1),f(""),_(""),w(""),N(""),T([])},L=U=>{U||I(),s(U)},R=async()=>{const U=b&&b!=="none"?b:i||null;await r({name:p.trim(),description:y.trim()||void 0,brokerage_id:U,leaderId:j||void 0,memberIds:S.length>0?S:void 0}),I()},$=U=>{U!==j&&T(V=>V.includes(U)?V.filter(X=>X!==U):[...V,U])},q=a.filter(U=>U.id!==j);return e.jsx(_s,{open:t,onOpenChange:L,children:e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:c===1?"Create New Team":"Assign Team Members"}),e.jsx(Zr,{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:At("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:At("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(_e,{htmlFor:"team-name",children:"Team Name *"}),e.jsx(Fe,{id:"team-name",value:p,onChange:U=>f(U.target.value),placeholder:"e.g., Downtown Squad",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"team-desc",children:"Description"}),e.jsx(Ar,{id:"team-desc",value:y,onChange:U=>_(U.target.value),placeholder:"What is this team focused on?",rows:3})]}),o&&l&&l.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Brokerage"}),e.jsxs(rr,{value:b,onValueChange:w,children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"No brokerage (independent team)"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"No brokerage (independent)"}),l.map(U=>e.jsx(Tt,{value:U.id,children:U.name},U.id))]})]})]})]}):e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{className:"flex items-center gap-1.5",children:[e.jsx(Sm,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs(rr,{value:j,onValueChange:U=>{N(U),T(V=>V.filter(X=>X!==U))},children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select a team leader (optional)"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"No leader for now"}),a.map(U=>e.jsx(Tt,{value:U.id,children:U.name||U.email||"Unknown"},U.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{className:"flex items-center gap-1.5",children:[e.jsx(Pc,{className:"h-3.5 w-3.5"}),"Initial Members",S.length>0&&e.jsxs(nt,{variant:"secondary",className:"ml-1 text-xs",children:[S.length," selected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click agents to add them. You can always add more later."}),e.jsx("div",{className:"border rounded-lg max-h-[240px] overflow-y-auto divide-y",children:q.length===0?e.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:[e.jsx(mr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):q.map(U=>{const V=S.includes(U.id);return e.jsxs("button",{type:"button",className:At("w-full flex items-center gap-3 p-3 text-left transition-colors hover:bg-accent/50",V&&"bg-primary/5"),onClick:()=>$(U.id),children:[e.jsxs(yn,{className:"h-8 w-8",children:[e.jsx(Da,{src:U.avatar_url||""}),e.jsx(vn,{className:"text-xs",children:(U.name||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:U.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:U.email})]}),e.jsx("div",{className:At("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(ma,{className:"h-3 w-3"})})]},U.id)})})]})]})}),e.jsx(Vn,{className:"gap-2 sm:gap-0",children:c===1?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>u(2),disabled:!p.trim(),children:["Next",e.jsx(Ki,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>u(1),children:[e.jsx(di,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(K,{onClick:R,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},lUt=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=QS(),[c,u]=C.useState(!1),[p,f]=C.useState(null),[y,_]=C.useState(""),{data:b}=wt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:L,error:R}=await G.from("brokerages").select("id, name").order("name");if(R)throw R;return L||[]}}),{data:w}=wt({queryKey:["admin-team-member-info",t.map(L=>L.id).join(",")],queryFn:async()=>{var U;if(t.length===0)return{};const{data:L}=await G.from("team_members").select("team_id, user_id, role").in("team_id",t.map(V=>V.id));if(!L)return{};const R=L.filter(V=>V.role==="team_leader").map(V=>V.user_id);let $={};if(R.length>0){const{data:V}=await G.from("profiles").select("id, name").in("id",R);V&&($=Object.fromEntries(V.map(X=>[X.id,{name:X.name}])))}const q={};for(const V of t){const X=L.filter(ee=>ee.team_id===V.id),se=X.find(ee=>ee.role==="team_leader");q[V.id]={count:X.length,leaderName:se&&((U=$[se.user_id])==null?void 0:U.name)||null}}return q},enabled:t.length>0}),j=(p==null?void 0:p.brokerage_id)||null,{data:N}=wt({queryKey:["brokerage-agents-for-teams",j],queryFn:async()=>{let L=G.from("profiles").select("id, name, email, avatar_url").order("name");j&&(L=L.eq("brokerage_id",j));const{data:R,error:$}=await L;if($)throw $;return R||[]},enabled:!!p}),S=Object.fromEntries((b||[]).map(L=>[L.id,L.name])),T=async L=>{const R=await r.mutateAsync({name:L.name,brokerage_id:L.brokerage_id||null,description:L.description});if(L.leaderId&&L.leaderId!=="none"&&await o.mutateAsync({team_id:R.id,user_id:L.leaderId,role:"team_leader"}),L.memberIds)for(const $ of L.memberIds)await o.mutateAsync({team_id:R.id,user_id:$,role:"team_member"});u(!1)};if(p)return e.jsx(Iet,{team:p,brokerageAgents:N||[],onBack:()=>f(null),onUpdate:L=>n.mutateAsync({id:p.id,...L}).then(R=>f(R)),onAddMember:(L,R)=>o.mutateAsync({team_id:p.id,user_id:L,role:R}),onRemoveMember:L=>l.mutateAsync({team_id:p.id,member_id:L}),onUpdateRole:(L,R)=>i.mutateAsync({team_id:p.id,member_id:L,role:R}),onDeleteTeam:()=>{a.mutate(p.id),f(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const I=t.filter(L=>L.name.toLowerCase().includes(y.toLowerCase())||(L.description||"").toLowerCase().includes(y.toLowerCase()));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search teams...",value:y,onChange:L=>_(L.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[I.length," of ",t.length," teams"]})]}),e.jsxs(K,{size:"sm",onClick:()=>u(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(Let,{open:c,onOpenChange:u,onCreateTeam:T,isCreating:r.isPending,brokerageAgents:[],isAdmin:!0,allBrokerages:b,activeBrokerageId:null}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(bt,{className:"font-semibold",children:"Team Name"}),e.jsx(bt,{className:"font-semibold",children:"Brokerage"}),e.jsx(bt,{className:"font-semibold",children:"Leader"}),e.jsx(bt,{className:"font-semibold",children:"Members"}),e.jsx(bt,{className:"font-semibold",children:"Visibility"}),e.jsx(bt,{className:"w-[100px]"})]})}),e.jsx(Pn,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(L=>e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsx(xs,{className:"h-4 w-32"})}),e.jsx(dt,{children:e.jsx(xs,{className:"h-4 w-24"})}),e.jsx(dt,{children:e.jsx(xs,{className:"h-4 w-28"})}),e.jsx(dt,{children:e.jsx(xs,{className:"h-4 w-12"})}),e.jsx(dt,{children:e.jsx(xs,{className:"h-4 w-20"})}),e.jsx(dt,{children:e.jsx(xs,{className:"h-4 w-16"})})]},L))}):I.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:6,className:"text-center py-12 text-muted-foreground",children:y?"No teams match your search":"No teams found. Create one to get started."})}):I.map(L=>{const R=w==null?void 0:w[L.id];return e.jsxs(ks,{className:"hover:bg-muted/30",children:[e.jsxs(dt,{children:[e.jsx("button",{onClick:()=>f(L),className:"text-primary hover:underline font-medium",children:L.name}),L.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:L.description})]}),e.jsx(dt,{children:L.brokerage_id?e.jsx("span",{className:"text-sm",children:S[L.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(dt,{children:R!=null&&R.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(Sm,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),R.leaderName]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No leader"})}),e.jsx(dt,{children:e.jsxs(nt,{variant:"secondary",className:"text-xs",children:[e.jsx(mr,{className:"h-3 w-3 mr-1"}),(R==null?void 0:R.count)??0]})}),e.jsx(dt,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(Bh,{className:"h-3 w-3"}),L.contact_visibility.replace("_"," ")]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>f(L),title:"Edit team",children:e.jsx($a,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>{confirm(`Delete team "${L.name}"? This cannot be undone.`)&&a.mutate(L.id)},title:"Delete team",children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})})]},L.id)})})]})})]})},cUt=()=>{const t=Pr(),{user:s,isAdmin:r}=Ws(),{startImpersonation:n,isLoading:a}=Dwe(),{toast:o}=Ra(),[l,i]=C.useState([]),[c,u]=C.useState([]),[p,f]=C.useState([]),[y,_]=C.useState({}),[b,w]=C.useState(!0),[j,N]=C.useState({}),[S,T]=C.useState(!1),[I,L]=C.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[R,$]=C.useState(!1),[q,U]=C.useState(""),[V,X]=C.useState(1),[se,ee]=C.useState(50),[Q,de]=C.useState("all"),[re,ne]=C.useState("all"),[le,he]=C.useState("all"),[we,ye]=C.useState("all"),[je,ke]=C.useState(!1),[We,be]=C.useState(!1),[Me,Ae]=C.useState(null),[Re,Te]=C.useState(null),[qe,ct]=C.useState(!1),[De,Rt]=C.useState({name:"",email:"",brokerage_id:"",phone:""}),[pe,Je]=C.useState(null),[lt,rt]=C.useState(!1),[Se,it]=C.useState(""),[$e,ot]=C.useState(!1),[Ue,Ke]=C.useState(!1),[Xe,He]=C.useState(null),[Ye,tt]=C.useState(""),[Et,qt]=C.useState(!1),[ms,Xt]=C.useState(!1),[rs,ps]=C.useState(null),[Ms,jt]=C.useState(!1),[As,Ps]=C.useState(!1),[ar,Dn]=C.useState(null),[Va,pa]=C.useState(""),[qa,Kr]=C.useState(!1),[Yn,mn]=C.useState({email:"",name:"",password:"",phone:""}),[Gn,Zt]=C.useState(!1),[$r,es]=C.useState(!1),[an,Ha]=C.useState(""),[Xn,Ir]=C.useState(!1),[_i,rl]=C.useState(!1),[Ni,sc]=C.useState(""),[Vt,ve]=C.useState(new Set),[ze,Qe]=C.useState(!1),[Ct,Nt]=C.useState(!1),[zt,Kt]=C.useState(null),[$t,Qt]=C.useState(!1),[Is,gs]=C.useState(null),[gr,qr]=C.useState([]),[hr,Cn]=C.useState([]),[Mn,jn]=C.useState(!1),[fa,go]=C.useState({});C.useEffect(()=>{!s||!r||(Qa(),nl())},[s,r]);const Qo=async()=>{try{const{data:xt,error:Ts}=await G.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(Ts)throw Ts;const Ys={};for(const ln of xt??[])Ys[ln.brokerage_id]||(Ys[ln.brokerage_id]=[]),Ys[ln.brokerage_id].push(ln.user_id);_(Ys)}catch(xt){console.error("Error loading brokerage manager assignments:",xt)}},Qa=async()=>{try{w(!0);const{data:xt,error:Ts}=await G.functions.invoke("get-user-details");if(Ts)throw Ts;const Ys=xt.users||[];i(Ys),f(xt.brokerages||[]),await Qo();const ln=Ys.filter(cn=>cn.roles.includes("assistant"));if(ln.length>0){const cn=ln.map(Fr=>Fr.id),{data:na}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",cn);if(na&&na.length>0){const Fr=[...new Set(na.map(Ap=>Ap.agent_id))],{data:oo}=await G.from("profiles").select("id, name, email").in("id",Fr),Hg={};for(const Ap of na){const Hr=oo==null?void 0:oo.find(H0=>H0.id===Ap.agent_id);Hr&&(Hg[Ap.assistant_id]={agent_name:Hr.name||"",agent_email:Hr.email||""})}go(Hg)}}}catch(xt){console.error("Error loading members:",xt),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{w(!1)}},nl=async()=>{try{const{data:xt,error:Ts}=await G.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(Ts)throw Ts;u(xt||[])}catch(xt){console.error("Error loading apps:",xt),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},no=async xt=>{if(!De.name.trim()||!De.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(De.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:Ys}=await G.from("profiles").update({name:De.name.trim(),email:De.email.trim(),brokerage_id:De.brokerage_id||null,phone:De.phone.trim()||null}).eq("id",xt);if(Ys)throw Ys;o({title:"Success",description:"Member details updated successfully"}),Ae(null),Qa()}catch(Ys){console.error("Error updating member:",Ys),o({title:"Error",description:Ys.message||"Failed to update member",variant:"destructive"})}},Na=async xt=>{try{const{data:{session:Ts}}=await G.auth.getSession(),Ys=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ts==null?void 0:Ts.access_token}`},body:JSON.stringify({userId:xt})}),ln=await Ys.json();if(!Ys.ok)throw new Error(ln.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(Ts){console.error("Error resending welcome email:",Ts),o({title:"Error",description:Ts.message||"Failed to resend welcome email",variant:"destructive"})}},ao=async(xt,Ts)=>{try{const{error:Ys}=await G.functions.invoke("send-password-reset",{body:{email:xt,redirectTo:window.location.origin}});if(Ys)throw Ys;o({title:"Password Reset Sent",description:`Password reset email sent to ${Ts}`})}catch(Ys){console.error("Error sending password reset:",Ys),o({title:"Error",description:Ys.message||"Failed to send password reset email",variant:"destructive"})}},Si=async(xt,Ts)=>{if(confirm(`Are you sure you want to delete ${Ts}? This action cannot be undone.`))try{const{data:{session:Ys}}=await G.auth.getSession(),ln=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ys==null?void 0:Ys.access_token}`},body:JSON.stringify({userId:xt})}),cn=await ln.json();if(!ln.ok)throw new Error(cn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),Qa()}catch(Ys){console.error("Error deleting user:",Ys),o({title:"Error",description:Ys.message||"Failed to delete user",variant:"destructive"})}},aa=async()=>{if(!I.email||!I.name||!I.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}if(I.role==="brokerage_manager"&&!I.brokerage_id){o({title:"Error",description:"Please select a brokerage for this manager",variant:"destructive"});return}T(!0);try{const{data:{session:xt}}=await G.auth.getSession(),Ts=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${xt==null?void 0:xt.access_token}`},body:JSON.stringify(I)}),Ys=await Ts.json();if(!Ts.ok)throw new Error(Ys.error||"Failed to create user");if(I.role&&I.role!=="user"&&Ys.userId){const ln=I.role==="brokerage_manager"?I.brokerage_id:void 0;await io(Ys.userId,I.role,"add",ln)}o({title:"Success",description:`User ${I.email} created successfully`}),L({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),$(!1),Qa()}catch(xt){console.error("Error creating user:",xt),o({title:"Error",description:xt.message||"Failed to create user",variant:"destructive"})}finally{T(!1)}},io=async(xt,Ts,Ys,ln)=>{try{const{data:{session:cn}}=await G.auth.getSession(),na={userId:xt,role:Ts,action:Ys};if(Ts==="brokerage_manager"){if(!ln){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}na.brokerageId=ln}const Fr=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${cn==null?void 0:cn.access_token}`},body:JSON.stringify(na)}),oo=await Fr.json();if(!Fr.ok)throw new Error(oo.error||"Failed to manage user role");o({title:"Success",description:`Role ${Ys==="add"?"added":"removed"} successfully`}),Qa()}catch(cn){console.error("Error managing user role:",cn),o({title:"Error",description:cn.message||"Failed to manage user role",variant:"destructive"})}},yc=(xt,Ts)=>Ts.length===0?!0:Ts.some(Ys=>xt.includes(Ys)),Lc=async(xt,Ts,Ys)=>{const ln=`${xt}-${Ts.id}`;Je(ln);try{if(Ys){const cn=l.find(Fr=>Fr.id===xt),na=Ts.required_tags.filter(Fr=>cn==null?void 0:cn.tags.includes(Fr));for(const Fr of na){const{error:oo}=await G.from("user_tags").delete().eq("user_id",xt).eq("tag",Fr);if(oo)throw oo}o({title:"Access Removed",description:`Removed access to ${Ts.name}`})}else if(Ts.required_tags.length>0){const{error:cn}=await G.from("user_tags").insert({user_id:xt,tag:Ts.required_tags[0]});if(cn)throw cn;o({title:"Access Granted",description:`Granted access to ${Ts.name}`})}await Qa()}catch(cn){console.error("Error toggling access:",cn),o({title:"Error",description:cn.message||"Failed to update access",variant:"destructive"})}finally{Je(null)}},eu=async()=>{const xt=Se.trim();if(!xt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(xt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(p.find(Ys=>Ys.name.toLowerCase()===xt.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}ot(!0);try{const{error:Ys}=await G.from("brokerages").insert({name:xt});if(Ys)throw Ys;o({title:"Success",description:`Brokerage "${xt}" created successfully`}),it(""),rt(!1),Qa()}catch(Ys){console.error("Error creating brokerage:",Ys),o({title:"Error",description:Ys.message||"Failed to create brokerage",variant:"destructive"})}finally{ot(!1)}},Cf=xt=>{He(xt),tt(xt.name),Ke(!0)},El=()=>{He(null),tt(""),Ke(!1)},th=async()=>{if(!Xe)return;const xt=Ye.trim();if(!xt){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(xt.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}qt(!0);try{const{error:Ts}=await G.from("brokerages").update({name:xt}).eq("id",Xe.id);if(Ts)throw Ts;o({title:"Success",description:"Brokerage updated successfully"}),El(),Qa()}catch(Ts){console.error("Error updating brokerage:",Ts),o({title:"Error",description:Ts.message||"Failed to update brokerage",variant:"destructive"})}finally{qt(!1)}},yd=async(xt,Ts)=>{var Ys;if(!Ts||typeof Ts!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const ln={userId:xt,role:"brokerage_manager",action:"add",brokerageId:Ts};console.debug("[assignManagerToBrokerage] payload",ln);const{data:{session:cn}}=await G.auth.getSession(),na=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${cn==null?void 0:cn.access_token}`},body:JSON.stringify(ln)}),Fr=await na.json();if(!na.ok&&!((Ys=Fr.error)!=null&&Ys.includes("duplicate")))throw new Error(Fr.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await Qa()}catch(ln){console.error("Error assigning manager:",ln),o({title:"Error",description:ln.message||"Failed to assign manager",variant:"destructive"})}},zm=xt=>{ps(xt),Xt(!0)},Pl=async()=>{if(rs){jt(!0);try{const xt=l.filter(ln=>ln.brokerage_id===rs.id),{data:{session:Ts}}=await G.auth.getSession();for(const ln of xt){const cn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ts==null?void 0:Ts.access_token}`},body:JSON.stringify({userId:ln.id})});if(!cn.ok){const na=await cn.json();console.error(`Failed to delete user ${ln.email}:`,na.error)}}const{error:Ys}=await G.from("brokerages").delete().eq("id",rs.id);if(Ys)throw Ys;o({title:"Success",description:`Brokerage "${rs.name}" and ${xt.length} member(s) deleted`}),Xt(!1),ps(null),Qa()}catch(xt){console.error("Error deleting brokerage:",xt),o({title:"Error",description:xt.message||"Failed to delete brokerage",variant:"destructive"})}finally{jt(!1)}}},qg=xt=>{Dn(xt),pa(""),Ps(!0)},uy=()=>{Dn(null),pa(""),Ps(!1)},D1=async xt=>{try{const{error:Ts}=await G.from("profiles").update({brokerage_id:null}).eq("id",xt);if(Ts)throw Ts;o({title:"Success",description:"User removed from brokerage"}),Qa()}catch(Ts){console.error("Error removing user from brokerage:",Ts),o({title:"Error",description:Ts.message||"Failed to remove user",variant:"destructive"})}},O1=async(xt,Ts)=>{try{const{error:Ys}=await G.from("profiles").update({brokerage_id:Ts}).eq("id",xt);if(Ys)throw Ys;o({title:"Success",description:"User added to brokerage"}),Qa()}catch(Ys){console.error("Error adding user to brokerage:",Ys),o({title:"Error",description:Ys.message||"Failed to add user",variant:"destructive"})}},R1=async()=>{if(!ar||!Yn.email||!Yn.name||!Yn.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}Zt(!0);try{const{data:{session:xt}}=await G.auth.getSession(),Ts=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${xt==null?void 0:xt.access_token}`},body:JSON.stringify({...Yn,brokerage_id:ar.id,role:"user"})}),Ys=await Ts.json();if(!Ts.ok)throw new Error(Ys.error||"Failed to create agent");o({title:"Success",description:`Agent ${Yn.email} created successfully`}),mn({email:"",name:"",password:"",phone:""}),Kr(!1),Qa()}catch(xt){console.error("Error creating agent:",xt),o({title:"Error",description:xt.message||"Failed to create agent",variant:"destructive"})}finally{Zt(!1)}},Tp=xt=>l.filter(Ts=>Ts.brokerage_id===xt),Qh=xt=>{const Ts=Tp(xt);if(!Va)return Ts;const Ys=Va.toLowerCase();return Ts.filter(ln=>ln.name.toLowerCase().includes(Ys)||ln.email.toLowerCase().includes(Ys))},tu=xt=>l.filter(Ts=>Ts.brokerage_id!==xt),Jh=l.filter(xt=>{var Ys;if(q){const ln=q.toLowerCase();if(!(xt.name.toLowerCase().includes(ln)||xt.email.toLowerCase().includes(ln)||((Ys=xt.brokerage_name)==null?void 0:Ys.toLowerCase().includes(ln))))return!1}if(Q==="claimed"&&!xt.claimed||Q==="unclaimed"&&xt.claimed||re!=="all"&&!xt.roles.includes(re))return!1;const Ts=xt.is_trial||xt.subscription_status==="trialing";return!(le==="trial"&&!Ts||le==="non-trial"&&Ts||we==="none"&&xt.brokerage_id||we!=="all"&&we!=="none"&&xt.brokerage_id!==we)}),{sortKey:Ld,sortDirection:vd,handleSort:su,sortData:Mf}=EO("created_at","desc"),Tf=Mf(Jh,{name:xt=>{var Ts;return((Ts=xt.name)==null?void 0:Ts.toLowerCase())||""},brokerage:xt=>{var Ts;return((Ts=xt.brokerage_name)==null?void 0:Ts.toLowerCase())||""},status:xt=>xt.claimed?"active":"pending",role:xt=>xt.roles[0]||"",last_login:xt=>xt.last_sign_in_at?new Date(xt.last_sign_in_at).getTime():null,created_at:xt=>xt.created_at?new Date(xt.created_at).getTime():null}),Bm=Tf.length,$m=se===0,_d=$m?1:Math.ceil(Bm/se),$0=$m?0:(V-1)*se,Ug=$m?Bm:$0+se,jl=Tf.slice($0,Ug),F1=xt=>{U(xt),X(1)},Vg=xt=>{ee(xt),X(1)},jh=(xt,Ts)=>{xt(Ts),X(1)},R2=async(xt,Ts)=>{ke(!0);try{const Ys=l.find(Fr=>Fr.id===xt);if(!Ys)return;const ln=Ys.trial_expires_at?new Date(Ys.trial_expires_at):new Date,cn=new Date(ln.getTime()+Ts*24*60*60*1e3),{error:na}=await G.from("profiles").update({trial_expires_at:cn.toISOString()}).eq("id",xt);if(na)throw na;o({title:"Trial Extended",description:`Trial extended by ${Ts} days`}),Qa()}catch(Ys){console.error("Error extending trial:",Ys),o({title:"Error",description:Ys.message||"Failed to extend trial",variant:"destructive"})}finally{ke(!1)}},lC=async xt=>{be(!0);try{const{error:Ts}=await G.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",xt);if(Ts)throw Ts;o({title:"Account Converted",description:"User has been converted to a full account"}),Qa(),hy()}catch(Ts){console.error("Error converting trial:",Ts),o({title:"Error",description:Ts.message||"Failed to convert account",variant:"destructive"})}finally{be(!1)}},q0=async xt=>{jn(!0);try{const{data:Ts}=await G.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",xt);if(Ts&&Ts.length>0){const ln=Ts.map(na=>na.assistant_id),{data:cn}=await G.from("profiles").select("id, name, email").in("id",ln);qr(Ts.map(na=>{const Fr=cn==null?void 0:cn.find(oo=>oo.id===na.assistant_id);return{id:na.id,assistant_id:na.assistant_id,assistant_name:(Fr==null?void 0:Fr.name)||"Unknown",assistant_email:(Fr==null?void 0:Fr.email)||"",permissions:na.permissions||{}}}))}else qr([]);const{data:Ys}=await G.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",xt);if(Ys&&Ys.length>0){const ln=Ys.map(na=>na.agent_id),{data:cn}=await G.from("profiles").select("id, name, email").in("id",ln);Cn(Ys.map(na=>{const Fr=cn==null?void 0:cn.find(oo=>oo.id===na.agent_id);return{id:na.id,agent_id:na.agent_id,agent_name:(Fr==null?void 0:Fr.name)||"Unknown",agent_email:(Fr==null?void 0:Fr.email)||"",permissions:na.permissions||{}}}))}else Cn([])}catch(Ts){console.error("Error loading assistant data:",Ts)}finally{jn(!1)}},Sa=xt=>{Te(xt),Rt({name:xt.name,email:xt.email,brokerage_id:xt.brokerage_id||"",phone:xt.phone||""}),ct(!0),q0(xt.id)},hy=()=>{Te(null),ct(!1),Rt({name:"",email:"",brokerage_id:"",phone:""})},F2=async()=>{Re&&(await no(Re.id),hy())},cC=xt=>{ve(Ts=>{const Ys=new Set(Ts);return Ys.has(xt)?Ys.delete(xt):Ys.add(xt),Ys})},dC=()=>{if(Vt.size===jl.length&&jl.every(xt=>Vt.has(xt.id))){const xt=new Set(Vt);jl.forEach(Ts=>xt.delete(Ts.id)),ve(xt)}else{const xt=new Set(Vt);jl.forEach(Ts=>xt.add(Ts.id)),ve(xt)}},em=()=>{ve(new Set)},U0=async()=>{if(Vt.size===0)return;Qe(!0);let xt=0,Ts=0;try{const{data:{session:Ys}}=await G.auth.getSession();for(const ln of Vt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ys==null?void 0:Ys.access_token}`},body:JSON.stringify({userId:ln})})).ok?xt++:Ts++}catch{Ts++}o({title:"Bulk Email Complete",description:`Sent ${xt} emails${Ts>0?`, ${Ts} failed`:""}`}),em()}catch(Ys){o({title:"Error",description:Ys.message||"Failed to send emails",variant:"destructive"})}finally{Qe(!1)}},V0=async()=>{if(Vt.size===0)return;Qe(!0);let xt=0,Ts=0;try{const{data:{session:Ys}}=await G.auth.getSession();for(const ln of Vt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ys==null?void 0:Ys.access_token}`},body:JSON.stringify({userId:ln})})).ok?xt++:Ts++}catch{Ts++}o({title:"Bulk Password Reset Complete",description:`Sent ${xt} reset emails${Ts>0?`, ${Ts} failed`:""}`}),em()}catch(Ys){o({title:"Error",description:Ys.message||"Failed to send password reset emails",variant:"destructive"})}finally{Qe(!1)}},z2=async()=>{if(Vt.size===0)return;const xt=l.filter(cn=>Vt.has(cn.id)).map(cn=>cn.name).slice(0,5).join(", "),Ts=Vt.size>5?` and ${Vt.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${Vt.size} users (${xt}${Ts})? This action cannot be undone.`))return;Qe(!0);let Ys=0,ln=0;try{const{data:{session:cn}}=await G.auth.getSession();for(const na of Vt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${cn==null?void 0:cn.access_token}`},body:JSON.stringify({userId:na})})).ok?Ys++:ln++}catch{ln++}o({title:"Bulk Delete Complete",description:`Deleted ${Ys} users${ln>0?`, ${ln} failed`:""}`}),em(),Qa()}catch(cn){o({title:"Error",description:cn.message||"Failed to delete users",variant:"destructive"})}finally{Qe(!1)}},z1=async()=>{Nt(!0);try{const{data:{session:xt}}=await G.auth.getSession(),Ts=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-phone-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${xt==null?void 0:xt.access_token}`}});if(!Ts.ok){const ln=await Ts.json();throw new Error(ln.error||"Failed to sync phones")}const Ys=await Ts.json();o({title:"Phone Sync Complete",description:`Pulled ${Ys.summary.pulledFromGHL} from GHL, pushed ${Ys.summary.pushedToGHL} to GHL, ${Ys.summary.alreadySynced} already synced`}),Qa()}catch(xt){o({title:"Error",description:xt.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{Nt(!1)}},qm=async(xt,Ts)=>{Kt(xt);try{const{data:{session:Ys}}=await G.auth.getSession(),{data:ln}=await G.from("profiles").select("phone").eq("id",xt).single(),cn=(ln==null?void 0:ln.phone)||"",na=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ys==null?void 0:Ys.access_token}`},body:JSON.stringify({email:Ts,action:"update",phone:cn||void 0})});if(!na.ok){const oo=await na.json();throw new Error(oo.error||"Failed to sync with GHL")}const Fr=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(Ts)}`,{method:"GET",headers:{"Content-Type":"application/json"}});o({title:"Phone Synced",description:cn?`Phone ${cn} synced to GHL`:"Sync attempted - run bulk sync to pull phone from GHL"}),Qa()}catch(Ys){o({title:"Error",description:Ys.message||"Failed to sync phone",variant:"destructive"})}finally{Kt(null)}},my=async xt=>{await n(xt)},B2=()=>{if(Vt.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const xt=l.filter(oo=>Vt.has(oo.id)),Ts=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],Ys=xt.map(oo=>[oo.name,oo.email,oo.phone||"",oo.brokerage_name||"",oo.roles.join("; "),oo.claimed?"Claimed":"Unclaimed",new Date(oo.created_at).toLocaleDateString()]),ln=[Ts.join(","),...Ys.map(oo=>oo.map(Hg=>`"${(Hg||"").replace(/"/g,'""')}"`).join(","))].join(` `),cn=new Blob([ln],{type:"text/csv"}),na=URL.createObjectURL(cn),Fr=document.createElement("a");Fr.href=na,Fr.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,Fr.click(),URL.revokeObjectURL(na),o({title:"Export complete",description:`Exported ${xt.length} member(s)`})};return b?e.jsx(Es,{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(Es,{title:"Members",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{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:z1,disabled:Ct,children:[Ct?e.jsx(Ss,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(ea,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:Ct?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:Ct?"Syncing...":"Sync GHL"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>es(!0),children:[e.jsx(Yv,{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(_s,{open:R,onOpenChange:$,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Pc,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Add Member"}),e.jsx("span",{className:"sm:hidden",children:"Add"})]})}),e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Create New User"}),e.jsx(Zr,{children:"Add a new user to the system. They'll be able to sign in immediately."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"name",children:"Name"}),e.jsx(Fe,{id:"name",placeholder:"John Doe",value:I.name,onChange:xt=>L({...I,name:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"email",children:"Email"}),e.jsx(Fe,{id:"email",type:"email",placeholder:"john@example.com",value:I.email,onChange:xt=>L({...I,email:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"password",children:"Password"}),e.jsx(Fe,{id:"password",type:"password",placeholder:"Min 6 characters",value:I.password,onChange:xt=>L({...I,password:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Fe,{id:"phone",type:"tel",placeholder:"555-123-4567",value:I.phone,onChange:xt=>L({...I,phone:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{htmlFor:"brokerage",children:["Brokerage",I.role==="brokerage_manager"?" (required)":""]}),e.jsxs(rr,{value:I.brokerage_id||"none",onValueChange:xt=>L({...I,brokerage_id:xt==="none"?"":xt}),children:[e.jsx(tr,{id:"brokerage",children:e.jsx(nr,{placeholder:I.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"None"}),p.map(xt=>e.jsx(Tt,{value:xt.id,children:xt.name},xt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"role",children:"Role"}),e.jsxs(rr,{value:I.role,onValueChange:xt=>L({...I,role:xt}),children:[e.jsx(tr,{id:"role",children:e.jsx(nr,{placeholder:"Select role"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"user",children:"User"}),e.jsx(Tt,{value:"moderator",children:"Moderator"}),e.jsx(Tt,{value:"brokerage_manager",children:"Brokerage Manager"}),e.jsx(Tt,{value:"admin",children:"Admin"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"trial_days",children:"Trial Period (optional)"}),e.jsxs(rr,{value:I.trial_days||"none",onValueChange:xt=>L({...I,trial_days:xt==="none"?"":xt}),children:[e.jsx(tr,{id:"trial_days",children:e.jsx(nr,{placeholder:"No trial (full access)"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"No trial (full access)"}),e.jsx(Tt,{value:"7",children:"7-day trial"}),e.jsx(Tt,{value:"30",children:"30-day trial"}),e.jsx(Tt,{value:"60",children:"60-day trial"}),e.jsx(Tt,{value:"90",children:"90-day trial"}),e.jsx(Tt,{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(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),e.jsx(K,{onClick:aa,disabled:S,children:S?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(Aa,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(ja,{children:[e.jsx(js,{value:"members",children:"Members"}),e.jsx(js,{value:"brokerages",children:"Brokerages"}),e.jsx(js,{value:"teams",children:"Teams"}),e.jsx(js,{value:"trials",children:"Trial Users"}),e.jsx(js,{value:"access",children:"Access Matrix"}),e.jsx(js,{value:"celebrations",children:"Celebrations"}),e.jsx(js,{value:"deletions",children:"Deletion Log"})]}),e.jsxs($s,{value:"members",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search members...",value:q,onChange:xt=>F1(xt.target.value),className:"pl-10 h-9"})]}),e.jsxs(rr,{value:Q,onValueChange:xt=>jh(de,xt),children:[e.jsx(tr,{className:"w-[130px] h-9",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Status"}),e.jsx(Tt,{value:"claimed",children:"Active"}),e.jsx(Tt,{value:"unclaimed",children:"Pending"})]})]}),e.jsxs(rr,{value:re,onValueChange:xt=>jh(ne,xt),children:[e.jsx(tr,{className:"w-[130px] h-9",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Roles"}),e.jsx(Tt,{value:"admin",children:"Admin"}),e.jsx(Tt,{value:"brokerage_manager",children:"Manager"}),e.jsx(Tt,{value:"assistant",children:"Assistant"}),e.jsx(Tt,{value:"user",children:"User"})]})]}),e.jsxs(rr,{value:le,onValueChange:xt=>jh(he,xt),children:[e.jsx(tr,{className:"w-[130px] h-9",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Users"}),e.jsx(Tt,{value:"trial",children:"Trial Only"}),e.jsx(Tt,{value:"non-trial",children:"Full Only"})]})]}),e.jsxs(rr,{value:we,onValueChange:xt=>jh(ye,xt),children:[e.jsx(tr,{className:"w-[150px] h-9",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Brokerages"}),e.jsx(Tt,{value:"none",children:"No Brokerage"}),p.map(xt=>e.jsx(Tt,{value:xt.id,children:xt.name},xt.id))]})]}),(q||Q!=="all"||re!=="all"||le!=="all"||we!=="all")&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{U(""),de("all"),ne("all"),he("all"),ye("all"),X(1)},children:[e.jsx(Ur,{className:"h-4 w-4 mr-1"}),"Clear"]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:$m?`Showing all ${Bm} members`:`Showing ${$0+1}-${Math.min(Ug,Bm)} of ${Bm} members`}),e.jsxs(rr,{value:se.toString(),onValueChange:xt=>Vg(Number(xt)),children:[e.jsx(tr,{className:"h-9 w-[110px]",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"50",children:"50 / page"}),e.jsx(Tt,{value:"100",children:"100 / page"}),e.jsx(Tt,{value:"250",children:"250 / page"}),e.jsx(Tt,{value:"0",children:"All"})]})]})]})]}),Vt.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(Pv,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm font-medium",children:[Vt.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:U0,disabled:ze,children:[ze?e.jsx(Ss,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(br,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Resend Invite"}),e.jsx("span",{className:"sm:hidden",children:"Invite"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:V0,disabled:ze,children:[ze?e.jsx(Ss,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(vp,{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:B2,children:[e.jsx(ki,{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:z2,disabled:ze,children:[ze?e.jsx(Ss,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(jr,{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:em,disabled:ze,children:e.jsx(Ur,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(bt,{className:"w-[50px]",children:e.jsx(Yo,{checked:jl.length>0&&jl.every(xt=>Vt.has(xt.id)),onCheckedChange:dC,"aria-label":"Select all on page"})}),e.jsx(dl,{sortKey:"name",currentSortKey:Ld,currentDirection:vd,onSort:su,children:"Name"}),e.jsx(dl,{sortKey:"brokerage",currentSortKey:Ld,currentDirection:vd,onSort:su,children:"Brokerage"}),e.jsx(dl,{sortKey:"status",currentSortKey:Ld,currentDirection:vd,onSort:su,children:"Status"}),e.jsx(dl,{sortKey:"role",currentSortKey:Ld,currentDirection:vd,onSort:su,children:"Role"}),e.jsx(dl,{sortKey:"last_login",currentSortKey:Ld,currentDirection:vd,onSort:su,children:"Last Login"}),e.jsx(dl,{sortKey:"created_at",currentSortKey:Ld,currentDirection:vd,onSort:su,children:"Member Since"}),e.jsx(bt,{className:"w-[100px]"})]})}),e.jsx(Pn,{children:jl.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):jl.map(xt=>e.jsxs(ks,{className:`hover:bg-muted/30 ${Vt.has(xt.id)?"bg-primary/5":""}`,children:[e.jsx(dt,{children:e.jsx(Yo,{checked:Vt.has(xt.id),onCheckedChange:()=>cC(xt.id),"aria-label":`Select ${xt.name}`})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>Sa(xt),className:"text-primary hover:underline font-medium text-left",children:xt.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:xt.email})]})}),e.jsx(dt,{className:"text-muted-foreground",children:xt.brokerage_name||"—"}),e.jsx(dt,{children:e.jsx("div",{className:"flex flex-col",children:(()=>{const Ts=xt.is_trial&&xt.trial_expires_at||!xt.is_trial&&xt.subscription_status==="trialing"&&xt.subscription_end_date,Ys=xt.trial_expires_at||xt.subscription_end_date;if(Ts&&Ys){const ln=Math.ceil((new Date(Ys).getTime()-Date.now())/864e5),cn=ln<=0,na=ln<=3;return e.jsx(nt,{variant:"outline",className:At("w-fit",cn?"border-destructive text-destructive":na?"border-amber-500 text-amber-600":"border-violet-300 text-violet-700 bg-violet-50"),children:cn?"Trial Expired":`Trial · ${ln}d left`})}return e.jsx(nt,{variant:xt.claimed?"default":"secondary",className:xt.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:xt.claimed?"Active":"Pending"})})()})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col",children:[xt.roles.length>0?e.jsx("span",{className:"text-sm capitalize",children:xt.roles[0]}):e.jsx("span",{className:"text-muted-foreground",children:"—"}),xt.roles.includes("assistant")&&fa[xt.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",fa[xt.id].agent_name||fa[xt.id].agent_email]})]})}),e.jsx(dt,{className:"text-muted-foreground",children:xt.last_sign_in_at?new Date(xt.last_sign_in_at).toLocaleDateString():"—"}),e.jsx(dt,{className:"text-muted-foreground",children:xt.created_at?new Date(xt.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(xt),Qt(!0)},title:"Send celebration",children:e.jsx(Zd,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Sa(xt),title:"Edit member",children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>qm(xt.id,xt.email),disabled:zt===xt.id,title:"Sync phone with GHL",children:zt===xt.id?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(ea,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Na(xt.id),title:"Resend welcome email",children:e.jsx(br,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>ao(xt.email,xt.name),title:"Send password reset",children:e.jsx(q4,{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:()=>my(xt.id),disabled:a||xt.id===(s==null?void 0:s.id),title:xt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${xt.name}`,children:a?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(gM,{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:()=>Si(xt.id,xt.name),title:"Delete user",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},xt.id))})]})}),_d>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 ",_d]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>X(1),disabled:V===1,children:"First"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(xt=>Math.max(1,xt-1)),disabled:V===1,children:e.jsx(Xl,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,_d)},(xt,Ts)=>{let Ys;return _d<=5||V<=3?Ys=Ts+1:V>=_d-2?Ys=_d-4+Ts:Ys=V-2+Ts,e.jsx(K,{variant:V===Ys?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>X(Ys),children:Ys},Ys)})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(xt=>Math.min(_d,xt+1)),disabled:V===_d,children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>X(_d),disabled:V===_d,children:"Last"})]})]})]}),e.jsx(_s,{open:qe,onOpenChange:ct,children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Edit Member"}),e.jsx(Zr,{children:"Update member details, roles, and app access"})]}),Re&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Basic Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"edit-name",children:"Name"}),e.jsx(Fe,{id:"edit-name",value:De.name,onChange:xt=>Rt({...De,name:xt.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"edit-email",children:"Email"}),e.jsx(Fe,{id:"edit-email",type:"email",value:De.email,onChange:xt=>Rt({...De,email:xt.target.value}),maxLength:255})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Fe,{id:"edit-phone",type:"tel",value:De.phone,onChange:xt=>Rt({...De,phone:xt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(rr,{value:De.brokerage_id||"none",onValueChange:xt=>Rt({...De,brokerage_id:xt==="none"?"":xt}),children:[e.jsx(tr,{id:"edit-brokerage",children:e.jsx(nr,{placeholder:"Select brokerage"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"None"}),p.map(xt=>e.jsx(Tt,{value:xt.id,children:xt.name},xt.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:[Re.roles.map(xt=>e.jsxs(nt,{variant:"default",className:"gap-1",children:[e.jsx(Bh,{className:"h-3 w-3"}),xt,xt==="brokerage_manager"?e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(manage in Brokerages tab)"}):e.jsx("button",{onClick:()=>io(Re.id,xt,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(Ur,{className:"h-3 w-3"})})]},xt)),Re.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs(rr,{onValueChange:xt=>io(Re.id,xt,"add"),children:[e.jsx(tr,{className:"w-[200px]",children:e.jsx(nr,{placeholder:"Add role..."})}),e.jsxs(sr,{children:[!Re.roles.includes("admin")&&e.jsx(Tt,{value:"admin",children:"Admin"}),!Re.roles.includes("user")&&e.jsx(Tt,{value:"user",children:"User"})]})]}),!Re.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"})]}),(gr.length>0||hr.length>0||Re.roles.includes("assistant"))&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),"Assistant Relationships"]}),Mn?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ss,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[gr.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:"}),gr.map(xt=>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:xt.assistant_name}),e.jsx(nt,{variant:"outline",className:"text-xs",children:"Assistant"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:xt.assistant_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(xt.permissions).filter(([,Ts])=>Ts).map(([Ts])=>e.jsx(nt,{variant:"secondary",className:"text-[10px] capitalize",children:Ts},Ts))})]},xt.id))]}),hr.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Assists agents:"}),hr.map(xt=>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:xt.agent_name}),e.jsx(nt,{variant:"outline",className:"text-xs",children:"Agent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:xt.agent_email}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(xt.permissions).filter(([,Ts])=>Ts).map(([Ts])=>e.jsx(nt,{variant:"secondary",className:"text-[10px] capitalize",children:Ts},Ts))})]},xt.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(xt=>{const Ts=yc(Re.tags,xt.required_tags),Ys=`${Re.id}-${xt.id}`,ln=pe===Ys,cn=xt.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:xt.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:xt.name}),cn&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Available to all members"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:ln?e.jsx(Ss,{className:"h-4 w-4 animate-spin text-muted-foreground"}):cn?e.jsx(nt,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx(Br,{checked:Ts,onCheckedChange:()=>Lc(Re.id,xt,Ts)})})]},xt.id)})})]}),(Re.is_trial||Re.subscription_status==="trialing")&&e.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(Tn,{className:"h-4 w-4"}),"Trial Status"]}),e.jsxs("div",{className:"p-4 rounded-lg border bg-amber-50 dark:bg-amber-950/20 border-amber-200 dark:border-amber-800",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[Re.trial_expires_at&&e.jsx($Le,{expiresAt:Re.trial_expires_at}),!Re.trial_expires_at&&Re.subscription_status==="trialing"&&Re.subscription_end_date&&e.jsx($Le,{expiresAt:Re.subscription_end_date})]}),(Re.trial_expires_at||Re.subscription_end_date)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(Re.trial_expires_at||Re.subscription_end_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>R2(Re.id,7),disabled:je,children:[e.jsx(Tb,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>R2(Re.id,14),disabled:je,children:[e.jsx(Tb,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>R2(Re.id,30),disabled:je,children:[e.jsx(Tb,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(K,{size:"sm",variant:"default",onClick:()=>lC(Re.id),disabled:We,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(zb,{className:"h-4 w-4 mr-1"}),"Convert to Full Account"]})]}),Re.trial_started_at&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(Re.trial_started_at).toLocaleDateString(),Re.trial_claimed_at&&e.jsxs("span",{children:[" • Claimed: ",new Date(Re.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:[Re.email_confirmed_at&&e.jsxs("div",{children:["Claimed: ",new Date(Re.email_confirmed_at).toLocaleString()]}),Re.last_sign_in_at&&e.jsxs("div",{children:["Last login: ",new Date(Re.last_sign_in_at).toLocaleString()]}),e.jsxs("div",{children:["Created: ",new Date(Re.created_at).toLocaleString()]})]})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:hy,children:"Cancel"}),e.jsx(K,{onClick:F2,children:"Save Changes"})]})]})}),e.jsxs($s,{value:"access",children:[c.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),e.jsx(K,{onClick:()=>t("/admin/apps"),children:"Configure Apps"})]})}):e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Member Access Matrix"}),e.jsx(fr,{children:"Toggle switches to grant or revoke app access for each member"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left p-4 font-semibold sticky left-0 bg-card z-10",children:"Member"}),c.map(xt=>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:xt.icon}),e.jsx("span",{className:"text-sm",children:xt.name})]})},xt.id))]})}),e.jsxs("tbody",{children:[jl.map(xt=>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:xt.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:xt.email})]})}),c.map(Ts=>{const Ys=yc(xt.tags,Ts.required_tags),ln=`${xt.id}-${Ts.id}`,cn=pe===ln;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:cn?e.jsx(Ss,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx(Br,{checked:Ys,onCheckedChange:()=>Lc(xt.id,Ts,Ys),disabled:Ts.required_tags.length===0})})},Ts.id)})]},xt.id)),jl.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"})})]})]})}),_d>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 ",$0+1,"-",Math.min(Ug,Bm)," of ",Bm," • Page ",V," of ",_d]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(xt=>Math.max(1,xt-1)),disabled:V===1,children:e.jsx(Xl,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>X(xt=>Math.min(_d,xt+1)),disabled:V===_d,children:e.jsx(Xa,{className:"h-4 w-4"})})]})]})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(K,{variant:"outline",onClick:()=>t("/admin/apps"),children:"Manage Apps"})})]}),e.jsxs($s,{value:"brokerages",className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search brokerages...",value:an,onChange:xt=>Ha(xt.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[p.filter(xt=>xt.name.toLowerCase().includes(an.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 xt=[];for(const Fr of p){const oo=y[Fr.id]??[];for(const Hg of oo){const Ap=l.find(Hr=>Hr.id===Hg);if(Ap){const Hr=(Ap.name||"").trim().split(/\s+/),H0=Hr[0]||"",W0=Hr.slice(1).join(" ")||"";xt.push({firstName:H0,lastName:W0,email:Ap.email,brokerageName:Fr.name})}}}if(xt.length===0){o({title:"No managers found to export"});return}const Ys=[["First Name","Last Name","Email","Brokerage Name"].join(","),...xt.map(Fr=>[Fr.firstName,Fr.lastName,Fr.email,Fr.brokerageName].map(oo=>`"${(oo||"").replace(/"/g,'""')}"`).join(","))].join(` `),ln=new Blob([Ys],{type:"text/csv"}),cn=URL.createObjectURL(ln),na=document.createElement("a");na.href=cn,na.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,na.click(),URL.revokeObjectURL(cn),o({title:`Exported ${xt.length} managers`})},children:[e.jsx(ki,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(_s,{open:lt,onOpenChange:rt,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(La,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Create New Brokerage"}),e.jsx(Zr,{children:"Add a new brokerage to the system."})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(Fe,{id:"brokerage-name",placeholder:"Enter brokerage name",value:Se,onChange:xt=>it(xt.target.value),maxLength:100})]})}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>rt(!1),children:"Cancel"}),e.jsx(K,{onClick:eu,disabled:$e,children:$e?"Creating...":"Create Brokerage"})]})]})]})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(bt,{className:"font-semibold",children:"Brokerage Name"}),e.jsx(bt,{className:"font-semibold",children:"Manager(s)"}),e.jsx(bt,{className:"font-semibold",children:"Agents"}),e.jsx(bt,{className:"w-[150px]"})]})}),e.jsx(Pn,{children:(()=>{const xt=p.filter(Ts=>Ts.name.toLowerCase().includes(an.toLowerCase()));return xt.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:an?"No brokerages match your search":"No brokerages found"})}):xt.map(Ts=>{const Ys=l.filter(Fr=>Fr.brokerage_id===Ts.id),cn=(y[Ts.id]??[]).map(Fr=>l.find(oo=>oo.id===Fr)).filter(Boolean),na=Ys.length;return e.jsxs(ks,{className:"hover:bg-muted/30",children:[e.jsx(dt,{children:e.jsx("button",{onClick:()=>Cf(Ts),className:"text-primary hover:underline font-medium",children:Ts.name})}),e.jsx(dt,{children:cn.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:cn.map(Fr=>e.jsx(nt,{variant:"secondary",className:"text-xs",children:Fr.name},Fr.id))}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"No manager"})}),e.jsxs(dt,{children:[na," member",na!==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:()=>qg(Ts),children:[e.jsx(mr,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Cf(Ts),title:"Edit brokerage",children:e.jsx($a,{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:()=>zm(Ts),title:"Delete brokerage",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},Ts.id)})})()})]})}),e.jsx(_s,{open:Ue,onOpenChange:Ke,children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Edit Brokerage"}),e.jsx(Zr,{children:"Update brokerage details and manage managers"})]}),Xe&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"edit-brokerage-name",children:"Brokerage Name"}),e.jsx(Fe,{id:"edit-brokerage-name",value:Ye,onChange:xt=>tt(xt.target.value),maxLength:100})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{children:"Managers"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click × to remove manager access for this brokerage (keeps them as a member)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:(()=>{const Ts=(y[Xe.id]??[]).map(Ys=>l.find(ln=>ln.id===Ys)).filter(Boolean);return Ts.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):Ts.map(Ys=>e.jsxs(nt,{variant:"default",className:"gap-1",children:[e.jsx(Bh,{className:"h-3 w-3"}),Ys.name,e.jsx("button",{onClick:()=>io(Ys.id,"brokerage_manager","remove",Xe.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:e.jsx(Ur,{className:"h-3 w-3"})})]},Ys.id))})()}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm text-muted-foreground",children:"Assign manager from existing members:"}),e.jsxs(Lo,{open:Xn,onOpenChange:Ir,children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Xn,className:"w-full justify-between",children:["Search for a member...",e.jsx(xn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Eo,{className:"w-full p-0",align:"start",children:e.jsxs(Mg,{children:[e.jsx(Tg,{placeholder:"Search by name or email..."}),e.jsxs(Ag,{className:"max-h-[200px]",children:[e.jsx(Eg,{children:"No members found."}),e.jsx(Pg,{children:(()=>{const xt=new Set(y[Xe.id]??[]);return l.filter(Ts=>!xt.has(Ts.id)&&(r||Ts.brokerage_id===Xe.id)).map(Ts=>e.jsxs(up,{value:`${Ts.name} ${Ts.email}`,onSelect:()=>{yd(Ts.id,Xe.id),Ir(!1)},children:[Ts.name," (",Ts.email,")"]},Ts.id))})()})]})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Members in this Brokerage"}),e.jsx("div",{className:"max-h-32 overflow-y-auto border rounded p-2",children:l.filter(xt=>xt.brokerage_id===Xe.id).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(xt=>xt.brokerage_id===Xe.id).map(xt=>e.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[e.jsx("span",{children:xt.name}),xt.roles.includes("brokerage_manager")&&e.jsx(nt,{variant:"outline",className:"text-xs",children:"Manager"})]},xt.id))})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:El,children:"Cancel"}),e.jsx(K,{onClick:th,disabled:Et,children:Et?"Saving...":"Save Changes"})]})]})}),e.jsx(_s,{open:ms,onOpenChange:Xt,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Zr,{children:['Are you sure you want to delete "',rs==null?void 0:rs.name,'"?']})]}),e.jsx("div",{className:"py-4",children:e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-destructive",children:"Warning: This action cannot be undone!"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This will permanently delete:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground list-disc list-inside",children:[e.jsxs("li",{children:['The brokerage "',rs==null?void 0:rs.name,'"']}),e.jsxs("li",{children:["All ",l.filter(xt=>xt.brokerage_id===(rs==null?void 0:rs.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Xt(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Pl,disabled:Ms,children:Ms?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(_s,{open:As,onOpenChange:Ps,children:e.jsxs(vs,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(La,{className:"h-5 w-5"}),"Manage ",ar==null?void 0:ar.name]}),e.jsx(Zr,{children:"Add, remove, or manage users in this brokerage"})]}),ar&&e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search members...",value:Va,onChange:xt=>pa(xt.target.value),className:"pl-10 h-9"})]}),e.jsxs(_s,{open:qa,onOpenChange:Kr,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Pc,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Add New Agent"}),e.jsxs(Zr,{children:["Create a new agent for ",ar.name]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"agent-name",children:"Name"}),e.jsx(Fe,{id:"agent-name",placeholder:"John Doe",value:Yn.name,onChange:xt=>mn({...Yn,name:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"agent-email",children:"Email"}),e.jsx(Fe,{id:"agent-email",type:"email",placeholder:"john@example.com",value:Yn.email,onChange:xt=>mn({...Yn,email:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"agent-password",children:"Password"}),e.jsx(Fe,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:Yn.password,onChange:xt=>mn({...Yn,password:xt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(Fe,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:Yn.phone,onChange:xt=>mn({...Yn,phone:xt.target.value})})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Kr(!1),children:"Cancel"}),e.jsx(K,{onClick:R1,disabled:Gn,children:Gn?"Creating...":"Create Agent"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Add existing user:"}),e.jsxs(Lo,{open:_i,onOpenChange:rl,children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":_i,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(xn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Eo,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Mg,{children:[e.jsx(Tg,{placeholder:"Search users...",value:Ni,onValueChange:sc}),e.jsxs(Ag,{children:[e.jsx(Eg,{children:"No users found."}),e.jsx(Pg,{children:tu(ar.id).filter(xt=>Ni===""||xt.name.toLowerCase().includes(Ni.toLowerCase())||xt.email.toLowerCase().includes(Ni.toLowerCase())).map(xt=>e.jsxs(up,{value:`${xt.name} ${xt.email}`,onSelect:()=>{O1(xt.id,ar.id),rl(!1),sc("")},children:[xt.name," (",xt.email,")"]},xt.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(bt,{className:"font-semibold",children:"Name"}),e.jsx(bt,{className:"font-semibold",children:"Email"}),e.jsx(bt,{className:"font-semibold",children:"Status"}),e.jsx(bt,{className:"font-semibold",children:"Role"}),e.jsx(bt,{className:"w-[120px]"})]})}),e.jsx(Pn,{children:Qh(ar.id).length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:Va?"No matching members found":"No members in this brokerage"})}):Qh(ar.id).map(xt=>e.jsxs(ks,{className:"hover:bg-muted/30",children:[e.jsx(dt,{className:"font-medium",children:xt.name}),e.jsx(dt,{className:"text-muted-foreground",children:xt.email}),e.jsx(dt,{children:xt.claimed?e.jsx(nt,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(nt,{variant:"secondary",children:"Pending"})}),e.jsx(dt,{children:xt.roles.includes("brokerage_manager")?e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(Bh,{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:[!xt.claimed&&e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Na(xt.id),title:"Resend welcome email",children:e.jsx(br,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>D1(xt.id),title:"Remove from brokerage",children:e.jsx(Ur,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>my(xt.id),disabled:a||xt.id===(s==null?void 0:s.id),title:xt.id===(s==null?void 0:s.id)?"Cannot impersonate yourself":`Login as ${xt.name}`,children:a?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(gM,{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:()=>Si(xt.id,xt.name),title:"Delete user",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},xt.id))})]})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Tp(ar.id).length," total member",Tp(ar.id).length!==1?"s":""," •",Tp(ar.id).filter(xt=>xt.roles.includes("brokerage_manager")).length," manager",Tp(ar.id).filter(xt=>xt.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(Vn,{children:e.jsx(K,{variant:"outline",onClick:uy,children:"Close"})})]})})]}),e.jsx($s,{value:"teams",children:e.jsx(lUt,{})}),e.jsx($s,{value:"trials",children:e.jsx(nUt,{})}),e.jsx($s,{value:"celebrations",children:e.jsx(rUt,{})}),e.jsx($s,{value:"deletions",children:e.jsx(aUt,{})})]})]}),e.jsx(Met,{open:$r,onOpenChange:es,brokerages:p,onSuccess:Qa}),Is&&e.jsx(Tet,{open:$t,onOpenChange:xt=>{Qt(xt),xt||gs(null)},userId:Is.id,userName:Is.name})]})},dUt=()=>{const[t,s]=C.useState([]),[r,n]=C.useState(!0),[a,o]=C.useState(!1),[l,i]=C.useState(""),[c,u]=C.useState(""),[p,f]=C.useState(""),[y,_]=C.useState("");C.useEffect(()=>{b()},[]);const b=async()=>{const{data:L,error:R}=await G.from("invite_codes").select("*").order("created_at",{ascending:!1});R?(me.error("Failed to load invite codes"),console.error(R)):s(L||[]),n(!1)},w=async L=>{if(L.preventDefault(),!l.trim()){me.error("Please enter a code");return}o(!0);const{error:R}=await G.from("invite_codes").insert({code:l.trim().toUpperCase(),description:c.trim()||null,max_uses:p?parseInt(p):null,trial_days:y?parseInt(y):null});R?R.code==="23505"?me.error("This code already exists"):(me.error("Failed to create invite code"),console.error(R)):(me.success("Invite code created"),i(""),u(""),f(""),_(""),b()),o(!1)},j=async(L,R)=>{const{error:$}=await G.from("invite_codes").update({is_active:!R}).eq("id",L);$?me.error("Failed to update code"):s(t.map(q=>q.id===L?{...q,is_active:!R}:q))},N=async L=>{const{error:R}=await G.from("invite_codes").delete().eq("id",L);R?me.error("Failed to delete code"):(me.success("Code deleted"),s(t.filter($=>$.id!==L)))},S="https://dashboard.relevelup.com",T=L=>{const R=`${S}/join?code=${L}`;navigator.clipboard.writeText(R),me.success("Link copied to clipboard")},I=`${S}/join`;return e.jsx(Es,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Create New Code"}),e.jsxs(fr,{children:["Share link: ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:I})]})]}),e.jsx(Oe,{children:e.jsxs("form",{onSubmit:w,className:"flex flex-wrap gap-4 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"code",children:"Code"}),e.jsx(Fe,{id:"code",placeholder:"WELCOME2024",value:l,onChange:L=>i(L.target.value),className:"w-40"})]}),e.jsxs("div",{className:"space-y-2 flex-1 min-w-[200px]",children:[e.jsx(_e,{htmlFor:"description",children:"Description (optional)"}),e.jsx(Fe,{id:"description",placeholder:"For marketing campaign",value:c,onChange:L=>u(L.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"maxUses",children:"Max Uses"}),e.jsx(Fe,{id:"maxUses",type:"number",placeholder:"Unlimited",value:p,onChange:L=>f(L.target.value),className:"w-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"trialDays",children:"Trial Days"}),e.jsx(Fe,{id:"trialDays",type:"number",placeholder:"None",value:y,onChange:L=>_(L.target.value),className:"w-28"})]}),e.jsxs(K,{type:"submit",disabled:a,children:[a?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Active Codes"})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx("p",{className:"text-center py-8 text-muted-foreground",children:"No invite codes yet"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Code"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{children:"Uses"}),e.jsx(bt,{children:"Trial"}),e.jsx(bt,{children:"Created"}),e.jsx(bt,{children:"Active"}),e.jsx(bt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(L=>e.jsxs(ks,{children:[e.jsx(dt,{className:"font-mono font-medium",children:L.code}),e.jsx(dt,{className:"text-muted-foreground",children:L.description||"—"}),e.jsxs(dt,{children:[L.uses_count,L.max_uses&&` / ${L.max_uses}`]}),e.jsx(dt,{children:L.trial_days?e.jsxs("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:[L.trial_days," days"]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-muted-foreground",children:ys(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx(Br,{checked:L.is_active,onCheckedChange:()=>j(L.id,L.is_active)})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>T(L.code),title:"Copy invite link",children:e.jsx(mi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>N(L.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},L.id))})]})})]})]})})},PO=async t=>{try{const{data:s,error:r}=await G.from("push_notification_settings").select("is_enabled").eq("setting_key",t).maybeSingle();return r?(console.error("Error checking notification setting:",r),!0):(s==null?void 0:s.is_enabled)??!0}catch(s){return console.error("Error checking notification setting:",s),!0}},UA=async t=>{try{const{data:s,error:r}=await G.functions.invoke("send-push-notification",{body:t});return r?(console.error("Error sending notification:",r),{success:!1,error:r}):(console.log("Notification sent:",s),{success:!0,data:s})}catch(s){return console.error("Error sending notification:",s),{success:!1,error:s}}},uUt=async(t,s)=>await PO("new_templates")?UA({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}),hUt=async(t,s)=>UA({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),mUt=async(t,s)=>await PO("new_events")?UA({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),pUt=async(t,s)=>await PO("new_toolbox")?UA({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),W1e=async(t,s)=>await PO("new_social_swag")?UA({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}),fUt=async(t,s)=>await PO("new_newsletters")?UA({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),nz={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 gUt(){const t=Pr(),s=ss(),[r,n]=C.useState(!1),[a,o]=C.useState(null),[l,i]=C.useState(nz),[c,u]=C.useState(null),[p,f]=C.useState(null),[y,_]=C.useState(!1),b=C.useRef(null),[w,j]=C.useState(!1),[N,S]=C.useState(null),[T,I]=C.useState(!1),[L,R]=C.useState(null),[$,q]=C.useState(null),[U,V]=C.useState(!0),[X,se]=C.useState(""),{data:ee,isLoading:Q}=wt({queryKey:["admin-events"],queryFn:async()=>{const{data:Se,error:it}=await G.from("events").select("*").order("event_date",{ascending:!0});if(it)throw it;return Se}}),{data:de}=wt({queryKey:["event-registrations-count"],queryFn:async()=>{let Se=[],it=0;const $e=1e3;for(;;){const{data:Ue,error:Ke}=await G.from("event_registrations").select("event_id").range(it,it+$e-1);if(Ke)throw Ke;if(!Ue||Ue.length===0||(Se=Se.concat(Ue),Ue.length<$e))break;it+=$e}const ot={};return Se.forEach(Ue=>{ot[Ue.event_id]=(ot[Ue.event_id]||0)+1}),ot}}),{data:re,isLoading:ne}=wt({queryKey:["event-registrations-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:Se,error:it}=await G.from("event_registrations").select("id, user_id, registered_at, zoom_join_url, zoom_name, zoom_email").eq("event_id",N.id).order("registered_at",{ascending:!1});if(it)throw it;if(!Se||Se.length===0)return[];const $e=Se.map(Ke=>Ke.user_id).filter(Boolean);let ot=[];if($e.length>0){const{data:Ke,error:Xe}=await G.from("profiles").select("id, name, email").in("id",$e);if(Xe)throw Xe;ot=Ke||[]}const Ue=new Map((ot==null?void 0:ot.map(Ke=>[Ke.id,Ke]))||[]);return Se.map(Ke=>({...Ke,profiles:Ke.user_id&&Ue.get(Ke.user_id)||null}))},enabled:!!N}),{data:le,isLoading:he}=wt({queryKey:["event-attendees-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:Se,error:it}=await G.from("event_attendees").select("id, user_id, zoom_email, zoom_name, join_time, leave_time, duration_minutes, manually_added, created_at").eq("event_id",N.id).order("created_at",{ascending:!1});if(it)throw it;if(!Se||Se.length===0)return[];const $e=Se.map(He=>He.user_id).filter(Boolean);let ot=[];if($e.length>0){const{data:He,error:Ye}=await G.from("profiles").select("id, name, email").in("id",$e);if(Ye)throw Ye;ot=He||[]}const{data:Ue}=await G.from("agent_points").select("user_id").eq("event_id",N.id),Ke=new Set((Ue==null?void 0:Ue.map(He=>He.user_id))||[]),Xe=new Map((ot==null?void 0:ot.map(He=>[He.id,He]))||[]);return Se.map(He=>({...He,profiles:He.user_id&&Xe.get(He.user_id)||null,points_awarded:He.user_id?Ke.has(He.user_id):!1}))},enabled:!!N}),we=Se=>{S(Se),j(!0)},ye=Dt({mutationFn:async Se=>{const{data:{session:it}}=await G.auth.getSession();if(!it)throw new Error("Not authenticated");const $e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${it.access_token}`},body:JSON.stringify({event_id:Se})}),ot=await $e.json();if(!$e.ok)throw new Error(ot.error||"Failed to sync");return ot},onSuccess:Se=>{s.invalidateQueries({queryKey:["event-registrations-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),me.success(Se.message)},onError:Se=>{me.error("Failed to sync: "+Se.message)}}),je=Dt({mutationFn:async Se=>{const{data:{session:it}}=await G.auth.getSession();if(!it)throw new Error("Not authenticated");const $e=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${it.access_token}`},body:JSON.stringify({event_id:Se})}),ot=await $e.json();if(!$e.ok)throw new Error(ot.error||"Failed to sync attendees");return ot},onSuccess:Se=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),Se!=null&&Se.message?me.success(Se.message):me.success(`Synced ${Se.synced||0} attendees. ${Se.points_awarded||0} points awarded!`)},onError:Se=>{me.error("Failed to sync attendees: "+Se.message)}}),ke=Dt({mutationFn:async({eventId:Se,testMode:it})=>{const{data:{session:$e}}=await G.auth.getSession();if(!$e)throw new Error("Not authenticated");const ot=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${$e.access_token}`},body:JSON.stringify({event_id:Se,test_mode:it})}),Ue=await ot.json();if(!ot.ok)throw new Error(Ue.error||"Failed to send reminders");return Ue},onSuccess:Se=>{Se.test?me.success(Se.message||"Test email sent!"):me.success(Se.message||`Reminder emails sent to ${Se.sent} registrants!`)},onError:Se=>{me.error("Failed to send reminders: "+Se.message)}}),{data:We}=wt({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let Se=[],it=0;const $e=1e3;for(;;){const{data:ot,error:Ue}=await G.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(it,it+$e-1);if(Ue)throw Ue;if(!ot||ot.length===0||(Se=[...Se,...ot],ot.length<$e))break;it+=$e}return Se},enabled:T}),be=Dt({mutationFn:async({attendeeId:Se,userId:it,zoomEmail:$e,shouldSaveAlias:ot})=>{const{error:Ue}=await G.from("event_attendees").update({user_id:it}).eq("id",Se);if(Ue)throw Ue;if(ot&&$e){const{error:Xe}=await G.from("zoom_email_aliases").upsert({user_id:it,zoom_email:$e.toLowerCase()},{onConflict:"zoom_email"});Xe&&console.error("Failed to save alias:",Xe)}const Ke=N==null?void 0:N.id;if(Ke){const{data:Xe}=await G.from("user_roles").select("id").eq("user_id",it).eq("role","admin").single();if(!Xe){const{data:He}=await G.from("agent_points").select("id").eq("user_id",it).eq("event_id",Ke).single();He||(await G.rpc("award_attendance_points",{p_user_id:it,p_event_id:Ke,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await G.rpc("check_and_award_badges",{p_user_id:it}))}}return{userId:it,zoomEmail:$e,shouldSaveAlias:ot}},onSuccess:Se=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let it="Attendee linked and points awarded!";Se.shouldSaveAlias&&Se.zoomEmail&&(it+=` Email "${Se.zoomEmail}" will be auto-matched in the future.`),me.success(it),I(!1),R(null),q(null),se("")},onError:Se=>{me.error("Failed to link attendee: "+Se.message)}}),Me=Se=>{R(Se),q(null),V(!0),se(""),I(!0)},Ae=()=>{!L||!$||be.mutate({attendeeId:L.id,userId:$,zoomEmail:L.zoom_email,shouldSaveAlias:U})},Re=(We==null?void 0:We.filter(Se=>{var $e,ot;if(!X)return!0;const it=X.toLowerCase();return(($e=Se.name)==null?void 0:$e.toLowerCase().includes(it))||((ot=Se.email)==null?void 0:ot.toLowerCase().includes(it))}))||[],Te=async Se=>{const it=Se.name.split(".").pop(),ot=`${`${crypto.randomUUID()}.${it}`}`,{error:Ue}=await G.storage.from("event-images").upload(ot,Se);if(Ue)throw Ue;const{data:{publicUrl:Ke}}=G.storage.from("event-images").getPublicUrl(ot);return Ke},qe=Se=>{var $e;const it=($e=Se.target.files)==null?void 0:$e[0];if(it){if(it.size>5*1024*1024){me.error("Image must be less than 5MB");return}u(it),f(URL.createObjectURL(it))}},ct=()=>{u(null),f(null),i({...l,image_url:""}),b.current&&(b.current.value="")},De=Dt({mutationFn:async Se=>{_(!0);let it=Se.image_url;c&&(it=await Te(c)||"");const $e=new Date(Se.event_date),[ot,Ue]=Se.event_time.split(":");$e.setHours(parseInt(ot),parseInt(Ue));const Ke=[new Date($e)];if(Se.is_recurring&&Se.recurrence_end_date){let tt=new Date($e);for(;Se.recurrence_pattern==="weekly"?tt=c4(tt,1):Se.recurrence_pattern==="biweekly"?tt=c4(tt,2):tt=Em(tt,1),!(tt>Se.recurrence_end_date);)Ke.push(new Date(tt))}const Xe=Ke.map(tt=>({title:Se.title,description:Se.description||null,image_url:it||null,video_url:Se.video_url||null,event_date:tt.toISOString(),zoom_link:Se.zoom_link,zoom_meeting_id:Se.zoom_meeting_id||null,capacity:Se.capacity?parseInt(Se.capacity):null,is_published:Se.is_published})),{data:He,error:Ye}=await G.from("events").insert(Xe).select();if(Ye)throw Ye;return He&&He.length>0&&mUt(Se.title,He[0].id),Ke.length},onSuccess:Se=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success(Se>1?`${Se} recurring events created successfully`:"Event created successfully"),n(!1),i(nz),u(null),f(null),_(!1)},onError:Se=>{me.error("Failed to create event: "+Se.message),_(!1)}}),Rt=Dt({mutationFn:async({id:Se,data:it})=>{_(!0);let $e=it.image_url;c&&($e=await Te(c)||"");const ot=new Date(it.event_date),[Ue,Ke]=it.event_time.split(":");ot.setHours(parseInt(Ue),parseInt(Ke));const{error:Xe}=await G.from("events").update({title:it.title,description:it.description||null,image_url:$e||null,video_url:it.video_url||null,event_date:ot.toISOString(),zoom_link:it.zoom_link,zoom_meeting_id:it.zoom_meeting_id||null,capacity:it.capacity?parseInt(it.capacity):null,is_published:it.is_published}).eq("id",Se);if(Xe)throw Xe},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event updated successfully"),n(!1),o(null),i(nz),u(null),f(null),_(!1)},onError:Se=>{me.error("Failed to update event: "+Se.message),_(!1)}}),pe=Dt({mutationFn:async Se=>{const{error:it}=await G.from("events").delete().eq("id",Se);if(it)throw it},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),me.success("Event deleted successfully")},onError:Se=>{me.error("Failed to delete event: "+Se.message)}}),Je=Se=>{var $e;const it=new Date(Se.event_date);o(Se),i({title:Se.title,description:Se.description||"",image_url:Se.image_url||"",video_url:Se.video_url||"",event_date:it,event_time:ys(it,"HH:mm"),zoom_link:Se.zoom_link,zoom_meeting_id:Se.zoom_meeting_id||"",capacity:(($e=Se.capacity)==null?void 0:$e.toString())||"",is_published:Se.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),f(Se.image_url||null),u(null),n(!0)},lt=Se=>{if(Se.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?Rt.mutate({id:a.id,data:l}):De.mutate(l)},rt=()=>{n(!1),o(null),i(nz),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(di,{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(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{children:"All Events"}),e.jsxs(_s,{open:r,onOpenChange:Se=>!Se&&rt(),children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Event"]})}),e.jsxs(vs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:lt,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Fe,{id:"title",value:l.title,onChange:Se=>i({...l,title:Se.target.value}),placeholder:"Event title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(iy,{content:l.description,onChange:Se=>i({...l,description:Se}),placeholder:"Event description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Event Image"}),e.jsx("input",{type:"file",ref:b,accept:"image/*",onChange:qe,className:"hidden"}),p?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:p,alt:"Event preview",className:"w-full h-32 object-cover rounded-lg border"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:ct,children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs(K,{type:"button",variant:"outline",className:"w-full h-32 border-dashed flex flex-col gap-2",onClick:()=>{var Se;return(Se=b.current)==null?void 0:Se.click()},children:[e.jsx(ni,{className:"h-6 w-6"}),e.jsx("span",{className:"text-sm",children:"Click to upload image"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Date *"}),e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:At("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),l.event_date?ys(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(Eo,{className:"w-auto p-0",align:"start",children:e.jsx(mf,{mode:"single",selected:l.event_date,onSelect:Se=>i({...l,event_date:Se}),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"time",children:"Time *"}),e.jsx(Fe,{id:"time",type:"time",value:l.event_time,onChange:Se=>i({...l,event_time:Se.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(Fe,{id:"zoom_link",value:l.zoom_link,onChange:Se=>i({...l,zoom_link:Se.target.value}),placeholder:"https://zoom.us/j/...",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"zoom_meeting_id",children:"Zoom Meeting ID (for API registration)"}),e.jsx(Fe,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:Se=>i({...l,zoom_meeting_id:Se.target.value}),placeholder:"e.g., 1234567890 (find in Zoom dashboard)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional: Enter the numeric meeting ID for automatic Zoom registration"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"video_url",children:"Promo Video URL (optional)"}),e.jsx(Fe,{id:"video_url",value:l.video_url,onChange:Se=>i({...l,video_url:Se.target.value}),placeholder:"YouTube, Vimeo, or Bunny.net embed URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a preview/promo video for this event"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"capacity",children:"Capacity (optional)"}),e.jsx(Fe,{id:"capacity",type:"number",value:l.capacity,onChange:Se=>i({...l,capacity:Se.target.value}),placeholder:"Leave empty for unlimited",min:"1"})]}),!a&&e.jsxs("div",{className:"space-y-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(_e,{htmlFor:"is_recurring",children:"Recurring Event"})]}),e.jsx(Br,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:Se=>i({...l,is_recurring:Se})})]}),l.is_recurring&&e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Frequency"}),e.jsxs(rr,{value:l.recurrence_pattern,onValueChange:Se=>i({...l,recurrence_pattern:Se}),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"weekly",children:"Weekly"}),e.jsx(Tt,{value:"biweekly",children:"Every 2 Weeks"}),e.jsx(Tt,{value:"monthly",children:"Monthly"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Repeat Until"}),e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:At("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?ys(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(Eo,{className:"w-auto p-0",align:"start",children:e.jsx(mf,{mode:"single",selected:l.recurrence_end_date,onSelect:Se=>i({...l,recurrence_end_date:Se}),disabled:Se=>Se<(l.event_date||new Date),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),l.event_date&&l.recurrence_end_date&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This will create ",(()=>{let Se=1,it=new Date(l.event_date);for(;it=l.recurrence_pattern==="weekly"?c4(it,1):l.recurrence_pattern==="biweekly"?c4(it,2):Em(it,1),!(it>l.recurrence_end_date);)Se++;return Se})()," events with the same Zoom link"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{htmlFor:"is_published",children:"Published"}),e.jsx(Br,{id:"is_published",checked:l.is_published,onCheckedChange:Se=>i({...l,is_published:Se})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:rt,className:"flex-1",children:"Cancel"}),e.jsx(K,{type:"submit",className:"flex-1",disabled:De.isPending||Rt.isPending||y,children:y?"Uploading...":a?"Update Event":l.is_recurring&&l.event_date&&l.recurrence_end_date?"Create Recurring Events":"Create Event"})]})]})]})]})]}),e.jsx(Oe,{children:Q?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading events..."}):(ee==null?void 0:ee.length)===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No events yet. Create your first event!"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Date & Time"}),e.jsx(bt,{children:"Registrations"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:ee==null?void 0:ee.map(Se=>e.jsxs(ks,{children:[e.jsx(dt,{className:"font-medium",children:Se.title}),e.jsx(dt,{children:ys(new Date(Se.event_date),"PPP p")}),e.jsx(dt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>we(Se),children:[e.jsx(mr,{className:"h-4 w-4"}),(de==null?void 0:de[Se.id])||0,Se.capacity&&` / ${Se.capacity}`]})}),e.jsx(dt,{children:e.jsx("span",{className:At("px-2 py-1 rounded-full text-xs font-medium",Se.is_published?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200"),children:Se.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>window.open(Se.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(rn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Je(Se),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&pe.mutate(Se.id)},children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},Se.id))})]})})]}),e.jsx(_s,{open:w,onOpenChange:j,children:e.jsxs(vs,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),N==null?void 0:N.title]}),e.jsx(Zr,{children:"View registrations and attendees for this event"})]}),e.jsxs("div",{className:"flex items-center justify-end mb-4 gap-2 flex-wrap",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>ke.mutate({eventId:N.id,testMode:!0}),disabled:ke.isPending,children:[e.jsx(br,{className:At("h-4 w-4 mr-2",ke.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ke.mutate({eventId:N.id}),disabled:ke.isPending||!(re!=null&&re.length),children:[e.jsx(br,{className:At("h-4 w-4 mr-2",ke.isPending&&"animate-spin")}),ke.isPending?"Sending...":"Send Reminder to All"]}),(N==null?void 0:N.zoom_meeting_id)&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ye.mutate(N.id),disabled:ye.isPending,children:[e.jsx(Bo,{className:At("h-4 w-4 mr-2",ye.isPending&&"animate-spin")}),ye.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>je.mutate(N.id),disabled:je.isPending,children:[e.jsx(mo,{className:At("h-4 w-4 mr-2",je.isPending&&"animate-spin")}),je.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(Aa,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(ja,{className:"grid w-full grid-cols-2",children:[e.jsxs(js,{value:"registrations",className:"gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),"Registrations (",(re==null?void 0:re.length)||0,")"]}),e.jsxs(js,{value:"attendees",className:"gap-2",children:[e.jsx(ha,{className:"h-4 w-4"}),"Attendees (",(le==null?void 0:le.length)||0,")"]})]}),e.jsx($s,{value:"registrations",className:"mt-4",children:ne?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."}),(N==null?void 0:N.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Registrations" to import from Zoom.'})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Registered"}),e.jsx(bt,{children:"Status"})]})}),e.jsx(Pn,{children:re==null?void 0:re.map(Se=>{var Ue,Ke;const it=((Ue=Se.profiles)==null?void 0:Ue.name)||Se.zoom_name||"Unknown",$e=((Ke=Se.profiles)==null?void 0:Ke.email)||Se.zoom_email||null,ot=!Se.user_id;return e.jsxs(ks,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[it,ot&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(dt,{children:$e?e.jsxs("a",{href:`mailto:${$e}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(br,{className:"h-3 w-3"}),$e]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(dt,{className:"text-muted-foreground text-sm",children:ys(new Date(Se.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{children:Se.zoom_join_url?e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:"Registered"}):e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground",children:"Pending"})})]},Se.id)})})]})}),e.jsx($s,{value:"attendees",className:"mt-4",children:he?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading attendees..."}):(le==null?void 0:le.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No attendees recorded yet."}),(N==null?void 0:N.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Attendees & Award Points" after the event ends to import actual participants from Zoom.'})]}):e.jsxs(e.Fragment,{children:[(le==null?void 0:le.filter(Se=>!Se.user_id).length)>0&&e.jsxs("div",{className:"mb-6 p-4 border border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(yl,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}),e.jsxs("h4",{className:"font-medium text-amber-800 dark:text-amber-200",children:["Unmatched Attendees (",le==null?void 0:le.filter(Se=>!Se.user_id).length,")"]})]}),e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300 mb-3",children:"These attendees couldn't be matched to a profile. Link them to award points."}),e.jsx("div",{className:"space-y-2",children:le==null?void 0:le.filter(Se=>!Se.user_id).map(Se=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-background rounded border",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium text-sm",children:Se.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Se.zoom_email||"No email"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Me(Se),className:"gap-1",children:[e.jsx(sl,{className:"h-3 w-3"}),"Link to Profile"]})]},Se.id))})]}),e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Duration"}),e.jsx(bt,{children:"Points"})]})}),e.jsx(Pn,{children:le==null?void 0:le.filter(Se=>Se.user_id).map(Se=>{var ot,Ue;const it=((ot=Se.profiles)==null?void 0:ot.name)||Se.zoom_name||"Unknown",$e=((Ue=Se.profiles)==null?void 0:Ue.email)||Se.zoom_email||null;return e.jsxs(ks,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[it,Se.manually_added&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",children:"Manual"})]})}),e.jsx(dt,{children:$e?e.jsxs("a",{href:`mailto:${$e}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(br,{className:"h-3 w-3"}),$e]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(dt,{children:Se.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(Tn,{className:"h-3 w-3"}),Se.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:Se.points_awarded?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:[e.jsx(mo,{className:"h-3 w-3"}),"+10 pts"]}):e.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground",children:"Pending"})})]},Se.id)})})]})]})})]})]})}),e.jsx(_s,{open:T,onOpenChange:I,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(sl,{className:"h-5 w-5"}),"Link Attendee to Profile"]}),e.jsx(Zr,{children:"Link this Zoom attendee to an existing member profile to award them points."})]}),L&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm font-medium",children:L.zoom_name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:L.zoom_email||"No email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Search for a profile"}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name or email...",value:X,onChange:Se=>se(Se.target.value),className:"pl-9"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:Re.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:Re.slice(0,20).map(Se=>e.jsxs("button",{type:"button",onClick:()=>q(Se.id),className:At("w-full p-3 text-left hover:bg-muted/50 transition-colors",$===Se.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:Se.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Se.email})]},Se.id))})}),L.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Yo,{id:"save-alias",checked:U,onCheckedChange:Se=>V(Se)}),e.jsx("label",{htmlFor:"save-alias",className:"text-sm text-muted-foreground cursor-pointer",children:"Remember this email for future auto-matching"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),e.jsx(K,{onClick:Ae,disabled:!$||be.isPending,children:be.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function xUt({selectedKitIds:t,onChange:s}){const[r,n]=C.useState(""),[a,o]=C.useState(!1),{data:l=[]}=wt({queryKey:["all-resource-kits-picker"],queryFn:async()=>{const{data:f,error:y}=await G.from("resource_kits").select("id, name, featured_image_url").eq("is_published",!0).order("name");if(y)throw y;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(y=>y!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{className:"flex items-center gap-2",children:[e.jsx(bl,{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(nt,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Ur,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(Lo,{open:a,onOpenChange:o,children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(bl,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs(Eo,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(xn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Fe,{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(bl,{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 yUt=()=>{const{user:t}=Ws(),{toast:s}=Ra(),r=ss(),[n,a]=Xc(),[o,l]=C.useState(!1),[i,c]=C.useState(null),[u,p]=C.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,y]=C.useState(null),[_,b]=C.useState(0),[w,j]=C.useState(!1),[N,S]=C.useState(null),[T,I]=C.useState(""),[L,R]=C.useState([]),[$,q]=C.useState(""),[U,V]=C.useState(""),[X,se]=C.useState(!1),[ee,Q]=C.useState(!1),{data:de=[]}=wt({queryKey:["template-categories"],queryFn:async()=>{const{data:Je,error:lt}=await G.from("template_categories").select("*").order("name");if(lt)throw lt;return Je}}),{data:re=[]}=wt({queryKey:["template-types"],queryFn:async()=>{const{data:Je,error:lt}=await G.from("template_types").select("*").order("name");if(lt)throw lt;return Je}}),{data:ne=[],isLoading:le}=wt({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:Je,error:lt}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(lt)throw lt;const{data:rt,error:Se}=await G.from("template_links").select("*").order("sort_order");if(Se)throw Se;const{data:it,error:$e}=await G.from("template_guides").select("*").order("sort_order");if($e)throw $e;return Je.map(Ue=>({...Ue,links:(rt==null?void 0:rt.filter(Ke=>Ke.template_id===Ue.id))||[],guides:(it==null?void 0:it.filter(Ke=>Ke.template_id===Ue.id))||[]}))}});C.useEffect(()=>{const Je=n.get("edit");if(Je&&ne.length>0){const lt=ne.find(rt=>rt.id===Je);lt&&(We(lt),a({},{replace:!0}))}},[ne,n]);const he=Dt({mutationFn:async Je=>{const{data:lt,error:rt}=await G.from("template_categories").insert({name:Je}).select().single();if(rt)throw rt;return lt},onSuccess:Je=>{r.invalidateQueries({queryKey:["template-categories"]}),p({...u,category_id:Je.id}),q(""),se(!1),s({title:"Category added"})},onError:Je=>{s({title:"Error adding category",description:Je.message,variant:"destructive"})}}),we=Dt({mutationFn:async Je=>{const{data:lt,error:rt}=await G.from("template_types").insert({name:Je}).select().single();if(rt)throw rt;return lt},onSuccess:Je=>{r.invalidateQueries({queryKey:["template-types"]}),p({...u,type_id:Je.id}),V(""),Q(!1),s({title:"Type added"})},onError:Je=>{s({title:"Error adding type",description:Je.message,variant:"destructive"})}}),ye=Dt({mutationFn:async Je=>{var $e;let lt=Je.existingImageUrl;if(Je.image){const ot=Je.image.name.split(".").pop(),Ue=`${Date.now()}-${Math.random().toString(36).substring(7)}.${ot}`,{error:Ke}=await G.storage.from("template-previews").upload(Ue,Je.image);if(Ke)throw Ke;const{data:Xe}=G.storage.from("template-previews").getPublicUrl(Ue);lt=Xe.publicUrl}const rt={name:Je.template.name,description:Je.template.description||null,category_id:Je.template.category_id||null,type_id:Je.template.type_id||null,preview_image_url:lt,video_url:Je.videoUrl||null,publish_date:Je.template.publish_date?new Date(Je.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let Se=Je.templateId;if(Se){const{error:ot}=await G.from("canva_templates").update(rt).eq("id",Se);if(ot)throw ot;const{error:Ue}=await G.from("template_links").delete().eq("template_id",Se);if(Ue)throw Ue;const Ke=(($e=Je.existingGuides)==null?void 0:$e.map(Ye=>Ye.id).filter(Boolean))||[],Xe=Je.template.guides.map(Ye=>Ye.id).filter(Boolean),He=Ke.filter(Ye=>!Xe.includes(Ye));He.length>0&&await G.from("template_guides").delete().in("id",He)}else{const{data:ot,error:Ue}=await G.from("canva_templates").insert(rt).select().single();if(Ue)throw Ue;Se=ot.id,uUt(Je.template.name,ot.id)}const it=Je.template.links.filter(ot=>ot.title.trim()&&ot.canva_share_link.trim());if(it.length>0){const ot=it.map((Ke,Xe)=>({template_id:Se,title:Ke.title.trim(),canva_share_link:Ke.canva_share_link.trim(),sort_order:Xe})),{error:Ue}=await G.from("template_links").insert(ot);if(Ue)throw Ue}for(let ot=0;ot0)){const{error:ot}=await G.from("resource_kit_templates").insert(Je.linkedKitIds.map(Ue=>({template_id:Se,kit_id:Ue})));if(ot)throw ot}},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),ke(),l(!1),s({title:i?"Template updated":"Template created"})},onError:Je=>{s({title:"Error saving template",description:Je.message,variant:"destructive"})}}),je=Dt({mutationFn:async Je=>{const{error:lt}=await G.from("canva_templates").delete().eq("id",Je);if(lt)throw lt},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:Je=>{s({title:"Error deleting template",description:Je.message,variant:"destructive"})}}),ke=()=>{p({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),S(null),I(""),c(null),se(!1),Q(!1),q(""),V(""),y(null),b(0),j(!1),R([])},We=async Je=>{var rt;c(Je),p({name:Je.name,description:Je.description||"",category_id:Je.category_id||"",type_id:Je.type_id||"",publish_date:Je.publish_date?new Date(Je.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:Je.links&&Je.links.length>0?Je.links.map(Se=>({id:Se.id,title:Se.title,canva_share_link:Se.canva_share_link,sort_order:Se.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((rt=Je.guides)==null?void 0:rt.map(Se=>({id:Se.id,name:Se.name,file_url:Se.file_url,file_type:Se.file_type,file_size:Se.file_size,sort_order:Se.sort_order})))||[],video_url:Je.video_url||""}),I(Je.preview_image_url||""),y(null);const{data:lt}=await G.from("resource_kit_templates").select("kit_id").eq("template_id",Je.id);R((lt||[]).map(Se=>Se.kit_id)),l(!0)},be=Je=>{var rt;const lt=(rt=Je.target.files)==null?void 0:rt[0];lt&&(S(lt),I(URL.createObjectURL(lt)))},Me=()=>{p({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},Ae=Je=>{if(u.links.length<=1)return;const lt=u.links.filter((rt,Se)=>Se!==Je);p({...u,links:lt})},Re=(Je,lt,rt)=>{const Se=[...u.links];Se[Je]={...Se[Je],[lt]:rt},p({...u,links:Se})},Te=Je=>{const lt=Je.target.files;if(!lt)return;const rt=Array.from(lt).map((Se,it)=>({name:Se.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:Se.type,file_size:Se.size,sort_order:u.guides.length+it,file:Se}));p({...u,guides:[...u.guides,...rt]}),Je.target.value=""},qe=Je=>{const lt=u.guides.filter((rt,Se)=>Se!==Je);p({...u,guides:lt})},ct=(Je,lt)=>{const rt=[...u.guides];rt[Je]={...rt[Je],name:lt},p({...u,guides:rt})},De=async()=>{if(!f)return null;j(!0),b(0);try{const{data:Je,error:lt}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||f.name}});if(lt)throw new Error(lt.message);const{videoId:rt,libraryId:Se}=Je,{data:it,error:$e}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:rt}});if($e)throw new Error($e.message);const ot=new XMLHttpRequest;return await new Promise((Ke,Xe)=>{ot.upload.addEventListener("progress",He=>{if(He.lengthComputable){const Ye=Math.round(He.loaded/He.total*100);b(Ye)}}),ot.addEventListener("load",()=>{ot.status>=200&&ot.status<300?Ke():Xe(new Error(`Upload failed with status ${ot.status}`))}),ot.addEventListener("error",()=>Xe(new Error("Upload failed"))),ot.open("PUT",it.uploadUrl),ot.setRequestHeader("AccessKey",it.apiKey),ot.send(f)}),`https://player.mediadelivery.net/embed/${Se}/${rt}`}catch(Je){return console.error("Bunny upload error:",Je),s({title:"Video upload failed",description:Je instanceof Error?Je.message:"Unknown error",variant:"destructive"}),null}finally{j(!1)}},Rt=Je=>{var rt;const lt=(rt=Je.target.files)==null?void 0:rt[0];lt&&y(lt),Je.target.value=""},pe=async Je=>{if(Je.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(Se=>Se.title.trim()&&Se.canva_share_link.trim()).length===0){s({title:"Please add at least one Canva link",variant:"destructive"});return}let rt=u.video_url;if(f){const Se=await De();if(!Se)return;rt=Se}ye.mutate({template:u,image:N,existingImageUrl:(i==null?void 0:i.preview_image_url)||null,templateId:i==null?void 0:i.id,existingGuides:i==null?void 0:i.guides,videoUrl:rt,linkedKitIds:L})};return e.jsx(Es,{title:"Manage Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{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(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:ne.length})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:de.length})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:re.length})})]})]}),e.jsxs(_s,{open:o,onOpenChange:Je=>{l(Je),Je||ke()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Template"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:i?"Edit Template":"Add New Template"})}),e.jsxs("form",{onSubmit:pe,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"name",children:"Name *"}),e.jsx(Fe,{id:"name",value:u.name,onChange:Je=>p({...u,name:Je.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(iy,{content:u.description,onChange:Je=>p({...u,description:Je}),placeholder:"Brief description of the template",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Canva Links *"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Me,className:"gap-1",children:[e.jsx(Zs,{className:"h-3 w-3"}),"Add Link"]})]}),e.jsx("div",{className:"space-y-3",children:u.links.map((Je,lt)=>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(Fe,{value:Je.title,onChange:rt=>Re(lt,"title",rt.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(Fe,{value:Je.canva_share_link,onChange:rt=>Re(lt,"canva_share_link",rt.target.value),placeholder:"https://www.canva.com/design/..."})]}),u.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>Ae(lt),children:e.jsx(Ur,{className:"h-4 w-4"})})]},lt))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Category"}),X?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:$,onChange:Je=>q(Je.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>$.trim()&&he.mutate($.trim()),disabled:he.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{se(!1),q("")},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(rr,{value:u.category_id,onValueChange:Je=>p({...u,category_id:Je}),children:[e.jsx(tr,{className:"flex-1",children:e.jsx(nr,{placeholder:"Select category"})}),e.jsx(sr,{children:de.map(Je=>e.jsx(Tt,{value:Je.id,children:Je.name},Je.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>se(!0),children:e.jsx(Zs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Template Type"}),ee?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:U,onChange:Je=>V(Je.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>U.trim()&&we.mutate(U.trim()),disabled:we.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Q(!1),V("")},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(rr,{value:u.type_id,onValueChange:Je=>p({...u,type_id:Je}),children:[e.jsx(tr,{className:"flex-1",children:e.jsx(nr,{placeholder:"Select type"})}),e.jsx(sr,{children:re.map(Je=>e.jsx(Tt,{value:Je.id,children:Je.name},Je.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>Q(!0),children:e.jsx(Zs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Fe,{id:"publish_date",type:"date",value:u.publish_date,onChange:Je=>p({...u,publish_date:Je.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Templates are sorted by publish date (newest first) on the member page"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[T?e.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border bg-muted",children:[e.jsx("img",{src:T,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),I("")},children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsx("div",{className:"w-32 h-24 rounded-lg border-2 border-dashed border-muted-foreground/25 flex items-center justify-center",children:e.jsx(cl,{className:"h-8 w-8 text-muted-foreground/50"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Fe,{type:"file",accept:"image/*",onChange:be,className:"cursor-pointer"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Upload a preview image for this template"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{children:"Video (Optional)"}),u.video_url&&!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(Nn,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:"Video uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>p({...u,video_url:""}),className:"text-destructive hover:text-destructive",children:"Remove"})]}),e.jsx("div",{className:"aspect-video max-w-md rounded-lg overflow-hidden border",children:e.jsx("iframe",{src:u.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}):w?e.jsxs("div",{className:"space-y-2 p-4 border rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ss,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",_,"%"]})]}),e.jsx(Oi,{value:_,className:"h-2"})]}):f?e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[e.jsx(Nn,{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:()=>y(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Fe,{type:"file",accept:"video/*",onChange:Rt,className:"hidden"}),e.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 border-2 border-dashed rounded-lg hover:border-primary/50 transition-colors",children:[e.jsx(Nn,{className:"h-8 w-8 text-muted-foreground/50"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Click to upload a video"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload a video to embed on the template page (Bunny.net)"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Guide Files (PDFs)"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(Fe,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:Te,className:"hidden"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:e.jsxs("span",{children:[e.jsx(ni,{className:"h-3 w-3"}),"Add Files"]})})]})]}),u.guides.length>0?e.jsx("div",{className:"space-y-2",children:u.guides.map((Je,lt)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(In,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(Fe,{value:Je.name,onChange:rt=>ct(lt,rt.target.value),placeholder:"Guide name",className:"flex-1"}),Je.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(Je.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:()=>qe(lt),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Je.id||lt))}):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(xUt,{selectedKitIds:L,onChange:R}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{l(!1),ke()},children:"Cancel"}),e.jsx(K,{type:"submit",disabled:ye.isPending,children:ye.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:le?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):ne.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No templates yet. Add your first template!"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Preview"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Links"}),e.jsx(bt,{children:"Category"}),e.jsx(bt,{children:"Type"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:ne.map(Je=>{var lt,rt,Se,it,$e;return e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:Je.preview_image_url?e.jsx("img",{src:Je.preview_image_url,alt:Je.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(cl,{className:"h-4 w-4 text-muted-foreground"})})})}),e.jsx(dt,{className:"font-medium",children:Je.name}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(nt,{variant:"secondary",children:[((lt=Je.links)==null?void 0:lt.length)||0," link",(((rt=Je.links)==null?void 0:rt.length)||0)!==1?"s":""]}),(((Se=Je.guides)==null?void 0:Se.length)||0)>0&&e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),(it=Je.guides)==null?void 0:it.length," guide",((($e=Je.guides)==null?void 0:$e.length)||0)!==1?"s":""]})]})}),e.jsx(dt,{children:Je.category?e.jsx(nt,{variant:"secondary",children:Je.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{children:Je.type?e.jsx(nt,{variant:"outline",children:Je.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{className:"text-muted-foreground",children:new Date(Je.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:()=>We(Je),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&je.mutate(Je.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},Je.id)})})]})})})]})})};function Det({selectedTemplateIds:t,onChange:s}){const[r,n]=C.useState(""),[a,o]=C.useState(!1),{data:l=[]}=wt({queryKey:["all-canva-templates-picker"],queryFn:async()=>{const{data:f,error:y}=await G.from("canva_templates").select("id, name, preview_image_url").order("name");if(y)throw y;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(y=>y!==f))};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{className:"flex items-center gap-2",children:[e.jsx(V4,{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(nt,{variant:"secondary",className:"gap-1 pr-1",children:[f.name,e.jsx("button",{type:"button",onClick:()=>p(f.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:e.jsx(Ur,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(Lo,{open:a,onOpenChange:o,children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(V4,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(Eo,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(xn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Fe,{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(V4,{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 vUt=[{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"}],_Ut=()=>{const{user:t}=Ws(),[s,r]=Xc(),{toast:n}=Ra(),a=ss(),[o,l]=C.useState(!1),[i,c]=C.useState(null),[u,p]=C.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[f,y]=C.useState(null),[_,b]=C.useState(""),[w,j]=C.useState([]),[N,S]=C.useState([]),[T,I]=C.useState([]),[L,R]=C.useState([]),[$,q]=C.useState(""),[U,V]=C.useState(!1),[X,se]=C.useState(null),[ee,Q]=C.useState(0),[de,re]=C.useState(!1),[ne,le]=C.useState(null),{data:he=[]}=wt({queryKey:["academy-categories"],queryFn:async()=>{const{data:pe,error:Je}=await G.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(Je)throw Je;return pe}}),{data:we=[],isLoading:ye}=wt({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:pe,error:Je}=await G.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(Je)throw Je;const{data:lt,error:rt}=await G.from("academy_resources").select("*").order("sort_order");if(rt)throw rt;return pe.map(it=>({...it,resources:(lt==null?void 0:lt.filter($e=>$e.video_id===it.id))||[]}))}});C.useEffect(()=>{const pe=s.get("edit");if(pe&&we.length>0){const Je=we.find(lt=>lt.id===pe);Je&&(Ae(Je),r({},{replace:!0}))}},[we,s]);const je=Dt({mutationFn:async pe=>{const{data:Je,error:lt}=await G.from("academy_categories").insert({name:pe,sort_order:he.length}).select().single();if(lt)throw lt;return Je},onSuccess:pe=>{a.invalidateQueries({queryKey:["academy-categories"]}),p({...u,category_id:pe.id}),q(""),V(!1),n({title:"Category added"})},onError:pe=>{n({title:"Error adding category",description:pe.message,variant:"destructive"})}}),ke=Dt({mutationFn:async pe=>{let Je=pe.existingThumbnailUrl;if(pe.thumbnail){const Se=pe.thumbnail.name.split(".").pop(),it=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${Se}`,{error:$e}=await G.storage.from("academy-resources").upload(it,pe.thumbnail);if($e)throw $e;const{data:ot}=G.storage.from("academy-resources").getPublicUrl(it);Je=ot.publicUrl}const lt={title:pe.video.title,description:pe.video.description||null,video_url:pe.video.video_url,video_type:pe.video.video_type,duration:pe.video.duration||null,thumbnail_url:Je,category_id:pe.video.category_id||null,publish_date:pe.video.publish_date?new Date(pe.video.publish_date).toISOString():new Date().toISOString(),is_published:pe.video.is_published,created_by:t==null?void 0:t.id};let rt=pe.videoId;if(rt){const{error:Se}=await G.from("academy_videos").update(lt).eq("id",rt);if(Se)throw Se}else{const{data:Se,error:it}=await G.from("academy_videos").insert(lt).select().single();if(it)throw it;rt=Se.id,hUt(pe.video.title,Se.id)}if(pe.resourcesToDelete.length>0){const{error:Se}=await G.from("academy_resources").delete().in("id",pe.resourcesToDelete);if(Se)throw Se}for(let Se=0;Se0){const{error:Se}=await G.from("academy_video_templates").insert(L.map(it=>({video_id:rt,template_id:it})));if(Se)throw Se}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Me(),l(!1),n({title:i?"Video updated":"Video created"})},onError:pe=>{n({title:"Error saving video",description:pe.message,variant:"destructive"})}}),We=Dt({mutationFn:async pe=>{const{error:Je}=await G.from("academy_videos").delete().eq("id",pe);if(Je)throw Je},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),n({title:"Video deleted"})},onError:pe=>{n({title:"Error deleting video",description:pe.message,variant:"destructive"})}}),be=Dt({mutationFn:async({id:pe,is_published:Je})=>{const{error:lt}=await G.from("academy_videos").update({is_published:Je}).eq("id",pe);if(lt)throw lt},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:pe=>{n({title:"Error updating video",description:pe.message,variant:"destructive"})}}),Me=()=>{p({title:"",description:"",video_url:"",video_type:"bunny_stream",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),y(null),b(""),j([]),S([]),I([]),c(null),R([]),q(""),se(null),Q(0),re(!1),le(null)},Ae=async pe=>{c(pe),p({title:pe.title,description:pe.description||"",video_url:pe.video_url,video_type:pe.video_type,duration:pe.duration||"",category_id:pe.category_id||"",publish_date:pe.publish_date?new Date(pe.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:pe.is_published}),b(pe.thumbnail_url||""),S(pe.resources||[]),j([]),I([]);const{data:Je}=await G.from("academy_video_templates").select("template_id").eq("video_id",pe.id);R((Je||[]).map(lt=>lt.template_id)),l(!0)},Re=pe=>{var lt;const Je=(lt=pe.target.files)==null?void 0:lt[0];Je&&(y(Je),b(URL.createObjectURL(Je)))},Te=pe=>{const Je=pe.target.files;if(Je){const lt=Array.from(Je).map(rt=>({file:rt,title:rt.name.replace(/\.[^/.]+$/,"")}));j([...w,...lt])}pe.target.value=""},qe=pe=>{j(w.filter((Je,lt)=>lt!==pe))},ct=pe=>{I([...T,pe]),S(N.filter(Je=>Je.id!==pe))},De=async()=>{if(!X)return null;re(!0),Q(0);try{const{data:pe,error:Je}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||X.name}});if(Je)throw new Error(Je.message);const{videoId:lt,libraryId:rt}=pe;le(lt);const{data:Se,error:it}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:lt}});if(it)throw new Error(it.message);const $e=new XMLHttpRequest;return await new Promise((Ue,Ke)=>{$e.upload.addEventListener("progress",Xe=>{if(Xe.lengthComputable){const He=Math.round(Xe.loaded/Xe.total*100);Q(He)}}),$e.addEventListener("load",()=>{$e.status>=200&&$e.status<300?Ue():Ke(new Error(`Upload failed with status ${$e.status}`))}),$e.addEventListener("error",()=>Ke(new Error("Upload failed"))),$e.open("PUT",Se.uploadUrl),$e.setRequestHeader("AccessKey",Se.apiKey),$e.send(X)}),`https://player.mediadelivery.net/embed/${rt}/${lt}`}catch(pe){return console.error("Bunny upload error:",pe),n({title:"Video upload failed",description:pe instanceof Error?pe.message:"Unknown error",variant:"destructive"}),null}finally{re(!1)}},Rt=async pe=>{if(pe.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let Je=u.video_url;if(u.video_type==="bunny_stream"&&X&&!i){const lt=await De();if(!lt)return;Je=lt}else if(!u.video_url.trim()&&u.video_type!=="bunny_stream"){n({title:"Please enter a video URL",variant:"destructive"});return}else if(u.video_type==="bunny_stream"&&!X&&!u.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}ke.mutate({video:{...u,video_url:Je},thumbnail:f,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:w,resourcesToDelete:T})};return e.jsx(Es,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{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(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:we.length})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:we.filter(pe=>pe.is_published).length})})]})]}),e.jsxs(_s,{open:o,onOpenChange:pe=>{l(pe),pe||Me()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Video"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:Rt,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Fe,{id:"title",value:u.title,onChange:pe=>p({...u,title:pe.target.value}),placeholder:"Video title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(iy,{content:u.description,onChange:pe=>p({...u,description:pe}),placeholder:"Brief description of the video",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Video Type"}),e.jsxs(rr,{value:u.video_type,onValueChange:pe=>{p({...u,video_type:pe,video_url:""}),se(null)},disabled:de,children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:vUt.map(pe=>e.jsx(Tt,{value:pe.value,children:pe.label},pe.value))})]})]}),u.video_type==="bunny_stream"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs(_e,{children:["Upload Video File ",!i&&"*"]}),i&&u.video_url&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Current video: ",e.jsx("a",{href:u.video_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"View"})]}),!i&&e.jsxs(e.Fragment,{children:[e.jsx(Fe,{type:"file",accept:"video/*",onChange:pe=>{var lt;const Je=(lt=pe.target.files)==null?void 0:lt[0];Je&&se(Je)},disabled:de}),X&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Nn,{className:"h-4 w-4"}),X.name," (",(X.size/(1024*1024)).toFixed(1)," MB)"]}),de&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ss,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(Oi,{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(_e,{htmlFor:"video_url",children:"Video URL *"}),e.jsx(Fe,{id:"video_url",value:u.video_url,onChange:pe=>p({...u,video_url:pe.target.value}),placeholder:"https://...",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"duration",children:"Duration"}),e.jsx(Fe,{id:"duration",value:u.duration,onChange:pe=>p({...u,duration:pe.target.value}),placeholder:"e.g., 45:30"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Fe,{id:"publish_date",type:"date",value:u.publish_date,onChange:pe=>p({...u,publish_date:pe.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Category"}),U?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:$,onChange:pe=>q(pe.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>$.trim()&&je.mutate($.trim()),disabled:je.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{V(!1),q("")},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(rr,{value:u.category_id,onValueChange:pe=>p({...u,category_id:pe}),children:[e.jsx(tr,{className:"flex-1",children:e.jsx(nr,{placeholder:"Select category"})}),e.jsx(sr,{children:he.map(pe=>e.jsx(Tt,{value:pe.id,children:pe.name},pe.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:()=>V(!0),children:e.jsx(Zs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Thumbnail Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[_&&e.jsx("img",{src:_,alt:"Thumbnail preview",className:"w-32 h-20 object-cover rounded-md border"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(Fe,{type:"file",accept:"image/*",onChange:Re,className:"cursor-pointer"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Recommended: 16:9 aspect ratio"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Resource Files"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",asChild:!0,children:e.jsxs("label",{className:"cursor-pointer gap-1",children:[e.jsx(ni,{className:"h-3 w-3"}),"Add Files",e.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:Te,className:"hidden"})]})})]}),(N.length>0||w.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[N.map(pe=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:pe.title}),e.jsx(nt,{variant:"outline",className:"text-xs",children:pe.file_type}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>ct(pe.id),className:"text-destructive hover:text-destructive",children:e.jsx(Ur,{className:"h-4 w-4"})})]},pe.id)),w.map((pe,Je)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{value:pe.title,onChange:lt=>{const rt=[...w];rt[Je].title=lt.target.value,j(rt)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(nt,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>qe(Je),className:"text-destructive hover:text-destructive",children:e.jsx(Ur,{className:"h-4 w-4"})})]},Je))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),e.jsx(Det,{selectedTemplateIds:L,onChange:R}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_published",checked:u.is_published,onCheckedChange:pe=>p({...u,is_published:pe})}),e.jsx(_e,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(Vn,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:de,children:"Cancel"}),e.jsx(K,{type:"submit",disabled:ke.isPending||de,children:de?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):ke.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:ye?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):we.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Nn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No videos yet"}),e.jsx("p",{className:"text-sm",children:"Add your first academy video"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Category"}),e.jsx(bt,{children:"Duration"}),e.jsx(bt,{children:"Resources"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-[120px]",children:"Actions"})]})}),e.jsx(Pn,{children:we.map(pe=>e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[pe.thumbnail_url?e.jsx("img",{src:pe.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(Nn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:pe.title}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:pe.video_type.replace("_"," ")})]})]})}),e.jsx(dt,{children:pe.category?e.jsx(nt,{variant:"outline",children:pe.category.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(dt,{children:pe.duration||"-"}),e.jsx(dt,{children:pe.resources&&pe.resources.length>0?e.jsxs(nt,{variant:"secondary",children:[pe.resources.length," file(s)"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(dt,{children:new Date(pe.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(Br,{checked:pe.is_published,onCheckedChange:Je=>be.mutate({id:pe.id,is_published:Je})})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Ae(pe),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>We.mutate(pe.id),className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},pe.id))})]})})})]})})};function bUt(){var ke,We,be;const t=ss(),[s,r]=Xc(),[n,a]=C.useState(!1),[o,l]=C.useState(null),[i,c]=C.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=C.useState(null),[f,y]=C.useState(""),[_,b]=C.useState([]),[w,j]=C.useState([]),[N,S]=C.useState([]),[T,I]=C.useState(null),{data:L,isLoading:R}=wt({queryKey:["resource-kits"],queryFn:async()=>{const{data:Me,error:Ae}=await G.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(Ae)throw Ae;return Me}}),{data:$}=wt({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Me,error:Ae}=await G.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(Ae)throw Ae;return Me}}),{data:q}=wt({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Me,error:Ae}=await G.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(Ae)throw Ae;return Me}});C.useEffect(()=>{const Me=s.get("edit");if(Me&&L&&L.length>0&&$&&q){const Ae=L.find(Re=>Re.id===Me);Ae&&(V(Ae),r({},{replace:!0}))}},[L,$,q,s]);const U=()=>{c({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),y(""),b([]),j([]),S([]),l(null)},V=async Me=>{l(Me),c({name:Me.name,description:Me.description||"",publish_date:Me.publish_date.split("T")[0],is_published:Me.is_published}),y(Me.featured_image_url||"");const Ae=($==null?void 0:$.filter(qe=>qe.kit_id===Me.id))||[];b(Ae.map(qe=>({id:qe.id,name:qe.name,file_url:qe.file_url,file_type:qe.file_type,file_size:qe.file_size,sort_order:qe.sort_order})));const Re=(q==null?void 0:q.filter(qe=>qe.kit_id===Me.id))||[];j(Re.map(qe=>({id:qe.id,title:qe.title,canva_share_link:qe.canva_share_link,sort_order:qe.sort_order})));const{data:Te}=await G.from("resource_kit_templates").select("template_id").eq("kit_id",Me.id);S((Te||[]).map(qe=>qe.template_id)),a(!0)},X=Me=>{var Re;const Ae=(Re=Me.target.files)==null?void 0:Re[0];Ae&&(p(Ae),y(URL.createObjectURL(Ae)))},se=()=>{b([..._,{name:"",file_url:"",sort_order:_.length}])},ee=Me=>{b(_.filter((Ae,Re)=>Re!==Me))},Q=(Me,Ae,Re)=>{const Te=[..._];Te[Me]={...Te[Me],[Ae]:Re},b(Te)},de=()=>{j([...w,{title:"",canva_share_link:"",sort_order:w.length}])},re=Me=>{j(w.filter((Ae,Re)=>Re!==Me))},ne=(Me,Ae,Re)=>{const Te=[...w];Te[Me]={...Te[Me],[Ae]:Re},j(Te)},le=(Me,Ae)=>{var Te;const Re=(Te=Ae.target.files)==null?void 0:Te[0];if(Re){const qe=[..._],ct=Re.name.replace(/\.[^/.]+$/,"");qe[Me]={...qe[Me],file:Re,file_type:Re.type,file_size:Re.size,name:qe[Me].name||ct},b(qe)}},he=Dt({mutationFn:async()=>{let Me=(o==null?void 0:o.featured_image_url)||null;if(u){const ct=u.name.split(".").pop(),De=`${Date.now()}.${ct}`,{error:Rt}=await G.storage.from("resource-kits").upload(`featured/${De}`,u);if(Rt)throw Rt;const{data:pe}=G.storage.from("resource-kits").getPublicUrl(`featured/${De}`);Me=pe.publicUrl}const Ae={name:i.name,description:i.description||null,featured_image_url:Me,publish_date:i.publish_date,is_published:i.is_published};let Re;const Te=!o,qe=(o==null?void 0:o.is_published)||!1;if(o){const{error:ct}=await G.from("resource_kits").update(Ae).eq("id",o.id);if(ct)throw ct;Re=o.id;const De=($==null?void 0:$.filter(Se=>Se.kit_id===o.id).map(Se=>Se.id))||[],Rt=_.filter(Se=>Se.id).map(Se=>Se.id),pe=De.filter(Se=>!Rt.includes(Se));pe.length>0&&await G.from("resource_kit_files").delete().in("id",pe);const Je=(q==null?void 0:q.filter(Se=>Se.kit_id===o.id).map(Se=>Se.id))||[],lt=w.filter(Se=>Se.id).map(Se=>Se.id),rt=Je.filter(Se=>!lt.includes(Se));rt.length>0&&await G.from("resource_kit_links").delete().in("id",rt)}else{const{data:ct,error:De}=await G.from("resource_kits").insert(Ae).select().single();if(De)throw De;Re=ct.id}for(let ct=0;ct<_.length;ct++){const De=_[ct];let Rt=De.file_url;if(De.file){const pe=De.file.name.split(".").pop(),Je=`${Date.now()}-${ct}.${pe}`,{error:lt}=await G.storage.from("resource-kits").upload(`files/${Je}`,De.file);if(lt)throw lt;const{data:rt}=G.storage.from("resource-kits").getPublicUrl(`files/${Je}`);Rt=rt.publicUrl}De.id?await G.from("resource_kit_files").update({name:De.name,file_url:Rt,file_type:De.file_type,file_size:De.file_size,sort_order:ct}).eq("id",De.id):Rt&&De.name&&await G.from("resource_kit_files").insert({kit_id:Re,name:De.name,file_url:Rt,file_type:De.file_type,file_size:De.file_size,sort_order:ct})}for(let ct=0;ct0){const{error:ct}=await G.from("resource_kit_templates").insert(N.map(De=>({kit_id:Re,template_id:De})));if(ct)throw ct}return{kitId:Re,kitName:i.name,isNewKit:Te,wasPublished:qe,isPublished:i.is_published}},onSuccess:Me=>{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"),Me.isPublished&&(Me.isNewKit||!Me.wasPublished)&&pUt(Me.kitName,Me.kitId),a(!1),U()},onError:Me=>{me.error("Failed to save resource kit: "+Me.message)}}),we=Dt({mutationFn:async Me=>{const{error:Ae}=await G.from("resource_kits").delete().eq("id",Me);if(Ae)throw Ae},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),me.success("Resource kit deleted")},onError:Me=>{me.error("Failed to delete: "+Me.message)}}),ye=Me=>{if(Me.preventDefault(),!i.name){me.error("Please enter a name");return}he.mutate()},je=Me=>($==null?void 0:$.filter(Ae=>Ae.kit_id===Me).length)||0;return e.jsx(Es,{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(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.filter(Me=>Me.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{U(),a(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Files"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:R?e.jsx(ks,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(L==null?void 0:L.length)===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No resource kits yet. Create your first one!"})}):L==null?void 0:L.map(Me=>e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Me.featured_image_url?e.jsx("img",{src:Me.featured_image_url,alt:Me.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(bl,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Me.name}),Me.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Me.description})]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),je(Me.id)]})}),e.jsx(dt,{children:ys(new Date(Me.publish_date),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Me.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Me.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 Ae=($==null?void 0:$.filter(Te=>Te.kit_id===Me.id))||[],Re=(q==null?void 0:q.filter(Te=>Te.kit_id===Me.id))||[];I({...Me,files:Ae,links:Re})},children:e.jsx(va,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>V(Me),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&we.mutate(Me.id)},children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},Me.id))})]})})}),e.jsx(_s,{open:n,onOpenChange:a,children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:o?"Edit Resource Kit":"Add Resource Kit"})}),e.jsxs("form",{onSubmit:ye,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{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(bl,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Fe,{type:"file",accept:"image/*",onChange:X})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"name",children:"Name *"}),e.jsx(Fe,{id:"name",value:i.name,onChange:Me=>c({...i,name:Me.target.value}),placeholder:"Resource Kit Name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(iy,{content:i.description,onChange:Me=>c({...i,description:Me}),placeholder:"Brief description of this resource kit",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Fe,{id:"publish_date",type:"date",value:i.publish_date,onChange:Me=>c({...i,publish_date:Me.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(Br,{checked:i.is_published,onCheckedChange:Me=>c({...i,is_published:Me})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:i.is_published?"Visible to agents":"Hidden from agents"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(_e,{children:"Resource Files"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:se,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add File"]})]}),_.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No files added yet. Click "Add File" to include resources.'}):e.jsx("div",{className:"space-y-3",children:_.map((Me,Ae)=>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 ",Ae+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ee(Ae),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsx(Fe,{placeholder:"File name (e.g., Getting Started Guide)",value:Me.name,onChange:Re=>Q(Ae,"name",Re.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{type:"file",onChange:Re=>le(Ae,Re),className:"flex-1"}),Me.file_url&&!Me.file&&e.jsx("a",{href:Me.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),Me.file&&e.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},Ae))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(_e,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:de,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Canva Link"]})]}),w.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center border rounded-md border-dashed",children:'No Canva links added yet. Click "Add Canva Link" to include templates.'}):e.jsx("div",{className:"space-y-3",children:w.map((Me,Ae)=>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 ",Ae+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>re(Ae),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsx(Fe,{placeholder:"Link title (e.g., Social Media Post Template)",value:Me.title,onChange:Re=>ne(Ae,"title",Re.target.value)}),e.jsx(Fe,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Me.canva_share_link,onChange:Re=>ne(Ae,"canva_share_link",Re.target.value)})]},Ae))})]}),e.jsx(Det,{selectedTemplateIds:N,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:he.isPending,children:he.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(_s,{open:!!T,onOpenChange:()=>I(null),children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:T==null?void 0:T.name})}),e.jsxs("div",{className:"space-y-4",children:[(T==null?void 0:T.featured_image_url)&&e.jsx("img",{src:T.featured_image_url,alt:T.name,className:"w-full h-48 object-cover rounded-lg"}),(T==null?void 0:T.description)&&e.jsx("p",{className:"text-muted-foreground",children:T.description}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Resource Files (",((ke=T==null?void 0:T.files)==null?void 0:ke.length)||0,")"]}),((We=T==null?void 0:T.files)==null?void 0:We.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:(be=T==null?void 0:T.files)==null?void 0:be.map(Me=>e.jsxs("a",{href:Me.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[e.jsx(In,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Me.name})]},Me.id))})]}),(T==null?void 0:T.links)&&T.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",children:["Canva Links (",T.links.length,")"]}),e.jsx("div",{className:"space-y-2",children:T.links.map(Me=>e.jsxs("a",{href:Me.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(Vo,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Me.title})]},Me.id))})]})]})]})})]})})}const wUt=()=>{const{user:t}=Ws(),{toast:s}=Ra(),r=ss(),[n,a]=C.useState(!1),[o,l]=C.useState(null),[i,c]=C.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[u,p]=C.useState(null),[f,y]=C.useState(""),{data:_=[],isLoading:b}=wt({queryKey:["social-swag-admin"],queryFn:async()=>{const{data:q,error:U}=await G.from("social_swag").select("*").order("publish_date",{ascending:!1});if(U)throw U;const{data:V,error:X}=await G.from("social_swag_links").select("*").order("sort_order");if(X)throw X;return q.map(ee=>({...ee,links:(V==null?void 0:V.filter(Q=>Q.swag_id===ee.id))||[]}))}}),w=Dt({mutationFn:async q=>{let U=q.existingImageUrl;if(q.image){const de=q.image.name.split(".").pop(),re=`${Date.now()}-${Math.random().toString(36).substring(7)}.${de}`,{error:ne}=await G.storage.from("template-previews").upload(re,q.image);if(ne)throw ne;const{data:le}=G.storage.from("template-previews").getPublicUrl(re);U=le.publicUrl}const V={title:q.item.title,description:q.item.description||null,preview_image_url:U,publish_date:q.item.publish_date?new Date(q.item.publish_date).toISOString():new Date().toISOString(),is_published:q.item.is_published,created_by:t==null?void 0:t.id};let X=q.itemId;const se=!X,ee=(o==null?void 0:o.is_published)||!1;if(X){const{error:de}=await G.from("social_swag").update(V).eq("id",X);if(de)throw de;await G.from("social_swag_links").delete().eq("swag_id",X)}else{const{data:de,error:re}=await G.from("social_swag").insert(V).select().single();if(re)throw re;X=de.id}const Q=q.item.links.filter(de=>de.title.trim()&&de.canva_share_link.trim());if(Q.length>0){const de=Q.map((ne,le)=>({swag_id:X,title:ne.title.trim(),canva_share_link:ne.canva_share_link.trim(),sort_order:le})),{error:re}=await G.from("social_swag_links").insert(de);if(re)throw re}return{itemId:X,itemTitle:q.item.title,isNewItem:se,wasPublished:ee,isPublished:q.item.is_published}},onSuccess:q=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:o?"Item updated":"Item created"}),q.isPublished&&(q.isNewItem||!q.wasPublished)&&W1e(q.itemTitle,q.itemId),a(!1),N()},onError:q=>{s({title:"Error saving item",description:q.message,variant:"destructive"})}}),j=Dt({mutationFn:async q=>{const{error:U}=await G.from("social_swag").delete().eq("id",q);if(U)throw U},onSuccess:()=>{r.invalidateQueries({queryKey:["social-swag-admin"]}),r.invalidateQueries({queryKey:["social-swag"]}),s({title:"Item deleted"})},onError:q=>{s({title:"Error deleting item",description:q.message,variant:"destructive"})}}),N=()=>{c({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),p(null),y(""),l(null)},S=q=>{l(q),c({title:q.title,description:q.description||"",publish_date:q.publish_date?new Date(q.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:q.is_published,links:q.links&&q.links.length>0?q.links.map(U=>({id:U.id,title:U.title,canva_share_link:U.canva_share_link,sort_order:U.sort_order})):[{title:"",canva_share_link:"",sort_order:0}]}),y(q.preview_image_url||""),a(!0)},T=q=>{var V;const U=(V=q.target.files)==null?void 0:V[0];U&&(p(U),y(URL.createObjectURL(U)))},I=()=>{c({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},L=q=>{if(i.links.length<=1)return;const U=i.links.filter((V,X)=>X!==q);c({...i,links:U})},R=(q,U,V)=>{const X=[...i.links];X[q]={...X[q],[U]:V},c({...i,links:X})},$=q=>{if(q.preventDefault(),!i.title.trim()){s({title:"Title is required",variant:"destructive"});return}w.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Es,{title:"Manage Social Swag",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{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(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.filter(q=>q.is_published).length})})]})]}),e.jsxs(_s,{open:n,onOpenChange:q=>{a(q),q||N()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Item"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:o?"Edit Item":"Add New Item"})}),e.jsxs("form",{onSubmit:$,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Fe,{id:"title",value:i.title,onChange:q=>c({...i,title:q.target.value}),placeholder:"Enter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(iy,{content:i.description,onChange:q=>c({...i,description:q}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Fe,{id:"publish_date",type:"date",value:i.publish_date,onChange:q=>c({...i,publish_date:q.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Br,{id:"is_published",checked:i.is_published,onCheckedChange:q=>c({...i,is_published:q})}),e.jsx(_e,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Preview Image"}),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),y("")},children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(cl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(Fe,{type:"file",accept:"image/*",onChange:T,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:I,children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((q,U)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Link ",U+1]}),i.links.length>1&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>L(U),children:e.jsx(Ur,{className:"h-3 w-3"})})]}),e.jsx(Fe,{placeholder:"Link title (e.g., Instagram Post)",value:q.title,onChange:V=>R(U,"title",V.target.value)}),e.jsx(Fe,{placeholder:"Canva share link",value:q.canva_share_link,onChange:V=>R(U,"canva_share_link",V.target.value)})]})},U))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:b?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No items yet. Click "Add Item" to create your first one.'}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"w-16",children:"Preview"}),e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Links"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:_.map(q=>{var U;return e.jsxs(ks,{children:[e.jsx(dt,{children:q.preview_image_url?e.jsx("img",{src:q.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(cl,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(dt,{className:"font-medium",children:q.title}),e.jsxs(dt,{children:[((U=q.links)==null?void 0:U.length)||0," links"]}),e.jsx(dt,{children:new Date(q.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(nt,{variant:q.is_published?"default":"secondary",children:q.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/${q.id}`,"_blank"),children:e.jsx(va,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(q),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&j.mutate(q.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},q.id)})})]})})})]})})};function jUt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const Oue=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function VA(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function yNe(t){return"nodeType"in t}function Sp(t){var s,r;return t?VA(t)?t:yNe(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function vNe(t){const{Document:s}=Sp(t);return t instanceof s}function IO(t){return VA(t)?!1:t instanceof Sp(t).HTMLElement}function Oet(t){return t instanceof Sp(t).SVGElement}function HA(t){return t?VA(t)?t.document:yNe(t)?vNe(t)?t:IO(t)||Oet(t)?t.ownerDocument:document:document:document}const j0=Oue?C.useLayoutEffect:C.useEffect;function _Ne(t){const s=C.useRef(t);return j0(()=>{s.current=t}),C.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a{t.current=setInterval(n,a)},[]),r=C.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,r]}function eD(t,s){s===void 0&&(s=[t]);const r=C.useRef(t);return j0(()=>{r.current!==t&&(r.current=t)},s),r}function LO(t,s){const r=C.useRef();return C.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function Ile(t){const s=_Ne(t),r=C.useRef(null),n=C.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function G1e(t){const s=C.useRef();return C.useEffect(()=>{s.current=t},[t]),s.current}let jxe={};function DO(t,s){return C.useMemo(()=>{if(s)return s;const r=jxe[t]==null?0:jxe[t]+1;return jxe[t]=r,t+"-"+r},[t,s])}function Ret(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 RM=Ret(1),tD=Ret(-1);function NUt(t){return"clientX"in t&&"clientY"in t}function bNe(t){if(!t)return!1;const{KeyboardEvent:s}=Sp(t.target);return s&&t instanceof s}function SUt(t){if(!t)return!1;const{TouchEvent:s}=Sp(t.target);return s&&t instanceof s}function K1e(t){if(SUt(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 NUt(t)?{x:t.clientX,y:t.clientY}:null}const ET=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[ET.Translate.toString(t),ET.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),qLe="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function CUt(t){return t.matches(qLe)?t:t.querySelector(qLe)}const MUt={display:"none"};function TUt(t){let{id:s,value:r}=t;return ht.createElement("div",{id:s,style:MUt},r)}function AUt(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 EUt(){const[t,s]=C.useState("");return{announce:C.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const Fet=C.createContext(null);function PUt(t){const s=C.useContext(Fet);C.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function IUt(){const[t]=C.useState(()=>new Set),s=C.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[C.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 LUt={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. `},DUt={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 OUt(t){let{announcements:s=DUt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=LUt}=t;const{announce:o,announcement:l}=EUt(),i=DO("DndLiveRegion"),[c,u]=C.useState(!1);if(C.useEffect(()=>{u(!0)},[]),PUt(C.useMemo(()=>({onDragStart(f){let{active:y}=f;o(s.onDragStart({active:y}))},onDragMove(f){let{active:y,over:_}=f;s.onDragMove&&o(s.onDragMove({active:y,over:_}))},onDragOver(f){let{active:y,over:_}=f;o(s.onDragOver({active:y,over:_}))},onDragEnd(f){let{active:y,over:_}=f;o(s.onDragEnd({active:y,over:_}))},onDragCancel(f){let{active:y,over:_}=f;o(s.onDragCancel({active:y,over:_}))}}),[o,s])),!c)return null;const p=ht.createElement(ht.Fragment,null,ht.createElement(TUt,{id:n,value:a.draggable}),ht.createElement(AUt,{id:i,announcement:l}));return r?cp.createPortal(p,r):p}var cu;(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"})(cu||(cu={}));function Lle(){}function Z1e(t,s){return C.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function zet(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const ry=Object.freeze({x:0,y:0});function Bet(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function $et(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function RUt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function ULe(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 qet(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function VLe(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 Uet=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=VLe(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,c=r.get(i);if(c){const u=Bet(VLe(c),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort($et)},FUt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=ULe(s),o=[];for(const l of n){const{id:i}=l,c=r.get(i);if(c){const u=ULe(c),p=a.reduce((y,_,b)=>y+Bet(u[b],_),0),f=Number((p/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:f}})}}return o.sort($et)};function zUt(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=zUt(i,s);c>0&&a.push({id:l,data:{droppableContainer:o,value:c}})}}return a.sort(RUt)};function $Ut(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function Vet(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:ry}function qUt(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 UUt=qUt(1);function VUt(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 HUt(t,s,r){const n=VUt(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 WUt={ignoreTransform:!1};function WA(t,s){s===void 0&&(s=WUt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:p}=Sp(t).getComputedStyle(t);u&&(r=HUt(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 HLe(t){return WA(t,{ignoreTransform:!0})}function GUt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function KUt(t,s){return s===void 0&&(s=Sp(t).getComputedStyle(t)),s.position==="fixed"}function ZUt(t,s){s===void 0&&(s=Sp(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 Rue(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(vNe(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!IO(a)||Oet(a)||r.includes(a))return r;const o=Sp(t).getComputedStyle(a);return a!==t&&ZUt(a,o)&&r.push(a),KUt(a,o)?r:n(a.parentNode)}return t?n(t):r}function Het(t){const[s]=Rue(t,1);return s??null}function kxe(t){return!Oue||!t?null:VA(t)?t:yNe(t)?vNe(t)||t===HA(t).scrollingElement?window:IO(t)?t:null:null}function Wet(t){return VA(t)?t.scrollX:t.scrollLeft}function Get(t){return VA(t)?t.scrollY:t.scrollTop}function Y1e(t){return{x:Wet(t),y:Get(t)}}var zu;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(zu||(zu={}));function Ket(t){return!Oue||!t?!1:t===document.scrollingElement}function Zet(t){const s={x:0,y:0},r=Ket(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 YUt={x:.2,y:.2};function XUt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:c}=r;n===void 0&&(n=10),a===void 0&&(a=YUt);const{isTop:u,isBottom:p,isLeft:f,isRight:y}=Zet(t),_={x:0,y:0},b={x:0,y:0},w={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+w.height?(_.y=zu.Backward,b.y=n*Math.abs((s.top+w.height-o)/w.height)):!p&&c>=s.bottom-w.height&&(_.y=zu.Forward,b.y=n*Math.abs((s.bottom-w.height-c)/w.height)),!y&&i>=s.right-w.width?(_.x=zu.Forward,b.x=n*Math.abs((s.right-w.width-i)/w.width)):!f&&l<=s.left+w.width&&(_.x=zu.Backward,b.x=n*Math.abs((s.left+w.width-l)/w.width)),{direction:_,speed:b}}function QUt(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 Yet(t){return t.reduce((s,r)=>RM(s,Y1e(r)),ry)}function JUt(t){return t.reduce((s,r)=>s+Wet(r),0)}function eVt(t){return t.reduce((s,r)=>s+Get(r),0)}function tVt(t,s){if(s===void 0&&(s=WA),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);Het(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const sVt=[["x",["left","right"],JUt],["y",["top","bottom"],eVt]];class wNe{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=Rue(r),a=Yet(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of sVt)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 VL{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 rVt(t){const{EventTarget:s}=Sp(t);return t instanceof s?t:HA(t)}function Nxe(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 sg;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(sg||(sg={}));function WLe(t){t.preventDefault()}function nVt(t){t.stopPropagation()}var No;(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"})(No||(No={}));const Xet={start:[No.Space,No.Enter],cancel:[No.Esc],end:[No.Space,No.Enter,No.Tab]},aVt=(t,s)=>{let{currentCoordinates:r}=s;switch(t.code){case No.Right:return{...r,x:r.x+25};case No.Left:return{...r,x:r.x-25};case No.Down:return{...r,y:r.y+25};case No.Up:return{...r,y:r.y-25}}};class jNe{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 VL(HA(r)),this.windowListeners=new VL(Sp(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(sg.Resize,this.handleCancel),this.windowListeners.add(sg.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(sg.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&tVt(n),r(ry)}handleKeyDown(s){if(bNe(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=Xet,coordinateGetter:l=aVt,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}:ry;this.referenceCoordinates||(this.referenceCoordinates=p);const f=l(s,{active:r,context:n.current,currentCoordinates:p});if(f){const y=tD(f,p),_={x:0,y:0},{scrollableAncestors:b}=n.current;for(const w of b){const j=s.code,{isTop:N,isRight:S,isLeft:T,isBottom:I,maxScroll:L,minScroll:R}=Zet(w),$=QUt(w),q={x:Math.min(j===No.Right?$.right-$.width/2:$.right,Math.max(j===No.Right?$.left:$.left+$.width/2,f.x)),y:Math.min(j===No.Down?$.bottom-$.height/2:$.bottom,Math.max(j===No.Down?$.top:$.top+$.height/2,f.y))},U=j===No.Right&&!S||j===No.Left&&!T,V=j===No.Down&&!I||j===No.Up&&!N;if(U&&q.x!==f.x){const X=w.scrollLeft+y.x,se=j===No.Right&&X<=L.x||j===No.Left&&X>=R.x;if(se&&!y.y){w.scrollTo({left:X,behavior:i});return}se?_.x=w.scrollLeft-X:_.x=j===No.Right?w.scrollLeft-L.x:w.scrollLeft-R.x,_.x&&w.scrollBy({left:-_.x,behavior:i});break}else if(V&&q.y!==f.y){const X=w.scrollTop+y.y,se=j===No.Down&&X<=L.y||j===No.Up&&X>=R.y;if(se&&!y.x){w.scrollTo({top:X,behavior:i});return}se?_.y=w.scrollTop-X:_.y=j===No.Down?w.scrollTop-L.y:w.scrollTop-R.y,_.y&&w.scrollBy({top:-_.y,behavior:i});break}}this.handleMove(s,RM(tD(f,this.referenceCoordinates),_))}}}handleMove(s,r){const{onMove:n}=this.props;s.preventDefault(),n(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}jNe.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=Xet,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 GLe(t){return!!(t&&"distance"in t)}function KLe(t){return!!(t&&"delay"in t)}class kNe{constructor(s,r,n){var a;n===void 0&&(n=rVt(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=HA(l),this.documentListeners=new VL(this.document),this.listeners=new VL(n),this.windowListeners=new VL(Sp(l)),this.initialCoordinates=(a=K1e(o))!=null?a:ry,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(sg.Resize,this.handleCancel),this.windowListeners.add(sg.DragStart,WLe),this.windowListeners.add(sg.VisibilityChange,this.handleCancel),this.windowListeners.add(sg.ContextMenu,WLe),this.documentListeners.add(sg.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(KLe(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(GLe(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(sg.Click,nVt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(sg.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=K1e(s))!=null?r:ry,u=tD(a,c);if(!n&&i){if(GLe(i)){if(i.tolerance!=null&&Nxe(u,i.tolerance))return this.handleCancel();if(Nxe(u,i.distance))return this.handleStart()}if(KLe(i)&&Nxe(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===No.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const iVt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Fue extends kNe{constructor(s){const{event:r}=s,n=HA(r.target);super(s,iVt,n)}}Fue.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 oVt={move:{name:"mousemove"},end:{name:"mouseup"}};var X1e;(function(t){t[t.RightClick=2]="RightClick"})(X1e||(X1e={}));class lVt extends kNe{constructor(s){super(s,oVt,HA(s.event.target))}}lVt.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===X1e.RightClick?!1:(n==null||n({event:r}),!0)}}];const Sxe={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class cVt extends kNe{constructor(s){super(s,Sxe)}static setup(){return window.addEventListener(Sxe.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Sxe.move.name,s)};function s(){}}}cVt.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 HL;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(HL||(HL={}));var Dle;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Dle||(Dle={}));function dVt(t){let{acceleration:s,activator:r=HL.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=Dle.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:p,delta:f,threshold:y}=t;const _=hVt({delta:f,disabled:!o}),[b,w]=kUt(),j=C.useRef({x:0,y:0}),N=C.useRef({x:0,y:0}),S=C.useMemo(()=>{switch(r){case HL.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case HL.DraggableRect:return a}},[r,a,c]),T=C.useRef(null),I=C.useCallback(()=>{const R=T.current;if(!R)return;const $=j.current.x*N.current.x,q=j.current.y*N.current.y;R.scrollBy($,q)},[]),L=C.useMemo(()=>i===Dle.TreeOrder?[...u].reverse():u,[i,u]);C.useEffect(()=>{if(!o||!u.length||!S){w();return}for(const R of L){if((n==null?void 0:n(R))===!1)continue;const $=u.indexOf(R),q=p[$];if(!q)continue;const{direction:U,speed:V}=XUt(R,q,S,s,y);for(const X of["x","y"])_[X][U[X]]||(V[X]=0,U[X]=0);if(V.x>0||V.y>0){w(),T.current=R,b(I,l),j.current=V,N.current=U;return}}j.current={x:0,y:0},N.current={x:0,y:0},w()},[s,I,n,w,o,l,JSON.stringify(S),JSON.stringify(_),b,u,L,p,JSON.stringify(y)])}const uVt={x:{[zu.Backward]:!1,[zu.Forward]:!1},y:{[zu.Backward]:!1,[zu.Forward]:!1}};function hVt(t){let{delta:s,disabled:r}=t;const n=G1e(s);return LO(a=>{if(r||!n||!a)return uVt;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[zu.Backward]:a.x[zu.Backward]||o.x===-1,[zu.Forward]:a.x[zu.Forward]||o.x===1},y:{[zu.Backward]:a.y[zu.Backward]||o.y===-1,[zu.Forward]:a.y[zu.Forward]||o.y===1}}},[r,s,n])}function mVt(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return LO(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function pVt(t,s){return C.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 sD;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(sD||(sD={}));var Q1e;(function(t){t.Optimized="optimized"})(Q1e||(Q1e={}));const ZLe=new Map;function fVt(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=C.useState(null),{frequency:i,measure:c,strategy:u}=a,p=C.useRef(t),f=j(),y=eD(f),_=C.useCallback(function(N){N===void 0&&(N=[]),!y.current&&l(S=>S===null?N:S.concat(N.filter(T=>!S.includes(T))))},[y]),b=C.useRef(null),w=LO(N=>{if(f&&!r)return ZLe;if(!N||N===ZLe||p.current!==t||o!=null){const S=new Map;for(let T of t){if(!T)continue;if(o&&o.length>0&&!o.includes(T.id)&&T.rect.current){S.set(T.id,T.rect.current);continue}const I=T.node.current,L=I?new wNe(c(I),I):null;T.rect.current=L,L&&S.set(T.id,L)}return S}return N},[t,o,r,f,c]);return C.useEffect(()=>{p.current=t},[t]),C.useEffect(()=>{f||_()},[r,f]),C.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),C.useEffect(()=>{f||typeof i!="number"||b.current!==null||(b.current=setTimeout(()=>{_(),b.current=null},i))},[i,f,_,...n]),{droppableRects:w,measureDroppableContainers:_,measuringScheduled:o!=null};function j(){switch(u){case sD.Always:return!1;case sD.BeforeDragging:return r;default:return!r}}}function Qet(t,s){return LO(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function gVt(t,s){return Qet(t,s)}function xVt(t){let{callback:s,disabled:r}=t;const n=_Ne(s),a=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return C.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function zue(t){let{callback:s,disabled:r}=t;const n=_Ne(s),a=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return C.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function yVt(t){return new wNe(WA(t),t)}function YLe(t,s,r){s===void 0&&(s=yVt);const[n,a]=C.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=xVt({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=zue({callback:o});return j0(()=>{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 vVt(t){const s=Qet(t);return Vet(t,s)}const XLe=[];function _Vt(t){const s=C.useRef(t),r=LO(n=>t?n&&n!==XLe&&t&&s.current&&t.parentNode===s.current.parentNode?n:Rue(t):XLe,[t]);return C.useEffect(()=>{s.current=t},[t]),r}function bVt(t){const[s,r]=C.useState(null),n=C.useRef(t),a=C.useCallback(o=>{const l=kxe(o.target);l&&r(i=>i?(i.set(l,Y1e(l)),new Map(i)):null)},[]);return C.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(c=>{const u=kxe(c);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,Y1e(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=kxe(c);u==null||u.removeEventListener("scroll",a)})}},[a,t]),C.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>RM(o,l),ry):Yet(t):ry,[t,s])}function QLe(t,s){s===void 0&&(s=[]);const r=C.useRef(null);return C.useEffect(()=>{r.current=null},s),C.useEffect(()=>{const n=t!==ry;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?tD(t,r.current):ry}function wVt(t){C.useEffect(()=>{if(!Oue)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 jVt(t,s){return C.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:o}=n;return r[a]=l=>{o(l,s)},r},{}),[t,s])}function Jet(t){return C.useMemo(()=>t?GUt(t):null,[t])}const JLe=[];function kVt(t,s){s===void 0&&(s=WA);const[r]=t,n=Jet(r?Sp(r):null),[a,o]=C.useState(JLe);function l(){o(()=>t.length?t.map(c=>Ket(c)?n:new wNe(s(c),c)):JLe)}const i=zue({callback:l});return j0(()=>{i==null||i.disconnect(),l(),t.forEach(c=>i==null?void 0:i.observe(c))},[t]),a}function NVt(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return IO(s)?s:t}function SVt(t){let{measure:s}=t;const[r,n]=C.useState(null),a=C.useCallback(u=>{for(const{target:p}of u)if(IO(p)){n(f=>{const y=s(p);return f?{...f,width:y.width,height:y.height}:y});break}},[s]),o=zue({callback:a}),l=C.useCallback(u=>{const p=NVt(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),n(p?s(p):null)},[s,o]),[i,c]=Ile(l);return C.useMemo(()=>({nodeRef:i,rect:r,setRef:c}),[r,i,c])}const CVt=[{sensor:Fue,options:{}},{sensor:jNe,options:{}}],MVt={current:{}},kie={draggable:{measure:HLe},droppable:{measure:HLe,strategy:sD.WhileDragging,frequency:Q1e.Optimized},dragOverlay:{measure:WA}};class WL 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 TVt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new WL,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Lle},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:kie,measureDroppableContainers:Lle,windowRect:null,measuringScheduled:!1},AVt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Lle,draggableNodes:new Map,over:null,measureDroppableContainers:Lle},Bue=C.createContext(AVt),ett=C.createContext(TVt);function EVt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new WL}}}function PVt(t,s){switch(s.type){case cu.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case cu.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 cu.DragEnd:case cu.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case cu.RegisterDroppable:{const{element:r}=s,{id:n}=r,a=new WL(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case cu.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 WL(t.droppable.containers);return l.set(r,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case cu.UnregisterDroppable:{const{id:r,key:n}=s,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const o=new WL(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function IVt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=C.useContext(Bue),o=G1e(n),l=G1e(r==null?void 0:r.id);return C.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!bNe(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=CUt(p);if(f){f.focus();break}}})}},[n,s,a,l,o]),null}function LVt(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function DVt(t){return C.useMemo(()=>({draggable:{...kie.draggable,...t==null?void 0:t.draggable},droppable:{...kie.droppable,...t==null?void 0:t.droppable},dragOverlay:{...kie.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 OVt(t){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=t;const o=C.useRef(!1),{x:l,y:i}=typeof a=="boolean"?{x:a,y:a}:a;j0(()=>{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=Vet(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 y=Het(u);y&&y.scrollBy({top:f.y,left:f.x})}},[s,l,i,n,r])}const ttt=C.createContext({...ry,scaleX:1,scaleY:1});var U_;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(U_||(U_={}));const stt=C.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:c=!0,children:u,sensors:p=CVt,collisionDetection:f=BUt,measuring:y,modifiers:_,...b}=s;const w=C.useReducer(PVt,void 0,EVt),[j,N]=w,[S,T]=IUt(),[I,L]=C.useState(U_.Uninitialized),R=I===U_.Initialized,{draggable:{active:$,nodes:q,translate:U},droppable:{containers:V}}=j,X=$!=null?q.get($):null,se=C.useRef({initial:null,translated:null}),ee=C.useMemo(()=>{var qa;return $!=null?{id:$,data:(qa=X==null?void 0:X.data)!=null?qa:MVt,rect:se}:null},[$,X]),Q=C.useRef(null),[de,re]=C.useState(null),[ne,le]=C.useState(null),he=eD(b,Object.values(b)),we=DO("DndDescribedBy",l),ye=C.useMemo(()=>V.getEnabled(),[V]),je=DVt(y),{droppableRects:ke,measureDroppableContainers:We,measuringScheduled:be}=fVt(ye,{dragging:R,dependencies:[U.x,U.y],config:je.droppable}),Me=mVt(q,$),Ae=C.useMemo(()=>ne?K1e(ne):null,[ne]),Re=pa(),Te=gVt(Me,je.draggable.measure);OVt({activeNode:$!=null?q.get($):null,config:Re.layoutShiftCompensation,initialRect:Te,measure:je.draggable.measure});const qe=YLe(Me,je.draggable.measure,Te),ct=YLe(Me?Me.parentElement:null),De=C.useRef({activatorEvent:null,active:null,activeNode:Me,collisionRect:null,collisions:null,droppableRects:ke,draggableNodes:q,draggingNode:null,draggingNodeRect:null,droppableContainers:V,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Rt=V.getNodeFor((r=De.current.over)==null?void 0:r.id),pe=SVt({measure:je.dragOverlay.measure}),Je=(n=pe.nodeRef.current)!=null?n:Me,lt=R?(a=pe.rect)!=null?a:qe:null,rt=!!(pe.nodeRef.current&&pe.rect),Se=vVt(rt?null:qe),it=Jet(Je?Sp(Je):null),$e=_Vt(R?Rt??Me:null),ot=kVt($e),Ue=LVt(_,{transform:{x:U.x-Se.x,y:U.y-Se.y,scaleX:1,scaleY:1},activatorEvent:ne,active:ee,activeNodeRect:qe,containerNodeRect:ct,draggingNodeRect:lt,over:De.current.over,overlayNodeRect:pe.rect,scrollableAncestors:$e,scrollableAncestorRects:ot,windowRect:it}),Ke=Ae?RM(Ae,U):null,Xe=bVt($e),He=QLe(Xe),Ye=QLe(Xe,[qe]),tt=RM(Ue,He),Et=lt?UUt(lt,Ue):null,qt=ee&&Et?f({active:ee,collisionRect:Et,droppableRects:ke,droppableContainers:ye,pointerCoordinates:Ke}):null,ms=qet(qt,"id"),[Xt,rs]=C.useState(null),ps=rt?Ue:RM(Ue,Ye),Ms=$Ut(ps,(o=Xt==null?void 0:Xt.rect)!=null?o:null,qe),jt=C.useRef(null),As=C.useCallback((qa,Kr)=>{let{sensor:Yn,options:mn}=Kr;if(Q.current==null)return;const Gn=q.get(Q.current);if(!Gn)return;const Zt=qa.nativeEvent,$r=new Yn({active:Q.current,activeNode:Gn,event:Zt,options:mn,context:De,onAbort(an){if(!q.get(an))return;const{onDragAbort:Xn}=he.current,Ir={id:an};Xn==null||Xn(Ir),S({type:"onDragAbort",event:Ir})},onPending(an,Ha,Xn,Ir){if(!q.get(an))return;const{onDragPending:rl}=he.current,Ni={id:an,constraint:Ha,initialCoordinates:Xn,offset:Ir};rl==null||rl(Ni),S({type:"onDragPending",event:Ni})},onStart(an){const Ha=Q.current;if(Ha==null)return;const Xn=q.get(Ha);if(!Xn)return;const{onDragStart:Ir}=he.current,_i={activatorEvent:Zt,active:{id:Ha,data:Xn.data,rect:se}};cp.unstable_batchedUpdates(()=>{Ir==null||Ir(_i),L(U_.Initializing),N({type:cu.DragStart,initialCoordinates:an,active:Ha}),S({type:"onDragStart",event:_i}),re(jt.current),le(Zt)})},onMove(an){N({type:cu.DragMove,coordinates:an})},onEnd:es(cu.DragEnd),onCancel:es(cu.DragCancel)});jt.current=$r;function es(an){return async function(){const{active:Xn,collisions:Ir,over:_i,scrollAdjustedTranslate:rl}=De.current;let Ni=null;if(Xn&&rl){const{cancelDrop:sc}=he.current;Ni={activatorEvent:Zt,active:Xn,collisions:Ir,delta:rl,over:_i},an===cu.DragEnd&&typeof sc=="function"&&await Promise.resolve(sc(Ni))&&(an=cu.DragCancel)}Q.current=null,cp.unstable_batchedUpdates(()=>{N({type:an}),L(U_.Uninitialized),rs(null),re(null),le(null),jt.current=null;const sc=an===cu.DragEnd?"onDragEnd":"onDragCancel";if(Ni){const Vt=he.current[sc];Vt==null||Vt(Ni),S({type:sc,event:Ni})}})}}},[q]),Ps=C.useCallback((qa,Kr)=>(Yn,mn)=>{const Gn=Yn.nativeEvent,Zt=q.get(mn);if(Q.current!==null||!Zt||Gn.dndKit||Gn.defaultPrevented)return;const $r={active:Zt};qa(Yn,Kr.options,$r)===!0&&(Gn.dndKit={capturedBy:Kr.sensor},Q.current=mn,As(Yn,Kr))},[q,As]),ar=pVt(p,Ps);wVt(p),j0(()=>{qe&&I===U_.Initializing&&L(U_.Initialized)},[qe,I]),C.useEffect(()=>{const{onDragMove:qa}=he.current,{active:Kr,activatorEvent:Yn,collisions:mn,over:Gn}=De.current;if(!Kr||!Yn)return;const Zt={active:Kr,activatorEvent:Yn,collisions:mn,delta:{x:tt.x,y:tt.y},over:Gn};cp.unstable_batchedUpdates(()=>{qa==null||qa(Zt),S({type:"onDragMove",event:Zt})})},[tt.x,tt.y]),C.useEffect(()=>{const{active:qa,activatorEvent:Kr,collisions:Yn,droppableContainers:mn,scrollAdjustedTranslate:Gn}=De.current;if(!qa||Q.current==null||!Kr||!Gn)return;const{onDragOver:Zt}=he.current,$r=mn.get(ms),es=$r&&$r.rect.current?{id:$r.id,rect:$r.rect.current,data:$r.data,disabled:$r.disabled}:null,an={active:qa,activatorEvent:Kr,collisions:Yn,delta:{x:Gn.x,y:Gn.y},over:es};cp.unstable_batchedUpdates(()=>{rs(es),Zt==null||Zt(an),S({type:"onDragOver",event:an})})},[ms]),j0(()=>{De.current={activatorEvent:ne,active:ee,activeNode:Me,collisionRect:Et,collisions:qt,droppableRects:ke,draggableNodes:q,draggingNode:Je,draggingNodeRect:lt,droppableContainers:V,over:Xt,scrollableAncestors:$e,scrollAdjustedTranslate:tt},se.current={initial:lt,translated:Et}},[ee,Me,qt,Et,q,Je,lt,ke,V,Xt,$e,tt]),dVt({...Re,delta:U,draggingRect:Et,pointerCoordinates:Ke,scrollableAncestors:$e,scrollableAncestorRects:ot});const Dn=C.useMemo(()=>({active:ee,activeNode:Me,activeNodeRect:qe,activatorEvent:ne,collisions:qt,containerNodeRect:ct,dragOverlay:pe,draggableNodes:q,droppableContainers:V,droppableRects:ke,over:Xt,measureDroppableContainers:We,scrollableAncestors:$e,scrollableAncestorRects:ot,measuringConfiguration:je,measuringScheduled:be,windowRect:it}),[ee,Me,qe,ne,qt,ct,pe,q,V,ke,Xt,We,$e,ot,je,be,it]),Va=C.useMemo(()=>({activatorEvent:ne,activators:ar,active:ee,activeNodeRect:qe,ariaDescribedById:{draggable:we},dispatch:N,draggableNodes:q,over:Xt,measureDroppableContainers:We}),[ne,ar,ee,qe,N,we,q,Xt,We]);return ht.createElement(Fet.Provider,{value:T},ht.createElement(Bue.Provider,{value:Va},ht.createElement(ett.Provider,{value:Dn},ht.createElement(ttt.Provider,{value:Ms},u)),ht.createElement(IVt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),ht.createElement(OUt,{...i,hiddenTextDescribedById:we}));function pa(){const qa=(de==null?void 0:de.autoScrollEnabled)===!1,Kr=typeof c=="object"?c.enabled===!1:c===!1,Yn=R&&!qa&&!Kr;return typeof c=="object"?{...c,enabled:Yn}:{enabled:Yn}}}),RVt=C.createContext(null),e8e="button",FVt="Draggable";function zVt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=DO(FVt),{activators:l,activatorEvent:i,active:c,activeNodeRect:u,ariaDescribedById:p,draggableNodes:f,over:y}=C.useContext(Bue),{role:_=e8e,roleDescription:b="draggable",tabIndex:w=0}=a??{},j=(c==null?void 0:c.id)===s,N=C.useContext(j?ttt:RVt),[S,T]=Ile(),[I,L]=Ile(),R=jVt(l,s),$=eD(r);j0(()=>(f.set(s,{id:s,key:o,node:S,activatorNode:I,data:$}),()=>{const U=f.get(s);U&&U.key===o&&f.delete(s)}),[f,s]);const q=C.useMemo(()=>({role:_,tabIndex:w,"aria-disabled":n,"aria-pressed":j&&_===e8e?!0:void 0,"aria-roledescription":b,"aria-describedby":p.draggable}),[n,_,w,j,b,p.draggable]);return{active:c,activatorEvent:i,activeNodeRect:u,attributes:q,isDragging:j,listeners:n?void 0:R,node:S,over:y,setNodeRef:T,setActivatorNodeRef:L,transform:N}}function BVt(){return C.useContext(ett)}const $Vt="Droppable",qVt={timeout:25};function UVt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=DO($Vt),{active:l,dispatch:i,over:c,measureDroppableContainers:u}=C.useContext(Bue),p=C.useRef({disabled:r}),f=C.useRef(!1),y=C.useRef(null),_=C.useRef(null),{disabled:b,updateMeasurementsFor:w,timeout:j}={...qVt,...a},N=eD(w??n),S=C.useCallback(()=>{if(!f.current){f.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{u(Array.isArray(N.current)?N.current:[N.current]),_.current=null},j)},[j]),T=zue({callback:S,disabled:b||!l}),I=C.useCallback((q,U)=>{T&&(U&&(T.unobserve(U),f.current=!1),q&&T.observe(q))},[T]),[L,R]=Ile(I),$=eD(s);return C.useEffect(()=>{!T||!L.current||(T.disconnect(),f.current=!1,T.observe(L.current))},[L,T]),C.useEffect(()=>(i({type:cu.RegisterDroppable,element:{id:n,key:o,disabled:r,node:L,rect:y,data:$}}),()=>i({type:cu.UnregisterDroppable,key:o,id:n})),[n]),C.useEffect(()=>{r!==p.current.disabled&&(i({type:cu.SetDroppableDisabled,id:n,key:o,disabled:r}),p.current.disabled=r)},[n,o,r,i]),{active:l,rect:y,isOver:(c==null?void 0:c.id)===n,node:L,over:c,setNodeRef:R}}function NNe(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function VVt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function az(t){return t!==null&&t>=0}function HVt(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=GVt(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-c,y:0,...iz}:l=o?{x:i.width+c,y:0,...iz}:{x:0,y:0,...iz}};function GVt(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=NNe(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}},rtt="Sortable",ntt=ht.createContext({activeIndex:-1,containerId:rtt,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:$ue,disabled:{draggable:!1,droppable:!1}});function att(t){let{children:s,id:r,items:n,strategy:a=$ue,disabled:o=!1}=t;const{active:l,dragOverlay:i,droppableRects:c,over:u,measureDroppableContainers:p}=BVt(),f=DO(rtt,r),y=i.rect!==null,_=C.useMemo(()=>n.map(R=>typeof R=="object"&&"id"in R?R.id:R),[n]),b=l!=null,w=l?_.indexOf(l.id):-1,j=u?_.indexOf(u.id):-1,N=C.useRef(_),S=!HVt(_,N.current),T=j!==-1&&w===-1||S,I=WVt(o);j0(()=>{S&&b&&p(_)},[S,_,b,p]),C.useEffect(()=>{N.current=_},[_]);const L=C.useMemo(()=>({activeIndex:w,containerId:f,disabled:I,disableTransforms:T,items:_,overIndex:j,useDragOverlay:y,sortedRects:VVt(_,c),strategy:a}),[w,f,I.draggable,I.droppable,T,_,j,c,y,a]);return ht.createElement(ntt.Provider,{value:L},s)}const KVt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return NNe(r,n,a).indexOf(s)},ZVt=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},YVt={duration:200,easing:"ease"},itt="transform",XVt=ET.Transition.toString({property:itt,duration:0,easing:"linear"}),QVt={roleDescription:"sortable"};function JVt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=C.useState(null),i=C.useRef(r);return j0(()=>{if(!s&&r!==i.current&&n.current){const c=a.current;if(c){const u=WA(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]),C.useEffect(()=>{o&&l(null)},[o]),o}function ott(t){let{animateLayoutChanges:s=ZVt,attributes:r,disabled:n,data:a,getNewIndex:o=KVt,id:l,strategy:i,resizeObserverConfig:c,transition:u=YVt}=t;const{items:p,containerId:f,activeIndex:y,disabled:_,disableTransforms:b,sortedRects:w,overIndex:j,useDragOverlay:N,strategy:S}=C.useContext(ntt),T=eHt(n,_),I=p.indexOf(l),L=C.useMemo(()=>({sortable:{containerId:f,index:I,items:p},...a}),[f,a,I,p]),R=C.useMemo(()=>p.slice(p.indexOf(l)),[p,l]),{rect:$,node:q,isOver:U,setNodeRef:V}=UVt({id:l,data:L,disabled:T.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...c}}),{active:X,activatorEvent:se,activeNodeRect:ee,attributes:Q,setNodeRef:de,listeners:re,isDragging:ne,over:le,setActivatorNodeRef:he,transform:we}=zVt({id:l,data:L,attributes:{...QVt,...r},disabled:T.draggable}),ye=jUt(V,de),je=!!X,ke=je&&!b&&az(y)&&az(j),We=!N&&ne,be=We&&ke?we:null,Ae=ke?be??(i??S)({rects:w,activeNodeRect:ee,activeIndex:y,overIndex:j,index:I}):null,Re=az(y)&&az(j)?o({id:l,items:p,activeIndex:y,overIndex:j}):I,Te=X==null?void 0:X.id,qe=C.useRef({activeId:Te,items:p,newIndex:Re,containerId:f}),ct=p!==qe.current.items,De=s({active:X,containerId:f,isDragging:ne,isSorting:je,id:l,index:I,items:p,newIndex:qe.current.newIndex,previousItems:qe.current.items,previousContainerId:qe.current.containerId,transition:u,wasDragging:qe.current.activeId!=null}),Rt=JVt({disabled:!De,index:I,node:q,rect:$});return C.useEffect(()=>{je&&qe.current.newIndex!==Re&&(qe.current.newIndex=Re),f!==qe.current.containerId&&(qe.current.containerId=f),p!==qe.current.items&&(qe.current.items=p)},[je,Re,f,p]),C.useEffect(()=>{if(Te===qe.current.activeId)return;if(Te!=null&&qe.current.activeId==null){qe.current.activeId=Te;return}const Je=setTimeout(()=>{qe.current.activeId=Te},50);return()=>clearTimeout(Je)},[Te]),{active:X,activeIndex:y,attributes:Q,data:L,rect:$,index:I,newIndex:Re,items:p,isOver:U,isSorting:je,isDragging:ne,listeners:re,node:q,overIndex:j,over:le,setNodeRef:ye,setActivatorNodeRef:he,setDroppableNodeRef:V,setDraggableNodeRef:de,transform:Rt??Ae,transition:pe()};function pe(){if(Rt||ct&&qe.current.newIndex===I)return XVt;if(!(We&&!bNe(se)||!u)&&(je||De))return ET.Transition.toString({...u,property:itt})}}function eHt(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 Ole(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 tHt=[No.Down,No.Right,No.Up,No.Left],sHt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(tHt.includes(t.code)){if(t.preventDefault(),!r||!n)return;const c=[];o.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const y=a.get(f.id);if(y)switch(t.code){case No.Down:n.topy.top&&c.push(f);break;case No.Left:n.left>y.left&&c.push(f);break;case No.Right:n.left1&&(p=u[1].id),p!=null){const f=o.get(r.id),y=o.get(p),_=y?a.get(y.id):null,b=y==null?void 0:y.node.current;if(b&&_&&f&&y){const j=Rue(b).some((R,$)=>i[$]!==R),N=ltt(f,y),S=rHt(f,y),T=j||!N?{x:0,y:0}:{x:S?n.width-_.width:0,y:S?n.height-_.height:0},I={x:_.left,y:_.top};return T.x&&T.y?I:tD(I,T)}}}};function ltt(t,s){return!Ole(t)||!Ole(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function rHt(t,s){return!Ole(t)||!Ole(s)||!ltt(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx($a,{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(jr,{className:"h-3.5 w-3.5"})})]}),t.post_date&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(nt,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[e.jsx(on,{className:"h-2.5 w-2.5"}),ys(new Date(t.post_date+"T00:00:00"),"MMM d")]})})]}),e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:t.caption}),e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:At("w-full h-7 text-[11px] gap-1 justify-start font-normal",!t.post_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"h-3 w-3"}),t.post_date?ys(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(Eo,{className:"w-auto p-0",align:"start",children:[e.jsx(mf,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:f=>n(t.id,f?ys(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 aHt=()=>{const t=ss(),[s,r]=C.useState("all"),[n,a]=C.useState(!1),[o,l]=C.useState(ys(new Date,"yyyy-MM")),[i,c]=C.useState([]),[u,p]=C.useState(!1),[f,y]=C.useState(null),[_,b]=C.useState(null),[w,j]=C.useState(""),[N,S]=C.useState(null),[T,I]=C.useState(!1),[L,R]=C.useState(!1),[$,q]=C.useState(ys(new Date,"yyyy-MM")),[U,V]=C.useState(null),[X,se]=C.useState(""),[ee,Q]=C.useState(""),[de,re]=C.useState(""),[ne,le]=C.useState(!1),he=zet(Z1e(Fue,{activationConstraint:{distance:5}}),Z1e(jNe,{coordinateGetter:sHt})),{data:we=[],isLoading:ye}=wt({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:Ke,error:Xe}=await G.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(Xe)throw Xe;return Ke}}),{data:je=[]}=wt({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:Ke,error:Xe}=await G.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(Xe)throw Xe;return Ke}}),{data:ke=[]}=wt({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:Ke,error:Xe}=await G.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(Xe)throw Xe;return Ke}}),We=[...new Set(we.map(Ke=>Ke.month))].sort((Ke,Xe)=>Xe.localeCompare(Ke)),be=s==="all"?we:we.filter(Ke=>Ke.month===s),Me=Ke=>{const Xe=oje(Ke,"yyyy-MM",new Date);return ys(Xe,"MMMM yyyy")},Ae=Ke=>{b(Ke),j(Ke.caption),S(Ke.post_date)},Re=async()=>{if(_){I(!0);try{const{error:Ke}=await G.from("social_swag_2").update({caption:w,post_date:N}).eq("id",_.id);if(Ke)throw Ke;me.success("Image updated"),b(null),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})}catch{me.error("Failed to update image")}finally{I(!1)}}},Te=async Ke=>{const{active:Xe,over:He}=Ke;if(!He||Xe.id===He.id)return;const Ye=be,tt=Ye.findIndex(ms=>ms.id===Xe.id),Et=Ye.findIndex(ms=>ms.id===He.id);if(tt===-1||Et===-1)return;const qt=NNe(Ye,tt,Et);t.setQueryData(["admin-social-swag-2"],ms=>{if(!ms)return ms;const Xt={};return qt.forEach((rs,ps)=>{Xt[rs.id]=ps}),ms.map(rs=>Xt[rs.id]!==void 0?{...rs,sort_order:Xt[rs.id]}:rs).sort((rs,ps)=>rs.month!==ps.month?ps.month.localeCompare(rs.month):rs.sort_order-ps.sort_order)});try{await Promise.all(qt.map((ms,Xt)=>G.from("social_swag_2").update({sort_order:Xt}).eq("id",ms.id)))}catch{me.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},qe=Ke=>{const He=Array.from(Ke.target.files||[]).sort((Ye,tt)=>Ye.name.localeCompare(tt.name,void 0,{numeric:!0,sensitivity:"base"})).slice(0,16-i.length).map(Ye=>({file:Ye,preview:URL.createObjectURL(Ye),caption:""}));c(Ye=>[...Ye,...He].slice(0,16))},ct=Ke=>{c(Xe=>{const He=[...Xe];return URL.revokeObjectURL(He[Ke].preview),He.splice(Ke,1),He})},De=(Ke,Xe)=>{c(He=>{const Ye=[...He];return Ye[Ke]={...Ye[Ke],caption:Xe},Ye})},Rt=async()=>{var Xe;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 G.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),Ye=(((Xe=He==null?void 0:He[0])==null?void 0:Xe.sort_order)??-1)+1;for(let tt=0;tt{const Xe=Ke.image_url.split("/social-swag-2/");Xe[1]&&await G.storage.from("social-swag-2").remove([Xe[1]]);const{error:He}=await G.from("social_swag_2").delete().eq("id",Ke.id);if(He)throw He},onSuccess:()=>{me.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>me.error("Failed to delete image")}),Je=Dt({mutationFn:async({id:Ke,postDate:Xe})=>{const{error:He}=await G.from("social_swag_2").update({post_date:Xe}).eq("id",Ke);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")}),lt=Dt({mutationFn:async({month:Ke,link:Xe})=>{const{error:He}=await G.from("social_swag_2_months").upsert({month:Ke,canva_link:Xe||null},{onConflict:"month"});if(He)throw He},onSuccess:()=>{me.success("Canva link updated"),y(null),t.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>me.error("Failed to update Canva link")}),rt=Ke=>{var Xe;return((Xe=je.find(He=>He.month===Ke))==null?void 0:Xe.canva_link)||""},Se=Ke=>ke.find(Xe=>Xe.month===Ke)||null,it=Ke=>{var He;const Xe=(He=Ke.target.files)==null?void 0:He[0];Xe&&(V(Xe),se(URL.createObjectURL(Xe)))},$e=()=>{X&&URL.revokeObjectURL(X),V(null),se(""),Q(""),re("")},ot=async()=>{if(!U){me.error("Please select an image");return}le(!0);try{const Ke=U.name.split(".").pop(),Xe=`reels/${$}-${Date.now()}.${Ke}`,{error:He}=await G.storage.from("social-swag-2").upload(Xe,U);if(He)throw He;const{data:{publicUrl:Ye}}=G.storage.from("social-swag-2").getPublicUrl(Xe),{error:tt}=await G.from("social_swag_2_reels").upsert({month:$,image_url:Ye,canva_link:de||null,caption:ee||null},{onConflict:"month"});if(tt)throw tt;me.success("Reel uploaded successfully!"),W1e(`${Me($)} Reel`,"social-swag-2"),$e(),R(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(Ke){console.error("Reel upload error:",Ke),me.error("Failed to upload reel")}finally{le(!1)}},Ue=Dt({mutationFn:async Ke=>{const Xe=Ke.image_url.split("/social-swag-2/");Xe[1]&&await G.storage.from("social-swag-2").remove([Xe[1]]);const{error:He}=await G.from("social_swag_2_reels").delete().eq("id",Ke.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(Es,{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(_s,{open:n,onOpenChange:a,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Upload Images"]})}),e.jsxs(vs,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Upload Social Swag Images"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Month"}),e.jsx(Fe,{type:"month",value:o,onChange:Ke=>l(Ke.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{children:["Images (",i.length,"/16)"]}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",multiple:!0,onChange:qe,className:"hidden",id:"swag-upload",disabled:i.length>=16}),e.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[e.jsx(ni,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select images (max 16)"})]})]})]}),i.length>0&&e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:i.map((Ke,Xe)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative aspect-[4/5] rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:Ke.preview,alt:`Upload ${Xe+1}`,className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>ct(Xe),children:e.jsx(Ur,{className:"h-3 w-3"})})]}),e.jsx(Ar,{placeholder:"Caption...",value:Ke.caption,onChange:He=>De(Xe,He.target.value),className:"text-xs h-20"})]},Xe))}),e.jsx(K,{onClick:Rt,disabled:u||i.length===0,className:"w-full gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ni,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(_s,{open:L,onOpenChange:Ke=>{R(Ke),Ke||$e()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(Fu,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(vs,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Upload Monthly Reel"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Month"}),e.jsx(Fe,{type:"month",value:$,onChange:Ke=>q(Ke.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Reel Preview Image"}),X?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:X,alt:"Reel preview",className:"w-full h-full object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{URL.revokeObjectURL(X),V(null),se("")},children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:it,className:"hidden",id:"reel-upload"}),e.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[e.jsx(Fu,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select reel preview image"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Canva Download Link"}),e.jsx(Fe,{value:de,onChange:Ke=>re(Ke.target.value),placeholder:"https://www.canva.com/..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Caption"}),e.jsx(Ar,{value:ee,onChange:Ke=>Q(Ke.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(K,{onClick:ot,disabled:ne||!U,className:"w-full gap-2",children:ne?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ni,{className:"h-4 w-4"}),"Upload Reel"]})})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:we.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:We.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Aa,{value:s,onValueChange:r,children:e.jsxs(ja,{children:[e.jsx(js,{value:"all",children:"All"}),We.map(Ke=>e.jsx(js,{value:Ke,children:Me(Ke)},Ke))]})}),s!=="all"&&e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Vo,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(_e,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",Me(s)]}),(f==null?void 0:f.month)===s?e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(Fe,{value:f.link,onChange:Ke=>y({...f,link:Ke.target.value}),placeholder:"https://www.canva.com/..."}),e.jsx(K,{size:"sm",onClick:()=>lt.mutate(f),children:"Save"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>y(null),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-sm",children:rt(s)||"No link set"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>y({month:s,link:rt(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(Fu,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(_e,{className:"text-sm text-muted-foreground",children:["Reel for ",Me(s)]}),(()=>{const Ke=Se(s);return Ke?e.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[e.jsx("img",{src:Ke.image_url,alt:"Reel preview",className:"w-16 h-28 object-cover rounded"}),e.jsxs("div",{className:"flex-1 text-sm",children:[e.jsx("p",{className:"line-clamp-2",children:Ke.caption||"No caption"}),Ke.canva_link&&e.jsx("a",{href:Ke.canva_link,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-xs",children:"View Canva Link"})]}),e.jsx(K,{variant:"destructive",size:"sm",onClick:()=>Ue.mutate(Ke),children:e.jsx(jr,{className:"h-4 w-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"No reel uploaded for this month"})})()]})]})})})]}),ye?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}):be.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(cl,{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(stt,{sensors:he,collisionDetection:Uet,onDragEnd:Te,children:e.jsx(att,{items:be.map(Ke=>Ke.id),strategy:$ue,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:be.map(Ke=>e.jsx(nHt,{item:Ke,onEdit:Ae,onDelete:Xe=>pe.mutate(Xe),onDateChange:(Xe,He)=>Je.mutate({id:Xe,postDate:He})},Ke.id))})})})]}),e.jsx(_s,{open:!!_,onOpenChange:Ke=>{Ke||b(null)},children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Edit Image"})}),_&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"aspect-[4/5] max-h-48 w-full rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:_.image_url,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Caption"}),e.jsx(Ar,{value:w,onChange:Ke=>j(Ke.target.value),placeholder:"Enter caption...",className:"h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Post Date"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:At("flex-1 justify-start gap-2 font-normal",!N&&"text-muted-foreground"),children:[e.jsx(on,{className:"h-4 w-4"}),N?ys(new Date(N+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(Eo,{className:"w-auto p-0",align:"start",children:e.jsx(mf,{mode:"single",selected:N?new Date(N+"T00:00:00"):void 0,onSelect:Ke=>S(Ke?ys(Ke,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),N&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(null),children:"Cancel"}),e.jsx(K,{onClick:Re,disabled:T,className:"gap-2",children:T?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},iHt=()=>{const{toast:t}=Ra(),s=ss(),[r,n]=C.useState("categories"),[a,o]=C.useState(!1),[l,i]=C.useState(null),[c,u]=C.useState({name:"",description:"",icon:""}),[p,f]=C.useState(!1),[y,_]=C.useState(null),[b,w]=C.useState({name:"",description:"",icon:""}),[j,N]=C.useState(!1),[S,T]=C.useState(null),[I,L]=C.useState(""),{data:R=[],isLoading:$}=wt({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:Te,error:qe}=await G.from("community_categories").select("*").order("sort_order");if(qe)throw qe;return Te}}),{data:q=[],isLoading:U}=wt({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:Te,error:qe}=await G.from("community_private_groups").select("*").order("sort_order");if(qe)throw qe;return Te}}),{data:V=[]}=wt({queryKey:["admin-group-members",S==null?void 0:S.id],queryFn:async()=>{if(!S)return[];const{data:Te,error:qe}=await G.from("community_private_group_members").select("*").eq("group_id",S.id);if(qe)throw qe;return Te},enabled:!!S}),{data:X=[]}=wt({queryKey:["admin-all-profiles"],queryFn:async()=>{let qe=[],ct=0,De=!0;for(;De;){const{data:Rt,error:pe}=await G.from("profiles").select("id, name, email, brokerage_id").order("name").range(ct,ct+1e3-1);if(pe)throw pe;Rt&&Rt.length>0?(qe=[...qe,...Rt],ct+=1e3,De=Rt.length===1e3):De=!1}return qe}}),{data:se=[]}=wt({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:Te,error:qe}=await G.from("brokerages").select("*").order("name");if(qe)throw qe;return Te}}),ee=Dt({mutationFn:async Te=>{if(Te.id){const{error:qe}=await G.from("community_categories").update({name:Te.name,description:Te.description||null,icon:Te.icon||null}).eq("id",Te.id);if(qe)throw qe}else{const qe=Math.max(...R.map(De=>De.sort_order),0),{error:ct}=await G.from("community_categories").insert({name:Te.name,description:Te.description||null,icon:Te.icon||null,sort_order:qe+1});if(ct)throw ct}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),u({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:Te=>{t({title:"Error",description:Te.message,variant:"destructive"})}}),Q=Dt({mutationFn:async Te=>{const{error:qe}=await G.from("community_categories").delete().eq("id",Te);if(qe)throw qe},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),de=Dt({mutationFn:async({id:Te,direction:qe})=>{const ct=R.findIndex(De=>De.id===Te);if(qe==="up"&&ct>0){const De=R[ct-1],Rt=R[ct];await G.from("community_categories").update({sort_order:Rt.sort_order}).eq("id",De.id),await G.from("community_categories").update({sort_order:De.sort_order}).eq("id",Rt.id)}else if(qe==="down"&&cts.invalidateQueries({queryKey:["admin-community-categories"]})}),re=Dt({mutationFn:async Te=>{if(Te.id){const{error:qe}=await G.from("community_private_groups").update({name:Te.name,description:Te.description||null,icon:Te.icon||null}).eq("id",Te.id);if(qe)throw qe}else{const qe=Math.max(...q.map(De=>De.sort_order),0),{error:ct}=await G.from("community_private_groups").insert({name:Te.name,description:Te.description||null,icon:Te.icon||null,sort_order:qe+1});if(ct)throw ct}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),f(!1),_(null),w({name:"",description:"",icon:""}),t({title:y?"Private group updated!":"Private group created!"})},onError:Te=>{t({title:"Error",description:Te.message,variant:"destructive"})}}),ne=Dt({mutationFn:async Te=>{const{error:qe}=await G.from("community_private_groups").delete().eq("id",Te);if(qe)throw qe},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),le=Dt({mutationFn:async({id:Te,direction:qe})=>{const ct=q.findIndex(De=>De.id===Te);if(qe==="up"&&ct>0){const De=q[ct-1],Rt=q[ct];await G.from("community_private_groups").update({sort_order:Rt.sort_order}).eq("id",De.id),await G.from("community_private_groups").update({sort_order:De.sort_order}).eq("id",Rt.id)}else if(qe==="down"&&cts.invalidateQueries({queryKey:["admin-private-groups"]})}),he=Dt({mutationFn:async({groupId:Te,userId:qe,isMember:ct})=>{if(ct){const{error:De}=await G.from("community_private_group_members").delete().eq("group_id",Te).eq("user_id",qe);if(De)throw De}else{const{error:De}=await G.from("community_private_group_members").insert({group_id:Te,user_id:qe});if(De)throw De}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),we=Dt({mutationFn:async({groupId:Te,brokerageId:qe,isMember:ct})=>{if(ct){const{error:De}=await G.from("community_private_group_members").delete().eq("group_id",Te).eq("brokerage_id",qe);if(De)throw De}else{const{error:De}=await G.from("community_private_group_members").insert({group_id:Te,brokerage_id:qe});if(De)throw De}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",S==null?void 0:S.id]})}}),ye=Te=>{i(Te),u({name:Te.name,description:Te.description||"",icon:Te.icon||""}),o(!0)},je=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},ke=Te=>{_(Te),w({name:Te.name,description:Te.description||"",icon:Te.icon||""}),f(!0)},We=()=>{_(null),w({name:"",description:"",icon:""}),f(!0)},be=Te=>{T(Te),L(""),N(!0)},Me=Te=>V.some(qe=>qe.user_id===Te),Ae=Te=>V.some(qe=>qe.brokerage_id===Te),Re=X.filter(Te=>Te.name.toLowerCase().includes(I.toLowerCase())||Te.email.toLowerCase().includes(I.toLowerCase()));return e.jsx(Es,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(Aa,{value:r,onValueChange:n,children:[e.jsxs(ja,{children:[e.jsx(js,{value:"categories",children:"Public Categories"}),e.jsxs(js,{value:"private-groups",children:[e.jsx(vh,{className:"h-4 w-4 mr-1"}),"Private Groups"]})]}),e.jsxs($s,{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:je,children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"w-[50px]",children:"Order"}),e.jsx(bt,{className:"w-[80px]",children:"Icon"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Pn,{children:$?e.jsx(ks,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):R.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):R.map((Te,qe)=>e.jsxs(ks,{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:qe===0,onClick:()=>de.mutate({id:Te.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:qe===R.length-1,onClick:()=>de.mutate({id:Te.id,direction:"down"}),children:"↓"})]})}),e.jsx(dt,{className:"text-2xl",children:Te.icon||"📁"}),e.jsx(dt,{className:"font-medium",children:Te.name}),e.jsx(dt,{className:"text-muted-foreground",children:Te.description||"—"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ye(Te),children:e.jsx($a,{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(Te.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},Te.id))})]})})})]}),e.jsxs($s,{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(La,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(K,{onClick:We,children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"w-[50px]",children:"Order"}),e.jsx(bt,{className:"w-[80px]",children:"Icon"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{className:"w-[120px]",children:"Members"}),e.jsx(bt,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(Pn,{children:U?e.jsx(ks,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):q.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No private groups yet. Create your first one!"})}):q.map((Te,qe)=>e.jsxs(ks,{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:qe===0,onClick:()=>le.mutate({id:Te.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:qe===q.length-1,onClick:()=>le.mutate({id:Te.id,direction:"down"}),children:"↓"})]})}),e.jsx(dt,{className:"text-2xl",children:Te.icon||"🔒"}),e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Te.name,Te.brokerage_id?e.jsxs(nt,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(La,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(nt,{variant:"secondary",className:"text-xs",children:[e.jsx(vh,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(dt,{className:"text-muted-foreground",children:Te.description||"—"}),e.jsx(dt,{children:e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>be(Te),children:[e.jsx(mr,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[!Te.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ke(Te),children:e.jsx($a,{className:"h-4 w-4"})}),!Te.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.")&&ne.mutate(Te.id)},children:e.jsx(jr,{className:"h-4 w-4"})}),Te.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},Te.id))})]})})})]})]}),e.jsx(_s,{open:a,onOpenChange:o,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:l?"Edit Category":"Create Category"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Icon (emoji)"}),e.jsx(Fe,{value:c.icon,onChange:Te=>u(qe=>({...qe,icon:Te.target.value})),placeholder:"💬",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(Fe,{value:c.name,onChange:Te=>u(qe=>({...qe,name:Te.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Ar,{value:c.description,onChange:Te=>u(qe=>({...qe,description:Te.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(_s,{open:p,onOpenChange:f,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:y?"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(Fe,{value:b.icon,onChange:Te=>w(qe=>({...qe,icon:Te.target.value})),placeholder:"🔒",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Name *"}),e.jsx(Fe,{value:b.name,onChange:Te=>w(qe=>({...qe,name:Te.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(Ar,{value:b.description,onChange:Te=>w(qe=>({...qe,description:Te.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({...b,id:y==null?void 0:y.id}),disabled:!b.name.trim(),children:y?"Save Changes":"Create Private Group"})]})]})]})}),e.jsx(_s,{open:j,onOpenChange:N,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:["Manage Members: ",S==null?void 0:S.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Aa,{defaultValue:"brokerages",children:[e.jsxs(ja,{className:"w-full",children:[e.jsx(js,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(js,{value:"users",className:"flex-1",children:"Individual Users"})]}),e.jsxs($s,{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(Vi,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[se.map(Te=>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(Yo,{checked:Ae(Te.id),onCheckedChange:()=>{S&&we.mutate({groupId:S.id,brokerageId:Te.id,isMember:Ae(Te.id)})}}),e.jsx("span",{className:"font-medium",children:Te.name})]}),e.jsxs(nt,{variant:"secondary",children:[X.filter(qe=>qe.brokerage_id===Te.id).length," agents"]})]},Te.id)),se.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No brokerages found"})]})})]}),e.jsxs($s,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search users...",value:I,onChange:Te=>L(Te.target.value),className:"pl-9"})]}),e.jsx(Vi,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Re.map(Te=>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(Yo,{checked:Me(Te.id),onCheckedChange:()=>{S&&he.mutate({groupId:S.id,userId:Te.id,isMember:Me(Te.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Te.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:Te.email})]})]})},Te.id)),Re.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No users found"})]})})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{onClick:()=>N(!1),children:"Done"})})]})]})})]})})},t8e=t=>{switch(t){case"academy_video":return e.jsx(wl,{className:"h-3 w-3"});case"template":return e.jsx(In,{className:"h-3 w-3"});case"toolbox":return e.jsx(bl,{className:"h-3 w-3"});case"newsletter":return e.jsx(s1,{className:"h-3 w-3"});case"social_swag":return e.jsx(hn,{className:"h-3 w-3"});default:return e.jsx(rn,{className:"h-3 w-3"})}},oHt=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}},lHt=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}},cHt=()=>{const{toast:t}=Ra(),[s,r]=C.useState([]),[n,a]=C.useState([]),[o,l]=C.useState([]),[i,c]=C.useState(!0),[u,p]=C.useState(""),[f,y]=C.useState(null),[_,b]=C.useState([]),[w,j]=C.useState([]);C.useEffect(()=>{N()},[]);const N=async()=>{try{c(!0);const{data:V,error:X}=await G.from("activity_logs").select(` id, user_id, app_name, launched_at, profiles ( name, email, brokerages ( name ) ) `).order("launched_at",{ascending:!1}).limit(5e3);if(X)throw X;const{data:se,error:ee}=await G.from("content_engagement_logs").select(` id, user_id, resource_type, resource_id, resource_title, action_type, created_at `).order("created_at",{ascending:!1}).limit(5e3);if(ee)throw ee;const Q=[...new Set((se==null?void 0:se.map(ye=>ye.user_id))||[])],{data:de}=await G.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",Q),re=new Map((de==null?void 0:de.map(ye=>[ye.id,ye]))||[]),ne=(V==null?void 0:V.map(ye=>{var je,ke,We,be;return{id:ye.id,user_id:ye.user_id,app_name:ye.app_name,launched_at:ye.launched_at,user_name:((je=ye.profiles)==null?void 0:je.name)||"Unknown",user_email:((ke=ye.profiles)==null?void 0:ke.email)||"Unknown",brokerage_name:((be=(We=ye.profiles)==null?void 0:We.brokerages)==null?void 0:be.name)||null}}))||[],le=(se==null?void 0:se.map(ye=>{var ke;const je=re.get(ye.user_id);return{id:ye.id,user_id:ye.user_id,resource_type:ye.resource_type,resource_id:ye.resource_id,resource_title:ye.resource_title,action_type:ye.action_type,created_at:ye.created_at,user_name:(je==null?void 0:je.name)||"Unknown",user_email:(je==null?void 0:je.email)||"Unknown",brokerage_name:((ke=je==null?void 0:je.brokerages)==null?void 0:ke.name)||null}}))||[];r(ne),a(le);const he=new Map;ne.forEach(ye=>{if(!he.has(ye.user_id))he.set(ye.user_id,{user_id:ye.user_id,user_name:ye.user_name,user_email:ye.user_email,brokerage_name:ye.brokerage_name,last_activity_type:"app",last_activity_name:ye.app_name,last_activity_at:ye.launched_at,total_app_launches:1,total_content_views:0});else{const je=he.get(ye.user_id);je.total_app_launches++,new Date(ye.launched_at)>new Date(je.last_activity_at)&&(je.last_activity_type="app",je.last_activity_name=ye.app_name,je.last_activity_at=ye.launched_at)}}),le.forEach(ye=>{if(!he.has(ye.user_id))he.set(ye.user_id,{user_id:ye.user_id,user_name:ye.user_name,user_email:ye.user_email,brokerage_name:ye.brokerage_name,last_activity_type:ye.resource_type,last_activity_name:ye.resource_title,last_activity_at:ye.created_at,total_app_launches:0,total_content_views:1});else{const je=he.get(ye.user_id);je.total_content_views++,new Date(ye.created_at)>new Date(je.last_activity_at)&&(je.last_activity_type=ye.resource_type,je.last_activity_name=ye.resource_title,je.last_activity_at=ye.created_at)}});const we=Array.from(he.values()).sort((ye,je)=>new Date(je.last_activity_at).getTime()-new Date(ye.last_activity_at).getTime());l(we)}catch(V){console.error("Error loading activity:",V),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{c(!1)}},S=V=>{y({id:V.user_id,name:V.user_name,email:V.user_email});const X=s.filter(ee=>ee.user_id===V.user_id),se=n.filter(ee=>ee.user_id===V.user_id);b(X),j(se)},T=()=>{y(null),b([]),j([])},{sortKey:I,sortDirection:L,handleSort:R,sortData:$}=EO("last_activity_at","desc"),q=o.filter(V=>{var se;if(!u)return!0;const X=u.toLowerCase();return V.user_name.toLowerCase().includes(X)||V.user_email.toLowerCase().includes(X)||((se=V.brokerage_name)==null?void 0:se.toLowerCase().includes(X))}),U=$(q,{user:V=>{var X;return((X=V.user_name)==null?void 0:X.toLowerCase())||""},brokerage:V=>{var X;return((X=V.brokerage_name)==null?void 0:X.toLowerCase())||""},last_activity_at:V=>new Date(V.last_activity_at).getTime(),apps:V=>V.total_app_launches,content:V=>V.total_content_views});return i?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"User Activity"}),e.jsx(fr,{children:"App launches and content engagement - click to see full history"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name, email, or brokerage...",value:u,onChange:V=>p(V.target.value),className:"pl-9"})]})}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(dl,{sortKey:"user",currentSortKey:I,currentDirection:L,onSort:R,children:"User"}),e.jsx(dl,{sortKey:"brokerage",currentSortKey:I,currentDirection:L,onSort:R,children:"Brokerage"}),e.jsx(bt,{children:"Last Activity"}),e.jsx(dl,{sortKey:"last_activity_at",currentSortKey:I,currentDirection:L,onSort:R,children:"Last Active"}),e.jsx(dl,{sortKey:"apps",currentSortKey:I,currentDirection:L,onSort:R,className:"text-right",children:"Apps"}),e.jsx(dl,{sortKey:"content",currentSortKey:I,currentDirection:L,onSort:R,className:"text-right",children:"Content"})]})}),e.jsx(Pn,{children:U.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):U.map(V=>e.jsxs(ks,{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(nt,{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(nt,{variant:"secondary",children:[e.jsx(rn,{className:"h-3 w-3 mr-1"}),V.last_activity_name]}):e.jsxs(nt,{variant:"outline",className:"flex items-center gap-1",children:[t8e(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:Yd(new Date(V.last_activity_at),{addSuffix:!0})}),e.jsx(dt,{className:"text-right",children:e.jsx(nt,{variant:"outline",children:V.total_app_launches})}),e.jsx(dt,{className:"text-right",children:e.jsx(nt,{variant:"outline",children:V.total_content_views})})]},V.user_id))})]})})]})]}),e.jsx(_s,{open:!!f,onOpenChange:V=>!V&&T(),children:e.jsxs(vs,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{children:[f==null?void 0:f.name,"'s Activity"]}),e.jsx(Zr,{children:f==null?void 0:f.email})]}),e.jsxs(Aa,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(ja,{className:"grid w-full grid-cols-2",children:[e.jsxs(js,{value:"content",children:["Content (",w.length,")"]}),e.jsxs(js,{value:"apps",children:["App Launches (",_.length,")"]})]}),e.jsx($s,{value:"content",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Type"}),e.jsx(bt,{children:"Resource"}),e.jsx(bt,{children:"Action"}),e.jsx(bt,{children:"Time"})]})}),e.jsx(Pn,{children:w.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):w.map(V=>e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsxs(nt,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[t8e(V.resource_type),oHt(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(nt,{variant:"secondary",children:lHt(V.action_type)})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Yd(new Date(V.created_at),{addSuffix:!0})})]},V.id))})]})})}),e.jsx($s,{value:"apps",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"App"}),e.jsx(bt,{children:"Time"})]})}),e.jsx(Pn,{children:_.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):_.map(V=>e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsx(nt,{variant:"secondary",children:V.app_name})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Yd(new Date(V.launched_at),{addSuffix:!0})})]},V.id))})]})})})]})]})})]})},dHt=()=>{const{toast:t}=Ra(),[s,r]=C.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=C.useState(!0);C.useEffect(()=>{o()},[]);const o=async()=>{try{a(!0);const{count:l}=await G.from("profiles").select("*",{count:"exact",head:!0}),{count:i}=await G.from("profiles").select("*",{count:"exact",head:!0}).not("last_login","is",null),c=(l||0)-(i||0),{count:u}=await G.from("brokerages").select("*",{count:"exact",head:!0}),{count:p}=await G.from("activity_logs").select("*",{count:"exact",head:!0}),f=new Date;f.setDate(f.getDate()-7);const{count:y}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",f.toISOString()),_=new Date;_.setMonth(_.getMonth()-1);const{count:b}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",_.toISOString()),{data:w}=await G.from("activity_logs").select("user_id").gte("launched_at",f.toISOString()),j=new Set(w==null?void 0:w.map(N=>N.user_id)).size;r({totalUsers:l||0,activeUsers:i||0,pendingUsers:c,totalBrokerages:u||0,totalLaunches:p||0,launchesThisWeek:y||0,launchesThisMonth:b||0,uniqueActiveThisWeek:j})}catch(l){console.error("Error loading analytics:",l),t({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{a(!1)}};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalUsers}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.activeUsers," active, ",s.pendingUsers," pending"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(vi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.activeUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.totalUsers>0?`${Math.round(s.activeUsers/s.totalUsers*100)}% of total`:"0% of total"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(Tn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.pendingUsers}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(La,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalBrokerages}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total brokerages"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(gp,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(gp,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(gp,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(xc,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.uniqueActiveThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},s8e={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},r8e={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 ctt({brokerageOnly:t=!1,brokerageId:s}){const[r,n]=C.useState([]),[a,o]=C.useState(!0),[l,i]=C.useState(""),[c,u]=C.useState("all");C.useEffect(()=>{p()},[s]);const p=async()=>{o(!0);try{let R=[];if(t&&s){const{data:Q}=await G.from("profiles").select("id").eq("brokerage_id",s);if(R=(Q==null?void 0:Q.map(de=>de.id))||[],R.length===0){n([]),o(!1);return}}let $=G.from("resource_shares").select("*").order("created_at",{ascending:!1});t&&R.length>0&&($=$.or(`sender_id.in.(${R.join(",")}),recipient_id.in.(${R.join(",")})`));const{data:q,error:U}=await $;if(U)throw U;const V=new Set;q==null||q.forEach(Q=>{V.add(Q.sender_id),V.add(Q.recipient_id)});const{data:X}=await G.from("profiles").select("id, name, email").in("id",Array.from(V)),se=new Map((X==null?void 0:X.map(Q=>[Q.id,Q]))||[]),ee=(q==null?void 0:q.map(Q=>({...Q,sender:se.get(Q.sender_id),recipient:se.get(Q.recipient_id)})))||[];n(ee)}catch(R){console.error("Error loading shares:",R)}finally{o(!1)}},{sortKey:f,sortDirection:y,handleSort:_,sortData:b}=EO("created_at","desc"),w=r.filter(R=>{var U,V;const $=l===""||R.resource_title.toLowerCase().includes(l.toLowerCase())||((U=R.sender)==null?void 0:U.name.toLowerCase().includes(l.toLowerCase()))||((V=R.recipient)==null?void 0:V.name.toLowerCase().includes(l.toLowerCase())),q=c==="all"||R.resource_type===c;return $&&q}),j=b(w,{resource:R=>{var $;return(($=R.resource_title)==null?void 0:$.toLowerCase())||""},type:R=>R.resource_type,sender:R=>{var $,q;return((q=($=R.sender)==null?void 0:$.name)==null?void 0:q.toLowerCase())||""},recipient:R=>{var $,q;return((q=($=R.recipient)==null?void 0:$.name)==null?void 0:q.toLowerCase())||""},status:R=>R.is_read?1:0,created_at:R=>new Date(R.created_at).getTime()}),N=r.length,S=new Set(r.map(R=>R.sender_id)).size,T=new Set(r.map(R=>R.recipient_id)).size,I=r.length>0?Math.round(r.filter(R=>R.is_read).length/r.length*100):0,L=r.reduce((R,$)=>(R[$.resource_type]=(R[$.resource_type]||0)+1,R),{});return a?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((R,$)=>e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(xs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(xs,{className:"h-8 w-16"})})]},$))}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(xs,{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(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(Ad,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:N})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:S})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(xc,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:T})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(In,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[I,"%"]})})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(L).map(([R,$])=>e.jsxs(nt,{variant:"secondary",className:r8e[R],children:[s8e[R],": ",$]},R)),Object.keys(L).length===0&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Share History"}),e.jsxs(fr,{children:["All resource shares ",t?"in your brokerage":"across the platform"]})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by resource, sender, or recipient...",value:l,onChange:R=>i(R.target.value),className:"pl-9"})]}),e.jsxs(rr,{value:c,onValueChange:u,children:[e.jsx(tr,{className:"w-[180px]",children:e.jsx(nr,{placeholder:"Resource type"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Types"}),e.jsx(Tt,{value:"event",children:"Events"}),e.jsx(Tt,{value:"template",children:"Templates"}),e.jsx(Tt,{value:"academy_video",children:"Academy Videos"}),e.jsx(Tt,{value:"resource_kit",children:"Resource Kits"}),e.jsx(Tt,{value:"newsletter",children:"Newsletters"}),e.jsx(Tt,{value:"social_swag",children:"Social Swag"})]})]})]}),e.jsx(Vi,{className:"h-[400px]",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(dl,{sortKey:"resource",currentSortKey:f,currentDirection:y,onSort:_,children:"Resource"}),e.jsx(dl,{sortKey:"type",currentSortKey:f,currentDirection:y,onSort:_,children:"Type"}),e.jsx(dl,{sortKey:"sender",currentSortKey:f,currentDirection:y,onSort:_,children:"Sender"}),e.jsx(dl,{sortKey:"recipient",currentSortKey:f,currentDirection:y,onSort:_,children:"Recipient"}),e.jsx(dl,{sortKey:"status",currentSortKey:f,currentDirection:y,onSort:_,children:"Status"}),e.jsx(dl,{sortKey:"created_at",currentSortKey:f,currentDirection:y,onSort:_,children:"Date"})]})}),e.jsx(Pn,{children:j.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):j.map(R=>{var $,q;return e.jsxs(ks,{children:[e.jsx(dt,{className:"font-medium max-w-[200px] truncate",children:R.resource_title}),e.jsx(dt,{children:e.jsx(nt,{variant:"secondary",className:r8e[R.resource_type],children:s8e[R.resource_type]})}),e.jsx(dt,{children:(($=R.sender)==null?void 0:$.name)||"Unknown"}),e.jsx(dt,{children:((q=R.recipient)==null?void 0:q.name)||"Unknown"}),e.jsx(dt,{children:e.jsx(nt,{variant:R.is_read?"default":"outline",children:R.is_read?"Read":"Unread"})}),e.jsx(dt,{className:"text-muted-foreground",children:ys(new Date(R.created_at),"MMM d, yyyy")})]},R.id)})})]})})]})]})]})}const Cxe={academy_video:{label:"Academy Videos",icon:Nn,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:va},template:{label:"Templates",icon:Av,color:"bg-blue-100 text-blue-800",actionLabel:"Accessed",actionIcon:Lh},toolbox:{label:"Toolkit",icon:Kx,color:"bg-amber-100 text-amber-800",actionLabel:"Downloaded",actionIcon:ki},newsletter:{label:"Newsletters",icon:br,color:"bg-emerald-100 text-emerald-800",actionLabel:"Clicked",actionIcon:Lh},social_swag:{label:"Social Swag",icon:Ql,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:Lh},event:{label:"Events",icon:on,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:Lh}};function n8e(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function uHt(t,s){return t==="toolbox"?s.downloads:s.clicks}function hHt(){var R;const[t,s]=C.useState([]),[r,n]=C.useState(!0),[a,o]=C.useState(null),l=C.useRef(null),{sortKey:i,sortDirection:c,handleSort:u,sortData:p}=EO("total_views","desc");C.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:$,error:q}=await G.rpc("get_admin_content_engagement");if(q)throw q;s($||[])}catch($){console.error("Error loading content engagement:",$)}finally{n(!1)}},y=$=>{o(q=>{const U=q===$?null:$;return requestAnimationFrame(()=>{var V;(V=l.current)==null||V.scrollIntoView({behavior:"smooth",block:"start"})}),U})};if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-4",children:[...Array(4)].map(($,q)=>e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(xs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(xs,{className:"h-8 w-16"})})]},q))}),e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8",children:e.jsx(xs,{className:"h-64 w-full"})})})]});const _=t.reduce(($,q)=>$+q.total_views,0),b=t.reduce(($,q)=>$+q.total_clicks,0),w=t.reduce(($,q)=>$+q.total_downloads,0),j=t.length,N=t.reduce(($,q)=>($[q.resource_type]||($[q.resource_type]={views:0,clicks:0,downloads:0,assets:0,uniqueUsers:0}),$[q.resource_type].views+=q.total_views,$[q.resource_type].clicks+=q.total_clicks,$[q.resource_type].downloads+=q.total_downloads,$[q.resource_type].assets+=1,$[q.resource_type].uniqueUsers+=q.unique_users,$),{}),S=a?t.filter($=>$.resource_type===a):t,T=p(S,{asset:$=>{var q;return((q=$.resource_title)==null?void 0:q.toLowerCase())||""},type:$=>$.resource_type,views:$=>$.total_views,actions:$=>n8e($),unique_users:$=>$.unique_users,last_activity:$=>$.last_engaged_at?new Date($.last_engaged_at).getTime():0}),I=a?Cxe[a]||{label:a,icon:va,actionLabel:"Actions"}:null,L=I==null?void 0:I.icon;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-5",children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(va,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:_.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Across all content"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(Lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:b.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Link & Canva clicks"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(ki,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:w.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF downloads"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(xc,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique content items"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(Lh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[_>0?Math.round((b+w)/_*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Of views → actions"})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(fr,{children:"Click a category to see individual asset performance"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-3",children:Object.entries(N).map(([$,q])=>{const U=Cxe[$]||{label:$,icon:va,color:"bg-muted text-muted-foreground",actionIcon:Lh},V=U.icon,X=a===$;return e.jsxs("button",{type:"button",onClick:()=>y($),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors cursor-pointer ${X?"ring-2 ring-primary border-primary bg-primary/5":"hover:bg-muted/50"}`,children:[e.jsx("div",{className:`p-2 rounded-md ${U.color}`,children:e.jsx(V,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:U.label}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(va,{className:"h-3 w-3"})," ",q.views]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(U.actionIcon,{className:"h-3 w-3"})," ",uHt($,q)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mr,{className:"h-3 w-3"})," ",q.uniqueUsers]})]})]}),e.jsxs(nt,{variant:"secondary",className:"text-[10px]",children:[q.assets," items"]})]},$)})})})]}),e.jsx("div",{ref:l,children:e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{className:"text-sm font-medium flex items-center gap-2",children:I&&L?e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"h-4 w-4"}),I.label," — Top Performers"]}):"Top Content by Engagement"}),e.jsx(fr,{children:a?`${S.length} ${((R=I==null?void 0:I.label)==null?void 0:R.toLowerCase())||"items"} ranked by total interactions`:"All tracked assets ranked by total interactions"})]}),a&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>o(null),className:"gap-1",children:[e.jsx(di,{className:"h-3.5 w-3.5"}),"Show All"]})]})}),e.jsx(Oe,{children:S.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No engagement data yet. As users view and click content, stats will appear here."}):e.jsx(Vi,{className:"h-[400px]",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"w-[40px]",children:"#"}),e.jsx(dl,{sortKey:"asset",currentSortKey:i,currentDirection:c,onSort:u,children:"Asset"}),!a&&e.jsx(dl,{sortKey:"type",currentSortKey:i,currentDirection:c,onSort:u,children:"Type"}),e.jsx(dl,{sortKey:"views",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:"Views"}),e.jsx(dl,{sortKey:"actions",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:I?I.actionLabel:"Actions"}),e.jsx(dl,{sortKey:"unique_users",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:"Unique Users"}),e.jsx(dl,{sortKey:"last_activity",currentSortKey:i,currentDirection:c,onSort:u,children:"Last Activity"})]})}),e.jsx(Pn,{children:T.map(($,q)=>{const U=Cxe[$.resource_type]||{label:$.resource_type,color:"bg-muted text-muted-foreground"};return e.jsxs(ks,{children:[e.jsx(dt,{className:"text-muted-foreground text-xs",children:q+1}),e.jsx(dt,{children:e.jsx("p",{className:"font-medium text-sm truncate max-w-[250px]",children:$.resource_title})}),!a&&e.jsx(dt,{children:e.jsx(nt,{className:`text-[10px] ${U.color}`,children:U.label})}),e.jsx(dt,{className:"text-right font-medium",children:$.total_views}),e.jsx(dt,{className:"text-right font-medium",children:n8e($)}),e.jsx(dt,{className:"text-right",children:$.unique_users}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:$.last_engaged_at?Yd(new Date($.last_engaged_at),{addSuffix:!0}):"—"})]},`${$.resource_type}-${$.resource_id}`)})})]})})})]})})]})}var mHt=Array.isArray,Cp=mHt,pHt=typeof Fv=="object"&&Fv&&Fv.Object===Object&&Fv,dtt=pHt,fHt=dtt,gHt=typeof self=="object"&&self&&self.Object===Object&&self,xHt=fHt||gHt||Function("return this")(),P0=xHt,yHt=P0,vHt=yHt.Symbol,OO=vHt,a8e=OO,utt=Object.prototype,_Ht=utt.hasOwnProperty,bHt=utt.toString,L6=a8e?a8e.toStringTag:void 0;function wHt(t){var s=_Ht.call(t,L6),r=t[L6];try{t[L6]=void 0;var n=!0}catch{}var a=bHt.call(t);return n&&(s?t[L6]=r:delete t[L6]),a}var jHt=wHt,kHt=Object.prototype,NHt=kHt.toString;function SHt(t){return NHt.call(t)}var CHt=SHt,i8e=OO,MHt=jHt,THt=CHt,AHt="[object Null]",EHt="[object Undefined]",o8e=i8e?i8e.toStringTag:void 0;function PHt(t){return t==null?t===void 0?EHt:AHt:o8e&&o8e in Object(t)?MHt(t):THt(t)}var P1=PHt;function IHt(t){return t!=null&&typeof t=="object"}var I1=IHt,LHt=P1,DHt=I1,OHt="[object Symbol]";function RHt(t){return typeof t=="symbol"||DHt(t)&&LHt(t)==OHt}var GA=RHt,FHt=Cp,zHt=GA,BHt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$Ht=/^\w*$/;function qHt(t,s){if(FHt(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||zHt(t)?!0:$Ht.test(t)||!BHt.test(t)||s!=null&&t in Object(s)}var SNe=qHt;function UHt(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var E2=UHt;const KA=Co(E2);var VHt=P1,HHt=E2,WHt="[object AsyncFunction]",GHt="[object Function]",KHt="[object GeneratorFunction]",ZHt="[object Proxy]";function YHt(t){if(!HHt(t))return!1;var s=VHt(t);return s==GHt||s==KHt||s==WHt||s==ZHt}var CNe=YHt;const ji=Co(CNe);var XHt=P0,QHt=XHt["__core-js_shared__"],JHt=QHt,Mxe=JHt,l8e=function(){var t=/[^.]+$/.exec(Mxe&&Mxe.keys&&Mxe.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function eWt(t){return!!l8e&&l8e in t}var tWt=eWt,sWt=Function.prototype,rWt=sWt.toString;function nWt(t){if(t!=null){try{return rWt.call(t)}catch{}try{return t+""}catch{}}return""}var htt=nWt,aWt=CNe,iWt=tWt,oWt=E2,lWt=htt,cWt=/[\\^$.*+?()[\]{}|]/g,dWt=/^\[object .+?Constructor\]$/,uWt=Function.prototype,hWt=Object.prototype,mWt=uWt.toString,pWt=hWt.hasOwnProperty,fWt=RegExp("^"+mWt.call(pWt).replace(cWt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function gWt(t){if(!oWt(t)||iWt(t))return!1;var s=aWt(t)?fWt:dWt;return s.test(lWt(t))}var xWt=gWt;function yWt(t,s){return t==null?void 0:t[s]}var vWt=yWt,_Wt=xWt,bWt=vWt;function wWt(t,s){var r=bWt(t,s);return _Wt(r)?r:void 0}var JS=wWt,jWt=JS,kWt=jWt(Object,"create"),que=kWt,c8e=que;function NWt(){this.__data__=c8e?c8e(null):{},this.size=0}var SWt=NWt;function CWt(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var MWt=CWt,TWt=que,AWt="__lodash_hash_undefined__",EWt=Object.prototype,PWt=EWt.hasOwnProperty;function IWt(t){var s=this.__data__;if(TWt){var r=s[t];return r===AWt?void 0:r}return PWt.call(s,t)?s[t]:void 0}var LWt=IWt,DWt=que,OWt=Object.prototype,RWt=OWt.hasOwnProperty;function FWt(t){var s=this.__data__;return DWt?s[t]!==void 0:RWt.call(s,t)}var zWt=FWt,BWt=que,$Wt="__lodash_hash_undefined__";function qWt(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=BWt&&s===void 0?$Wt:s,this}var UWt=qWt,VWt=SWt,HWt=MWt,WWt=LWt,GWt=zWt,KWt=UWt;function ZA(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var uGt=dGt,hGt=Uue;function mGt(t,s){var r=this.__data__,n=hGt(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var pGt=mGt,fGt=XWt,gGt=aGt,xGt=lGt,yGt=uGt,vGt=pGt;function YA(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},y4=function(s){return ES(s)&&s.indexOf("%")===s.length-1},sn=function(s){return zKt(s)&&!RO(s)},UKt=function(s){return Ri(s)},pu=function(s){return sn(s)||ES(s)},VKt=0,QA=function(s){var r=++VKt;return"".concat(s||"").concat(r)},jm=function(s,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!sn(s)&&!ES(s))return n;var o;if(y4(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return RO(o)&&(o=n),a&&o>r&&(o=r),o},Q_=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},HKt=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 QKt(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 e_e(t){"@babel/helpers - typeof";return e_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},e_e(t)}var g8e={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"},c1=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},x8e=null,Axe=null,RNe=function t(s){if(s===x8e&&Array.isArray(Axe))return Axe;var r=[];return C.Children.forEach(s,function(n){Ri(n)||(LKt.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),Axe=r,x8e=s,r};function ff(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return c1(a)}):n=[c1(s)],RNe(t).forEach(function(a){var o=pf(a,"type.displayName")||pf(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function Zp(t,s){var r=ff(t,s);return r&&r[0]}var y8e=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!sn(n)||n<=0||!sn(a)||a<=0)},JKt=["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"],eZt=function(s){return s&&s.type&&ES(s.type)&&JKt.indexOf(s.type)>=0},tZt=function(s){return s&&e_e(s)==="object"&&"clipDot"in s},sZt=function(s,r,n,a){var o,l=(o=Txe==null?void 0:Txe[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!ji(s)&&(a&&l.includes(r)||KKt.includes(r))||n&&ONe.includes(r)},ti=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(C.isValidElement(s)&&(a=s.props),!KA(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;sZt((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},t_e=function t(s,r){if(s===r)return!0;var n=C.Children.count(s);if(n!==C.Children.count(r))return!1;if(n===0)return!0;if(n===1)return v8e(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 oZt(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 r_e(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=iZt(t,aZt),p=a||{width:r,height:n,x:0,y:0},f=Bi("recharts-surface",o);return ht.createElement("svg",s_e({},ti(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 lZt=["children","className"];function n_e(){return n_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 dZt(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 qo=ht.forwardRef(function(t,s){var r=t.children,n=t.className,a=cZt(t,lZt),o=Bi("recharts-layer",n);return ht.createElement("g",n_e({className:o},ti(a,!0),{ref:s}),r)}),Yx=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:mZt(t,s,r)}var fZt=pZt,gZt="\\ud800-\\udfff",xZt="\\u0300-\\u036f",yZt="\\ufe20-\\ufe2f",vZt="\\u20d0-\\u20ff",_Zt=xZt+yZt+vZt,bZt="\\ufe0e\\ufe0f",wZt="\\u200d",jZt=RegExp("["+wZt+gZt+_Zt+bZt+"]");function kZt(t){return jZt.test(t)}var wtt=kZt;function NZt(t){return t.split("")}var SZt=NZt,jtt="\\ud800-\\udfff",CZt="\\u0300-\\u036f",MZt="\\ufe20-\\ufe2f",TZt="\\u20d0-\\u20ff",AZt=CZt+MZt+TZt,EZt="\\ufe0e\\ufe0f",PZt="["+jtt+"]",a_e="["+AZt+"]",i_e="\\ud83c[\\udffb-\\udfff]",IZt="(?:"+a_e+"|"+i_e+")",ktt="[^"+jtt+"]",Ntt="(?:\\ud83c[\\udde6-\\uddff]){2}",Stt="[\\ud800-\\udbff][\\udc00-\\udfff]",LZt="\\u200d",Ctt=IZt+"?",Mtt="["+EZt+"]?",DZt="(?:"+LZt+"(?:"+[ktt,Ntt,Stt].join("|")+")"+Mtt+Ctt+")*",OZt=Mtt+Ctt+DZt,RZt="(?:"+[ktt+a_e+"?",a_e,Ntt,Stt,PZt].join("|")+")",FZt=RegExp(i_e+"(?="+i_e+")|"+RZt+OZt,"g");function zZt(t){return t.match(FZt)||[]}var BZt=zZt,$Zt=SZt,qZt=wtt,UZt=BZt;function VZt(t){return qZt(t)?UZt(t):$Zt(t)}var HZt=VZt,WZt=fZt,GZt=wtt,KZt=HZt,ZZt=gtt;function YZt(t){return function(s){s=ZZt(s);var r=GZt(s)?KZt(s):void 0,n=r?r[0]:s.charAt(0),a=r?WZt(r,1).join(""):s.slice(1);return n[t]()+a}}var XZt=YZt,QZt=XZt,JZt=QZt("toUpperCase"),eYt=JZt;const rhe=Co(eYt);function Bl(t){return function(){return t}}const Ttt=Math.cos,zle=Math.sin,oy=Math.sqrt,Ble=Math.PI,nhe=2*Ble,o_e=Math.PI,l_e=2*o_e,XN=1e-6,tYt=l_e-XN;function Att(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return Att;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;aXN)if(!(Math.abs(f*c-u*p)>XN)||!o)this._append`L${this._x1=s},${this._y1=r}`;else{let _=n-l,b=a-i,w=c*c+u*u,j=_*_+b*b,N=Math.sqrt(w),S=Math.sqrt(y),T=o*Math.tan((o_e-Math.acos((w+y-j)/(2*N*S)))/2),I=T/S,L=T/N;Math.abs(I-1)>XN&&this._append`L${s+I*p},${r+I*f}`,this._append`A${o},${o},0,0,${+(f*_>p*b)},${this._x1=s+L*c},${this._y1=r+L*u}`}}arc(s,r,n,a,o,l){if(s=+s,r=+r,n=+n,l=!!l,n<0)throw new Error(`negative radius: ${n}`);let i=n*Math.cos(a),c=n*Math.sin(a),u=s+i,p=r+c,f=1^l,y=l?a-o:o-a;this._x1===null?this._append`M${u},${p}`:(Math.abs(this._x1-u)>XN||Math.abs(this._y1-p)>XN)&&this._append`L${u},${p}`,n&&(y<0&&(y=y%l_e+l_e),y>tYt?this._append`A${n},${n},0,1,${f},${s-i},${r-c}A${n},${n},0,1,${f},${this._x1=u},${this._y1=p}`:y>XN&&this._append`A${n},${n},0,${+(y>=o_e)},${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 FNe(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 rYt(s)}function zNe(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Ett(t){this._context=t}Ett.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 ahe(t){return new Ett(t)}function Ptt(t){return t[0]}function Itt(t){return t[1]}function Ltt(t,s){var r=Bl(!0),n=null,a=ahe,o=null,l=FNe(i);t=typeof t=="function"?t:t===void 0?Ptt:Bl(t),s=typeof s=="function"?s:s===void 0?Itt:Bl(s);function i(c){var u,p=(c=zNe(c)).length,f,y=!1,_;for(n==null&&(o=a(_=l())),u=0;u<=p;++u)!(u=_;--b)i.point(T[b],I[b]);i.lineEnd(),i.areaEnd()}N&&(T[y]=+t(j,y,f),I[y]=+s(j,y,f),i.point(n?+n(j,y,f):T[y],r?+r(j,y,f):I[y]))}if(S)return i=null,S+""||null}function p(){return Ltt().defined(a).curve(l).context(o)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Bl(+f),n=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Bl(+f),u):t},u.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Bl(+f),u):n},u.y=function(f){return arguments.length?(s=typeof f=="function"?f:Bl(+f),r=null,u):s},u.y0=function(f){return arguments.length?(s=typeof f=="function"?f:Bl(+f),u):s},u.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Bl(+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:Bl(!!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 Dtt{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 nYt(t){return new Dtt(t,!0)}function aYt(t){return new Dtt(t,!1)}const BNe={draw(t,s){const r=oy(s/Ble);t.moveTo(r,0),t.arc(0,0,r,0,nhe)}},iYt={draw(t,s){const r=oy(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()}},Ott=oy(1/3),oYt=Ott*2,lYt={draw(t,s){const r=oy(s/oYt),n=r*Ott;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},cYt={draw(t,s){const r=oy(s),n=-r/2;t.rect(n,n,r,r)}},dYt=.8908130915292852,Rtt=zle(Ble/10)/zle(7*Ble/10),uYt=zle(nhe/10)*Rtt,hYt=-Ttt(nhe/10)*Rtt,mYt={draw(t,s){const r=oy(s*dYt),n=uYt*r,a=hYt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=nhe*o/5,i=Ttt(l),c=zle(l);t.lineTo(c*r,-i*r),t.lineTo(i*n-c*a,c*n+i*a)}t.closePath()}},Exe=oy(3),pYt={draw(t,s){const r=-oy(s/(Exe*3));t.moveTo(0,r*2),t.lineTo(-Exe*r,-r),t.lineTo(Exe*r,-r),t.closePath()}},Uf=-.5,Vf=oy(3)/2,c_e=1/oy(12),fYt=(c_e/2+1)*3,gYt={draw(t,s){const r=oy(s/fYt),n=r/2,a=r*c_e,o=n,l=r*c_e+r,i=-o,c=l;t.moveTo(n,a),t.lineTo(o,l),t.lineTo(i,c),t.lineTo(Uf*n-Vf*a,Vf*n+Uf*a),t.lineTo(Uf*o-Vf*l,Vf*o+Uf*l),t.lineTo(Uf*i-Vf*c,Vf*i+Uf*c),t.lineTo(Uf*n+Vf*a,Uf*a-Vf*n),t.lineTo(Uf*o+Vf*l,Uf*l-Vf*o),t.lineTo(Uf*i+Vf*c,Uf*c-Vf*i),t.closePath()}};function xYt(t,s){let r=null,n=FNe(a);t=typeof t=="function"?t:Bl(t||BNe),s=typeof s=="function"?s:Bl(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:Bl(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:Bl(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function $le(){}function qle(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 Ftt(t){this._context=t}Ftt.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:qle(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:qle(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function yYt(t){return new Ftt(t)}function ztt(t){this._context=t}ztt.prototype={areaStart:$le,areaEnd:$le,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:qle(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function vYt(t){return new ztt(t)}function Btt(t){this._context=t}Btt.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:qle(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function _Yt(t){return new Btt(t)}function $tt(t){this._context=t}$tt.prototype={areaStart:$le,areaEnd:$le,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 bYt(t){return new $tt(t)}function b8e(t){return t<0?-1:1}function w8e(t,s,r){var n=t._x1-t._x0,a=s-t._x1,o=(t._y1-t._y0)/(n||a<0&&-0),l=(r-t._y1)/(a||n<0&&-0),i=(o*a+l*n)/(n+a);return(b8e(o)+b8e(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function j8e(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function Pxe(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 Ule(t){this._context=t}Ule.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:Pxe(this,this._t0,j8e(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,Pxe(this,j8e(this,r=w8e(this,t,s)),r);break;default:Pxe(this,this._t0,r=w8e(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function qtt(t){this._context=new Utt(t)}(qtt.prototype=Object.create(Ule.prototype)).point=function(t,s){Ule.prototype.point.call(this,s,t)};function Utt(t){this._context=t}Utt.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 wYt(t){return new Ule(t)}function jYt(t){return new qtt(t)}function Vtt(t){this._context=t}Vtt.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,s=this._y,r=t.length;if(r)if(this._line?this._context.lineTo(t[0],s[0]):this._context.moveTo(t[0],s[0]),r===2)this._context.lineTo(t[1],s[1]);else for(var n=k8e(t),a=k8e(s),o=0,l=1;l=0;--s)a[s]=(l[s]-a[s+1])/o[s];for(o[r-1]=(t[r]+a[r-1])/2,s=0;s=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,s){switch(t=+t,s=+s,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,s):this._context.moveTo(t,s);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,s),this._context.lineTo(t,s);else{var r=this._x*(1-this._t)+t*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,s)}break}}this._x=t,this._y=s}};function NYt(t){return new ihe(t,.5)}function SYt(t){return new ihe(t,0)}function CYt(t){return new ihe(t,1)}function PT(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 MYt(t,s){return t[s]}function TYt(t){const s=[];return s.key=t,s}function AYt(){var t=Bl([]),s=d_e,r=PT,n=MYt;function a(o){var l=Array.from(t.apply(this,arguments),TYt),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 zYt(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 Htt={symbolCircle:BNe,symbolCross:iYt,symbolDiamond:lYt,symbolSquare:cYt,symbolStar:mYt,symbolTriangle:pYt,symbolWye:gYt},BYt=Math.PI/180,$Yt=function(s){var r="symbol".concat(rhe(s));return Htt[r]||BNe},qYt=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*BYt;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}},UYt=function(s,r){Htt["symbol".concat(rhe(s))]=r},$Ne=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=FYt(s,LYt),u=S8e(S8e({},c),{},{type:n,size:o,sizeType:i}),p=function(){var j=$Yt(n),N=xYt().type(j).size(qYt(o,i,n));return N()},f=u.className,y=u.cx,_=u.cy,b=ti(u,!0);return y===+y&&_===+_&&o===+o?ht.createElement("path",u_e({},b,{className:Bi("recharts-symbols",f),transform:"translate(".concat(y,", ").concat(_,")"),d:p()})):null};$Ne.registerSymbol=UYt;function IT(t){"@babel/helpers - typeof";return IT=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},IT(t)}function h_e(){return h_e=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var S=_.inactive?u:_.color;return ht.createElement("li",h_e({className:j,style:f,key:"legend-item-".concat(b)},PS(n.props,_,b)),ht.createElement(r_e,{width:l,height:l,viewBox:p,style:y},n.renderIcon(_)),ht.createElement("span",{className:"recharts-legend-item-text",style:{color:S}},w?w(N,_,b):N))})}},{key:"render",value:function(){var n=this.props,a=n.payload,o=n.layout,l=n.align;if(!a||!a.length)return null;var i={padding:0,margin:0,textAlign:o==="horizontal"?l:"left"};return ht.createElement("ul",{className:"recharts-default-legend",style:i},this.renderItems())}}])}(C.PureComponent);nD(qNe,"displayName","Legend");nD(qNe,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var JYt=Vue;function eXt(){this.__data__=new JYt,this.size=0}var tXt=eXt;function sXt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var rXt=sXt;function nXt(t){return this.__data__.get(t)}var aXt=nXt;function iXt(t){return this.__data__.has(t)}var oXt=iXt,lXt=Vue,cXt=TNe,dXt=ANe,uXt=200;function hXt(t,s){var r=this.__data__;if(r instanceof lXt){var n=r.__data__;if(!cXt||n.lengthi))return!1;var u=o.get(t),p=o.get(s);if(u&&p)return u==s&&p==t;var f=-1,y=!0,_=r&LXt?new AXt:void 0;for(o.set(t,s),o.set(s,t);++f-1&&t%1==0&&t-1&&t%1==0&&t<=FQt}var WNe=zQt,BQt=P1,$Qt=WNe,qQt=I1,UQt="[object Arguments]",VQt="[object Array]",HQt="[object Boolean]",WQt="[object Date]",GQt="[object Error]",KQt="[object Function]",ZQt="[object Map]",YQt="[object Number]",XQt="[object Object]",QQt="[object RegExp]",JQt="[object Set]",eJt="[object String]",tJt="[object WeakMap]",sJt="[object ArrayBuffer]",rJt="[object DataView]",nJt="[object Float32Array]",aJt="[object Float64Array]",iJt="[object Int8Array]",oJt="[object Int16Array]",lJt="[object Int32Array]",cJt="[object Uint8Array]",dJt="[object Uint8ClampedArray]",uJt="[object Uint16Array]",hJt="[object Uint32Array]",cc={};cc[nJt]=cc[aJt]=cc[iJt]=cc[oJt]=cc[lJt]=cc[cJt]=cc[dJt]=cc[uJt]=cc[hJt]=!0;cc[UQt]=cc[VQt]=cc[sJt]=cc[HQt]=cc[rJt]=cc[WQt]=cc[GQt]=cc[KQt]=cc[ZQt]=cc[YQt]=cc[XQt]=cc[QQt]=cc[JQt]=cc[eJt]=cc[tJt]=!1;function mJt(t){return qQt(t)&&$Qt(t.length)&&!!cc[BQt(t)]}var pJt=mJt;function fJt(t){return function(s){return t(s)}}var sst=fJt,Gle={exports:{}};Gle.exports;(function(t,s){var r=dtt,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})(Gle,Gle.exports);var gJt=Gle.exports,xJt=pJt,yJt=sst,I8e=gJt,L8e=I8e&&I8e.isTypedArray,vJt=L8e?yJt(L8e):xJt,rst=vJt,_Jt=jQt,bJt=VNe,wJt=Cp,jJt=tst,kJt=HNe,NJt=rst,SJt=Object.prototype,CJt=SJt.hasOwnProperty;function MJt(t,s){var r=wJt(t),n=!r&&bJt(t),a=!r&&!n&&jJt(t),o=!r&&!n&&!a&&NJt(t),l=r||n||a||o,i=l?_Jt(t.length,String):[],c=i.length;for(var u in t)(s||CJt.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||kJt(u,c)))&&i.push(u);return i}var TJt=MJt,AJt=Object.prototype;function EJt(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||AJt;return t===r}var PJt=EJt;function IJt(t,s){return function(r){return t(s(r))}}var nst=IJt,LJt=nst,DJt=LJt(Object.keys,Object),OJt=DJt,RJt=PJt,FJt=OJt,zJt=Object.prototype,BJt=zJt.hasOwnProperty;function $Jt(t){if(!RJt(t))return FJt(t);var s=[];for(var r in Object(t))BJt.call(t,r)&&r!="constructor"&&s.push(r);return s}var qJt=$Jt,UJt=CNe,VJt=WNe;function HJt(t){return t!=null&&VJt(t.length)&&!UJt(t)}var FO=HJt,WJt=TJt,GJt=qJt,KJt=FO;function ZJt(t){return KJt(t)?WJt(t):GJt(t)}var ohe=ZJt,YJt=uQt,XJt=bQt,QJt=ohe;function JJt(t){return YJt(t,QJt,XJt)}var ees=JJt,D8e=ees,tes=1,ses=Object.prototype,res=ses.hasOwnProperty;function nes(t,s,r,n,a,o){var l=r&tes,i=D8e(t),c=i.length,u=D8e(s),p=u.length;if(c!=p&&!l)return!1;for(var f=c;f--;){var y=i[f];if(!(l?y in s:res.call(s,y)))return!1}var _=o.get(t),b=o.get(s);if(_&&b)return _==s&&b==t;var w=!0;o.set(t,s),o.set(s,t);for(var j=l;++f-1}var sss=tss;function rss(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=yss){var u=s?null:gss(t);if(u)return xss(u);l=!1,a=fss,c=new hss}else c=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Lss(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 Dss(t){return t.value}function Oss(t,s){if(ht.isValidElement(t))return ht.cloneElement(t,s);if(typeof t=="function")return ht.createElement(t,s);s.ref;var r=Iss(s,Nss);return ht.createElement(qNe,r)}var X8e=1,zM=function(t){function s(){var r;Sss(this,s);for(var n=arguments.length,a=new Array(n),o=0;oX8e||Math.abs(a.height-this.lastBoundingBox.height)>X8e)&&(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?yv({},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,y;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(l==="center"&&o==="vertical"){var _=this.getBBoxSnapshot();f={left:((u||0)-_.width)/2}}else f=l==="right"?{right: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 b=this.getBBoxSnapshot();y={top:((p||0)-b.height)/2}}else y=i==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return yv(yv({},f),y)}},{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=yv(yv({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(c)),c);return ht.createElement("div",{className:"recharts-legend-wrapper",style:f,ref:function(_){n.wrapperNode=_}},Oss(o,yv(yv({},this.props),{},{payload:ust(p,u,Dss)})))}}],[{key:"getWithHeight",value:function(n,a){var o=yv(yv({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&sn(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(C.PureComponent);lhe(zM,"displayName","Legend");lhe(zM,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var Q8e=OO,Rss=VNe,Fss=Cp,J8e=Q8e?Q8e.isConcatSpreadable:void 0;function zss(t){return Fss(t)||Rss(t)||!!(J8e&&t&&t[J8e])}var Bss=zss,$ss=Jtt,qss=Bss;function pst(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=qss),a||(a=[]);++o0&&r(i)?s>1?pst(i,s-1,r,n,a):$ss(a,i):n||(a[a.length]=i)}return a}var fst=pst;function Uss(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 Vss=Uss,Hss=Vss,Wss=Hss(),Gss=Wss,Kss=Gss,Zss=ohe;function Yss(t,s){return t&&Kss(t,s,Zss)}var gst=Yss,Xss=FO;function Qss(t,s){return function(r,n){if(r==null)return r;if(!Xss(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 hrs=urs,Oxe=PNe,mrs=INe,prs=I0,frs=xst,grs=ors,xrs=sst,yrs=hrs,vrs=tE,_rs=Cp;function brs(t,s,r){s.length?s=Oxe(s,function(o){return _rs(o)?function(l){return mrs(l,o.length===1?o[0]:o)}:o}):s=[vrs];var n=-1;s=Oxe(s,xrs(prs));var a=frs(t,function(o,l,i){var c=Oxe(s,function(u){return u(o)});return{criteria:c,index:++n,value:o}});return grs(a,function(o,l){return yrs(o,l,r)})}var wrs=brs;function jrs(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 krs=jrs,Nrs=krs,tDe=Math.max;function Srs(t,s,r){return s=tDe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=tDe(n.length-s,0),l=Array(o);++a0){if(++s>=Ors)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var Brs=zrs,$rs=Drs,qrs=Brs,Urs=qrs($rs),Vrs=Urs,Hrs=tE,Wrs=Crs,Grs=Vrs;function Krs(t,s){return Grs(Wrs(t,s,Hrs),t+"")}var Zrs=Krs,Yrs=MNe,Xrs=FO,Qrs=HNe,Jrs=E2;function ens(t,s,r){if(!Jrs(r))return!1;var n=typeof s;return(n=="number"?Xrs(r)&&Qrs(s,r.length):n=="string"&&s in r)?Yrs(r[s],t):!1}var che=ens,tns=fst,sns=wrs,rns=Zrs,rDe=che,nns=rns(function(t,s){if(t==null)return[];var r=s.length;return r>1&&rDe(t,s[0],s[1])?s=[]:r>2&&rDe(s[0],s[1],s[2])&&(s=[s[0]]),sns(t,tns(s,1),[])}),ans=nns;const ZNe=Co(ans);function aD(t){"@babel/helpers - typeof";return aD=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},aD(t)}function __e(){return __e=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(D6,"-left"),sn(r)&&s&&sn(s.x)&&r=s.y),"".concat(D6,"-top"),sn(n)&&s&&sn(s.y)&&nw?Math.max(p,c[n]):Math.max(f,c[n])}function _ns(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 bns(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=_ns({translateX:p,translateY:f,useTranslate3d:i})):u=yns,{cssProperties:u,cssClasses:vns({translateX:p,translateY:f,coordinate:r})}}function DT(t){"@babel/helpers - typeof";return DT=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},DT(t)}function oDe(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 lDe(t){for(var s=1;scDe||Math.abs(n.height-this.state.lastBoundingBox.height)>cDe)&&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,y=a.isAnimationActive,_=a.offset,b=a.position,w=a.reverseDirection,j=a.useTranslate3d,N=a.viewBox,S=a.wrapperStyle,T=bns({allowEscapeViewBox:l,coordinate:p,offsetTopLeft:_,position:b,reverseDirection:w,tooltipBox:this.state.lastBoundingBox,useTranslate3d:j,viewBox:N}),I=T.cssClasses,L=T.cssProperties,R=lDe(lDe({transition:y&&o?"transform ".concat(i,"ms ").concat(c):void 0},L),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&f?"visible":"hidden",position:"absolute",top:0,left:0},S);return ht.createElement("div",{tabIndex:-1,className:I,style:R,ref:function(q){n.wrapperNode=q}},u)}}])}(C.PureComponent),Ens=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},eC={isSsr:Ens()};function OT(t){"@babel/helpers - typeof";return OT=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},OT(t)}function dDe(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 uDe(t){for(var s=1;s0;return ht.createElement(Ans,{allowEscapeViewBox:l,animationDuration:i,animationEasing:c,isAnimationActive:y,active:o,coordinate:p,hasPayload:R,offset:_,position:j,reverseDirection:N,useTranslate3d:S,viewBox:T,wrapperStyle:I},$ns(u,uDe(uDe({},this.props),{},{payload:L})))}}])}(C.PureComponent);YNe(rp,"displayName","Tooltip");YNe(rp,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!eC.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 qns=P0,Uns=function(){return qns.Date.now()},Vns=Uns,Hns=/\s/;function Wns(t){for(var s=t.length;s--&&Hns.test(t.charAt(s)););return s}var Gns=Wns,Kns=Gns,Zns=/^\s+/;function Yns(t){return t&&t.slice(0,Kns(t)+1).replace(Zns,"")}var Xns=Yns,Qns=Xns,hDe=E2,Jns=GA,mDe=NaN,eas=/^[-+]0x[0-9a-f]+$/i,tas=/^0b[01]+$/i,sas=/^0o[0-7]+$/i,ras=parseInt;function nas(t){if(typeof t=="number")return t;if(Jns(t))return mDe;if(hDe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=hDe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=Qns(t);var r=tas.test(t);return r||sas.test(t)?ras(t.slice(2),r?2:8):eas.test(t)?mDe:+t}var jst=nas,aas=E2,Fxe=Vns,pDe=jst,ias="Expected a function",oas=Math.max,las=Math.min;function cas(t,s,r){var n,a,o,l,i,c,u=0,p=!1,f=!1,y=!0;if(typeof t!="function")throw new TypeError(ias);s=pDe(s)||0,aas(r)&&(p=!!r.leading,f="maxWait"in r,o=f?oas(pDe(r.maxWait)||0,s):o,y="trailing"in r?!!r.trailing:y);function _(R){var $=n,q=a;return n=a=void 0,u=R,l=t.apply(q,$),l}function b(R){return u=R,i=setTimeout(N,s),p?_(R):l}function w(R){var $=R-c,q=R-u,U=s-$;return f?las(U,o-q):U}function j(R){var $=R-c,q=R-u;return c===void 0||$>=s||$<0||f&&q>=o}function N(){var R=Fxe();if(j(R))return S(R);i=setTimeout(N,w(R))}function S(R){return i=void 0,y&&n?_(R):(n=a=void 0,l)}function T(){i!==void 0&&clearTimeout(i),u=0,n=c=a=i=void 0}function I(){return i===void 0?l:S(Fxe())}function L(){var R=Fxe(),$=j(R);if(n=arguments,a=this,c=R,$){if(i===void 0)return b(c);if(f)return clearTimeout(i),i=setTimeout(N,s),_(c)}return i===void 0&&(i=setTimeout(N,s)),l}return L.cancel=T,L.flush=I,L}var das=cas,uas=das,has=E2,mas="Expected a function";function pas(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(mas);return has(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),uas(t,s,{leading:n,maxWait:s,trailing:a})}var fas=pas;const kst=Co(fas);function oD(t){"@babel/helpers - typeof";return oD=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},oD(t)}function fDe(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 dz(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(ee=kst(ee,w,{trailing:!0,leading:!1}));var Q=new ResizeObserver(ee),de=L.current.getBoundingClientRect(),re=de.width,ne=de.height;return X(re,ne),Q.observe(L.current),function(){Q.disconnect()}},[X,w]);var se=C.useMemo(function(){var ee=U.containerWidth,Q=U.containerHeight;if(ee<0||Q<0)return null;Yx(y4(l)||y4(c),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,c),Yx(!r||r>0,"The aspect(%s) must be greater than zero.",r);var de=y4(l)?ee:l,re=y4(c)?Q:c;r&&r>0&&(de?re=de/r:re&&(de=re*r),y&&re>y&&(re=y)),Yx(de>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.`,de,re,l,c,p,f,r);var ne=!Array.isArray(_)&&c1(_.type).endsWith("Chart");return ht.Children.map(_,function(le){return ht.isValidElement(le)?C.cloneElement(le,dz({width:de,height:re},ne?{style:dz({height:"100%",width:"100%",maxHeight:re,maxWidth:de},le.props.style)}:{})):le})},[r,_,c,y,f,p,U,l]);return ht.createElement("div",{id:j?"".concat(j):void 0,className:Bi("recharts-responsive-container",N),style:dz(dz({},I),{},{width:l,height:c,minWidth:p,minHeight:f,maxHeight:y}),ref:L},se)}),zO=function(s){return null};zO.displayName="Cell";function lD(t){"@babel/helpers - typeof";return lD=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},lD(t)}function xDe(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 k_e(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||eC.isSsr)return{width:0,height:0};var n=Tas(r),a=JSON.stringify({text:s,copyStyle:n});if(i5.widthCache[a])return i5.widthCache[a];try{var o=document.getElementById(yDe);o||(o=document.createElement("span"),o.setAttribute("id",yDe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=k_e(k_e({},Mas),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),c={width:i.width,height:i.height};return i5.widthCache[a]=c,++i5.cacheCount>Cas&&(i5.cacheCount=0,i5.widthCache={}),c}catch{return{width:0,height:0}}},Aas=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 Xle(t,s){return Las(t)||Ias(t,s)||Pas(t,s)||Eas()}function Eas(){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 Pas(t,s){if(t){if(typeof t=="string")return vDe(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 vDe(t,s)}}function vDe(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 Kas(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 NDe(t,s){return Qas(t)||Xas(t,s)||Yas(t,s)||Zas()}function Zas(){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 Yas(t,s){if(t){if(typeof t=="string")return SDe(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 SDe(t,s)}}function SDe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&arguments[0]!==void 0?arguments[0]:[];return de.reduce(function(re,ne){var le=ne.word,he=ne.width,we=re[re.length-1];if(we&&(a==null||o||we.width+he+nne.width?re:ne})};if(!p)return _;for(var w="…",j=function(de){var re=f.slice(0,de),ne=Mst({breakAll:u,style:c,children:re+w}).wordsWithComputedWidth,le=y(ne),he=le.length>l||b(le).width>Number(a);return[he,le]},N=0,S=f.length-1,T=0,I;N<=S&&T<=f.length-1;){var L=Math.floor((N+S)/2),R=L-1,$=j(R),q=NDe($,2),U=q[0],V=q[1],X=j(L),se=NDe(X,1),ee=se[0];if(!U&&!ee&&(N=L+1),U&&ee&&(S=L-1),!U&&ee){I=V;break}T++}return I||_},CDe=function(s){var r=Ri(s)?[]:s.toString().split(Cst);return[{words:r}]},eis=function(s){var r=s.width,n=s.scaleToFit,a=s.children,o=s.style,l=s.breakAll,i=s.maxLines;if((r||n)&&!eC.isSsr){var c,u,p=Mst({breakAll:l,children:a,style:o});if(p){var f=p.wordsWithComputedWidth,y=p.spaceWidth;c=f,u=y}else return CDe(a);return Jas({breakAll:l,children:a,maxLines:i,style:o},c,u,r,n)}return CDe(a)},MDe="#808080",IS=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,y=s.textAnchor,_=y===void 0?"start":y,b=s.verticalAnchor,w=b===void 0?"end":b,j=s.fill,N=j===void 0?MDe:j,S=kDe(s,Was),T=C.useMemo(function(){return eis({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]),I=S.dx,L=S.dy,R=S.angle,$=S.className,q=S.breakAll,U=kDe(S,Gas);if(!pu(n)||!pu(o))return null;var V=n+(sn(I)?I:0),X=o+(sn(L)?L:0),se;switch(w){case"start":se=zxe("calc(".concat(u,")"));break;case"middle":se=zxe("calc(".concat((T.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:se=zxe("calc(".concat(T.length-1," * -").concat(i,")"));break}var ee=[];if(f){var Q=T[0].width,de=S.width;ee.push("scale(".concat((sn(de)?de/Q:1)/Q,")"))}return R&&ee.push("rotate(".concat(R,", ").concat(V,", ").concat(X,")")),ee.length&&(U.transform=ee.join(" ")),ht.createElement("text",N_e({},ti(U,!0),{x:V,y:X,className:Bi("recharts-text",$),textAnchor:_,fill:N.includes("url")?MDe:N}),T.map(function(re,ne){var le=re.words.join(q?"":" ");return ht.createElement("tspan",{x:V,dy:ne===0?se:i,key:"".concat(le,"-").concat(ne)},le)}))};function Zb(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function tis(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function XNe(t){let s,r,n;t.length!==2?(s=Zb,r=(i,c)=>Zb(t(i),c),n=(i,c)=>t(i)-c):(s=t===Zb||t===tis?t:sis,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 sis(){return 0}function Tst(t){return t===null?NaN:+t}function*ris(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const nis=XNe(Zb),BO=nis.right;XNe(Tst).center;class TDe extends Map{constructor(s,r=ois){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(ADe(this,s))}has(s){return super.has(ADe(this,s))}set(s,r){return super.set(ais(this,s),r)}delete(s){return super.delete(iis(this,s))}}function ADe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function ais({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function iis({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function ois(t){return t!==null&&typeof t=="object"?t.valueOf():t}function lis(t=Zb){if(t===Zb)return Ast;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 Ast(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const cis=Math.sqrt(50),dis=Math.sqrt(10),uis=Math.sqrt(2);function Qle(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>=cis?10:o>=dis?5:o>=uis?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 PDe(t,s){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function Est(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?Ast:lis(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),y=.5*Math.sqrt(p*f*(c-f)/c)*(u-c/2<0?-1:1),_=Math.max(r,Math.floor(s-u*f/c+y)),b=Math.min(n,Math.floor(s+(c-u)*f/c+y));Est(t,s,_,b,a)}const o=t[s];let l=r,i=n;for(O6(t,r,s),a(t[n],o)>0&&O6(t,r,n);l0;)--i}a(t[r],o)===0?O6(t,r,i):(++i,O6(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function O6(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function his(t,s,r){if(t=Float64Array.from(ris(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return PDe(t);if(s>=1)return EDe(t);var n,a=(n-1)*s,o=Math.floor(a),l=EDe(Est(t,o).subarray(0,o+1)),i=PDe(t.subarray(o+1));return l+(i-l)*(a-o)}}function mis(t,s,r=Tst){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 pis(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?hz(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?hz(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=gis.exec(t))?new hp(s[1],s[2],s[3],1):(s=xis.exec(t))?new hp(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=yis.exec(t))?hz(s[1],s[2],s[3],s[4]):(s=vis.exec(t))?hz(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=_is.exec(t))?zDe(s[1],s[2]/100,s[3]/100,1):(s=bis.exec(t))?zDe(s[1],s[2]/100,s[3]/100,s[4]):IDe.hasOwnProperty(t)?ODe(IDe[t]):t==="transparent"?new hp(NaN,NaN,NaN,0):null}function ODe(t){return new hp(t>>16&255,t>>8&255,t&255,1)}function hz(t,s,r,n){return n<=0&&(t=s=r=NaN),new hp(t,s,r,n)}function kis(t){return t instanceof $O||(t=mD(t)),t?(t=t.rgb(),new hp(t.r,t.g,t.b,t.opacity)):new hp}function A_e(t,s,r,n){return arguments.length===1?kis(t):new hp(t,s,r,n??1)}function hp(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}JNe(hp,A_e,Ist($O,{brighter(t){return t=t==null?Jle:Math.pow(Jle,t),new hp(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?uD:Math.pow(uD,t),new hp(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new hp(rS(this.r),rS(this.g),rS(this.b),ece(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:RDe,formatHex:RDe,formatHex8:Nis,formatRgb:FDe,toString:FDe}));function RDe(){return`#${v4(this.r)}${v4(this.g)}${v4(this.b)}`}function Nis(){return`#${v4(this.r)}${v4(this.g)}${v4(this.b)}${v4((isNaN(this.opacity)?1:this.opacity)*255)}`}function FDe(){const t=ece(this.opacity);return`${t===1?"rgb(":"rgba("}${rS(this.r)}, ${rS(this.g)}, ${rS(this.b)}${t===1?")":`, ${t})`}`}function ece(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function rS(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function v4(t){return t=rS(t),(t<16?"0":"")+t.toString(16)}function zDe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new Rx(t,s,r,n)}function Lst(t){if(t instanceof Rx)return new Rx(t.h,t.s,t.l,t.opacity);if(t instanceof $O||(t=mD(t)),!t)return new Rx;if(t instanceof Rx)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 Rx(l,i,c,t.opacity)}function Sis(t,s,r,n){return arguments.length===1?Lst(t):new Rx(t,s,r,n??1)}function Rx(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}JNe(Rx,Sis,Ist($O,{brighter(t){return t=t==null?Jle:Math.pow(Jle,t),new Rx(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?uD:Math.pow(uD,t),new Rx(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 hp(Bxe(t>=240?t-240:t+120,a,n),Bxe(t,a,n),Bxe(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new Rx(BDe(this.h),mz(this.s),mz(this.l),ece(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=ece(this.opacity);return`${t===1?"hsl(":"hsla("}${BDe(this.h)}, ${mz(this.s)*100}%, ${mz(this.l)*100}%${t===1?")":`, ${t})`}`}}));function BDe(t){return t=(t||0)%360,t<0?t+360:t}function mz(t){return Math.max(0,Math.min(1,t||0))}function Bxe(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 e4e=t=>()=>t;function Cis(t,s){return function(r){return t+r*s}}function Mis(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 Tis(t){return(t=+t)==1?Dst:function(s,r){return r-s?Mis(s,r,t):e4e(isNaN(s)?r:s)}}function Dst(t,s){var r=s-t;return r?Cis(t,r):e4e(isNaN(t)?s:t)}const $De=function t(s){var r=Tis(s);function n(a,o){var l=r((a=A_e(a)).r,(o=A_e(o)).r),i=r(a.g,o.g),c=r(a.b,o.b),u=Dst(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 Ais(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:tce(n,a)})),r=$xe.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function $is(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?qis:$is,c=u=null,f}function f(y){return y==null||isNaN(y=+y)?o:(c||(c=i(t.map(n),s,r)))(n(l(y)))}return f.invert=function(y){return l(a((u||(u=i(s,t.map(n),tce)))(y)))},f.domain=function(y){return arguments.length?(t=Array.from(y,sce),p()):t.slice()},f.range=function(y){return arguments.length?(s=Array.from(y),p()):s.slice()},f.rangeRound=function(y){return s=Array.from(y),r=t4e,p()},f.clamp=function(y){return arguments.length?(l=y?!0:km,p()):l!==km},f.interpolate=function(y){return arguments.length?(r=y,p()):r},f.unknown=function(y){return arguments.length?(o=y,f):o},function(y,_){return n=y,a=_,p()}}function s4e(){return dhe()(km,km)}function Uis(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function rce(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 RT(t){return t=rce(Math.abs(t)),t?t[1]:NaN}function Vis(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 His(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var Wis=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function pD(t){if(!(s=Wis.exec(t)))throw new Error("invalid format: "+t);var s;return new r4e({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=r4e.prototype;function r4e(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+""}r4e.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 Gis(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 Ost;function Kis(t,s){var r=rce(t,s);if(!r)return t+"";var n=r[0],a=r[1],o=a-(Ost=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")+rce(t,Math.max(0,s+o-1))[0]}function UDe(t,s){var r=rce(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 VDe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Uis,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)=>UDe(t*100,s),r:UDe,s:Kis,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function HDe(t){return t}var WDe=Array.prototype.map,GDe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Zis(t){var s=t.grouping===void 0||t.thousands===void 0?HDe:Vis(WDe.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?HDe:His(WDe.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 y=f.fill,_=f.align,b=f.sign,w=f.symbol,j=f.zero,N=f.width,S=f.comma,T=f.precision,I=f.trim,L=f.type;L==="n"?(S=!0,L="g"):VDe[L]||(T===void 0&&(T=12),I=!0,L="g"),(j||y==="0"&&_==="=")&&(j=!0,y="0",_="=");var R=w==="$"?r:w==="#"&&/[boxX]/.test(L)?"0"+L.toLowerCase():"",$=w==="$"?n:/[%p]/.test(L)?l:"",q=VDe[L],U=/[defgprs%]/.test(L);T=T===void 0?6:/[gprs]/.test(L)?Math.max(1,Math.min(21,T)):Math.max(0,Math.min(20,T));function V(X){var se=R,ee=$,Q,de,re;if(L==="c")ee=q(X)+ee,X="";else{X=+X;var ne=X<0||1/X<0;if(X=isNaN(X)?c:q(Math.abs(X),T),I&&(X=Gis(X)),ne&&+X==0&&b!=="+"&&(ne=!1),se=(ne?b==="("?b:i:b==="-"||b==="("?"":b)+se,ee=(L==="s"?GDe[8+Ost/3]:"")+ee+(ne&&b==="("?")":""),U){for(Q=-1,de=X.length;++Qre||re>57){ee=(re===46?a+X.slice(Q+1):X.slice(Q))+ee,X=X.slice(0,Q);break}}}S&&!j&&(X=s(X,1/0));var le=se.length+X.length+ee.length,he=le>1)+se+X+ee+he.slice(le);break;default:X=he+se+X+ee;break}return o(X)}return V.toString=function(){return f+""},V}function p(f,y){var _=u((f=pD(f),f.type="f",f)),b=Math.max(-8,Math.min(8,Math.floor(RT(y)/3)))*3,w=Math.pow(10,-b),j=GDe[8+b/3];return function(N){return _(w*N)+j}}return{format:u,formatPrefix:p}}var pz,n4e,Rst;Yis({thousands:",",grouping:[3],currency:["$",""]});function Yis(t){return pz=Zis(t),n4e=pz.format,Rst=pz.formatPrefix,pz}function Xis(t){return Math.max(0,-RT(Math.abs(t)))}function Qis(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(RT(s)/3)))*3-RT(Math.abs(t)))}function Jis(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,RT(s)-RT(t))+1}function Fst(t,s,r,n){var a=M_e(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=Qis(a,l))&&(n.precision=o),Rst(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=Jis(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=Xis(a))&&(n.precision=o-(n.type==="%")*2);break}}return n4e(n)}function P2(t){var s=t.domain;return t.ticks=function(r){var n=s();return S_e(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var a=s();return Fst(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=C_e(l,i,r),u===c)return n[a]=l,n[o]=i,s(n);if(u>0)l=Math.floor(l/u)*u,i=Math.ceil(i/u)*u;else if(u<0)l=Math.ceil(l*u)/u,i=Math.floor(i*u)/u;else break;c=u}return t},t}function nce(){var t=s4e();return t.copy=function(){return qO(t,nce())},zg.apply(t,arguments),P2(t)}function zst(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,sce),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return zst(t).unknown(s)},t=arguments.length?Array.from(t,sce):[0,1],P2(r)}function Bst(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 nos(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 YDe(t){return(s,r)=>-t(-s,r)}function a4e(t){const s=t(KDe,ZDe),r=s.domain;let n=10,a,o;function l(){return a=nos(n),o=ros(n),r()[0]<0?(a=YDe(a),o=YDe(o),t(eos,tos)):t(KDe,ZDe),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(;y<=_;++y)for(b=1;bp)break;N.push(w)}}else for(;y<=_;++y)for(b=n-1;b>=1;--b)if(w=y>0?b/o(-y):b*o(y),!(wp)break;N.push(w)}N.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=n4e(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(Bst(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function $st(){const t=a4e(dhe()).domain([1,10]);return t.copy=()=>qO(t,$st()).base(t.base()),zg.apply(t,arguments),t}function XDe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function QDe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function i4e(t){var s=1,r=t(XDe(s),QDe(s));return r.constant=function(n){return arguments.length?t(XDe(s=+n),QDe(s)):s},P2(r)}function qst(){var t=i4e(dhe());return t.copy=function(){return qO(t,qst()).constant(t.constant())},zg.apply(t,arguments)}function JDe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function aos(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function ios(t){return t<0?-t*t:t*t}function o4e(t){var s=t(km,km),r=1;function n(){return r===1?t(km,km):r===.5?t(aos,ios):t(JDe(r),JDe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},P2(s)}function l4e(){var t=o4e(dhe());return t.copy=function(){return qO(t,l4e()).exponent(t.exponent())},zg.apply(t,arguments),t}function oos(){return l4e.apply(null,arguments).exponent(.5)}function eOe(t){return Math.sign(t)*t*t}function los(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function Ust(){var t=s4e(),s=[0,1],r=!1,n;function a(o){var l=los(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(eOe(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,sce)).map(eOe)),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 Ust(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},zg.apply(a,arguments),P2(a)}function Vst(){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 Hst().domain([t,s]).range(a).unknown(o)},zg.apply(P2(l),arguments)}function Wst(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[BO(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 Wst().domain(t).range(s).unknown(r)},zg.apply(a,arguments)}const qxe=new Date,Uxe=new Date;function Su(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(uSu(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)=>(qxe.setTime(+o),Uxe.setTime(+l),t(qxe),t(Uxe),Math.floor(r(qxe,Uxe))),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 ace=Su(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);ace.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Su(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):ace);ace.range;const Uv=1e3,mg=Uv*60,Vv=mg*60,w1=Vv*24,c4e=w1*7,tOe=w1*30,Vxe=w1*365,_4=Su(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*Uv)},(t,s)=>(s-t)/Uv,t=>t.getUTCSeconds());_4.range;const d4e=Su(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Uv)},(t,s)=>{t.setTime(+t+s*mg)},(t,s)=>(s-t)/mg,t=>t.getMinutes());d4e.range;const u4e=Su(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*mg)},(t,s)=>(s-t)/mg,t=>t.getUTCMinutes());u4e.range;const h4e=Su(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Uv-t.getMinutes()*mg)},(t,s)=>{t.setTime(+t+s*Vv)},(t,s)=>(s-t)/Vv,t=>t.getHours());h4e.range;const m4e=Su(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*Vv)},(t,s)=>(s-t)/Vv,t=>t.getUTCHours());m4e.range;const UO=Su(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*mg)/w1,t=>t.getDate()-1);UO.range;const uhe=Su(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/w1,t=>t.getUTCDate()-1);uhe.range;const Gst=Su(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/w1,t=>Math.floor(t/w1));Gst.range;function tC(t){return Su(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())*mg)/c4e)}const hhe=tC(0),ice=tC(1),cos=tC(2),dos=tC(3),FT=tC(4),uos=tC(5),hos=tC(6);hhe.range;ice.range;cos.range;dos.range;FT.range;uos.range;hos.range;function sC(t){return Su(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)/c4e)}const mhe=sC(0),oce=sC(1),mos=sC(2),pos=sC(3),zT=sC(4),fos=sC(5),gos=sC(6);mhe.range;oce.range;mos.range;pos.range;zT.range;fos.range;gos.range;const p4e=Su(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());p4e.range;const f4e=Su(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());f4e.range;const j1=Su(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());j1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Su(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)});j1.range;const k1=Su(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());k1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Su(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)});k1.range;function Kst(t,s,r,n,a,o){const l=[[_4,1,Uv],[_4,5,5*Uv],[_4,15,15*Uv],[_4,30,30*Uv],[o,1,mg],[o,5,5*mg],[o,15,15*mg],[o,30,30*mg],[a,1,Vv],[a,3,3*Vv],[a,6,6*Vv],[a,12,12*Vv],[n,1,w1],[n,2,2*w1],[r,1,c4e],[s,1,tOe],[s,3,3*tOe],[t,1,Vxe]];function i(u,p,f){const y=pj).right(l,y);if(_===l.length)return t.every(M_e(u/Vxe,p/Vxe,f));if(_===0)return ace.every(Math.max(M_e(u,p,f),1));const[b,w]=l[y/l[_-1][2]53)return null;"w"in De||(De.w=1),"Z"in De?(pe=Wxe(R6(De.y,0,1)),Je=pe.getUTCDay(),pe=Je>4||Je===0?oce.ceil(pe):oce(pe),pe=uhe.offset(pe,(De.V-1)*7),De.y=pe.getUTCFullYear(),De.m=pe.getUTCMonth(),De.d=pe.getUTCDate()+(De.w+6)%7):(pe=Hxe(R6(De.y,0,1)),Je=pe.getDay(),pe=Je>4||Je===0?ice.ceil(pe):ice(pe),pe=UO.offset(pe,(De.V-1)*7),De.y=pe.getFullYear(),De.m=pe.getMonth(),De.d=pe.getDate()+(De.w+6)%7)}else("W"in De||"U"in De)&&("w"in De||(De.w="u"in De?De.u%7:"W"in De?1:0),Je="Z"in De?Wxe(R6(De.y,0,1)).getUTCDay():Hxe(R6(De.y,0,1)).getDay(),De.m=0,De.d="W"in De?(De.w+6)%7+De.W*7-(Je+5)%7:De.w+De.U*7-(Je+6)%7);return"Z"in De?(De.H+=De.Z/100|0,De.M+=De.Z%100,Wxe(De)):Hxe(De)}}function q(Te,qe,ct,De){for(var Rt=0,pe=qe.length,Je=ct.length,lt,rt;Rt=Je)return-1;if(lt=qe.charCodeAt(Rt++),lt===37){if(lt=qe.charAt(Rt++),rt=L[lt in sOe?qe.charAt(Rt++):lt],!rt||(De=rt(Te,ct,De))<0)return-1}else if(lt!=ct.charCodeAt(De++))return-1}return De}function U(Te,qe,ct){var De=u.exec(qe.slice(ct));return De?(Te.p=p.get(De[0].toLowerCase()),ct+De[0].length):-1}function V(Te,qe,ct){var De=_.exec(qe.slice(ct));return De?(Te.w=b.get(De[0].toLowerCase()),ct+De[0].length):-1}function X(Te,qe,ct){var De=f.exec(qe.slice(ct));return De?(Te.w=y.get(De[0].toLowerCase()),ct+De[0].length):-1}function se(Te,qe,ct){var De=N.exec(qe.slice(ct));return De?(Te.m=S.get(De[0].toLowerCase()),ct+De[0].length):-1}function ee(Te,qe,ct){var De=w.exec(qe.slice(ct));return De?(Te.m=j.get(De[0].toLowerCase()),ct+De[0].length):-1}function Q(Te,qe,ct){return q(Te,s,qe,ct)}function de(Te,qe,ct){return q(Te,r,qe,ct)}function re(Te,qe,ct){return q(Te,n,qe,ct)}function ne(Te){return l[Te.getDay()]}function le(Te){return o[Te.getDay()]}function he(Te){return c[Te.getMonth()]}function we(Te){return i[Te.getMonth()]}function ye(Te){return a[+(Te.getHours()>=12)]}function je(Te){return 1+~~(Te.getMonth()/3)}function ke(Te){return l[Te.getUTCDay()]}function We(Te){return o[Te.getUTCDay()]}function be(Te){return c[Te.getUTCMonth()]}function Me(Te){return i[Te.getUTCMonth()]}function Ae(Te){return a[+(Te.getUTCHours()>=12)]}function Re(Te){return 1+~~(Te.getUTCMonth()/3)}return{format:function(Te){var qe=R(Te+="",T);return qe.toString=function(){return Te},qe},parse:function(Te){var qe=$(Te+="",!1);return qe.toString=function(){return Te},qe},utcFormat:function(Te){var qe=R(Te+="",I);return qe.toString=function(){return Te},qe},utcParse:function(Te){var qe=$(Te+="",!0);return qe.toString=function(){return Te},qe}}}var sOe={"-":"",_:" ",0:"0"},eh=/^\s*\d+/,wos=/^%/,jos=/[\\^$*+?|[\]().{}]/g;function Ho(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function Nos(t,s,r){var n=eh.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function Sos(t,s,r){var n=eh.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function Cos(t,s,r){var n=eh.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function Mos(t,s,r){var n=eh.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function Tos(t,s,r){var n=eh.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function rOe(t,s,r){var n=eh.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function nOe(t,s,r){var n=eh.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function Aos(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 Eos(t,s,r){var n=eh.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function Pos(t,s,r){var n=eh.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function aOe(t,s,r){var n=eh.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Ios(t,s,r){var n=eh.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=eh.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function Los(t,s,r){var n=eh.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function Dos(t,s,r){var n=eh.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function Oos(t,s,r){var n=eh.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function Ros(t,s,r){var n=eh.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function Fos(t,s,r){var n=wos.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function zos(t,s,r){var n=eh.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function Bos(t,s,r){var n=eh.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function oOe(t,s){return Ho(t.getDate(),s,2)}function $os(t,s){return Ho(t.getHours(),s,2)}function qos(t,s){return Ho(t.getHours()%12||12,s,2)}function Uos(t,s){return Ho(1+UO.count(j1(t),t),s,3)}function Zst(t,s){return Ho(t.getMilliseconds(),s,3)}function Vos(t,s){return Zst(t,s)+"000"}function Hos(t,s){return Ho(t.getMonth()+1,s,2)}function Wos(t,s){return Ho(t.getMinutes(),s,2)}function Gos(t,s){return Ho(t.getSeconds(),s,2)}function Kos(t){var s=t.getDay();return s===0?7:s}function Zos(t,s){return Ho(hhe.count(j1(t)-1,t),s,2)}function Yst(t){var s=t.getDay();return s>=4||s===0?FT(t):FT.ceil(t)}function Yos(t,s){return t=Yst(t),Ho(FT.count(j1(t),t)+(j1(t).getDay()===4),s,2)}function Xos(t){return t.getDay()}function Qos(t,s){return Ho(ice.count(j1(t)-1,t),s,2)}function Jos(t,s){return Ho(t.getFullYear()%100,s,2)}function els(t,s){return t=Yst(t),Ho(t.getFullYear()%100,s,2)}function tls(t,s){return Ho(t.getFullYear()%1e4,s,4)}function sls(t,s){var r=t.getDay();return t=r>=4||r===0?FT(t):FT.ceil(t),Ho(t.getFullYear()%1e4,s,4)}function rls(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+Ho(s/60|0,"0",2)+Ho(s%60,"0",2)}function lOe(t,s){return Ho(t.getUTCDate(),s,2)}function nls(t,s){return Ho(t.getUTCHours(),s,2)}function als(t,s){return Ho(t.getUTCHours()%12||12,s,2)}function ils(t,s){return Ho(1+uhe.count(k1(t),t),s,3)}function Xst(t,s){return Ho(t.getUTCMilliseconds(),s,3)}function ols(t,s){return Xst(t,s)+"000"}function lls(t,s){return Ho(t.getUTCMonth()+1,s,2)}function cls(t,s){return Ho(t.getUTCMinutes(),s,2)}function dls(t,s){return Ho(t.getUTCSeconds(),s,2)}function uls(t){var s=t.getUTCDay();return s===0?7:s}function hls(t,s){return Ho(mhe.count(k1(t)-1,t),s,2)}function Qst(t){var s=t.getUTCDay();return s>=4||s===0?zT(t):zT.ceil(t)}function mls(t,s){return t=Qst(t),Ho(zT.count(k1(t),t)+(k1(t).getUTCDay()===4),s,2)}function pls(t){return t.getUTCDay()}function fls(t,s){return Ho(oce.count(k1(t)-1,t),s,2)}function gls(t,s){return Ho(t.getUTCFullYear()%100,s,2)}function xls(t,s){return t=Qst(t),Ho(t.getUTCFullYear()%100,s,2)}function yls(t,s){return Ho(t.getUTCFullYear()%1e4,s,4)}function vls(t,s){var r=t.getUTCDay();return t=r>=4||r===0?zT(t):zT.ceil(t),Ho(t.getUTCFullYear()%1e4,s,4)}function _ls(){return"+0000"}function cOe(){return"%"}function dOe(t){return+t}function uOe(t){return Math.floor(+t/1e3)}var o5,Jst,ert;bls({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 bls(t){return o5=bos(t),Jst=o5.format,o5.parse,ert=o5.utcFormat,o5.utcParse,o5}function wls(t){return new Date(t)}function jls(t){return t instanceof Date?+t:+new Date(+t)}function g4e(t,s,r,n,a,o,l,i,c,u){var p=s4e(),f=p.invert,y=p.domain,_=u(".%L"),b=u(":%S"),w=u("%I:%M"),j=u("%I %p"),N=u("%a %d"),S=u("%b %d"),T=u("%B"),I=u("%Y");function L(R){return(c(R)s(a/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,o)=>his(t,o/n))},r.copy=function(){return nrt(s).domain(t)},L1.apply(r,arguments)}function fhe(){var t=0,s=.5,r=1,n=1,a,o,l,i,c,u=km,p,f=!1,y;function _(w){return isNaN(w=+w)?y:(w=.5+((w=+p(w))-o)*(n*ws}var lrt=Als,Els=ghe,Pls=lrt,Ils=tE;function Lls(t){return t&&t.length?Els(t,Ils,Pls):void 0}var Dls=Lls;const xhe=Co(Dls);function Ols(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};Jn.decimalPlaces=Jn.dp=function(){var t=this,s=t.d.length-1,r=(s-t.e)*hc;if(s=t.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};Jn.dividedBy=Jn.div=function(t){return d1(this,new this.constructor(t))};Jn.dividedToIntegerBy=Jn.idiv=function(t){var s=this,r=s.constructor;return Al(d1(s,new r(t),0,1),r.precision)};Jn.equals=Jn.eq=function(t){return!this.cmp(t)};Jn.exponent=function(){return Xd(this)};Jn.greaterThan=Jn.gt=function(t){return this.cmp(t)>0};Jn.greaterThanOrEqualTo=Jn.gte=function(t){return this.cmp(t)>=0};Jn.isInteger=Jn.isint=function(){return this.e>this.d.length-2};Jn.isNegative=Jn.isneg=function(){return this.s<0};Jn.isPositive=Jn.ispos=function(){return this.s>0};Jn.isZero=function(){return this.s===0};Jn.lessThan=Jn.lt=function(t){return this.cmp(t)<0};Jn.lessThanOrEqualTo=Jn.lte=function(t){return this.cmp(t)<1};Jn.logarithm=Jn.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(rf))throw Error(Ig+"NaN");if(r.s<1)throw Error(Ig+(r.s?"NaN":"-Infinity"));return r.eq(rf)?new n(0):(Ac=!1,s=d1(fD(r,o),fD(t,o),o),Ac=!0,Al(s,a))};Jn.minus=Jn.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?mrt(s,t):urt(s,(t.s=-t.s,t))};Jn.modulo=Jn.mod=function(t){var s,r=this,n=r.constructor,a=n.precision;if(t=new n(t),!t.s)throw Error(Ig+"NaN");return r.s?(Ac=!1,s=d1(r,t,0,1).times(t),Ac=!0,r.minus(s)):Al(new n(r),a)};Jn.naturalExponential=Jn.exp=function(){return hrt(this)};Jn.naturalLogarithm=Jn.ln=function(){return fD(this)};Jn.negated=Jn.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};Jn.plus=Jn.add=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?urt(s,t):mrt(s,(t.s=-t.s,t))};Jn.precision=Jn.sd=function(t){var s,r,n,a=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(nS+t);if(s=Xd(a)+1,n=a.d.length-1,r=n*hc+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};Jn.squareRoot=Jn.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(Ig+"NaN")}for(t=Xd(i),Ac=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=e0(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=nE((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(d1(i,o,l+2)).times(.5),e0(o.d).slice(0,l)===(s=e0(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(Al(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return Ac=!0,Al(n,r)};Jn.times=Jn.mul=function(t){var s,r,n,a,o,l,i,c,u,p=this,f=p.constructor,y=p.d,_=(t=new f(t)).d;if(!p.s||!t.s)return new f(0);for(t.s*=p.s,r=p.e+t.e,c=y.length,u=_.length,c=0;){for(s=0,a=c+n;a>n;)i=o[a]+_[n]*y[a-n-1]+s,o[a--]=i%Ou|0,s=i/Ou|0;o[a]=(o[a]+s)%Ou|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,Ac?Al(t,f.precision):t};Jn.toDecimalPlaces=Jn.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(k0(t,0,rE),s===void 0?s=n.rounding:k0(s,0,8),Al(r,t+Xd(r)+1,s))};Jn.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=LS(n,!0):(k0(t,0,rE),s===void 0?s=a.rounding:k0(s,0,8),n=Al(new a(n),t+1,s),r=LS(n,!0,t+1)),r};Jn.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?LS(a):(k0(t,0,rE),s===void 0?s=o.rounding:k0(s,0,8),n=Al(new o(a),t+Xd(a)+1,s),r=LS(n.abs(),!1,t+Xd(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};Jn.toInteger=Jn.toint=function(){var t=this,s=t.constructor;return Al(new s(t),Xd(t)+1,s.rounding)};Jn.toNumber=function(){return+this};Jn.toPower=Jn.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(rf);if(i=new c(i),!i.s){if(t.s<1)throw Error(Ig+"Infinity");return i}if(i.eq(rf))return i;if(n=c.precision,t.eq(rf))return Al(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=p<0?-p:p)<=drt){for(a=new c(rf),s=Math.ceil(n/hc+4),Ac=!1;r%2&&(a=a.times(i),pOe(a.d,s)),r=nE(r/2),r!==0;)i=i.times(i),pOe(i.d,s);return Ac=!0,t.s<0?new c(rf).div(a):Al(a,n)}}else if(o<0)throw Error(Ig+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,Ac=!1,a=t.times(fD(i,n+u)),Ac=!0,a=hrt(a),a.s=o,a};Jn.toPrecision=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?(r=Xd(a),n=LS(a,r<=o.toExpNeg||r>=o.toExpPos)):(k0(t,1,rE),s===void 0?s=o.rounding:k0(s,0,8),a=Al(new o(a),t,s),r=Xd(a),n=LS(a,t<=r||r<=o.toExpNeg,t)),n};Jn.toSignificantDigits=Jn.tosd=function(t,s){var r=this,n=r.constructor;return t===void 0?(t=n.precision,s=n.rounding):(k0(t,1,rE),s===void 0?s=n.rounding:k0(s,0,8)),Al(new n(r),t,s)};Jn.toString=Jn.valueOf=Jn.val=Jn.toJSON=Jn[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,s=Xd(t),r=t.constructor;return LS(t,s<=r.toExpNeg||s>=r.toExpPos)};function urt(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)),Ac?Al(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/hc),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)/Ou|0,c[o]%=Ou;for(r&&(c.unshift(r),++a),i=c.length;c[--i]==0;)c.pop();return s.d=c,s.e=a,Ac?Al(s,f):s}function k0(t,s,r){if(t!==~~t||tr)throw Error(nS+t)}function e0(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,y,_,b,w,j,N,S,T,I,L,R,$,q,U=n.constructor,V=n.s==a.s?1:-1,X=n.d,se=a.d;if(!n.s)return new U(n);if(!a.s)throw Error(Ig+"Division by zero");for(c=n.e-a.e,$=se.length,L=X.length,_=new U(V),b=_.d=[],u=0;se[u]==(X[u]||0);)++u;if(se[u]>(X[u]||0)&&--c,o==null?S=o=U.precision:l?S=o+(Xd(n)-Xd(a))+1:S=o,S<0)return new U(0);if(S=S/hc+2|0,u=0,$==1)for(p=0,se=se[0],S++;(u1&&(se=t(se,p),X=t(X,p),$=se.length,L=X.length),I=$,w=X.slice(0,$),j=w.length;j<$;)w[j++]=0;q=se.slice(),q.unshift(0),R=se[0],se[1]>=Ou/2&&++R;do p=0,i=s(se,w,$,j),i<0?(N=w[0],$!=j&&(N=N*Ou+(w[1]||0)),p=N/R|0,p>1?(p>=Ou&&(p=Ou-1),f=t(se,p),y=f.length,j=w.length,i=s(f,w,y,j),i==1&&(p--,r(f,$16)throw Error(v4e+Xd(t));if(!t.s)return new p(rf);for(Ac=!1,i=f,l=new p(.03125);t.abs().gte(.1);)t=t.times(l),u+=5;for(n=Math.log(JN(2,u))/Math.LN10*2+5|0,i+=n,r=a=o=new p(rf),p.precision=i;;){if(a=Al(a.times(t),i),r=r.times(++c),l=o.plus(d1(a,r,i)),e0(l.d).slice(0,i)===e0(o.d).slice(0,i)){for(;u--;)o=Al(o.times(o),i);return p.precision=f,s==null?(Ac=!0,Al(o,f)):o}o=l}}function Xd(t){for(var s=t.e*hc,r=t.d[0];r>=10;r/=10)s++;return s}function Gxe(t,s,r){if(s>t.LN10.sd())throw Ac=!0,r&&(t.precision=r),Error(Ig+"LN10 precision limit exceeded");return Al(new t(t.LN10),s)}function V_(t){for(var s="";t--;)s+="0";return s}function fD(t,s){var r,n,a,o,l,i,c,u,p,f=1,y=10,_=t,b=_.d,w=_.constructor,j=w.precision;if(_.s<1)throw Error(Ig+(_.s?"NaN":"-Infinity"));if(_.eq(rf))return new w(0);if(s==null?(Ac=!1,u=j):u=s,_.eq(10))return s==null&&(Ac=!0),Gxe(w,u);if(u+=y,w.precision=u,r=e0(b),n=r.charAt(0),o=Xd(_),Math.abs(o)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)_=_.times(t),r=e0(_.d),n=r.charAt(0),f++;o=Xd(_),n>1?(_=new w("0."+r),o++):_=new w(n+"."+r.slice(1))}else return c=Gxe(w,u+2,j).times(o+""),_=fD(new w(n+"."+r.slice(1)),u-y).plus(c),w.precision=j,s==null?(Ac=!0,Al(_,j)):_;for(i=l=_=d1(_.minus(rf),_.plus(rf),u),p=Al(_.times(_),u),a=3;;){if(l=Al(l.times(p),u),c=i.plus(d1(l,new w(a),u)),e0(c.d).slice(0,u)===e0(i.d).slice(0,u))return i=i.times(2),o!==0&&(i=i.plus(Gxe(w,u+2,j).times(o+""))),i=d1(i,new w(f),u),w.precision=j,s==null?(Ac=!0,Al(i,j)):i;i=c,a+=2}}function mOe(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=nE(r/hc),t.d=[],n=(r+1)%hc,r<0&&(n+=hc),nlce||t.e<-lce))throw Error(v4e+r)}else t.s=0,t.e=0,t.d=[0];return t}function Al(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+=hc,a=s,u=f[p=0];else{if(p=Math.ceil((n+1)/hc),o=f.length,p>=o)return t;for(u=o=f[p],l=1;o>=10;o/=10)l++;n%=hc,a=n-hc+l}if(r!==void 0&&(o=JN(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/JN(10,l-a):0:f[p-1])%10&1||r==(t.s<0?8:7))),s<1||!f[0])return c?(o=Xd(t),f.length=1,s=s-o-1,f[0]=JN(10,(hc-s%hc)%hc),t.e=nE(-s/hc)||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=JN(10,hc-n),f[p]=a>0?(u/JN(10,l-a)%JN(10,a)|0)*o:0),c)for(;;)if(p==0){(f[0]+=o)==Ou&&(f[0]=1,++t.e);break}else{if(f[p]+=o,f[p]!=Ou)break;f[p--]=0,o=1}for(n=f.length;f[--n]===0;)f.pop();if(Ac&&(t.e>lce||t.e<-lce))throw Error(v4e+Xd(t));return t}function mrt(t,s){var r,n,a,o,l,i,c,u,p,f,y=t.constructor,_=y.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new y(t),Ac?Al(s,_):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(_/hc),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)+V_(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+V_(-a-1)+o,r&&(n=r-l)>0&&(o+=V_(n))):a>=l?(o+=V_(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+V_(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=V_(n))),t.s<0?"-"+o:o}function pOe(t,s){if(t.length>s)return t.length=s,!0}function prt(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(nS+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 mOe(l,o.toString())}else if(typeof o!="string")throw Error(nS+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,rcs.test(o))mOe(l,o);else throw Error(nS+o)}if(a.prototype=Jn,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=prt,a.config=a.set=ncs,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(nS+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(nS+r+": "+n);return this}var _4e=prt(scs);rf=new _4e(1);const gl=_4e;function acs(t){return ccs(t)||lcs(t)||ocs(t)||ics()}function ics(){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 ocs(t,s){if(t){if(typeof t=="string")return I_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 I_e(t,s)}}function lcs(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function ccs(t){if(Array.isArray(t))return I_e(t)}function I_e(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=s?r.apply(void 0,a):t(s-l,fOe(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 kcs(t){if(Array.isArray(t))return t}function vrt(t){var s=gD(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function _rt(t,s,r){if(t.lte(0))return new gl(0);var n=_he.getDigitCount(t.toNumber()),a=new gl(10).pow(n),o=t.div(a),l=n!==1?.05:.1,i=new gl(Math.ceil(o.div(l).toNumber())).add(r).mul(l),c=i.mul(a);return s?c:new gl(Math.ceil(c))}function Ncs(t,s,r){var n=1,a=new gl(t);if(!a.isint()&&r){var o=Math.abs(t);o<1?(n=new gl(10).pow(_he.getDigitCount(t)-1),a=new gl(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new gl(Math.floor(t)))}else t===0?a=new gl(Math.floor((s-1)/2)):r||(a=new gl(Math.floor(t)));var l=Math.floor((s-1)/2),i=mcs(hcs(function(c){return a.add(new gl(c-l).mul(n)).toNumber()}),L_e);return i(0,s)}function brt(t,s,r,n){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((s-t)/(r-1)))return{step:new gl(0),tickMin:new gl(0),tickMax:new gl(0)};var o=_rt(new gl(s).sub(t).div(r-1),n,a),l;t<=0&&s>=0?l=new gl(0):(l=new gl(t).add(s).div(2),l=l.sub(new gl(l).mod(o)));var i=Math.ceil(l.sub(t).div(o).toNumber()),c=Math.ceil(new gl(s).sub(l).div(o).toNumber()),u=i+c+1;return u>r?brt(t,s,r,n,a+1):(u0?c+(r-u):c,i=s>0?i:i+(r-u)),{step:o,tickMin:l.sub(new gl(i).mul(o)),tickMax:l.add(new gl(c).mul(o))})}function Scs(t){var s=gD(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=vrt([r,n]),c=gD(i,2),u=c[0],p=c[1];if(u===-1/0||p===1/0){var f=p===1/0?[u].concat(O_e(L_e(0,a-1).map(function(){return 1/0}))):[].concat(O_e(L_e(0,a-1).map(function(){return-1/0})),[p]);return r>n?D_e(f):f}if(u===p)return Ncs(u,a,o);var y=brt(u,p,l,o),_=y.step,b=y.tickMin,w=y.tickMax,j=_he.rangeStep(b,w.add(new gl(.1).mul(_)),_);return r>n?D_e(j):j}function Ccs(t,s){var r=gD(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=vrt([n,a]),i=gD(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=_rt(new gl(u).sub(c).div(p-1),o,0),y=[].concat(O_e(_he.rangeStep(new gl(c),new gl(u).sub(new gl(.99).mul(f)),f)),[u]);return n>a?D_e(y):y}var Mcs=xrt(Scs),Tcs=xrt(Ccs),Acs="Invariant failed";function DS(t,s){throw new Error(Acs)}var Ecs=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function BT(t){"@babel/helpers - typeof";return BT=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},BT(t)}function cce(){return cce=Object.assign?Object.assign.bind():function(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Fcs(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 zcs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Bcs(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,y=u>=i-1?a[0].coordinate:a[u+1].coordinate,_=void 0;if(wm(f-p)!==wm(y-f)){var b=[];if(wm(y-f)===wm(c[1]-c[0])){_=y;var w=f+c[1]-c[0];b[0]=Math.min(w,(w+p)/2),b[1]=Math.max(w,(w+p)/2)}else{_=p;var j=y+c[1]-c[0];b[0]=Math.min(f,(j+f)/2),b[1]=Math.max(f,(j+f)/2)}var N=[Math.min(f,(_+f)/2),Math.max(f,(_+f)/2)];if(s>N[0]&&s<=N[1]||s>=b[0]&&s<=b[1]){l=a[u].index;break}}else{var S=Math.min(p,y),T=Math.max(p,y);if(s>(S+f)/2&&s<=(T+f)/2){l=a[u].index;break}}}else for(var I=0;I0&&I(n[I].coordinate+n[I-1].coordinate)/2&&s<=(n[I].coordinate+n[I+1].coordinate)/2||I===i-1&&s>(n[I].coordinate+n[I-1].coordinate)/2){l=n[I].index;break}return l},b4e=function(s){var r,n=s,a=n.type.displayName,o=(r=s.type)!==null&&r!==void 0&&r.defaultProps?id(id({},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},rds=function(s){var r=s.barSize,n=s.totalSize,a=s.stackGroups,o=a===void 0?{}:a;if(!o)return{};for(var l={},i=Object.keys(o),c=0,u=i.length;c=0});if(N&&N.length){var S=N[0].type.defaultProps,T=S!==void 0?id(id({},S),N[0].props):N[0].props,I=T.barSize,L=T[j];l[L]||(l[L]=[]);var R=Ri(I)?r:I;l[L].push({item:N[0],stackList:N.slice(1),barSize:Ri(R)?void 0:jm(R,n,0)})}}return l},nds=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=jm(r,a,0,!0),p,f=[];if(l[0].barSize===+l[0].barSize){var y=!1,_=a/c,b=l.reduce(function(I,L){return I+L.barSize||0},0);b+=(c-1)*u,b>=a&&(b-=(c-1)*u,u=0),b>=a&&_>0&&(y=!0,_*=.9,b=c*_);var w=(a-b)/2>>0,j={offset:w-u,size:0};p=l.reduce(function(I,L){var R={item:L.item,position:{offset:j.offset+j.size+u,size:y?_:L.barSize}},$=[].concat(yOe(I),[R]);return j=$[$.length-1].position,L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){$.push({item:q,position:j})}),$},f)}else{var N=jm(n,a,0,!0);a-2*N-(c-1)*u<=0&&(u=0);var S=(a-2*N-(c-1)*u)/c;S>1&&(S>>=0);var T=i===+i?Math.min(S,i):S;p=l.reduce(function(I,L,R){var $=[].concat(yOe(I),[{item:L.item,position:{offset:N+(S+u)*R+(S-T)/2,size:T}}]);return L.stackList&&L.stackList.length&&L.stackList.forEach(function(q){$.push({item:q,position:$[$.length-1].position})}),$},f)}return p},ads=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,c=l-(i.left||0)-(i.right||0),u=Nrt({children:o,legendWidth:c});if(u){var p=a||{},f=p.width,y=p.height,_=u.align,b=u.verticalAlign,w=u.layout;if((w==="vertical"||w==="horizontal"&&b==="middle")&&_!=="center"&&sn(s[_]))return id(id({},s),{},qM({},_,s[_]+(f||0)));if((w==="horizontal"||w==="vertical"&&_==="center")&&b!=="middle"&&sn(s[b]))return id(id({},s),{},qM({},b,s[b]+(y||0)))}return s},ids=function(s,r,n){return Ri(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},Srt=function(s,r,n,a,o){var l=r.props.children,i=ff(l,HO).filter(function(u){return ids(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=hu(p,n);if(Ri(f))return u;var y=Array.isArray(f)?[yhe(f),xhe(f)]:[f,f],_=c.reduce(function(b,w){var j=hu(p,w,0),N=y[0]-Math.abs(Array.isArray(j)?j[0]:j),S=y[1]+Math.abs(Array.isArray(j)?j[1]:j);return[Math.min(N,b[0]),Math.max(S,b[1])]},[1/0,-1/0]);return[Math.min(_[0],u[0]),Math.max(_[1],u[1])]},[1/0,-1/0])}return null},ods=function(s,r,n,a,o){var l=r.map(function(i){return Srt(s,i,n,o,a)}).filter(function(i){return!Ri(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},Crt=function(s,r,n,a,o){var l=r.map(function(c){var u=c.props.dataKey;return n==="number"&&u&&Srt(s,c,u,a)||ZL(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?wm(i[0]-i[1])*2*u:u,r&&(s.ticks||s.niceTicks)){var p=(s.ticks||s.niceTicks).map(function(f){var y=o?o.indexOf(f):f;return{coordinate:a(y)+u,value:f,offset:u}});return p.filter(function(f){return!RO(f.coordinate)})}return s.isCategorical&&s.categoricalDomain?s.categoricalDomain.map(function(f,y){return{coordinate:a(f)+u,value:f,index:y,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,y){return{coordinate:a(f)+u,value:o?o[f]:f,index:y,offset:u}})},Kxe=new WeakMap,fz=function(s,r){if(typeof r!="function")return s;Kxe.has(s)||Kxe.set(s,new WeakMap);var n=Kxe.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},Art=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:dD(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:nce(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:KL(),realScaleType:"point"}:o==="category"?{scale:dD(),realScaleType:"band"}:{scale:nce(),realScaleType:"linear"};if(ES(a)){var c="scale".concat(rhe(a));return{scale:(hOe[c]||KL)(),realScaleType:hOe[c]?c:"point"}}return ji(a)?{scale:a}:{scale:KL(),realScaleType:"point"}},_Oe=1e-4,Ert=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])-_Oe,l=Math.max(a[0],a[1])+_Oe,i=s(r[0]),c=s(r[n-1]);(il||cl)&&s.domain([r[0],r[n-1]])}},lds=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])}},uds=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)}},hds={sign:dds,expand:EYt,none:PT,silhouette:PYt,wiggle:IYt,positive:uds},mds=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=hds[n],l=AYt().keys(a).value(function(i,c){return+hu(i,c,0)}).order(d_e).offset(o);return l(s)},pds=function(s,r,n,a,o,l){if(!s)return null;var i=l?r.reverse():r,c={},u=i.reduce(function(f,y){var _,b=(_=y.type)!==null&&_!==void 0&&_.defaultProps?id(id({},y.type.defaultProps),y.props):y.props,w=b.stackId,j=b.hide;if(j)return f;var N=b[n],S=f[N]||{hasStack:!1,stackGroups:{}};if(pu(w)){var T=S.stackGroups[w]||{numericAxisId:n,cateAxisId:a,items:[]};T.items.push(y),S.hasStack=!0,S.stackGroups[w]=T}else S.stackGroups[QA("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[y]};return id(id({},f),{},qM({},N,S))},c),p={};return Object.keys(u).reduce(function(f,y){var _=u[y];if(_.hasStack){var b={};_.stackGroups=Object.keys(_.stackGroups).reduce(function(w,j){var N=_.stackGroups[j];return id(id({},w),{},qM({},j,{numericAxisId:n,cateAxisId:a,items:N.items,stackedData:mds(s,N.items,o)}))},b)}return id(id({},f),{},qM({},y,_))},p)},Prt=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=Mcs(u,o,i);return s.domain([yhe(p),xhe(p)]),{niceTicks:p}}if(o&&a==="number"){var f=s.domain(),y=Tcs(f,o,i);return{niceTicks:y}}return null};function bOe(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&&!Ri(a[s.dataKey])){var i=Rle(r,"value",a[s.dataKey]);if(i)return i.coordinate+n/2}return r[o]?r[o].coordinate+n/2:null}var c=hu(a,Ri(l)?s.dataKey:l);return Ri(c)?null:s.scale(c)}var wOe=function(s){var r=s.axis,n=s.ticks,a=s.offset,o=s.bandSize,l=s.entry,i=s.index;if(r.type==="category")return n[i]?n[i].coordinate+a:null;var c=hu(l,r.dataKey,r.domain[i]);return Ri(c)?null:r.scale(c)-o/2+a},fds=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]},gds=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?id(id({},s.type.defaultProps),s.props):s.props,o=a.stackId;if(pu(o)){var l=r[o];if(l){var i=l.items.indexOf(s);return i>=0?l.stackedData[i]:null}}return null},xds=function(s){return s.reduce(function(r,n){return[yhe(n.concat([r[0]]).filter(sn)),xhe(n.concat([r[1]]).filter(sn))]},[1/0,-1/0])},Irt=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=xds(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})},jOe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,kOe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,B_e=function(s,r,n){if(ji(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(sn(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(jOe.test(s[0])){var o=+jOe.exec(s[0])[1];a[0]=r[0]-o}else ji(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(sn(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(kOe.test(s[1])){var l=+kOe.exec(s[1])[1];a[1]=r[1]+l}else ji(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},uce=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=ZNe(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},Sds=function(s,r,n,a,o){var l=s.width,i=s.height,c=s.startAngle,u=s.endAngle,p=jm(s.cx,l,l/2),f=jm(s.cy,i,i/2),y=Ort(l,i,n),_=jm(s.innerRadius,y,0),b=jm(s.outerRadius,y,y*.8),w=Object.keys(r);return w.reduce(function(j,N){var S=r[N],T=S.domain,I=S.reversed,L;if(Ri(S.range))a==="angleAxis"?L=[c,u]:a==="radiusAxis"&&(L=[_,b]),I&&(L=[L[1],L[0]]);else{L=S.range;var R=L,$=_ds(R,2);c=$[0],u=$[1]}var q=Art(S,o),U=q.realScaleType,V=q.scale;V.domain(T).range(L),Ert(V);var X=Prt(V,Sv(Sv({},S),{},{realScaleType:U})),se=Sv(Sv(Sv({},S),X),{},{range:L,radius:b,realScaleType:U,scale:V,cx:p,cy:f,innerRadius:_,outerRadius:b,startAngle:c,endAngle:u});return Sv(Sv({},j),{},Drt({},N,se))},{})},Cds=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))},Mds=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=Cds({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:Nds(u),angleInRadian:u}},Tds=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}},Ads=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},MOe=function(s,r){var n=s.x,a=s.y,o=Mds({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=Tds(r),f=p.startAngle,y=p.endAngle,_=i,b;if(f<=y){for(;_>y;)_-=360;for(;_=f&&_<=y}else{for(;_>f;)_-=360;for(;_=y&&_<=f}return b?Sv(Sv({},r),{},{radius:l,angle:Ads(_,r)}):null},Rrt=function(s){return!C.isValidElement(s)&&!ji(s)&&typeof s!="boolean"?s.className:""};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)}var Eds=["offset"];function Pds(t){return Ods(t)||Dds(t)||Lds(t)||Ids()}function Ids(){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 Lds(t,s){if(t){if(typeof t=="string")return $_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(t,s)}}function Dds(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Ods(t){if(Array.isArray(t))return $_e(t)}function $_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 Fds(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function TOe(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 nu(t){for(var s=1;s=0?1:-1,T,I;a==="insideStart"?(T=_+S*l,I=w):a==="insideEnd"?(T=b-S*l,I=!w):a==="end"&&(T=b+S*l,I=w),I=N<=0?I:!I;var L=Yl(u,p,j,T),R=Yl(u,p,j,T+(I?1:-1)*359),$="M".concat(L.x,",").concat(L.y,` A`).concat(j,",").concat(j,",0,1,").concat(I?0:1,`, `).concat(R.x,",").concat(R.y),q=Ri(s.id)?QA("recharts-radial-line-"):s.id;return ht.createElement("text",bD({},n,{dominantBaseline:"central",className:Bi("recharts-radial-bar-label",i)}),ht.createElement("defs",null,ht.createElement("path",{id:q,d:$})),ht.createElement("textPath",{xlinkHref:"#".concat(q)},r))},Hds=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,y=(p+f)/2;if(a==="outside"){var _=Yl(l,i,u+n,y),b=_.x,w=_.y;return{x:b,y:w,textAnchor:b>=l?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:l,y:i,textAnchor:"middle",verticalAnchor:"end"};var j=(c+u)/2,N=Yl(l,i,j,y),S=N.x,T=N.y;return{x:S,y:T,textAnchor:"middle",verticalAnchor:"middle"}},Wds=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,y=f*a,_=f>0?"end":"start",b=f>0?"start":"end",w=u>=0?1:-1,j=w*a,N=w>0?"end":"start",S=w>0?"start":"end";if(o==="top"){var T={x:i+u/2,y:c-f*a,textAnchor:"middle",verticalAnchor:_};return nu(nu({},T),n?{height:Math.max(c-n.y,0),width:u}:{})}if(o==="bottom"){var I={x:i+u/2,y:c+p+y,textAnchor:"middle",verticalAnchor:b};return nu(nu({},I),n?{height:Math.max(n.y+n.height-(c+p),0),width:u}:{})}if(o==="left"){var L={x:i-j,y:c+p/2,textAnchor:N,verticalAnchor:"middle"};return nu(nu({},L),n?{width:Math.max(L.x-n.x,0),height:p}:{})}if(o==="right"){var R={x:i+u+j,y:c+p/2,textAnchor:S,verticalAnchor:"middle"};return nu(nu({},R),n?{width:Math.max(n.x+n.width-R.x,0),height:p}:{})}var $=n?{width:u,height:p}:{};return o==="insideLeft"?nu({x:i+j,y:c+p/2,textAnchor:S,verticalAnchor:"middle"},$):o==="insideRight"?nu({x:i+u-j,y:c+p/2,textAnchor:N,verticalAnchor:"middle"},$):o==="insideTop"?nu({x:i+u/2,y:c+y,textAnchor:"middle",verticalAnchor:b},$):o==="insideBottom"?nu({x:i+u/2,y:c+p-y,textAnchor:"middle",verticalAnchor:_},$):o==="insideTopLeft"?nu({x:i+j,y:c+y,textAnchor:S,verticalAnchor:b},$):o==="insideTopRight"?nu({x:i+u-j,y:c+y,textAnchor:N,verticalAnchor:b},$):o==="insideBottomLeft"?nu({x:i+j,y:c+p-y,textAnchor:S,verticalAnchor:_},$):o==="insideBottomRight"?nu({x:i+u-j,y:c+p-y,textAnchor:N,verticalAnchor:_},$):KA(o)&&(sn(o.x)||y4(o.x))&&(sn(o.y)||y4(o.y))?nu({x:i+jm(o.x,u),y:c+jm(o.y,p),textAnchor:"end",verticalAnchor:"end"},$):nu({x:i+u/2,y:c+p/2,textAnchor:"middle",verticalAnchor:"middle"},$)},Gds=function(s){return"cx"in s&&sn(s.cx)};function Uu(t){var s=t.offset,r=s===void 0?5:s,n=Rds(t,Eds),a=nu({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,y=a.textBreakAll;if(!o||Ri(i)&&Ri(c)&&!C.isValidElement(u)&&!ji(u))return null;if(C.isValidElement(u))return C.cloneElement(u,a);var _;if(ji(u)){if(_=C.createElement(u,a),C.isValidElement(_))return _}else _=qds(a);var b=Gds(o),w=ti(a,!0);if(b&&(l==="insideStart"||l==="insideEnd"||l==="end"))return Vds(a,_,w);var j=b?Hds(a):Wds(a);return ht.createElement(IS,bD({className:Bi("recharts-label",f)},w,j,{breakAll:y}),_)}Uu.displayName="Label";var Frt=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,y=s.y,_=s.top,b=s.left,w=s.width,j=s.height,N=s.clockWise,S=s.labelViewBox;if(S)return S;if(sn(w)&&sn(j)){if(sn(f)&&sn(y))return{x:f,y,width:w,height:j};if(sn(_)&&sn(b))return{x:_,y:b,width:w,height:j}}return sn(f)&&sn(y)?{x:f,y,width:0,height:0}:sn(r)&&sn(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:u||0,outerRadius:p||c||i||0,clockWise:N}:s.viewBox?s.viewBox:{}},Kds=function(s,r){return s?s===!0?ht.createElement(Uu,{key:"label-implicit",viewBox:r}):pu(s)?ht.createElement(Uu,{key:"label-implicit",viewBox:r,value:s}):C.isValidElement(s)?s.type===Uu?C.cloneElement(s,{key:"label-implicit",viewBox:r}):ht.createElement(Uu,{key:"label-implicit",content:s,viewBox:r}):ji(s)?ht.createElement(Uu,{key:"label-implicit",content:s,viewBox:r}):KA(s)?ht.createElement(Uu,bD({viewBox:r},s,{key:"label-implicit"})):null:null},Zds=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=Frt(s),l=ff(a,Uu).map(function(c,u){return C.cloneElement(c,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=Kds(s.label,r||o);return[i].concat(Pds(l))};Uu.parseViewBox=Frt;Uu.renderCallByParent=Zds;function Yds(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var Xds=Yds;const Qds=Co(Xds);function wD(t){"@babel/helpers - typeof";return wD=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},wD(t)}var Jds=["valueAccessor"],eus=["data","dataKey","clockWise","id","textBreakAll"];function tus(t){return aus(t)||nus(t)||rus(t)||sus()}function sus(){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 rus(t,s){if(t){if(typeof t=="string")return q_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 q_e(t,s)}}function nus(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function aus(t){if(Array.isArray(t))return q_e(t)}function q_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 cus(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 dus=function(s){return Array.isArray(s.value)?Qds(s.value):s.value};function u1(t){var s=t.valueAccessor,r=s===void 0?dus:s,n=POe(t,Jds),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,c=n.textBreakAll,u=POe(n,eus);return!a||!a.length?null:ht.createElement(qo,{className:"recharts-label-list"},a.map(function(p,f){var y=Ri(o)?r(p,f):hu(p&&p.payload,o),_=Ri(i)?{}:{id:"".concat(i,"-").concat(f)};return ht.createElement(Uu,mce({},ti(p,!0),u,_,{parentViewBox:p.parentViewBox,value:y,textBreakAll:c,viewBox:Uu.parseViewBox(Ri(l)?p:EOe(EOe({},p),{},{clockWise:l})),key:"label-".concat(f),index:f}))}))}u1.displayName="LabelList";function uus(t,s){return t?t===!0?ht.createElement(u1,{key:"labelList-implicit",data:s}):ht.isValidElement(t)||ji(t)?ht.createElement(u1,{key:"labelList-implicit",data:s,content:t}):KA(t)?ht.createElement(u1,mce({data:s},t,{key:"labelList-implicit"})):null:null}function hus(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=ff(n,u1).map(function(l,i){return C.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=uus(t.label,s);return[o].concat(tus(a))}u1.renderCallByParent=hus;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 U_e(){return U_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 _=Yl(r,n,a,l),b=Yl(r,n,a,u);y+="L ".concat(b.x,",").concat(b.y,` A `).concat(a,",").concat(a,`,0, `).concat(+(Math.abs(c)>180),",").concat(+(l<=u),`, `).concat(_.x,",").concat(_.y," Z")}else y+="L ".concat(r,",").concat(n," Z");return y},xus=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=wm(p-u),y=gz({cx:r,cy:n,radius:o,angle:u,sign:f,cornerRadius:l,cornerIsExternal:c}),_=y.circleTangency,b=y.lineTangency,w=y.theta,j=gz({cx:r,cy:n,radius:o,angle:p,sign:-f,cornerRadius:l,cornerIsExternal:c}),N=j.circleTangency,S=j.lineTangency,T=j.theta,I=c?Math.abs(u-p):Math.abs(u-p)-w-T;if(I<0)return i?"M ".concat(b.x,",").concat(b.y,` a`).concat(l,",").concat(l,",0,0,1,").concat(l*2,`,0 a`).concat(l,",").concat(l,",0,0,1,").concat(-l*2,`,0 `):zrt({cx:r,cy:n,innerRadius:a,outerRadius:o,startAngle:u,endAngle:p});var L="M ".concat(b.x,",").concat(b.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(_.x,",").concat(_.y,` A`).concat(o,",").concat(o,",0,").concat(+(I>180),",").concat(+(f<0),",").concat(N.x,",").concat(N.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(S.x,",").concat(S.y,` `);if(a>0){var R=gz({cx:r,cy:n,radius:a,angle:u,sign:f,isExternal:!0,cornerRadius:l,cornerIsExternal:c}),$=R.circleTangency,q=R.lineTangency,U=R.theta,V=gz({cx:r,cy:n,radius:a,angle:p,sign:-f,isExternal:!0,cornerRadius:l,cornerIsExternal:c}),X=V.circleTangency,se=V.lineTangency,ee=V.theta,Q=c?Math.abs(u-p):Math.abs(u-p)-U-ee;if(Q<0&&l===0)return"".concat(L,"L").concat(r,",").concat(n,"Z");L+="L".concat(se.x,",").concat(se.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(X.x,",").concat(X.y,` A`).concat(a,",").concat(a,",0,").concat(+(Q>180),",").concat(+(f>0),",").concat($.x,",").concat($.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(q.x,",").concat(q.y,"Z")}else L+="L".concat(r,",").concat(n,"Z");return L},yus={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},Brt=function(s){var r=LOe(LOe({},yus),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,y=r.className;if(l0&&Math.abs(p-f)<360?j=xus({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(w,b/2),forceCornerRadius:c,cornerIsExternal:u,startAngle:p,endAngle:f}):j=zrt({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:p,endAngle:f}),ht.createElement("path",U_e({},ti(r,!0),{className:_,d:j,role:"img"}))};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 V_e(){return V_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 Rus(t,s){return rC(t.getTime(),s.getTime())}function Fus(t,s){return t.name===s.name&&t.message===s.message&&t.cause===s.cause&&t.stack===s.stack}function zus(t,s){return t===s}function qOe(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 y=l.value,_=i.value;if(r.equals(y[0],_[0],c,f,t,s,r)&&r.equals(y[1],_[1],y[0],_[0],t,s,r)){p=a[f]=!0;break}f++}if(!p)return!1;c++}return!0}var Bus=rC;function $us(t,s,r){var n=$Oe(t),a=n.length;if($Oe(s).length!==a)return!1;for(;a-- >0;)if(!Vrt(t,s,r,n[a]))return!1;return!0}function q6(t,s,r){var n=zOe(t),a=n.length;if(zOe(s).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],!Vrt(t,s,r,o)||(l=BOe(t,o),i=BOe(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function qus(t,s){return rC(t.valueOf(),s.valueOf())}function Uus(t,s){return t.source===s.source&&t.flags===s.flags}function UOe(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 Vus(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 Hus(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 Vrt(t,s,r,n){return(n===Dus||n===Lus||n===Ius)&&(t.$$typeof||s.$$typeof)?!0:Pus(s,n)&&r.equals(t[n],s[n],n,n,t,s,r)}var Wus="[object Arguments]",Gus="[object Boolean]",Kus="[object Date]",Zus="[object Error]",Yus="[object Map]",Xus="[object Number]",Qus="[object Object]",Jus="[object RegExp]",ehs="[object Set]",ths="[object String]",shs="[object URL]",rhs=Array.isArray,VOe=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,HOe=Object.assign,nhs=Object.prototype.toString.call.bind(Object.prototype.toString);function ahs(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,y=t.areUrlsEqual;return function(b,w,j){if(b===w)return!0;if(b==null||w==null)return!1;var N=typeof b;if(N!==typeof w)return!1;if(N!=="object")return N==="number"?l(b,w,j):N==="function"?a(b,w,j):!1;var S=b.constructor;if(S!==w.constructor)return!1;if(S===Object)return i(b,w,j);if(rhs(b))return s(b,w,j);if(VOe!=null&&VOe(b))return f(b,w,j);if(S===Date)return r(b,w,j);if(S===RegExp)return u(b,w,j);if(S===Map)return o(b,w,j);if(S===Set)return p(b,w,j);var T=nhs(b);return T===Kus?r(b,w,j):T===Jus?u(b,w,j):T===Yus?o(b,w,j):T===ehs?p(b,w,j):T===Qus?typeof b.then!="function"&&typeof w.then!="function"&&i(b,w,j):T===shs?y(b,w,j):T===Zus?n(b,w,j):T===Wus?i(b,w,j):T===Gus||T===Xus||T===ths?c(b,w,j):!1}}function ihs(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?q6:Ous,areDatesEqual:Rus,areErrorsEqual:Fus,areFunctionsEqual:zus,areMapsEqual:n?FOe(qOe,q6):qOe,areNumbersEqual:Bus,areObjectsEqual:n?q6:$us,arePrimitiveWrappersEqual:qus,areRegExpsEqual:Uus,areSetsEqual:n?FOe(UOe,q6):UOe,areTypedArraysEqual:n?q6:Vus,areUrlsEqual:Hus};if(r&&(a=HOe({},a,r(a))),s){var o=yz(a.areArraysEqual),l=yz(a.areMapsEqual),i=yz(a.areObjectsEqual),c=yz(a.areSetsEqual);a=HOe({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:c})}return a}function ohs(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function lhs(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,y=f===void 0?s?new WeakMap:void 0:f,_=p.meta;return r(c,u,{cache:y,equals:a,meta:_,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 chs=L2();L2({strict:!0});L2({circular:!0});L2({circular:!0,strict:!0});L2({createInternalComparator:function(){return rC}});L2({strict:!0,createInternalComparator:function(){return rC}});L2({circular:!0,createInternalComparator:function(){return rC}});L2({circular:!0,createInternalComparator:function(){return rC},strict:!0});function L2(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=ihs(t),c=ahs(i),u=n?n(c):ohs(c);return lhs({circular:r,comparator:c,createState:a,equals:u,strict:l})}function dhs(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function WOe(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):dhs(a)};requestAnimationFrame(n)}function H_e(t){"@babel/helpers - typeof";return H_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},H_e(t)}function uhs(t){return fhs(t)||phs(t)||mhs(t)||hhs()}function hhs(){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 mhs(t,s){if(t){if(typeof t=="string")return GOe(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 GOe(t,s)}}function GOe(t,s){(s==null||s>t.length)&&(s=t.length);for(var r=0,n=new Array(s);rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r1?1:N<0?0:N},w=function(N){for(var S=N>1?1:N,T=S,I=0;I<8;++I){var L=f(T)-S,R=_(T);if(Math.abs(L-S)0&&arguments[0]!==void 0?arguments[0]:{},r=s.stiff,n=r===void 0?100:r,a=s.damping,o=a===void 0?8:a,l=s.dt,i=l===void 0?17:l,c=function(p,f,y){var _=-(p-f)*n,b=y*o,w=y+(_-b)*i/1e3,j=y*i/1e3+p;return Math.abs(j-f)t.length)&&(s=t.length);for(var r=0,n=new Array(s);r=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Whs(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 Zxe(t){return Yhs(t)||Zhs(t)||Khs(t)||Ghs()}function Ghs(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Khs(t,s){if(t){if(typeof t=="string")return Y_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 Y_e(t,s)}}function Zhs(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Yhs(t){if(Array.isArray(t))return Y_e(t)}function Y_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 xce(t){return xce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},xce(t)}var N0=function(t){tms(r,t);var s=sms(r);function r(n,a){var o;Xhs(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,y=l.children,_=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(J_e(o)),o.changeStyle=o.changeStyle.bind(J_e(o)),!i||_<=0)return o.state={style:{}},typeof y=="function"&&(o.state={style:p}),Q_e(o);if(f&&f.length)o.state={style:f[0].style};else if(u){if(typeof y=="function")return o.state={style:u},Q_e(o);o.state={style:c?cI({},c,u):u}}else o.state={style:{}};return o}return Jhs(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,y=this.state.style;if(i){if(!l){var _={style:c?cI({},c,p):p};this.state&&y&&(c&&y[c]!==p||!c&&y!==p)&&this.setState(_);return}if(!(chs(a.to,p)&&a.canBegin&&a.isActive)){var b=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var w=b||u?f:a.to;if(this.state&&y){var j={style:c?cI({},c,w):w};(c&&y[c]!==w||!c&&y!==w)&&this.setState(j)}this.runAnimation(yx(yx({},this.props),{},{from:w,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var o=this,l=a.from,i=a.to,c=a.duration,u=a.easing,p=a.begin,f=a.onAnimationEnd,y=a.onAnimationStart,_=Uhs(l,i,Phs(u),c,this.changeStyle),b=function(){o.stopJSAnimation=_()};this.manager.start([y,p,b,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,y=f===void 0?0:f,_=function(w,j,N){if(N===0)return w;var S=j.duration,T=j.easing,I=T===void 0?"ease":T,L=j.style,R=j.properties,$=j.onAnimationEnd,q=N>0?l[N-1]:j,U=R||Object.keys(L);if(typeof I=="function"||I==="spring")return[].concat(Zxe(w),[o.runJSAnimation.bind(o,{from:q.style,to:L,duration:S,easing:I}),S]);var V=YOe(U,S,I),X=yx(yx(yx({},q.style),L),{},{transition:V});return[].concat(Zxe(w),[X,S,$]).filter(_hs)};return this.manager.start([c].concat(Zxe(l.reduce(_,[p,Math.max(y,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=ghs());var o=a.begin,l=a.duration,i=a.attributeName,c=a.to,u=a.easing,p=a.onAnimationStart,f=a.onAnimationEnd,y=a.steps,_=a.children,b=this.manager;if(this.unSubscribe=b.subscribe(this.handleStyleChange),typeof u=="function"||typeof _=="function"||u==="spring"){this.runJSAnimation(a);return}if(y.length>1){this.runStepAnimation(a);return}var w=i?cI({},i,c):c,j=YOe(Object.keys(w),l,u);b.start([p,o,yx(yx({},w),{},{transition:j}),l,f])}},{key:"render",value:function(){var a=this.props,o=a.children;a.begin;var l=a.duration;a.attributeName,a.easing;var i=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var c=Hhs(a,Vhs),u=C.Children.count(o),p=this.state.style;if(typeof o=="function")return o(p);if(!i||u===0||l<=0)return o;var f=function(_){var b=_.props,w=b.style,j=w===void 0?{}:w,N=b.className,S=C.cloneElement(_,yx(yx({},c),{},{style:yx(yx({},j),p),className:N}));return S};return u===1?f(C.Children.only(o)):ht.createElement("div",null,C.Children.map(o,function(y){return f(y)}))}}]),r}(C.PureComponent);N0.displayName="Animate";N0.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};N0.propTypes={from:Jo.oneOfType([Jo.object,Jo.string]),to:Jo.oneOfType([Jo.object,Jo.string]),attributeName:Jo.string,duration:Jo.number,begin:Jo.number,easing:Jo.oneOfType([Jo.string,Jo.func]),steps:Jo.arrayOf(Jo.shape({duration:Jo.number.isRequired,style:Jo.object.isRequired,easing:Jo.oneOfType([Jo.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),Jo.func]),properties:Jo.arrayOf("string"),onAnimationEnd:Jo.func})),children:Jo.oneOfType([Jo.node,Jo.func]),isActive:Jo.bool,canBegin:Jo.bool,onAnimationEnd:Jo.func,shouldReAnimate:Jo.bool,onAnimationStart:Jo.func,onAnimationReStart:Jo.func};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 yce(){return yce=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],y=0,_=4;y<_;y++)f[y]=o[y]>l?l:o[y];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 b=Math.min(l,o);p="M ".concat(s,",").concat(r+i*b,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+c*b,",").concat(r,` L `).concat(s+n-c*b,",").concat(r,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+n,",").concat(r+i*b,` L `).concat(s+n,",").concat(r+a-i*b,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s+n-c*b,",").concat(r+a,` L `).concat(s+c*b,",").concat(r+a,` A `).concat(b,",").concat(b,",0,0,").concat(u,",").concat(s,",").concat(r+a-i*b," Z")}else p="M ".concat(s,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return p},hms=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),y=Math.max(l,l+c);return n>=u&&n<=p&&a>=f&&a<=y}return!1},mms={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=nRe(nRe({},mms),s),n=C.useRef(),a=C.useState(-1),o=nms(a,2),l=o[0],i=o[1];C.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var I=n.current.getTotalLength();I&&i(I)}catch{}},[]);var c=r.x,u=r.y,p=r.width,f=r.height,y=r.radius,_=r.className,b=r.animationEasing,w=r.animationDuration,j=r.animationBegin,N=r.isAnimationActive,S=r.isUpdateAnimationActive;if(c!==+c||u!==+u||p!==+p||f!==+f||p===0||f===0)return null;var T=Bi("recharts-rectangle",_);return S?ht.createElement(N0,{canBegin:l>0,from:{width:p,height:f,x:c,y:u},to:{width:p,height:f,x:c,y:u},duration:w,animationEasing:b,isActive:S},function(I){var L=I.width,R=I.height,$=I.x,q=I.y;return ht.createElement(N0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:j,duration:w,isActive:N,easing:b},ht.createElement("path",yce({},ti(r,!0),{className:T,d:aRe($,q,L,R,y),ref:n})))}):ht.createElement("path",yce({},ti(r,!0),{className:T,d:aRe(c,u,p,f,y)}))},pms=["points","className","baseLinePoints","connectNulls"];function V5(){return V5=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 gms(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 _ms(t)||vms(t)||yms(t)||xms()}function xms(){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 yms(t,s){if(t){if(typeof t=="string")return ebe(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 ebe(t,s)}}function vms(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function _ms(t){if(Array.isArray(t))return ebe(t)}function ebe(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){oRe(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),oRe(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},XL=function(s,r){var n=bms(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},wms=function(s,r,n){var a=XL(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(XL(r.reverse(),n).slice(1))},jms=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=fms(s,pms);if(!r||!r.length)return null;var i=Bi("recharts-polygon",n);if(a&&a.length){var c=l.stroke&&l.stroke!=="none",u=wms(r,a,o);return ht.createElement("g",{className:i},ht.createElement("path",V5({},ti(l,!0),{fill:u.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:u})),c?ht.createElement("path",V5({},ti(l,!0),{fill:"none",d:XL(r,o)})):null,c?ht.createElement("path",V5({},ti(l,!0),{fill:"none",d:XL(a,o)})):null)}var p=XL(r,o);return ht.createElement("path",V5({},ti(l,!0),{fill:p.slice(-1)==="Z"?l.fill:"none",className:i,d:p}))};function tbe(){return tbe=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 Ams(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 Ems=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},Pms=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,y=s.height,_=y===void 0?0:y,b=s.className,w=Tms(s,kms),j=Nms({x:n,y:o,top:i,left:u,width:f,height:_},w);return!sn(n)||!sn(o)||!sn(f)||!sn(_)||!sn(i)||!sn(u)?null:ht.createElement("path",sbe({},ti(j,!0),{className:Bi("recharts-cross",b),d:Ems(n,o,f,_,i,u)}))},Ims=ghe,Lms=lrt,Dms=I0;function Oms(t,s){return t&&t.length?Ims(t,Dms(s),Lms):void 0}var Rms=Oms;const Fms=Co(Rms);var zms=ghe,Bms=I0,$ms=crt;function qms(t,s){return t&&t.length?zms(t,Bms(s),$ms):void 0}var Ums=qms;const Vms=Co(Ums);var Hms=["cx","cy","angle","ticks","axisLine"],Wms=["ticks","tick","angle","tickFormatter","stroke"];function qT(t){"@babel/helpers - typeof";return qT=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},qT(t)}function QL(){return QL=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 Gms(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 Kms(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function uRe(t,s){for(var r=0;rpRe?l=a==="outer"?"start":"end":o<-pRe?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=Lw(Lw({},ti(this.props,!1)),{},{fill:"none"},ti(i,!1));if(c==="circle")return ht.createElement(bhe,n4({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:o,r:l}));var p=this.props.ticks,f=p.map(function(y){return Yl(a,o,l,y.coordinate)});return ht.createElement(jms,n4({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=ti(this.props,!1),f=ti(l,!1),y=Lw(Lw({},p),{},{fill:"none"},ti(i,!1)),_=o.map(function(b,w){var j=n.getTickLineCoord(b),N=n.getTickTextAnchor(b),S=Lw(Lw(Lw({textAnchor:N},p),{},{stroke:"none",fill:u},f),{},{index:w,payload:b,x:j.x2,y:j.y2});return ht.createElement(qo,n4({className:Bi("recharts-polar-angle-axis-tick",Rrt(l)),key:"tick-".concat(b.coordinate)},PS(n.props,b,w)),i&&ht.createElement("line",n4({className:"recharts-polar-angle-axis-tick-line"},y,j)),l&&s.renderTickItem(l,S,c?c(b.value,w):b.value))});return ht.createElement(qo,{className:"recharts-polar-angle-axis-ticks"},_)}},{key:"render",value:function(){var n=this.props,a=n.ticks,o=n.radius,l=n.axisLine;return o<=0||!a||!a.length?null:ht.createElement(qo,{className:Bi("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):ji(n)?l=n(a):l=ht.createElement(IS,n4({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(C.PureComponent);khe(Nhe,"displayName","PolarAngleAxis");khe(Nhe,"axisType","angleAxis");khe(Nhe,"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 cps=nst,dps=cps(Object.getPrototypeOf,Object),ups=dps,hps=P1,mps=ups,pps=I1,fps="[object Object]",gps=Function.prototype,xps=Object.prototype,tnt=gps.toString,yps=xps.hasOwnProperty,vps=tnt.call(Object);function _ps(t){if(!pps(t)||hps(t)!=fps)return!1;var s=mps(t);if(s===null)return!0;var r=yps.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&tnt.call(r)==vps}var bps=_ps;const wps=Co(bps);var jps=P1,kps=I1,Nps="[object Boolean]";function Sps(t){return t===!0||t===!1||kps(t)&&jps(t)==Nps}var Cps=Sps;const Mps=Co(Cps);function TD(t){"@babel/helpers - typeof";return TD=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},TD(t)}function bce(){return bce=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:y,x:c,y:u},to:{upperWidth:p,lowerWidth:f,height:y,x:c,y:u},duration:w,animationEasing:b,isActive:N},function(T){var I=T.upperWidth,L=T.lowerWidth,R=T.height,$=T.x,q=T.y;return ht.createElement(N0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:j,duration:w,easing:b},ht.createElement("path",bce({},ti(r,!0),{className:S,d:yRe($,q,I,L,R),ref:n})))}):ht.createElement("g",null,ht.createElement("path",bce({},ti(r,!0),{className:S,d:yRe(c,u,p,f,y)})))},zps=["option","shapeType","propTransformer","activeClassName","isActive"];function AD(t){"@babel/helpers - typeof";return AD=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},AD(t)}function Bps(t,s){if(t==null)return{};var r=$ps(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 $ps(t,s){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(s.indexOf(n)>=0)continue;r[n]=t[n]}return r}function vRe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function wce(t){for(var s=1;s0?pf(T,"paddingAngle",0):0;if(L){var $=Qp(L.endAngle-L.startAngle,T.endAngle-T.startAngle),q=zl(zl({},T),{},{startAngle:S+R,endAngle:S+$(w)+R});j.push(q),S=q.endAngle}else{var U=T.endAngle,V=T.startAngle,X=Qp(0,U-V),se=X(w),ee=zl(zl({},T),{},{startAngle:S+R,endAngle:S+se+R});j.push(ee),S=ee.endAngle}}),ht.createElement(qo,null,n.renderSectorsStatically(j))})}},{key:"attachKeyboardHandlers",value:function(n){var a=this;n.onkeydown=function(o){if(!o.altKey)switch(o.key){case"ArrowLeft":{var l=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"ArrowRight":{var i=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[i].focus(),a.setState({sectorToFocus:i});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,a=n.sectors,o=n.isAnimationActive,l=this.state.prevSectors;return o&&a&&a.length&&(!l||!VO(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,y=a.outerRadius,_=a.isAnimationActive,b=this.state.isAnimationFinished;if(o||!l||!l.length||!sn(u)||!sn(p)||!sn(f)||!sn(y))return null;var w=Bi("recharts-pie",i);return ht.createElement(qo,{tabIndex:this.props.rootTabIndex,className:w,ref:function(N){n.pieRef=N}},this.renderSectors(),c&&this.renderLabels(l),Uu.renderCallByParent(this.props,null,!1),(!_||b)&&u1.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,I=j-S*_-T,L=a.reduce(function(q,U){var V=hu(U,N,0);return q+(sn(V)?V:0)},0),R;if(L>0){var $;R=a.map(function(q,U){var V=hu(q,N,0),X=hu(q,p,U),se=(sn(V)?V:0)/L,ee;U?ee=$.endAngle+wm(w)*c*(V!==0?1:0):ee=l;var Q=ee+wm(w)*((V!==0?_:0)+se*I),de=(ee+Q)/2,re=(b.innerRadius+b.outerRadius)/2,ne=[{name:X,value:V,payload:q,dataKey:N,type:y}],le=Yl(b.cx,b.cy,re,de);return $=zl(zl(zl({percent:se,cornerRadius:o,name:X,tooltipPayload:ne,midAngle:de,middleRadius:re,tooltipPosition:le},q),b),{},{value:hu(q,N),startAngle:ee,endAngle:Q,payload:q,paddingAngle:wm(w)*c}),$})}return zl(zl({},b),{},{sectors:R,data:a})});var lfs=Math.ceil,cfs=Math.max;function dfs(t,s,r,n){for(var a=-1,o=cfs(lfs((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var ufs=dfs,hfs=jst,jRe=1/0,mfs=17976931348623157e292;function pfs(t){if(!t)return t===0?t:0;if(t=hfs(t),t===jRe||t===-jRe){var s=t<0?-1:1;return s*mfs}return t===t?t:0}var ant=pfs,ffs=ufs,gfs=che,Yxe=ant;function xfs(t){return function(s,r,n){return n&&typeof n!="number"&&gfs(s,r,n)&&(r=n=void 0),s=Yxe(s),r===void 0?(r=s,s=0):r=Yxe(r),n=n===void 0?s0&&n.handleDrag(a.changedTouches[0])}),Gp(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()}),Gp(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),Gp(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),Gp(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),Gp(n,"handleSlideDragStart",function(a){var o=MRe(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 Efs(s,t),Cfs(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),y=Math.max(a,o),_=s.getIndexInRange(l,f),b=s.getIndexInRange(l,y);return{startIndex:_-_%c,endIndex:b===p?p:b-b%c}}},{key:"getTextOfTick",value:function(n){var a=this.props,o=a.data,l=a.tickFormatter,i=a.dataKey,c=hu(o[n],i,n);return ji(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,y=c.startIndex,_=c.endIndex,b=c.onChange,w=n.pageX-o;w>0?w=Math.min(w,u+p-f-i,u+p-f-l):w<0&&(w=Math.max(w,u-l,u-i));var j=this.getIndex({startX:l+w,endX:i+w});(j.startIndex!==y||j.endIndex!==_)&&b&&b(j),this.setState({startX:l+w,endX:i+w,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=MRe(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,y=p.width,_=p.travellerWidth,b=p.onChange,w=p.gap,j=p.data,N={startX:this.state.startX,endX:this.state.endX},S=n.pageX-o;S>0?S=Math.min(S,f+y-_-u):S<0&&(S=Math.max(S,f-u)),N[l]=u+S;var T=this.getIndex(N),I=T.startIndex,L=T.endIndex,R=function(){var q=j.length-1;return l==="startX"&&(i>c?I%w===0:L%w===0)||ic?L%w===0:I%w===0)||i>c&&L===q};this.setState(Gp(Gp({},l,u+S),"brushMoveStartX",n.pageX),function(){b&&R()&&b(T)})}},{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 y=f+n;if(!(y===-1||y>=i.length)){var _=i[y];a==="startX"&&_>=u||a==="endX"&&_<=c||this.setState(Gp({},a,_),function(){o.props.onChange(o.getIndex({startX:o.state.startX,endX:o.state.endX}))})}}}},{key:"renderBackground",value:function(){var n=this.props,a=n.x,o=n.y,l=n.width,i=n.height,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=C.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,y=c.traveller,_=c.ariaLabel,b=c.data,w=c.startIndex,j=c.endIndex,N=Math.max(n,this.props.x),S=Xxe(Xxe({},ti(this.props,!1)),{},{x:N,y:u,width:p,height:f}),T=_||"Min value: ".concat((o=b[w])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=b[j])===null||l===void 0?void 0:l.name);return ht.createElement(qo,{tabIndex:0,role:"slider","aria-label":T,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(L){["ArrowLeft","ArrowRight"].includes(L.key)&&(L.preventDefault(),L.stopPropagation(),i.handleTravellerMoveKeyboard(L.key==="ArrowRight"?1:-1,a))},onFocus:function(){i.setState({isTravellerFocused:!0})},onBlur:function(){i.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},s.renderTraveller(y,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,y=p.endX,_=5,b={pointerEvents:"none",fill:u};return ht.createElement(qo,{className:"recharts-brush-texts"},ht.createElement(IS,Nce({textAnchor:"end",verticalAnchor:"middle",x:Math.min(f,y)-_,y:l+i/2},b),this.getTextOfTick(a)),ht.createElement(IS,Nce({textAnchor:"start",verticalAnchor:"middle",x:Math.max(f,y)+c+_,y:l+i/2},b),this.getTextOfTick(o)))}},{key:"render",value:function(){var n=this.props,a=n.data,o=n.className,l=n.children,i=n.x,c=n.y,u=n.width,p=n.height,f=n.alwaysShowText,y=this.state,_=y.startX,b=y.endX,w=y.isTextActive,j=y.isSlideMoving,N=y.isTravellerMoving,S=y.isTravellerFocused;if(!a||!a.length||!sn(i)||!sn(c)||!sn(u)||!sn(p)||u<=0||p<=0)return null;var T=Bi("recharts-brush",o),I=ht.Children.count(l)===1,L=Nfs("userSelect","none");return ht.createElement(qo,{className:T,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:L},this.renderBackground(),I&&this.renderPanorama(),this.renderSlide(_,b),this.renderTravellerLayer(_,"startX"),this.renderTravellerLayer(b,"endX"),(w||j||N||S||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):ji(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 Xxe({prevData:o,prevTravellerWidth:c,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?Ifs({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 y=a.scale.domain().map(function(_){return a.scale(_)});return{prevData:o,prevTravellerWidth:c,prevUpdateId:u,prevX:i,prevWidth:l,startX:a.scale(n.startIndex),endX:a.scale(n.endIndex),scaleValues:y}}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}}])}(C.PureComponent);Gp(WT,"displayName","Brush");Gp(WT,"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 Lfs=KNe;function Dfs(t,s){var r;return Lfs(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var Ofs=Dfs,Rfs=Ytt,Ffs=I0,zfs=Ofs,Bfs=Cp,$fs=che;function qfs(t,s,r){var n=Bfs(t)?Rfs:zfs;return r&&$fs(t,s,r)&&(s=void 0),n(t,Ffs(s))}var Ufs=qfs;const Vfs=Co(Ufs);var f0=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},TRe=yst;function Hfs(t,s,r){s=="__proto__"&&TRe?TRe(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var Wfs=Hfs,Gfs=Wfs,Kfs=gst,Zfs=I0;function Yfs(t,s){var r={};return s=Zfs(s),Kfs(t,function(n,a,o){Gfs(r,a,s(n,a,o))}),r}var Xfs=Yfs;const Qfs=Co(Xfs);function Jfs(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 ggs(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 xgs(t,s){var r=t.x,n=t.y,a=fgs(t,ugs),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),y=parseInt(f,10);return U6(U6(U6(U6(U6({},s),a),l?{x:l}:{}),c?{y:c}:{}),{},{height:p,width:y,name:s.name,radius:s.radius})}function ERe(t){return ht.createElement(snt,obe({shapeType:"rectangle",propTransformer:xgs,activeClassName:"recharts-active-bar"},t))}var ygs=function(s){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(n,a){if(typeof s=="number")return s;var o=sn(n)||UKt(n);return o?s(n,a):(o||DS(),r)}},vgs=["value","background"],dnt;function GT(t){"@babel/helpers - typeof";return GT=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},GT(t)}function _gs(t,s){if(t==null)return{};var r=bgs(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 bgs(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 Cce(){return Cce=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(de)0&&Math.abs(Q)0&&(ee=Math.min((We||0)-(Q[be-1]||0),ee))}),Number.isFinite(ee)){var de=ee/se,re=w.layout==="vertical"?n.height:n.width;if(w.padding==="gap"&&($=de*re/2),w.padding==="no-gap"){var ne=jm(s.barCategoryGap,de*re),le=de*re/2;$=le-ne-(le-ne)/re*ne}}}a==="xAxis"?q=[n.left+(T.left||0)+($||0),n.left+n.width-(T.right||0)-($||0)]:a==="yAxis"?q=c==="horizontal"?[n.top+n.height-(T.bottom||0),n.top+(T.top||0)]:[n.top+(T.top||0)+($||0),n.top+n.height-(T.bottom||0)-($||0)]:q=w.range,L&&(q=[q[1],q[0]]);var he=Art(w,o,y),we=he.scale,ye=he.realScaleType;we.domain(N).range(q),Ert(we);var je=Prt(we,Ex(Ex({},w),{},{realScaleType:ye}));a==="xAxis"?(X=j==="top"&&!I||j==="bottom"&&I,U=n.left,V=f[R]-X*w.height):a==="yAxis"&&(X=j==="left"&&!I||j==="right"&&I,U=f[R]-X*w.width,V=n.top);var ke=Ex(Ex(Ex({},w),je),{},{realScaleType:ye,x:U,y:V,scale:we,width:a==="xAxis"?n.width:w.width,height:a==="yAxis"?n.height:w.height});return ke.bandSize=uce(ke,je),!w.hide&&a==="xAxis"?f[R]+=(X?-1:1)*ke.height:w.hide||(f[R]+=(X?-1:1)*ke.width),Ex(Ex({},_),{},Mhe({},b,ke))},{})},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)}},Pgs=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})},gnt=function(){function t(s){Tgs(this,t),this.scale=s}return Ags(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)}}])}();Mhe(gnt,"EPS",1e-4);var j4e=function(s){var r=Object.keys(s).reduce(function(n,a){return Ex(Ex({},n),{},Mhe({},a,gnt.create(s[a])))},{});return Ex(Ex({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return Qfs(a,function(c,u){return r[u].apply(c,{bandAware:l,position:i})})},isInRange:function(a){return cnt(a,function(o,l){return r[l].isInRange(o)})}})};function Igs(t){return(t%180+180)%180}var Lgs=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=Igs(a),l=o*Math.PI/180,i=Math.atan(n/r),c=l>i&&l-1?a[o?s[l]:l]:void 0}}var zgs=Fgs,Bgs=ant;function $gs(t){var s=Bgs(t),r=s%1;return s===s?r?s-r:s:0}var qgs=$gs,Ugs=dst,Vgs=I0,Hgs=qgs,Wgs=Math.max;function Ggs(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:Hgs(r);return a<0&&(a=Wgs(n+a,0)),Ugs(t,Vgs(s),a)}var Kgs=Ggs,Zgs=zgs,Ygs=Kgs,Xgs=Zgs(Ygs),Qgs=Xgs;const Jgs=Co(Qgs);var exs=ZGt(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=C.createContext(void 0),N4e=C.createContext(void 0),xnt=C.createContext(void 0),ynt=C.createContext({}),vnt=C.createContext(void 0),_nt=C.createContext(0),bnt=C.createContext(0),ORe=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=exs(o);return ht.createElement(k4e.Provider,{value:n},ht.createElement(N4e.Provider,{value:a},ht.createElement(ynt.Provider,{value:o},ht.createElement(xnt.Provider,{value:p},ht.createElement(vnt.Provider,{value:l},ht.createElement(_nt.Provider,{value:u},ht.createElement(bnt.Provider,{value:c},i)))))))},txs=function(){return C.useContext(vnt)},wnt=function(s){var r=C.useContext(k4e);r==null&&DS();var n=r[s];return n==null&&DS(),n},sxs=function(){var s=C.useContext(k4e);return Q_(s)},rxs=function(){var s=C.useContext(N4e),r=Jgs(s,function(n){return cnt(n.domain,Number.isFinite)});return r||Q_(s)},jnt=function(s){var r=C.useContext(N4e);r==null&&DS();var n=r[s];return n==null&&DS(),n},nxs=function(){var s=C.useContext(xnt);return s},axs=function(){return C.useContext(ynt)},S4e=function(){return C.useContext(bnt)},C4e=function(){return C.useContext(_nt)};function KT(t){"@babel/helpers - typeof";return KT=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},KT(t)}function ixs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function oxs(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 qxs(t,s){return Ant(t,s+1)}function Uxs(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 b=n==null?void 0:n[c];if(b===void 0)return{v:Ant(n,u)};var w=c,j,N=function(){return j===void 0&&(j=r(b,w)),j},S=b.coordinate,T=c===0||Pce(t,S,N,p,i);T||(c=0,p=l,u+=1),T&&(p=S+t*(N()/2+a),c+=u)},y;u<=o.length;)if(y=f(),y)return y.v;return[]}function DD(t){"@babel/helpers - typeof";return DD=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},DD(t)}function VRe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);s&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Ah(t){for(var s=1;s0?_.coordinate-j*t:_.coordinate})}else o[y]=_=Ah(Ah({},_),{},{tickCoord:_.coordinate});var N=Pce(t,_.tickCoord,w,i,c);N&&(c=_.tickCoord-t*(w()/2+a),o[y]=Ah(Ah({},_),{},{isShow:!0}))},p=l-1;p>=0;p--)u(p);return o}function Kxs(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),y=t*(p.coordinate+t*f/2-u);l[i-1]=p=Ah(Ah({},p),{},{tickCoord:y>0?p.coordinate-y*t:p.coordinate});var _=Pce(t,p.tickCoord,function(){return f},c,u);_&&(u=p.tickCoord-t*(f/2+a),l[i-1]=Ah(Ah({},p),{},{isShow:!0}))}for(var b=o?i-1:i,w=function(S){var T=l[S],I,L=function(){return I===void 0&&(I=r(T,S)),I};if(S===0){var R=t*(T.coordinate-t*L()/2-c);l[S]=T=Ah(Ah({},T),{},{tickCoord:R<0?T.coordinate-R*t:T.coordinate})}else l[S]=T=Ah(Ah({},T),{},{tickCoord:T.coordinate});var $=Pce(t,T.tickCoord,L,c,u);$&&(c=T.tickCoord+t*(L()/2+a),l[S]=Ah(Ah({},T),{},{isShow:!0}))},j=0;j=2?wm(a[1].coordinate-a[0].coordinate):1,N=$xs(o,j,_);return c==="equidistantPreserveStart"?Uxs(j,N,w,a,l):(c==="preserveStart"||c==="preserveStartEnd"?y=Kxs(j,N,w,a,l,c==="preserveStartEnd"):y=Gxs(j,N,w,a,l),y.filter(function(S){return S.isShow}))}var Zxs=["viewBox"],Yxs=["viewBox"],Xxs=["ticks"];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 W5(){return W5=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 Qxs(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 Jxs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function WRe(t,s){for(var r=0;r0?c(this.props):c(_)),l<=0||i<=0||!b||!b.length?null:ht.createElement(qo,{className:Bi("recharts-cartesian-axis",u),ref:function(j){n.layerReference=j}},o&&this.renderAxisLine(),this.renderTicks(b,this.state.fontSize,this.state.letterSpacing),Uu.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,o){var l,i=Bi(a.className,"recharts-cartesian-axis-tick-value");return ht.isValidElement(n)?l=ht.cloneElement(n,ru(ru({},a),{},{className:i})):ji(n)?l=n(ru(ru({},a),{},{className:i})):l=ht.createElement(IS,W5({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(C.Component);E4e(aE,"displayName","CartesianAxis");E4e(aE,"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 iys=["x1","y1","x2","y2","key"],oys=["offset"];function OS(t){"@babel/helpers - typeof";return OS=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},OS(t)}function GRe(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 Ih(t){for(var s=1;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function uys(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 hys=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 Int(t,s){var r;if(ht.isValidElement(t))r=ht.cloneElement(t,s);else if(ji(t))r=t(s);else{var n=s.x1,a=s.y1,o=s.x2,l=s.y2,i=s.key,c=KRe(s,iys),u=ti(c,!1);u.offset;var p=KRe(u,oys);r=ht.createElement("line",b4({},p,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function mys(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=Ih(Ih({},t),{},{x1:s,y1:i,x2:s+r,y2:i,key:"line-".concat(c),index:c});return Int(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function pys(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=Ih(Ih({},t),{},{x1:i,y1:s,x2:i,y2:s+r,key:"line-".concat(c),index:c});return Int(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function fys(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(y){return Math.round(y+a-a)}).sort(function(y,_){return y-_});a!==p[0]&&p.unshift(0);var f=p.map(function(y,_){var b=!p[_+1],w=b?a+l-y:p[_+1]-y;if(w<=0)return null;var j=_%s.length;return ht.createElement("rect",{key:"react-".concat(_),y,x:n,height:w,width:o,stroke:"none",fill:s[j],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function gys(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(y){return Math.round(y+o-o)}).sort(function(y,_){return y-_});o!==p[0]&&p.unshift(0);var f=p.map(function(y,_){var b=!p[_+1],w=b?o+i-y:p[_+1]-y;if(w<=0)return null;var j=_%n.length;return ht.createElement("rect",{key:"react-".concat(_),x:y,y:l,width:w,height:c,stroke:"none",fill:n[j],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var xys=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return Trt(A4e(Ih(Ih(Ih({},aE.defaultProps),n),{},{ticks:Hv(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},yys=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return Trt(A4e(Ih(Ih(Ih({},aE.defaultProps),n),{},{ticks:Hv(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},l5={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function Lnt(t){var s,r,n,a,o,l,i=S4e(),c=C4e(),u=axs(),p=Ih(Ih({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:l5.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:l5.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:l5.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:l5.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:l5.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:l5.verticalFill,x:sn(t.x)?t.x:u.left,y:sn(t.y)?t.y:u.top,width:sn(t.width)?t.width:u.width,height:sn(t.height)?t.height:u.height}),f=p.x,y=p.y,_=p.width,b=p.height,w=p.syncWithTicks,j=p.horizontalValues,N=p.verticalValues,S=sxs(),T=rxs();if(!sn(_)||_<=0||!sn(b)||b<=0||!sn(f)||f!==+f||!sn(y)||y!==+y)return null;var I=p.verticalCoordinatesGenerator||xys,L=p.horizontalCoordinatesGenerator||yys,R=p.horizontalPoints,$=p.verticalPoints;if((!R||!R.length)&&ji(L)){var q=j&&j.length,U=L({yAxis:T?Ih(Ih({},T),{},{ticks:q?j:T.ticks}):void 0,width:i,height:c,offset:u},q?!0:w);Yx(Array.isArray(U),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(OS(U),"]")),Array.isArray(U)&&(R=U)}if((!$||!$.length)&&ji(I)){var V=N&&N.length,X=I({xAxis:S?Ih(Ih({},S),{},{ticks:V?N:S.ticks}):void 0,width:i,height:c,offset:u},V?!0:w);Yx(Array.isArray(X),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(OS(X),"]")),Array.isArray(X)&&($=X)}return ht.createElement("g",{className:"recharts-cartesian-grid"},ht.createElement(hys,{fill:p.fill,fillOpacity:p.fillOpacity,x:p.x,y:p.y,width:p.width,height:p.height,ry:p.ry}),ht.createElement(mys,b4({},p,{offset:u,horizontalPoints:R,xAxis:S,yAxis:T})),ht.createElement(pys,b4({},p,{offset:u,verticalPoints:$,xAxis:S,yAxis:T})),ht.createElement(fys,b4({},p,{horizontalPoints:R})),ht.createElement(gys,b4({},p,{verticalPoints:$})))}Lnt.displayName="CartesianGrid";var vys=["type","layout","connectNulls","ref"],_ys=["key"];function QT(t){"@babel/helpers - typeof";return QT=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},QT(t)}function ZRe(t,s){if(t==null)return{};var r=bys(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 bys(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 JL(){return JL=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){_=[].concat(c5(c.slice(0,b)),[f-w]);break}var j=_.length%2===0?[0,y]:[y];return[].concat(c5(s.repeat(c,p)),c5(_),j).map(function(N){return"".concat(N,"px")}).join(", ")}),Px(r,"id",QA("recharts-line-")),Px(r,"pathRef",function(l){r.mainCurve=l}),Px(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),Px(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return Eys(s,t),Cys(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=ff(p,HO);if(!f)return null;var y=function(w,j){return{x:w.x,y:w.y,value:w.value,errorVal:hu(w.payload,j)}},_={clipPath:n?"url(#clipPath-".concat(a,")"):null};return ht.createElement(qo,_,f.map(function(b){return ht.cloneElement(b,{key:"bar-".concat(b.props.dataKey),data:l,xAxis:i,yAxis:c,layout:u,dataPointFormatter:y})}))}},{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=ti(this.props,!1),y=ti(c,!0),_=u.map(function(w,j){var N=Wp(Wp(Wp({key:"dot-".concat(j),r:3},f),y),{},{index:j,cx:w.x,cy:w.y,value:w.value,dataKey:p,payload:w.payload,points:u});return s.renderDotItem(c,N)}),b={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return ht.createElement(qo,JL({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=ZRe(i,vys),y=Wp(Wp(Wp({},ti(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(pce,JL({},y,{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,y=l.animationEasing,_=l.animationId,b=l.animateNewValues,w=l.width,j=l.height,N=this.state,S=N.prevPoints,T=N.totalLength;return ht.createElement(N0,{begin:p,duration:f,isActive:u,easing:y,from:{t:0},to:{t:1},key:"line-".concat(_),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(I){var L=I.t;if(S){var R=S.length/i.length,$=i.map(function(se,ee){var Q=Math.floor(ee*R);if(S[Q]){var de=S[Q],re=Qp(de.x,se.x),ne=Qp(de.y,se.y);return Wp(Wp({},se),{},{x:re(L),y:ne(L)})}if(b){var le=Qp(w*2,se.x),he=Qp(j/2,se.y);return Wp(Wp({},se),{},{x:le(L),y:he(L)})}return Wp(Wp({},se),{},{x:se.x,y:se.y})});return o.renderCurveStatically($,n,a)}var q=Qp(0,T),U=q(L),V;if(c){var X="".concat(c).split(/[,\s]+/gim).map(function(se){return parseFloat(se)});V=o.getStrokeDasharray(U,T,X)}else V=o.generateSimpleStrokeDasharray(T,U);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||!VO(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,y=a.left,_=a.width,b=a.height,w=a.isAnimationActive,j=a.id;if(o||!i||!i.length)return null;var N=this.state.isAnimationFinished,S=i.length===1,T=Bi("recharts-line",c),I=u&&u.allowDataOverflow,L=p&&p.allowDataOverflow,R=I||L,$=Ri(j)?this.id:j,q=(n=ti(l,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},U=q.r,V=U===void 0?3:U,X=q.strokeWidth,se=X===void 0?2:X,ee=tZt(l)?l:{},Q=ee.clipDot,de=Q===void 0?!0:Q,re=V*2+se;return ht.createElement(qo,{className:T},I||L?ht.createElement("defs",null,ht.createElement("clipPath",{id:"clipPath-".concat($)},ht.createElement("rect",{x:I?y:y-_/2,y:L?f:f-b/2,width:I?_:_*2,height:L?b:b*2})),!de&&ht.createElement("clipPath",{id:"clipPath-dots-".concat($)},ht.createElement("rect",{x:y-re/2,y:f-re/2,width:_+re,height:b+re}))):null,!S&&this.renderCurve(R,$),this.renderErrorBar(R,$),(S||l)&&this.renderDots(R,de,$),(!w||N)&&u1.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(c5(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 _0s(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 b0s(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function w0s(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&sn(a)&&sn(o)?s.slice(a,o+1):[]};function Ynt(t){return t==="number"?[0,"auto"]:void 0}var Sbe=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=Ihe(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 y;if(l.dataKey&&!l.allowDuplicatedCategory){var _=f===void 0?i:f;y=Rle(_,l.dataKey,a)}else y=f&&f[n]||i[n];return y?[].concat(sA(c),[Lrt(u,y)]):c},[])},rFe=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=L0s(o,n),i=s.orderedTooltipTicks,c=s.tooltipAxis,u=s.tooltipTicks,p=sds(l,i,u,c);if(p>=0&&u){var f=u[p]&&u[p].value,y=Sbe(s,r,p,f),_=D0s(n,i,p,o);return{activeTooltipIndex:p,activeLabel:f,activePayload:y,activeCoordinate:_}}return null},O0s=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,y=s.stackOffset,_=Mrt(p,o);return n.reduce(function(b,w){var j,N=w.type.defaultProps!==void 0?vr(vr({},w.type.defaultProps),w.props):w.props,S=N.type,T=N.dataKey,I=N.allowDataOverflow,L=N.allowDuplicatedCategory,R=N.scale,$=N.ticks,q=N.includeHidden,U=N[l];if(b[U])return b;var V=Ihe(s.data,{graphicalItems:a.filter(function(je){var ke,We=l in je.props?je.props[l]:(ke=je.type.defaultProps)===null||ke===void 0?void 0:ke[l];return We===U}),dataStartIndex:c,dataEndIndex:u}),X=V.length,se,ee,Q;l0s(N.domain,I,S)&&(se=B_e(N.domain,null,I),_&&(S==="number"||R!=="auto")&&(Q=ZL(V,T,"category")));var de=Ynt(S);if(!se||se.length===0){var re,ne=(re=N.domain)!==null&&re!==void 0?re:de;if(T){if(se=ZL(V,T,S),S==="category"&&_){var le=HKt(se);L&&le?(ee=se,se=kce(0,X)):L||(se=NOe(ne,se,w).reduce(function(je,ke){return je.indexOf(ke)>=0?je:[].concat(sA(je),[ke])},[]))}else if(S==="category")L?se=se.filter(function(je){return je!==""&&!Ri(je)}):se=NOe(ne,se,w).reduce(function(je,ke){return je.indexOf(ke)>=0||ke===""||Ri(ke)?je:[].concat(sA(je),[ke])},[]);else if(S==="number"){var he=ods(V,a.filter(function(je){var ke,We,be=l in je.props?je.props[l]:(ke=je.type.defaultProps)===null||ke===void 0?void 0:ke[l],Me="hide"in je.props?je.props.hide:(We=je.type.defaultProps)===null||We===void 0?void 0:We.hide;return be===U&&(q||!Me)}),T,o,p);he&&(se=he)}_&&(S==="number"||R!=="auto")&&(Q=ZL(V,T,"category"))}else _?se=kce(0,X):i&&i[U]&&i[U].hasStack&&S==="number"?se=y==="expand"?[0,1]:Irt(i[U].stackGroups,c,u):se=Crt(V,a.filter(function(je){var ke=l in je.props?je.props[l]:je.type.defaultProps[l],We="hide"in je.props?je.props.hide:je.type.defaultProps.hide;return ke===U&&(q||!We)}),S,p,!0);if(S==="number")se=jbe(f,se,U,o,$),ne&&(se=B_e(ne,se,I));else if(S==="category"&&ne){var we=ne,ye=se.every(function(je){return we.indexOf(je)>=0});ye&&(se=we)}}return vr(vr({},b),{},ci({},U,vr(vr({},N),{},{axisType:o,domain:se,categoricalDomain:Q,duplicateDomain:ee,originalDomain:(j=N.domain)!==null&&j!==void 0?j:de,isCategorical:_,layout:p})))},{})},R0s=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,y=Ihe(s.data,{graphicalItems:n,dataStartIndex:c,dataEndIndex:u}),_=y.length,b=Mrt(p,o),w=-1;return n.reduce(function(j,N){var S=N.type.defaultProps!==void 0?vr(vr({},N.type.defaultProps),N.props):N.props,T=S[l],I=Ynt("number");if(!j[T]){w++;var L;return b?L=kce(0,_):i&&i[T]&&i[T].hasStack?(L=Irt(i[T].stackGroups,c,u),L=jbe(f,L,T,o)):(L=B_e(I,Crt(y,n.filter(function(R){var $,q,U=l in R.props?R.props[l]:($=R.type.defaultProps)===null||$===void 0?void 0:$[l],V="hide"in R.props?R.props.hide:(q=R.type.defaultProps)===null||q===void 0?void 0:q.hide;return U===T&&!V}),"number",p),a.defaultProps.allowDataOverflow),L=jbe(f,L,T,o)),vr(vr({},j),{},ci({},T,vr(vr({axisType:o},a.defaultProps),{},{hide:!0,orientation:pf(P0s,"".concat(o,".").concat(w%2),null),domain:L,originalDomain:I,isCategorical:b,layout:p})))}return j},{})},F0s=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"),y=ff(p,o),_={};return y&&y.length?_=O0s(s,{axes:y,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:c,dataEndIndex:u}):l&&l.length&&(_=R0s(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:c,dataEndIndex:u})),_},z0s=function(s){var r=Q_(s),n=Hv(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:ZNe(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:uce(r,n)}},nFe=function(s){var r=s.children,n=s.defaultShowTooltip,a=Zp(r,WT),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}},B0s=function(s){return!s||!s.length?!1:s.some(function(r){var n=c1(r&&r.type);return n&&n.indexOf("Bar")>=0})},aFe=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"}},$0s=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,y=n.margin||{},_=Zp(f,WT),b=Zp(f,zM),w=Object.keys(c).reduce(function(L,R){var $=c[R],q=$.orientation;return!$.mirror&&!$.hide?vr(vr({},L),{},ci({},q,L[q]+$.width)):L},{left:y.left||0,right:y.right||0}),j=Object.keys(l).reduce(function(L,R){var $=l[R],q=$.orientation;return!$.mirror&&!$.hide?vr(vr({},L),{},ci({},q,pf(L,"".concat(q))+$.height)):L},{top:y.top||0,bottom:y.bottom||0}),N=vr(vr({},j),w),S=N.bottom;_&&(N.bottom+=_.props.height||WT.defaultProps.height),b&&r&&(N=ads(N,a,n,r));var T=u-N.left-N.right,I=p-N.top-N.bottom;return vr(vr({brushBottom:S},N),{},{width:Math.max(T,0),height:Math.max(I,0)})},q0s=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},P4e=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,y=function(N,S){var T=S.graphicalItems,I=S.stackGroups,L=S.offset,R=S.updateId,$=S.dataStartIndex,q=S.dataEndIndex,U=N.barSize,V=N.layout,X=N.barGap,se=N.barCategoryGap,ee=N.maxBarSize,Q=aFe(V),de=Q.numericAxisName,re=Q.cateAxisName,ne=B0s(T),le=[];return T.forEach(function(he,we){var ye=Ihe(N.data,{graphicalItems:[he],dataStartIndex:$,dataEndIndex:q}),je=he.type.defaultProps!==void 0?vr(vr({},he.type.defaultProps),he.props):he.props,ke=je.dataKey,We=je.maxBarSize,be=je["".concat(de,"Id")],Me=je["".concat(re,"Id")],Ae={},Re=c.reduce(function(ot,Ue){var Ke=S["".concat(Ue.axisType,"Map")],Xe=je["".concat(Ue.axisType,"Id")];Ke&&Ke[Xe]||Ue.axisType==="zAxis"||DS();var He=Ke[Xe];return vr(vr({},ot),{},ci(ci({},Ue.axisType,He),"".concat(Ue.axisType,"Ticks"),Hv(He)))},Ae),Te=Re[re],qe=Re["".concat(re,"Ticks")],ct=I&&I[be]&&I[be].hasStack&&gds(he,I[be].stackGroups),De=c1(he.type).indexOf("Bar")>=0,Rt=uce(Te,qe),pe=[],Je=ne&&rds({barSize:U,stackGroups:I,totalSize:q0s(Re,re)});if(De){var lt,rt,Se=Ri(We)?ee:We,it=(lt=(rt=uce(Te,qe,!0))!==null&&rt!==void 0?rt:Se)!==null&<!==void 0?lt:0;pe=nds({barGap:X,barCategoryGap:se,bandSize:it!==Rt?it:Rt,sizeList:Je[Me],maxBarSize:Se}),it!==Rt&&(pe=pe.map(function(ot){return vr(vr({},ot),{},{position:vr(vr({},ot.position),{},{offset:ot.position.offset-it/2})})}))}var $e=he&&he.type&&he.type.getComposedData;$e&&le.push({props:vr(vr({},$e(vr(vr({},Re),{},{displayedData:ye,props:N,dataKey:ke,item:he,bandSize:Rt,barPosition:pe,offset:L,stackedData:ct,layout:V,dataStartIndex:$,dataEndIndex:q}))),{},ci(ci(ci({key:he.key||"item-".concat(we)},de,Re[de]),re,Re[re]),"animationId",R)),childIndex:nZt(he,N.children),item:he})}),le},_=function(N,S){var T=N.props,I=N.dataStartIndex,L=N.dataEndIndex,R=N.updateId;if(!y8e({props:T}))return null;var $=T.children,q=T.layout,U=T.stackOffset,V=T.data,X=T.reverseStackOrder,se=aFe(q),ee=se.numericAxisName,Q=se.cateAxisName,de=ff($,n),re=pds(V,de,"".concat(ee,"Id"),"".concat(Q,"Id"),U,X),ne=c.reduce(function(je,ke){var We="".concat(ke.axisType,"Map");return vr(vr({},je),{},ci({},We,F0s(T,vr(vr({},ke),{},{graphicalItems:de,stackGroups:ke.axisType===ee&&re,dataStartIndex:I,dataEndIndex:L}))))},{}),le=$0s(vr(vr({},ne),{},{props:T,graphicalItems:de}),S==null?void 0:S.legendBBox);Object.keys(ne).forEach(function(je){ne[je]=p(T,ne[je],le,je.replace("Map",""),r)});var he=ne["".concat(Q,"Map")],we=z0s(he),ye=y(T,vr(vr({},ne),{},{dataStartIndex:I,dataEndIndex:L,updateId:R,graphicalItems:de,stackGroups:re,offset:le}));return vr(vr({formattedGraphicalItems:ye,graphicalItems:de,offset:le,stackGroups:re},we),ne)},b=function(j){function N(S){var T,I,L;return b0s(this,N),L=k0s(this,N,[S]),ci(L,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),ci(L,"accessibilityManager",new o0s),ci(L,"handleLegendBBoxUpdate",function(R){if(R){var $=L.state,q=$.dataStartIndex,U=$.dataEndIndex,V=$.updateId;L.setState(vr({legendBBox:R},_({props:L.props,dataStartIndex:q,dataEndIndex:U,updateId:V},vr(vr({},L.state),{},{legendBBox:R}))))}}),ci(L,"handleReceiveSyncEvent",function(R,$,q){if(L.props.syncId===R){if(q===L.eventEmitterSymbol&&typeof L.props.syncMethod!="function")return;L.applySyncEvent($)}}),ci(L,"handleBrushChange",function(R){var $=R.startIndex,q=R.endIndex;if($!==L.state.dataStartIndex||q!==L.state.dataEndIndex){var U=L.state.updateId;L.setState(function(){return vr({dataStartIndex:$,dataEndIndex:q},_({props:L.props,dataStartIndex:$,dataEndIndex:q,updateId:U},L.state))}),L.triggerSyncEvent({dataStartIndex:$,dataEndIndex:q})}}),ci(L,"handleMouseEnter",function(R){var $=L.getMouseInfo(R);if($){var q=vr(vr({},$),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var U=L.props.onMouseEnter;ji(U)&&U(q,R)}}),ci(L,"triggeredAfterMouseMove",function(R){var $=L.getMouseInfo(R),q=$?vr(vr({},$),{},{isTooltipActive:!0}):{isTooltipActive:!1};L.setState(q),L.triggerSyncEvent(q);var U=L.props.onMouseMove;ji(U)&&U(q,R)}),ci(L,"handleItemMouseEnter",function(R){L.setState(function(){return{isTooltipActive:!0,activeItem:R,activePayload:R.tooltipPayload,activeCoordinate:R.tooltipPosition||{x:R.cx,y:R.cy}}})}),ci(L,"handleItemMouseLeave",function(){L.setState(function(){return{isTooltipActive:!1}})}),ci(L,"handleMouseMove",function(R){R.persist(),L.throttleTriggeredAfterMouseMove(R)}),ci(L,"handleMouseLeave",function(R){L.throttleTriggeredAfterMouseMove.cancel();var $={isTooltipActive:!1};L.setState($),L.triggerSyncEvent($);var q=L.props.onMouseLeave;ji(q)&&q($,R)}),ci(L,"handleOuterEvent",function(R){var $=rZt(R),q=pf(L.props,"".concat($));if($&&ji(q)){var U,V;/.*touch.*/i.test($)?V=L.getMouseInfo(R.changedTouches[0]):V=L.getMouseInfo(R),q((U=V)!==null&&U!==void 0?U:{},R)}}),ci(L,"handleClick",function(R){var $=L.getMouseInfo(R);if($){var q=vr(vr({},$),{},{isTooltipActive:!0});L.setState(q),L.triggerSyncEvent(q);var U=L.props.onClick;ji(U)&&U(q,R)}}),ci(L,"handleMouseDown",function(R){var $=L.props.onMouseDown;if(ji($)){var q=L.getMouseInfo(R);$(q,R)}}),ci(L,"handleMouseUp",function(R){var $=L.props.onMouseUp;if(ji($)){var q=L.getMouseInfo(R);$(q,R)}}),ci(L,"handleTouchMove",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.throttleTriggeredAfterMouseMove(R.changedTouches[0])}),ci(L,"handleTouchStart",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.handleMouseDown(R.changedTouches[0])}),ci(L,"handleTouchEnd",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.handleMouseUp(R.changedTouches[0])}),ci(L,"handleDoubleClick",function(R){var $=L.props.onDoubleClick;if(ji($)){var q=L.getMouseInfo(R);$(q,R)}}),ci(L,"handleContextMenu",function(R){var $=L.props.onContextMenu;if(ji($)){var q=L.getMouseInfo(R);$(q,R)}}),ci(L,"triggerSyncEvent",function(R){L.props.syncId!==void 0&&Jxe.emit(eye,L.props.syncId,R,L.eventEmitterSymbol)}),ci(L,"applySyncEvent",function(R){var $=L.props,q=$.layout,U=$.syncMethod,V=L.state.updateId,X=R.dataStartIndex,se=R.dataEndIndex;if(R.dataStartIndex!==void 0||R.dataEndIndex!==void 0)L.setState(vr({dataStartIndex:X,dataEndIndex:se},_({props:L.props,dataStartIndex:X,dataEndIndex:se,updateId:V},L.state)));else if(R.activeTooltipIndex!==void 0){var ee=R.chartX,Q=R.chartY,de=R.activeTooltipIndex,re=L.state,ne=re.offset,le=re.tooltipTicks;if(!ne)return;if(typeof U=="function")de=U(le,R);else if(U==="value"){de=-1;for(var he=0;he=0){var ct,De;if(ee.dataKey&&!ee.allowDuplicatedCategory){var Rt=typeof ee.dataKey=="function"?qe:"payload.".concat(ee.dataKey.toString());ct=Rle(he,Rt,de),De=we&&ye&&Rle(ye,Rt,de)}else ct=he==null?void 0:he[Q],De=we&&ye&&ye[Q];if(Me||be){var pe=R.props.activeIndex!==void 0?R.props.activeIndex:Q;return[C.cloneElement(R,vr(vr(vr({},U.props),Re),{},{activeIndex:pe})),null,null]}if(!Ri(ct))return[Te].concat(sA(L.renderActivePoints({item:U,activePoint:ct,basePoint:De,childIndex:Q,isRange:we})))}else{var Je,lt=(Je=L.getItemByXY(L.state.activeCoordinate))!==null&&Je!==void 0?Je:{graphicalItem:Te},rt=lt.graphicalItem,Se=rt.item,it=Se===void 0?R:Se,$e=rt.childIndex,ot=vr(vr(vr({},U.props),Re),{},{activeIndex:$e});return[C.cloneElement(it,ot),null,null]}return we?[Te,null,null]:[Te,null]}),ci(L,"renderCustomized",function(R,$,q){return C.cloneElement(R,vr(vr({key:"recharts-customized-".concat(q)},L.props),L.state))}),ci(L,"renderMap",{CartesianGrid:{handler:_z,once:!0},ReferenceArea:{handler:L.renderReferenceElement},ReferenceLine:{handler:_z},ReferenceDot:{handler:L.renderReferenceElement},XAxis:{handler:_z},YAxis:{handler:_z},Brush:{handler:L.renderBrush,once:!0},Bar:{handler:L.renderGraphicChild},Line:{handler:L.renderGraphicChild},Area:{handler:L.renderGraphicChild},Radar:{handler:L.renderGraphicChild},RadialBar:{handler:L.renderGraphicChild},Scatter:{handler:L.renderGraphicChild},Pie:{handler:L.renderGraphicChild},Funnel:{handler:L.renderGraphicChild},Tooltip:{handler:L.renderCursor,once:!0},PolarGrid:{handler:L.renderPolarGrid,once:!0},PolarAngleAxis:{handler:L.renderPolarAxis},PolarRadiusAxis:{handler:L.renderPolarAxis},Customized:{handler:L.renderCustomized}}),L.clipPathId="".concat((T=S.id)!==null&&T!==void 0?T:QA("recharts"),"-clip"),L.throttleTriggeredAfterMouseMove=kst(L.triggeredAfterMouseMove,(I=S.throttleDelay)!==null&&I!==void 0?I:1e3/60),L.state={},L}return C0s(N,j),j0s(N,[{key:"componentDidMount",value:function(){var T,I;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(T=this.props.margin.left)!==null&&T!==void 0?T:0,top:(I=this.props.margin.top)!==null&&I!==void 0?I:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var T=this.props,I=T.children,L=T.data,R=T.height,$=T.layout,q=Zp(I,rp);if(q){var U=q.props.defaultIndex;if(!(typeof U!="number"||U<0||U>this.state.tooltipTicks.length-1)){var V=this.state.tooltipTicks[U]&&this.state.tooltipTicks[U].value,X=Sbe(this.state,L,U,V),se=this.state.tooltipTicks[U].coordinate,ee=(this.state.offset.top+R)/2,Q=$==="horizontal",de=Q?{x:se,y:ee}:{y:se,x:ee},re=this.state.formattedGraphicalItems.find(function(le){var he=le.item;return he.type.name==="Scatter"});re&&(de=vr(vr({},de),re.props.points[U].tooltipPosition),X=re.props.points[U].tooltipPayload);var ne={activeTooltipIndex:U,isTooltipActive:!0,activeLabel:V,activePayload:X,activeCoordinate:de};this.setState(ne),this.renderCursor(q),this.accessibilityManager.setIndex(U)}}}},{key:"getSnapshotBeforeUpdate",value:function(T,I){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==I.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==T.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==T.margin){var L,R;this.accessibilityManager.setDetails({offset:{left:(L=this.props.margin.left)!==null&&L!==void 0?L:0,top:(R=this.props.margin.top)!==null&&R!==void 0?R:0}})}return null}},{key:"componentDidUpdate",value:function(T){t_e([Zp(T.children,rp)],[Zp(this.props.children,rp)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var T=Zp(this.props.children,rp);if(T&&typeof T.props.shared=="boolean"){var I=T.props.shared?"axis":"item";return i.indexOf(I)>=0?I:o}return o}},{key:"getMouseInfo",value:function(T){if(!this.container)return null;var I=this.container,L=I.getBoundingClientRect(),R=Aas(L),$={chartX:Math.round(T.pageX-R.left),chartY:Math.round(T.pageY-R.top)},q=L.width/I.offsetWidth||1,U=this.inRange($.chartX,$.chartY,q);if(!U)return null;var V=this.state,X=V.xAxisMap,se=V.yAxisMap,ee=this.getTooltipEventType(),Q=rFe(this.state,this.props.data,this.props.layout,U);if(ee!=="axis"&&X&&se){var de=Q_(X).scale,re=Q_(se).scale,ne=de&&de.invert?de.invert($.chartX):null,le=re&&re.invert?re.invert($.chartY):null;return vr(vr({},$),{},{xValue:ne,yValue:le},Q)}return Q?vr(vr({},$),Q):null}},{key:"inRange",value:function(T,I){var L=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,R=this.props.layout,$=T/L,q=I/L;if(R==="horizontal"||R==="vertical"){var U=this.state.offset,V=$>=U.left&&$<=U.left+U.width&&q>=U.top&&q<=U.top+U.height;return V?{x:$,y:q}:null}var X=this.state,se=X.angleAxisMap,ee=X.radiusAxisMap;if(se&&ee){var Q=Q_(se);return MOe({x:$,y:q},Q)}return null}},{key:"parseEventsOfWrapper",value:function(){var T=this.props.children,I=this.getTooltipEventType(),L=Zp(T,rp),R={};L&&I==="axis"&&(L.props.trigger==="click"?R={onClick:this.handleClick}:R={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var $=Fle(this.props,this.handleOuterEvent);return vr(vr({},$),R)}},{key:"addListener",value:function(){Jxe.on(eye,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Jxe.removeListener(eye,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(T,I,L){for(var R=this.state.formattedGraphicalItems,$=0,q=R.length;${const{data:S,error:T}=await G.from("email_campaigns").select("*").eq("status","sent").order("sent_at",{ascending:!0});if(T)throw T;return S}}),{data:n}=wt({queryKey:["campaign-agent-profiles"],queryFn:async()=>{const{data:S,error:T}=await G.from("profiles").select("id, name, email");if(T)throw T;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,T)=>S+(T.sent_count||0),0),i=a.reduce((S,T)=>S+(T.open_count||0),0),c=a.reduce((S,T)=>S+(T.click_count||0),0),u=a.reduce((S,T)=>S+(T.bounce_count||0),0),p=a.reduce((S,T)=>S+(T.complaint_count||0),0),f=l>0?(i/l*100).toFixed(1):"0.0",y=l>0?(c/l*100).toFixed(1):"0.0",_=[{label:"Campaigns Sent",value:a.length,icon:oa,color:"text-foreground"},{label:"Total Emails Sent",value:l,icon:mr,color:"text-green-600"},{label:"Avg Open Rate",value:`${f}%`,icon:va,color:"text-blue-600"},{label:"Avg Click Rate",value:`${y}%`,icon:Lh,color:"text-purple-600"},{label:"Total Bounces",value:u,icon:uh,color:"text-orange-600"},{label:"Complaints",value:p,icon:xc,color:"text-destructive"}],b=new Map;a.forEach(S=>{var L,R;const T=S.user_id,I=b.get(T)||{name:((L=o.get(T))==null?void 0:L.name)||((R=o.get(T))==null?void 0:R.email)||"Unknown",campaigns:0,sent:0,opens:0,clicks:0};I.campaigns++,I.sent+=S.sent_count||0,I.opens+=S.open_count||0,I.clicks+=S.click_count||0,b.set(T,I)});const w=[...b.entries()].map(([S,T])=>({id:S,...T,openRate:T.sent>0?+(T.opens/T.sent*100).toFixed(1):0})).sort((S,T)=>T.sent-S.sent),j=w.slice(0,6).map(S=>({name:S.name,value:S.sent})),N=a.map(S=>{var T;return{name:S.name.length>20?S.name.slice(0,20)+"…":S.name,agent:((T=o.get(S.user_id))==null?void 0:T.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?ys(new Date(S.sent_at),"MMM d"):""}});return e.jsx("div",{className:"space-y-6",children:a.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(oa,{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:_.map(S=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx(S.icon,{className:`h-5 w-5 mx-auto mb-1 ${S.color}`}),e.jsx("p",{className:"text-2xl font-bold",children:S.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.label})]})},S.label))}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Open & Click Rates by Campaign"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(BM,{width:"100%",height:"100%",children:e.jsxs(Xnt,{data:N,children:[e.jsx(RS,{dataKey:"date",fontSize:11}),e.jsx(FS,{fontSize:11,unit:"%"}),e.jsx(rp,{formatter:S=>`${S}%`}),e.jsx(N1,{dataKey:"openRate",fill:"hsl(220, 70%, 50%)",name:"Open Rate",radius:[2,2,0,0]}),e.jsx(N1,{dataKey:"clickRate",fill:"hsl(270, 70%, 50%)",name:"Click Rate",radius:[2,2,0,0]})]})})})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Send Volume by Agent"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(BM,{width:"100%",height:"100%",children:e.jsxs(Qnt,{children:[e.jsx(L0,{data:j,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:100,label:({name:S,percent:T})=>`${S} (${(T*100).toFixed(0)}%)`,fontSize:11,children:j.map((S,T)=>e.jsx(zO,{fill:iFe[T%iFe.length]},T))}),e.jsx(rp,{})]})})})})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Send Volume Trend"})}),e.jsx(Oe,{children:e.jsx("div",{className:"h-[240px]",children:e.jsx(BM,{width:"100%",height:"100%",children:e.jsxs(U0s,{data:N,children:[e.jsx(RS,{dataKey:"date",fontSize:11}),e.jsx(FS,{fontSize:11}),e.jsx(rp,{}),e.jsx(WO,{type:"monotone",dataKey:"sent",stroke:"hsl(142, 71%, 45%)",strokeWidth:2,name:"Emails Sent",dot:{r:4}})]})})})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Agent Performance"})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"pb-2 font-medium",children:"Agent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Campaigns"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Sent"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Opens"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Clicks"}),e.jsx("th",{className:"pb-2 font-medium text-center",children:"Open Rate"})]})}),e.jsx("tbody",{children:w.map(S=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-2.5 font-medium",children:S.name}),e.jsx("td",{className:"py-2.5 text-center",children:S.campaigns}),e.jsx("td",{className:"py-2.5 text-center",children:S.sent}),e.jsx("td",{className:"py-2.5 text-center",children:S.opens}),e.jsx("td",{className:"py-2.5 text-center",children:S.clicks}),e.jsx("td",{className:"py-2.5 text-center",children:e.jsxs(nt,{variant:"outline",children:[S.openRate,"%"]})})]},S.id))})]})})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Campaign Leaderboard"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:[...a].sort((S,T)=>{const I=S.sent_count>0?S.open_count/S.sent_count:0;return(T.sent_count>0?T.open_count/T.sent_count:0)-I}).slice(0,10).map((S,T)=>{const I=S.sent_count>0?(S.open_count/S.sent_count*100).toFixed(1):"0.0",L=S.sent_count>0?(S.click_count/S.sent_count*100).toFixed(1):"0.0",R=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:["#",T+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:[(R==null?void 0:R.name)||"Unknown"," · ",S.sent_at?ys(new Date(S.sent_at),"MMM d, yyyy"):""," · ",S.sent_count," sent"]})]}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(va,{className:"h-3 w-3"})," ",I,"%"]}),e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(Lh,{className:"h-3 w-3"})," ",L,"%"]})]})]},S.id)})})})]})]})})}const H0s=()=>e.jsx(Es,{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(Aa,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(ja,{children:[e.jsx(js,{value:"analytics",children:"Analytics"}),e.jsx(js,{value:"content",children:"Content"}),e.jsx(js,{value:"email-campaigns",children:"Email Campaigns"}),e.jsx(js,{value:"activity",children:"Activity"}),e.jsx(js,{value:"shares",children:"Shares"})]}),e.jsx($s,{value:"analytics",className:"space-y-4",children:e.jsx(dHt,{})}),e.jsx($s,{value:"content",className:"space-y-4",children:e.jsx(hHt,{})}),e.jsx($s,{value:"email-campaigns",className:"space-y-4",children:e.jsx(V0s,{})}),e.jsx($s,{value:"activity",className:"space-y-4",children:e.jsx(cHt,{})}),e.jsx($s,{value:"shares",className:"space-y-4",children:e.jsx(ctt,{})})]})]})});function W0s(){const t=ss(),[s,r]=C.useState(!1),[n,a]=C.useState(null),[o,l]=C.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,c]=C.useState(null),[u,p]=C.useState(""),[f,y]=C.useState([]),[_,b]=C.useState([]),[w,j]=C.useState([]),[N,S]=C.useState(!1),[T,I]=C.useState(null),[L,R]=C.useState(""),{data:$,isLoading:q}=wt({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:De,error:Rt}=await G.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(Rt)throw Rt;return De}}),{data:U}=wt({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:De,error:Rt}=await G.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(Rt)throw Rt;return De}}),{data:V}=wt({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:De,error:Rt}=await G.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(Rt)throw Rt;return De}}),{data:X}=wt({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:De,error:Rt}=await G.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(Rt)throw Rt;return De}}),{data:se,isLoading:ee}=wt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:De,error:Rt}=await G.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(Rt)throw Rt;return De}}),Q=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),c(null),p(""),y([]),b([]),j([]),a(null),R("")},de=De=>{a(De),l({title:De.title,description:De.description||"",publish_date:De.publish_date.split("T")[0],is_published:De.is_published,category_id:De.category_id||""}),p(De.preview_image_url||""),R("");const Rt=(U==null?void 0:U.filter(lt=>lt.resource_id===De.id))||[];y(Rt.map(lt=>({id:lt.id,name:lt.name,file_url:lt.file_url,file_size:lt.file_size,sort_order:lt.sort_order})));const pe=(V==null?void 0:V.filter(lt=>lt.resource_id===De.id))||[];b(pe.map(lt=>({id:lt.id,title:lt.title,video_url:lt.video_url,sort_order:lt.sort_order})));const Je=(X==null?void 0:X.filter(lt=>lt.resource_id===De.id))||[];j(Je.map(lt=>({id:lt.id,title:lt.title,canva_share_link:lt.canva_share_link,sort_order:lt.sort_order}))),r(!0)},re=De=>{var pe;const Rt=(pe=De.target.files)==null?void 0:pe[0];Rt&&(c(Rt),p(URL.createObjectURL(Rt)))},ne=()=>{y([...f,{name:"",file_url:"",sort_order:f.length}])},le=De=>{y(f.filter((Rt,pe)=>pe!==De))},he=(De,Rt,pe)=>{const Je=[...f];if(Rt==="file"&&pe instanceof File){const lt=pe.name.replace(/\.[^/.]+$/,"");Je[De]={...Je[De],file:pe,file_size:pe.size,name:Je[De].name||lt}}else Je[De]={...Je[De],[Rt]:pe};y(Je)},we=()=>{b([..._,{title:"",video_url:"",sort_order:_.length}])},ye=De=>{b(_.filter((Rt,pe)=>pe!==De))},je=(De,Rt,pe)=>{const Je=[..._];Rt==="file"&&pe instanceof File?Je[De]={...Je[De],file:pe}:Je[De]={...Je[De],[Rt]:pe},b(Je)},ke=()=>{j([...w,{title:"",canva_share_link:"",sort_order:w.length}])},We=De=>{j(w.filter((Rt,pe)=>pe!==De))},be=(De,Rt,pe)=>{const Je=[...w];Je[De]={...Je[De],[Rt]:pe},j(Je)},Me=async(De,Rt)=>{try{const pe=await G.functions.invoke("bunny-upload",{body:{action:"create",title:De.name}});if(pe.error)throw pe.error;const{videoId:Je,uploadUrl:lt,libraryId:rt}=pe.data,Se=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Je,libraryId:rt}});if(Se.error)throw Se.error;const{uploadUrl:it,apiKey:$e}=Se.data,ot=new XMLHttpRequest;return ot.open("PUT",it,!0),ot.setRequestHeader("AccessKey",$e),ot.upload.onprogress=Ue=>{if(Ue.lengthComputable){const Ke=Math.round(Ue.loaded/Ue.total*100),Xe=[..._];Xe[Rt]={...Xe[Rt],uploadProgress:Ke},b(Xe)}},await new Promise((Ue,Ke)=>{ot.onload=()=>ot.status>=200&&ot.status<300?Ue():Ke(new Error("Upload failed")),ot.onerror=()=>Ke(new Error("Upload failed")),ot.send(De)}),`https://iframe.mediadelivery.net/embed/${rt}/${Je}`}catch(pe){throw console.error("Bunny upload error:",pe),pe}},Ae=Dt({mutationFn:async De=>{const{data:Rt,error:pe}=await G.from("brokerage_resource_categories").insert({name:De,sort_order:(se==null?void 0:se.length)||0}).select().single();if(pe)throw pe;return Rt},onSuccess:De=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:De.id}),R(""),me.success("Category created")},onError:De=>{me.error("Failed to create category: "+De.message)}}),Re=Dt({mutationFn:async()=>{S(!0);let De=(n==null?void 0:n.preview_image_url)||null;if(i){const Je=i.name.split(".").pop(),lt=`${Date.now()}.${Je}`,{error:rt}=await G.storage.from("brokerage-resources").upload(`previews/${lt}`,i);if(rt)throw rt;const{data:Se}=G.storage.from("brokerage-resources").getPublicUrl(`previews/${lt}`);De=Se.publicUrl}const Rt={title:o.title,description:o.description||null,preview_image_url:De,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let pe;if(n){const{error:Je}=await G.from("brokerage_resources").update(Rt).eq("id",n.id);if(Je)throw Je;pe=n.id;const lt=(U==null?void 0:U.filter(He=>He.resource_id===n.id).map(He=>He.id))||[],rt=f.filter(He=>He.id).map(He=>He.id),Se=lt.filter(He=>!rt.includes(He));Se.length>0&&await G.from("brokerage_resource_pdfs").delete().in("id",Se);const it=(V==null?void 0:V.filter(He=>He.resource_id===n.id).map(He=>He.id))||[],$e=_.filter(He=>He.id).map(He=>He.id),ot=it.filter(He=>!$e.includes(He));ot.length>0&&await G.from("brokerage_resource_videos").delete().in("id",ot);const Ue=(X==null?void 0:X.filter(He=>He.resource_id===n.id).map(He=>He.id))||[],Ke=w.filter(He=>He.id).map(He=>He.id),Xe=Ue.filter(He=>!Ke.includes(He));Xe.length>0&&await G.from("brokerage_resource_links").delete().in("id",Xe)}else{const{data:Je,error:lt}=await G.from("brokerage_resources").insert(Rt).select().single();if(lt)throw lt;pe=Je.id}for(let Je=0;Je{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:De=>{me.error("Failed to save resource: "+De.message),S(!1)}}),Te=Dt({mutationFn:async De=>{const{error:Rt}=await G.from("brokerage_resources").delete().eq("id",De);if(Rt)throw Rt},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),me.success("Resource deleted")},onError:De=>{me.error("Failed to delete: "+De.message)}}),qe=De=>{if(De.preventDefault(),!o.title){me.error("Please enter a title");return}Re.mutate()},ct=De=>{const Rt=(U==null?void 0:U.filter(lt=>lt.resource_id===De).length)||0,pe=(V==null?void 0:V.filter(lt=>lt.resource_id===De).length)||0,Je=(X==null?void 0:X.filter(lt=>lt.resource_id===De).length)||0;return{pdfCount:Rt,videoCount:pe,linkCount:Je}};return e.jsx(Es,{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(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:($==null?void 0:$.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:($==null?void 0:$.filter(De=>De.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{Q(),r(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Category"}),e.jsx(bt,{children:"Content"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:q?e.jsx(ks,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):($==null?void 0:$.length)===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No brokerage resources yet. Create your first one!"})}):$==null?void 0:$.map(De=>{const{pdfCount:Rt,videoCount:pe,linkCount:Je}=ct(De.id),lt=se==null?void 0:se.find(rt=>rt.id===De.category_id);return e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[De.preview_image_url?e.jsx("img",{src:De.preview_image_url,alt:De.title,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(Rh,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:De.title}),De.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:De.description})]})]})}),e.jsx(dt,{children:lt?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:lt.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(In,{className:"h-3.5 w-3.5"}),Rt]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nn,{className:"h-3.5 w-3.5"}),pe]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vo,{className:"h-3.5 w-3.5"}),Je]})]})}),e.jsx(dt,{children:ys(new Date(De.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 ${De.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:De.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 rt=(U==null?void 0:U.filter($e=>$e.resource_id===De.id))||[],Se=(V==null?void 0:V.filter($e=>$e.resource_id===De.id))||[],it=(X==null?void 0:X.filter($e=>$e.resource_id===De.id))||[];I({...De,pdfs:rt,videos:Se,links:it})},children:e.jsx(va,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>de(De),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&Te.mutate(De.id)},children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},De.id)})})]})})}),e.jsx(_s,{open:s,onOpenChange:r,children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),e.jsxs("form",{onSubmit:qe,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[u?e.jsx("img",{src:u,alt:"Preview",className:"w-24 h-24 rounded object-cover"}):e.jsx("div",{className:"w-24 h-24 rounded bg-muted flex items-center justify-center",children:e.jsx(Rh,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(Fe,{type:"file",accept:"image/*",onChange:re})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Fe,{id:"title",value:o.title,onChange:De=>l({...o,title:De.target.value}),placeholder:"Resource Title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{className:"flex items-center gap-2",children:[e.jsx(Tm,{className:"h-4 w-4"}),"Category"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(rr,{value:o.category_id,onValueChange:De=>l({...o,category_id:De}),children:[e.jsx(tr,{className:"flex-1",children:e.jsx(nr,{placeholder:"Select a category"})}),e.jsx(sr,{children:se==null?void 0:se.map(De=>e.jsx(Tt,{value:De.id,children:De.name},De.id))})]}),o.category_id&&e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>l({...o,category_id:""}),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{placeholder:"Or create new category...",value:L,onChange:De=>R(De.target.value),className:"flex-1"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",disabled:!L.trim()||Ae.isPending,onClick:()=>Ae.mutate(L.trim()),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(iy,{content:o.description,onChange:De=>l({...o,description:De}),placeholder:"Brief description of this resource",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Fe,{id:"publish_date",type:"date",value:o.publish_date,onChange:De=>l({...o,publish_date:De.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx(Br,{checked:o.is_published,onCheckedChange:De=>l({...o,is_published:De})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:o.is_published?"Visible to brokerage managers":"Hidden from brokerage managers"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(_e,{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-4 w-4"}),"PDF Documents (",f.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ne,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),f.map((De,Rt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(Fe,{placeholder:"PDF Name",value:De.name,onChange:pe=>he(Rt,"name",pe.target.value),className:"flex-1"}),e.jsx(Fe,{type:"file",accept:".pdf",onChange:pe=>{var lt;const Je=(lt=pe.target.files)==null?void 0:lt[0];Je&&he(Rt,"file",Je)},className:"flex-1"}),De.file_url&&!De.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>le(Rt),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Rt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(_e,{className:"flex items-center gap-2",children:[e.jsx(Nn,{className:"h-4 w-4"}),"Videos (",_.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:we,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),_.map((De,Rt)=>e.jsxs("div",{className:"space-y-2 p-3 border rounded-lg bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{placeholder:"Video Title",value:De.title,onChange:pe=>je(Rt,"title",pe.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>ye(Rt),children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsx(Fe,{type:"file",accept:"video/*",onChange:pe=>{var lt;const Je=(lt=pe.target.files)==null?void 0:lt[0];Je&&je(Rt,"file",Je)}}),De.uploadProgress!==void 0&&De.uploadProgress>0&&e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${De.uploadProgress}%`}})}),De.video_url&&!De.file&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},Rt))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(_e,{className:"flex items-center gap-2",children:[e.jsx(Vo,{className:"h-4 w-4"}),"Canva Links (",w.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ke,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),w.map((De,Rt)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[e.jsx(Fe,{placeholder:"Link Title",value:De.title,onChange:pe=>be(Rt,"title",pe.target.value),className:"flex-1"}),e.jsx(Fe,{placeholder:"Canva Share Link",value:De.canva_share_link,onChange:pe=>be(Rt,"canva_share_link",pe.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>We(Rt),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Rt))]}),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:Re.isPending||N,children:Re.isPending||N?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(_s,{open:!!T,onOpenChange:()=>I(null),children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:T==null?void 0:T.title})}),T&&e.jsxs("div",{className:"space-y-4",children:[T.preview_image_url&&e.jsx("img",{src:T.preview_image_url,alt:T.title,className:"w-full h-48 object-cover rounded-lg"}),T.description&&e.jsx("p",{className:"text-muted-foreground",children:T.description}),T.pdfs&&T.pdfs.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(In,{className:"h-4 w-4"}),"PDF Documents (",T.pdfs.length,")"]}),e.jsx("div",{className:"space-y-1",children:T.pdfs.map(De=>e.jsx("a",{href:De.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:De.name},De.id))})]}),T.videos&&T.videos.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Nn,{className:"h-4 w-4"}),"Videos (",T.videos.length,")"]}),e.jsx("div",{className:"space-y-2",children:T.videos.map(De=>e.jsx("div",{className:"p-2 border rounded",children:e.jsx("p",{className:"font-medium text-sm",children:De.title})},De.id))})]}),T.links&&T.links.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[e.jsx(Vo,{className:"h-4 w-4"}),"Canva Links (",T.links.length,")"]}),e.jsx("div",{className:"space-y-1",children:T.links.map(De=>e.jsx("a",{href:De.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:De.title},De.id))})]})]})]})})]})})}const Jnt=[{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 G0s(){const[t,s]=C.useState([]),[r,n]=C.useState(!0),[a,o]=C.useState(!1),[l,i]=C.useState(!1),[c,u]=C.useState(null),[p,f]=C.useState(!1),[y,_]=C.useState(!1),[b,w]=C.useState(""),[j,N]=C.useState(""),[S,T]=C.useState(""),[I,L]=C.useState(""),[R,$]=C.useState("Learn More"),[q,U]=C.useState("top"),[V,X]=C.useState(""),[se,ee]=C.useState(!0),[Q,de]=C.useState(""),[re,ne]=C.useState("");C.useEffect(()=>{le()},[]);const le=async()=>{try{const{data:Ae,error:Re}=await G.from("dashboard_banners").select("*").order("placement").order("sort_order");if(Re)throw Re;s(Ae||[])}catch(Ae){me.error("Failed to load banners: "+Ae.message)}finally{n(!1)}},he=()=>{w(""),N(""),T(""),L(""),$("Learn More"),U("top"),X(""),ee(!0),de(""),ne(""),u(null)},we=Ae=>{u(Ae),w(Ae.title),N(Ae.description||""),T(Ae.image_url),L(Ae.link_url||""),$(Ae.link_text||"Learn More"),U(Ae.placement),X(Ae.section_after||""),ee(Ae.is_active),de(Ae.start_date?ys(new Date(Ae.start_date),"yyyy-MM-dd'T'HH:mm"):""),ne(Ae.end_date?ys(new Date(Ae.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},ye=async Ae=>{var Te;const Re=(Te=Ae.target.files)==null?void 0:Te[0];if(Re){f(!0);try{const qe=Re.name.split(".").pop(),ct=`${Date.now()}.${qe}`,{error:De}=await G.storage.from("banner-images").upload(ct,Re);if(De)throw De;const{data:{publicUrl:Rt}}=G.storage.from("banner-images").getPublicUrl(ct);T(Rt),me.success("Image uploaded successfully")}catch(qe){me.error("Failed to upload image: "+qe.message)}finally{f(!1)}}},je=async()=>{if(!b.trim()||!S){me.error("Please fill in required fields (title and image)");return}_(!0);try{const Ae={title:b.trim(),description:j.trim()||null,image_url:S,link_url:I.trim()||null,link_text:R.trim()||"Learn More",placement:q,section_after:q==="between"?V:null,is_active:se,start_date:Q?new Date(Q).toISOString():null,end_date:re?new Date(re).toISOString():null};if(c){const{error:Re}=await G.from("dashboard_banners").update(Ae).eq("id",c.id);if(Re)throw Re;me.success("Banner updated successfully")}else{const Re=t.filter(qe=>qe.placement===q).length,{error:Te}=await G.from("dashboard_banners").insert({...Ae,sort_order:Re});if(Te)throw Te;me.success("Banner created successfully")}o(!1),he(),le()}catch(Ae){me.error("Failed to save banner: "+Ae.message)}finally{_(!1)}},ke=async()=>{if(c)try{const{error:Ae}=await G.from("dashboard_banners").delete().eq("id",c.id);if(Ae)throw Ae;me.success("Banner deleted successfully"),i(!1),u(null),le()}catch(Ae){me.error("Failed to delete banner: "+Ae.message)}},We=async Ae=>{try{const{error:Re}=await G.from("dashboard_banners").update({is_active:!Ae.is_active}).eq("id",Ae.id);if(Re)throw Re;me.success(Ae.is_active?"Banner deactivated":"Banner activated"),le()}catch(Re){me.error("Failed to update banner: "+Re.message)}},be=t.filter(Ae=>Ae.placement==="top"),Me=t.filter(Ae=>Ae.placement==="between");return r?e.jsx(Es,{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(Es,{title:"Dashboard Management",description:"Configure dashboard modules and banners",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(cl,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(fr,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(_s,{open:a&&q==="top",onOpenChange:Ae=>{Ae||he(),o(Ae),Ae&&U("top")},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{he(),U("top")},children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Add Hero Banner"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{children:[c?"Edit":"Create"," Banner"]}),e.jsx(Zr,{children:"Configure the banner's content and display settings"})]}),e.jsx(oFe,{title:b,setTitle:w,description:j,setDescription:N,imageUrl:S,linkUrl:I,setLinkUrl:L,linkText:R,setLinkText:$,placement:q,setPlacement:U,sectionAfter:V,setSectionAfter:X,isActive:se,setIsActive:ee,startDate:Q,setStartDate:de,endDate:re,setEndDate:ne,handleImageUpload:ye,uploading:p,showPlacementOptions:!1}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),he()},children:"Cancel"}),e.jsx(K,{onClick:je,disabled:y,children:y?"Saving...":c?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{children:be.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:be.map(Ae=>e.jsx(lFe,{banner:Ae,onEdit:()=>we(Ae),onDelete:()=>{u(Ae),i(!0)},onToggleActive:()=>We(Ae)},Ae.id))})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(cl,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(fr,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(_s,{open:a&&q==="between",onOpenChange:Ae=>{Ae||he(),o(Ae),Ae&&U("between")},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{he(),U("between")},children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Add Section Banner"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{children:[c?"Edit":"Create"," Section Banner"]}),e.jsx(Zr,{children:"Configure where this banner appears between sections"})]}),e.jsx(oFe,{title:b,setTitle:w,description:j,setDescription:N,imageUrl:S,linkUrl:I,setLinkUrl:L,linkText:R,setLinkText:$,placement:q,setPlacement:U,sectionAfter:V,setSectionAfter:X,isActive:se,setIsActive:ee,startDate:Q,setStartDate:de,endDate:re,setEndDate:ne,handleImageUpload:ye,uploading:p,showPlacementOptions:!0}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),he()},children:"Cancel"}),e.jsx(K,{onClick:je,disabled:y,children:y?"Saving...":c?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Oe,{children:Me.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No section banners yet. Add your first banner above."}):e.jsx("div",{className:"space-y-3",children:Me.map(Ae=>e.jsx(lFe,{banner:Ae,onEdit:()=>we(Ae),onDelete:()=>{u(Ae),i(!0)},onToggleActive:()=>We(Ae),showSection:!0},Ae.id))})})]})]}),e.jsx(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Delete Banner"}),e.jsxs(Zr,{children:['Are you sure you want to delete "',c==null?void 0:c.title,'"? This action cannot be undone.']})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:ke,children:"Delete"})]})]})})]})}function oFe({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:y,isActive:_,setIsActive:b,startDate:w,setStartDate:j,endDate:N,setEndDate:S,handleImageUpload:T,uploading:I,showPlacementOptions:L}){return e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Fe,{id:"title",placeholder:"Banner headline...",value:t,onChange:R=>s(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",placeholder:"Optional banner description...",value:r,onChange:R=>n(R.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Banner Image *"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(Fe,{type:"file",accept:"image/*",onChange:T,disabled:I,className:"flex-1"}),I&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),a&&e.jsx("div",{className:"mt-2 relative rounded-lg overflow-hidden border",children:e.jsx("img",{src:a,alt:"Preview",className:"w-full h-40 object-cover"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"linkUrl",children:"Link URL (optional)"}),e.jsx(Fe,{id:"linkUrl",placeholder:"https://...",value:o,onChange:R=>l(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"linkText",children:"Button Text"}),e.jsx(Fe,{id:"linkText",placeholder:"Learn More",value:i,onChange:R=>c(R.target.value)})]})]}),L&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Placement"}),e.jsxs(rr,{value:f,onValueChange:y,children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select section placement..."})}),e.jsx(sr,{children:Jnt.map(R=>e.jsx(Tt,{value:R.value,children:R.label},R.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{htmlFor:"startDate",className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(Fe,{id:"startDate",type:"datetime-local",value:w,onChange:R=>j(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{htmlFor:"endDate",className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(Fe,{id:"endDate",type:"datetime-local",value:N,onChange:R=>S(R.target.value)})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"isActive",checked:_,onCheckedChange:b}),e.jsx(_e,{htmlFor:"isActive",children:"Active"})]})})]})}function lFe({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var l;const o=(l=Jnt.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(yh,{className:"h-5 w-5 text-muted-foreground cursor-grab"}),e.jsx("img",{src:t.image_url,alt:t.title,className:"w-24 h-14 object-cover rounded"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-medium truncate",children:t.title}),!t.is_active&&e.jsx(nt,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(nt,{variant:"outline",children:"Scheduled"})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:t.description}),a&&o&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[t.link_url&&e.jsx("a",{href:t.link_url,target:"_blank",rel:"noopener noreferrer",children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(rn,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(va,{className:"h-4 w-4"}):e.jsx(xp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:s,children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})]})}const bz={open:{label:"Open",icon:Tn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:Ec,color:"bg-blue-500"},resolved:{label:"Resolved",icon:vi,color:"bg-green-500"},closed:{label:"Closed",icon:$c,color:"bg-muted-foreground"}},cFe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function K0s(){var R,$;const{user:t}=Ws(),s=ss(),[r,n]=C.useState(null),[a,o]=C.useState(""),[l,i]=C.useState("all"),[c,u]=C.useState("all"),[p,f]=C.useState(!1),{data:y=[],isLoading:_}=wt({queryKey:["admin-support-tickets",l,c],queryFn:async()=>{let q=G.from("support_tickets").select("*, profiles!support_tickets_user_id_fkey(name, email)").order("created_at",{ascending:!1});l!=="all"&&(q=q.eq("status",l)),c!=="all"&&(q=q.eq("category",c));const{data:U,error:V}=await q;if(V)throw V;return U}}),{data:b=[]}=wt({queryKey:["admin-users-notifications"],queryFn:async()=>{const{data:q,error:U}=await G.from("user_roles").select("user_id").eq("role","admin");if(U)throw U;const V=q.map(re=>re.user_id),{data:X,error:se}=await G.from("profiles").select("id, name, email").in("id",V);if(se)throw se;const{data:ee,error:Q}=await G.from("support_notification_settings").select("user_id, receive_notifications");if(Q)throw Q;const de=new Map((ee==null?void 0:ee.map(re=>[re.user_id,re.receive_notifications]))||[]);return X.map(re=>({...re,receives_notifications:de.get(re.id)||!1}))}}),{data:w=[]}=wt({queryKey:["admin-ticket-replies",r==null?void 0:r.id],queryFn:async()=>{if(!r)return[];const{data:q,error:U}=await G.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",r.id).order("created_at",{ascending:!0});if(U)throw U;return q},enabled:!!r}),j=Dt({mutationFn:async({userId:q,enabled:U})=>{const{data:V}=await G.from("support_notification_settings").select("id").eq("user_id",q).maybeSingle();if(V){const{error:X}=await G.from("support_notification_settings").update({receive_notifications:U}).eq("user_id",q);if(X)throw X}else{const{error:X}=await G.from("support_notification_settings").insert({user_id:q,receive_notifications:U});if(X)throw X}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),me.success("Notification settings updated")},onError:()=>{me.error("Failed to update settings")}}),N=Dt({mutationFn:async({ticketId:q,status:U})=>{const{error:V}=await G.from("support_tickets").update({status:U}).eq("id",q);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),r&&n({...r,status:r.status}),me.success("Status updated")},onError:()=>{me.error("Failed to update status")}}),S=Dt({mutationFn:async({ticketId:q,assignedTo:U})=>{const{error:V}=await G.from("support_tickets").update({assigned_to:U}).eq("id",q);if(V)throw V},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]}),me.success("Ticket assigned")},onError:()=>{me.error("Failed to assign ticket")}}),T=Dt({mutationFn:async q=>{var V,X;if(!r||!t)throw new Error("Missing data");const{error:U}=await G.from("support_ticket_replies").insert({ticket_id:r.id,user_id:t.id,content:q,is_admin_reply:!0});if(U)throw U;try{await G.functions.invoke("support-reply-notify",{body:{ticketId:r.id,ticketSubject:r.subject,replyContent:q,userEmail:(V=r.profiles)==null?void 0:V.email,userName:(X=r.profiles)==null?void 0:X.name}})}catch(se){console.error("Failed to send reply notification:",se)}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-ticket-replies",r==null?void 0:r.id]}),o(""),me.success("Reply sent!")},onError:()=>{me.error("Failed to send reply")}}),I=()=>{a.trim()&&T.mutate(a)};C.useEffect(()=>{const q=G.channel("admin-tickets").on("postgres_changes",{event:"*",schema:"public",table:"support_tickets"},()=>{s.invalidateQueries({queryKey:["admin-support-tickets"]})}).subscribe();return()=>{G.removeChannel(q)}},[s]);const L=y.filter(q=>q.status==="open").length;return r?(bz[r.status].icon,e.jsx(Es,{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(di,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-2xl font-bold",children:r.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(nt,{variant:"secondary",children:cFe[r.category]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["from ",((R=r.profiles)==null?void 0:R.name)||"Unknown"," (",($=r.profiles)==null?void 0:$.email,")"]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm",children:"Status"})}),e.jsx(Oe,{children:e.jsxs(rr,{value:r.status,onValueChange:q=>{N.mutate({ticketId:r.id,status:q}),n({...r,status:q})},children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"open",children:"Open"}),e.jsx(Tt,{value:"in_progress",children:"In Progress"}),e.jsx(Tt,{value:"resolved",children:"Resolved"}),e.jsx(Tt,{value:"closed",children:"Closed"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm",children:"Assigned To"})}),e.jsx(Oe,{children:e.jsxs(rr,{value:r.assigned_to||"unassigned",onValueChange:q=>{const U=q==="unassigned"?null:q;S.mutate({ticketId:r.id,assignedTo:U}),n({...r,assigned_to:U})},children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Unassigned"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"unassigned",children:"Unassigned"}),b.map(q=>e.jsx(Tt,{value:q.id,children:q.name},q.id))]})]})})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(fr,{children:["Created on ",ys(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Conversation"})}),e.jsxs(Oe,{children:[e.jsx(Vi,{className:"h-[300px] pr-4",children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):e.jsx("div",{className:"space-y-4",children:w.map(q=>{var U,V;return e.jsxs("div",{className:`p-4 rounded-lg ${q.is_admin_reply?"bg-primary/10 ml-4":"bg-muted mr-4"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:q.is_admin_reply?`${((U=q.profiles)==null?void 0:U.name)||"Admin"} (Support)`:((V=q.profiles)==null?void 0:V.name)||"User"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(new Date(q.created_at),"MMM d, h:mm a")})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:q.content})]},q.id)})})}),e.jsx(Zl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ar,{placeholder:"Type your reply...",value:a,onChange:q=>o(q.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:I,disabled:!a.trim()||T.isPending,className:"self-end",children:e.jsx(oa,{className:"h-4 w-4"})})]})]})]})]})})):e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Support Tickets"}),e.jsxs("p",{className:"text-muted-foreground",children:["Manage support requests from agents",L>0&&e.jsxs(nt,{variant:"destructive",className:"ml-2",children:[L," open"]})]})]}),e.jsxs(_s,{open:p,onOpenChange:f,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Jl,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Email Notification Settings"}),e.jsx(Zr,{children:"Choose which admins receive email notifications for new support tickets."})]}),e.jsx("div",{className:"space-y-4 mt-4",children:b.map(q=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ro,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:q.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q.email})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[q.receives_notifications?e.jsx(gg,{className:"h-4 w-4 text-primary"}):e.jsx(Mb,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Br,{checked:q.receives_notifications,onCheckedChange:U=>j.mutate({userId:q.id,enabled:U})})]})]},q.id))})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[e.jsx(Aa,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(ja,{children:[e.jsx(js,{value:"all",children:"All"}),e.jsx(js,{value:"open",children:"Open"}),e.jsx(js,{value:"in_progress",children:"In Progress"}),e.jsx(js,{value:"resolved",children:"Resolved"}),e.jsx(js,{value:"closed",children:"Closed"})]})}),e.jsxs(rr,{value:c,onValueChange:u,children:[e.jsx(tr,{className:"w-[180px]",children:e.jsx(nr,{placeholder:"All Categories"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Categories"}),e.jsx(Tt,{value:"general",children:"General Support"}),e.jsx(Tt,{value:"technology",children:"Technology Support"}),e.jsx(Tt,{value:"crm",children:"CRM Support"}),e.jsx(Tt,{value:"marketing",children:"Marketing Support"})]})]})]}),e.jsx("div",{className:"mt-4",children:_?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):y.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"text-center py-12",children:[e.jsx(Ec,{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:y.map(q=>{var V,X;const U=bz[q.status].icon;return e.jsx(Ee,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(q),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium truncate",children:q.subject}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[e.jsx(nt,{variant:"outline",className:"text-xs",children:cFe[q.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(V=q.profiles)==null?void 0:V.name," • ",ys(new Date(q.created_at),"MMM d, yyyy")]}),q.assigned_to&&e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(ro,{className:"h-3 w-3"}),((X=b.find(se=>se.id===q.assigned_to))==null?void 0:X.name)||"Assigned"]})]})]}),e.jsxs(nt,{className:bz[q.status].color,children:[e.jsx(U,{className:"h-3 w-3 mr-1"}),bz[q.status].label]})]})})},q.id)})})})]})]})})}const Z0s=wh.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 Y0s({content:t,onChange:s,variables:r}){const n=qQe({extensions:[KQe,nJe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),aJe.configure({types:["heading","paragraph"]}),iJe,Z0s],content:t,onUpdate:({editor:l})=>{s(l.getHTML())}});C.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(iM,{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(mM,{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(Mm,{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(Jv,{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(rM,{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(sM,{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(nM,{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(Vo,{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(F4,{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(kM,{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(wM,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),r.length>0&&e.jsxs(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(yL,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(Jd,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(Ta,{onClick:()=>a(l),className:"flex flex-col items-start",children:[e.jsx("span",{className:"font-medium",children:l.label}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:`{{${l.key}}}`}),l.description&&e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:l.description})]},l.key))})]})]}),e.jsx(BQe,{editor:n,className:"prose prose-sm max-w-none p-4 min-h-[300px] focus:outline-none [&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[280px]"}),r.length>0&&e.jsxs("div",{className:"border-t p-3 bg-muted/20",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Available variables (click to copy):"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(l=>e.jsx(nt,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 font-mono text-xs",onClick:()=>{navigator.clipboard.writeText(`{{${l.key}}}`)},children:`{{${l.key}}}`},l.key))})]})]}):null}function X0s(){const t=ss(),[s,r]=C.useState(null),[n,a]=C.useState(null),[o,l]=C.useState(""),[i,c]=C.useState(""),[u,p]=C.useState(""),[f,y]=C.useState(!0),[_,b]=C.useState("visual"),{data:w,isLoading:j}=wt({queryKey:["email-templates"],queryFn:async()=>{const{data:L,error:R}=await G.from("email_templates").select("*").order("name");if(R)throw R;return L.map($=>({...$,available_variables:$.available_variables||[]}))}}),N=Dt({mutationFn:async L=>{const{error:R}=await G.from("email_templates").update({subject:L.subject,body_html:L.body_html,description:L.description,is_active:L.is_active}).eq("id",L.id);if(R)throw R},onSuccess:()=>{t.invalidateQueries({queryKey:["email-templates"]}),me.success("Email template updated successfully"),r(null)},onError:L=>{me.error("Failed to update template: "+L.message)}}),S=L=>{r(L),l(L.subject),c(L.body_html),p(L.description||""),y(L.is_active),b("visual")},T=()=>{s&&N.mutate({id:s.id,subject:o,body_html:i,description:u,is_active:f})},I=(L,R)=>{let $=L;return R.forEach(q=>{const U=`{{${q.key}}}`,V=`[${q.label}]`;$=$.replace(new RegExp(U.replace(/[{}]/g,"\\$&"),"g"),V)}),$};return s?e.jsxs(Es,{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(di,{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(va,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{onClick:T,disabled:N.isPending,children:[e.jsx(Wu,{className:"h-4 w-4 mr-2"}),N.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),s.name]}),e.jsxs(fr,{className:"mt-1",children:["Template slug: ",e.jsx("code",{className:"bg-muted px-1 rounded",children:s.slug})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{htmlFor:"active-toggle",children:"Active"}),e.jsx(Br,{id:"active-toggle",checked:f,onCheckedChange:y})]})]})}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",value:u,onChange:L=>p(L.target.value),placeholder:"Brief description of when this email is sent",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"subject",children:"Email Subject"}),e.jsx(Fe,{id:"subject",value:o,onChange:L=>l(L.target.value),placeholder:"Email subject line"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["You can use variables like ","{{name}}"," in the subject"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Email Body"}),e.jsx(Aa,{value:_,onValueChange:L=>b(L),children:e.jsxs(ja,{className:"h-8",children:[e.jsxs(js,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(H4,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(js,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(F4,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),_==="visual"?e.jsx(Y0s,{content:i,onChange:c,variables:s.available_variables}):e.jsx(Ar,{value:i,onChange:L=>c(L.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"HTML email body"})]})]})]})]}),e.jsx(_s,{open:!!n,onOpenChange:()=>a(null),children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Email Preview"}),e.jsxs(Zr,{children:["Subject: ",o.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),e.jsx("div",{className:"border rounded-lg p-4 bg-white",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:I(i,s.available_variables)}})})]})})]}):e.jsx(Es,{title:"Email Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Email Templates"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage and customize system email templates"})]}),j?e.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((L,R)=>e.jsx(Ee,{children:e.jsxs(It,{children:[e.jsx(xs,{className:"h-5 w-48"}),e.jsx(xs,{className:"h-4 w-96"})]})},R))}):e.jsx("div",{className:"grid gap-4",children:w==null?void 0:w.map(L=>e.jsxs(Ee,{className:"hover:shadow-md transition-shadow",children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Ot,{className:"flex items-center gap-2 text-lg",children:[e.jsx(br,{className:"h-5 w-5 text-muted-foreground"}),L.name,!L.is_active&&e.jsx(nt,{variant:"secondary",children:"Inactive"})]}),e.jsx(fr,{children:L.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>a(L),children:[e.jsx(va,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{size:"sm",onClick:()=>S(L),children:[e.jsx(rd,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subject:"}),e.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-sm",children:L.subject})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Variables:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:L.available_variables.map(R=>e.jsx(nt,{variant:"outline",className:"font-mono text-xs",children:`{{${R.key}}}`},R.key))})]})]})})]},L.id))}),e.jsx(_s,{open:!!n&&!s,onOpenChange:()=>a(null),children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{children:["Email Preview: ",n==null?void 0:n.name]}),e.jsxs(Zr,{children:["Subject: ",n==null?void 0:n.subject.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),n&&e.jsx("div",{className:"border rounded-lg p-4 bg-white",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:I(n.body_html,n.available_variables)}})})]})})]})})}function Q0s(){const t=ss(),[s,r]=C.useState("templates"),[n,a]=C.useState(null),[o,l]=C.useState(null),[i,c]=C.useState(!1),[u,p]=C.useState(!1),[f,y]=C.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[_,b]=C.useState({name:"",description:"",icon:"📧"}),{data:w=[]}=wt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:V,error:X}=await G.from("email_template_categories").select("*").order("sort_order");if(X)throw X;return V}}),{data:j=[],isLoading:N}=wt({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:V,error:X}=await G.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(X)throw X;return V}}),S=Dt({mutationFn:async V=>{const X={title:V.title,subject:V.subject,body:V.body,description:V.description||null,tone:V.tone||null,category_id:V.category_id||null,is_active:V.is_active};if(V.id){const{error:se}=await G.from("agent_email_templates").update(X).eq("id",V.id);if(se)throw se}else{const{error:se}=await G.from("agent_email_templates").insert(X);if(se)throw se}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),c(!1),me.success(n?"Template updated":"Template created")},onError:()=>me.error("Failed to save template")}),T=Dt({mutationFn:async V=>{const{error:X}=await G.from("agent_email_templates").delete().eq("id",V);if(X)throw X},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),me.success("Template deleted")}}),I=Dt({mutationFn:async V=>{const X={name:V.name,description:V.description||null,icon:V.icon};if(V.id){const{error:se}=await G.from("email_template_categories").update(X).eq("id",V.id);if(se)throw se}else{const se=w.length>0?Math.max(...w.map(Q=>Q.sort_order))+1:0,{error:ee}=await G.from("email_template_categories").insert({...X,sort_order:se});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")}),L=Dt({mutationFn:async V=>{const{error:X}=await G.from("email_template_categories").delete().eq("id",V);if(X)throw X},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),me.success("Category deleted")}}),R=()=>{a(null),y({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),c(!0)},$=V=>{a(V),y({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)},q=()=>{l(null),b({name:"",description:"",icon:"📧"}),p(!0)},U=V=>{l(V),b({name:V.name,description:V.description||"",icon:V.icon}),p(!0)};return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(Ju,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(Aa,{value:s,onValueChange:r,children:[e.jsxs(ja,{children:[e.jsxs(js,{value:"templates",className:"gap-2",children:[e.jsx(br,{className:"h-4 w-4"})," Templates"]}),e.jsxs(js,{value:"categories",className:"gap-2",children:[e.jsx(Cm,{className:"h-4 w-4"})," Categories"]})]}),e.jsxs($s,{value:"templates",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:R,className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Template"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Category"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Tone"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:N?e.jsx(ks,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin mx-auto"})})}):j.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):j.map(V=>e.jsxs(ks,{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(nt,{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(nt,{variant:"secondary",children:V.tone}):"—"}),e.jsx(dt,{children:e.jsx(nt,{variant:V.is_active?"default":"secondary",children:V.is_active?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$(V),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&T.mutate(V.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},V.id))})]})})})]}),e.jsxs($s,{value:"categories",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:q,className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"})," Add Category"]})}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:w.map(V=>e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:V.icon})," ",V.name]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>U(V),children:e.jsx($a,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{confirm("Delete this category?")&&L.mutate(V.id)},children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:V.description||"No description"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[j.filter(X=>X.category_id===V.id).length," templates"]})]})]},V.id))})]})]}),e.jsx(_s,{open:i,onOpenChange:c,children:e.jsxs(vs,{className:"sm:max-w-[700px] max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:n?"Edit Template":"New Template"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Title"}),e.jsx(Fe,{value:f.title,onChange:V=>y(X=>({...X,title:V.target.value})),placeholder:"e.g. Quick Check-in"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Category"}),e.jsxs(rr,{value:f.category_id,onValueChange:V=>y(X=>({...X,category_id:V})),children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select category"})}),e.jsx(sr,{children:w.map(V=>e.jsxs(Tt,{value:V.id,children:[V.icon," ",V.name]},V.id))})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Subject Line"}),e.jsx(Fe,{value:f.subject,onChange:V=>y(X=>({...X,subject:V.target.value})),placeholder:"e.g. Hey {{first_name}}, just checking in!"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}",", ","{{full_name}}"," for merge variables"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Email Body"}),e.jsx(Ar,{value:f.body,onChange:V=>y(X=>({...X,body:V.target.value})),rows:12,placeholder:"Write your email template...",className:"resize-y"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Description (internal)"}),e.jsx(Fe,{value:f.description,onChange:V=>y(X=>({...X,description:V.target.value})),placeholder:"Short description for admin reference"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Tone"}),e.jsx(Fe,{value:f.tone,onChange:V=>y(X=>({...X,tone:V.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:f.is_active,onCheckedChange:V=>y(X=>({...X,is_active:V}))}),e.jsx(_e,{children:"Active"})]})]}),e.jsxs(Vn,{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(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),n?"Save Changes":"Create Template"]})]})]})}),e.jsx(_s,{open:u,onOpenChange:p,children:e.jsxs(vs,{className:"sm:max-w-[450px]",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:o?"Edit Category":"New Category"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-[60px_1fr] gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Icon"}),e.jsx(Fe,{value:_.icon,onChange:V=>b(X=>({...X,icon:V.target.value})),className:"text-center text-lg"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Name"}),e.jsx(Fe,{value:_.name,onChange:V=>b(X=>({...X,name:V.target.value})),placeholder:"e.g. Check-in & Stay in Touch"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Description"}),e.jsx(Fe,{value:_.description,onChange:V=>b(X=>({...X,description:V.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>I.mutate({..._,id:o==null?void 0:o.id}),disabled:I.isPending||!_.name,children:[I.isPending&&e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const J0s=({brokerageId:t})=>{var sc,Vt;const{toast:s}=Ra(),r=Pr(),[n,a]=C.useState([]),[o,l]=C.useState(!0),[i,c]=C.useState(""),[u,p]=C.useState("all"),[f,y]=C.useState(new Set),[_,b]=C.useState(!1),[w,j]=C.useState({}),[N,S]=C.useState(!1),[T,I]=C.useState(!1),[L,R]=C.useState({email:"",name:"",password:"",phone:""}),[$,q]=C.useState(!1),[U,V]=C.useState(null),[X,se]=C.useState(!1),[ee,Q]=C.useState(!1),[de,re]=C.useState(!1),[ne,le]=C.useState(""),[he,we]=C.useState(!1),[ye,je]=C.useState([]),[ke,We]=C.useState(!1),[be,Me]=C.useState(!1),[Ae,Re]=C.useState(null),[Te,qe]=C.useState({name:"",phone:"",email:""}),[ct,De]=C.useState(!1),[Rt,pe]=C.useState(!1),[Je,lt]=C.useState(null),[rt,Se]=C.useState("asc"),[it,$e]=C.useState(!1),[ot,Ue]=C.useState(null),[Ke,Xe]=C.useState(!1),[He,Ye]=C.useState(null),[tt,Et]=C.useState(""),[qt,ms]=C.useState(!1),[Xt,rs]=C.useState(null);C.useEffect(()=>{Ms(),ps()},[t]);const ps=async()=>{try{const{data:ve,error:ze}=await G.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if(ze)throw ze;je((ve==null?void 0:ve.map(Qe=>Qe.user_id))||[])}catch(ve){console.error("Error loading brokerage managers:",ve)}},Ms=async()=>{try{l(!0);const{data:ve,error:ze}=await G.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if(ze)throw ze;const Qe=ve.agents||[];if(a(Qe),Qe.length>0){const Ct=Qe.map(zt=>zt.id),{data:Nt}=await G.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",Ct);if(Nt&&Nt.length>0){const zt=Nt.map(Qt=>Qt.assistant_id),{data:Kt}=await G.from("profiles").select("id, name, email").in("id",zt),$t={};for(const Qt of Nt){const Is=Kt==null?void 0:Kt.find(gs=>gs.id===Qt.assistant_id);Is&&($t[Qt.agent_id]={name:Is.name||"",email:Is.email||""})}j($t)}else j({})}}catch(ve){console.error("Error loading agents:",ve),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{l(!1)}},jt=async()=>{if(!L.email||!L.name||!L.password){s({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}I(!0);try{const{data:{session:ve}}=await G.auth.getSession(),ze=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ve==null?void 0:ve.access_token}`},body:JSON.stringify({...L,brokerageId:t})}),Qe=await ze.json();if(!ze.ok)throw new Error(Qe.error||"Failed to create agent");s({title:"Success",description:`Agent ${L.email} created successfully`}),R({email:"",name:"",password:"",phone:""}),S(!1),Ms()}catch(ve){console.error("Error creating agent:",ve),s({title:"Error",description:ve.message||"Failed to create agent",variant:"destructive"})}finally{I(!1)}},As=async ve=>{try{const{data:{session:ze}}=await G.auth.getSession(),Qe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ze==null?void 0:ze.access_token}`},body:JSON.stringify({userId:ve})}),Ct=await Qe.json();if(!Qe.ok)throw new Error(Ct.error||"Failed to resend welcome email");s({title:"Success",description:"Welcome email sent successfully"})}catch(ze){console.error("Error resending welcome email:",ze),s({title:"Error",description:ze.message||"Failed to resend welcome email",variant:"destructive"})}},Ps=async(ve,ze)=>{try{const{error:Qe}=await G.functions.invoke("send-password-reset",{body:{email:ve,redirectTo:window.location.origin}});if(Qe)throw Qe;s({title:"Password Reset Sent",description:`Password reset email sent to ${ze}`})}catch(Qe){console.error("Error sending password reset:",Qe),s({title:"Error",description:Qe.message||"Failed to send password reset email",variant:"destructive"})}},ar=ve=>{V(ve),q(!0)},Dn=ve=>{Re(ve),qe({name:ve.name,phone:ve.phone||"",email:ve.email}),Me(!0)},Va=async()=>{if(!Ae)return;if(!Te.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const ve=Te.email.trim().toLowerCase()!==Ae.email.toLowerCase();De(!0);try{if(ve){if(!Te.email.trim())throw new Error("Email is required");pe(!0);const{data:{session:Qe}}=await G.auth.getSession(),Ct=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Qe==null?void 0:Qe.access_token}`},body:JSON.stringify({agentId:Ae.id,newEmail:Te.email.trim(),brokerageId:t})}),Nt=await Ct.json();if(pe(!1),!Ct.ok)throw new Error(Nt.error||"Failed to update email")}const{error:ze}=await G.from("profiles").update({name:Te.name.trim(),phone:Te.phone.trim()||null}).eq("id",Ae.id);if(ze)throw ze;s({title:"Success",description:"Agent profile updated successfully"}),Me(!1),Re(null),Ms()}catch(ze){console.error("Error updating agent:",ze),s({title:"Error",description:ze.message||"Failed to update agent",variant:"destructive"})}finally{De(!1),pe(!1)}},pa=async()=>{if(!ne){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}we(!0);try{const{data:{session:ve}}=await G.auth.getSession(),ze=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ve==null?void 0:ve.access_token}`},body:JSON.stringify({userId:ne,role:"brokerage_manager",action:"add",brokerageId:t})}),Qe=await ze.json();if(!ze.ok)throw new Error(Qe.error||"Failed to add brokerage manager");s({title:"Success",description:"Brokerage manager added successfully"}),re(!1),le(""),ps()}catch(ve){console.error("Error adding brokerage manager:",ve),s({title:"Error",description:ve.message||"Failed to add brokerage manager",variant:"destructive"})}finally{we(!1)}},qa=async ve=>{try{const{data:{session:ze}}=await G.auth.getSession(),Qe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ze==null?void 0:ze.access_token}`},body:JSON.stringify({userId:ve,role:"brokerage_manager",action:"remove",brokerageId:t})}),Ct=await Qe.json();if(!Qe.ok)throw new Error(Ct.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),ps()}catch(ze){console.error("Error removing brokerage manager:",ze),s({title:"Error",description:ze.message||"Failed to remove brokerage manager",variant:"destructive"})}},Kr=ve=>ye.includes(ve),Yn=ve=>{Ye(ve),Et(""),Xe(!0)},mn=async()=>{if(!(!He||!tt)){if(tt.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}ms(!0);try{const{data:{session:ve}}=await G.auth.getSession(),ze=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ve==null?void 0:ve.access_token}`},body:JSON.stringify({agentId:He.id,brokerageId:t,action:"set_password",newPassword:tt})}),Qe=await ze.json();if(!ze.ok)throw new Error(Qe.error||"Failed to set password");s({title:"Success",description:`Password set for ${He.name}`}),Xe(!1),Ye(null),Et("")}catch(ve){console.error("Error setting password:",ve),s({title:"Error",description:ve.message||"Failed to set password",variant:"destructive"})}finally{ms(!1)}}},Gn=async ve=>{rs(ve.id);try{const{data:{session:ze}}=await G.auth.getSession(),Qe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ze==null?void 0:ze.access_token}`},body:JSON.stringify({agentId:ve.id,brokerageId:t,action:"claim_account"})}),Ct=await Qe.json();if(!Qe.ok)throw new Error(Ct.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${ve.name}`}),Ms()}catch(ze){console.error("Error claiming account:",ze),s({title:"Error",description:ze.message||"Failed to claim account",variant:"destructive"})}finally{rs(null)}},Zt=async()=>{if(U){se(!0);try{const{data:{session:ve}}=await G.auth.getSession(),ze=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ve==null?void 0:ve.access_token}`},body:JSON.stringify({userId:U.id,brokerageId:t})}),Qe=await ze.json();if(!ze.ok)throw new Error(Qe.error||"Failed to remove agent");s({title:"Success",description:`${U.name} has been removed from your brokerage`}),q(!1),V(null),Ms()}catch(ve){console.error("Error removing agent:",ve),s({title:"Error",description:ve.message||"Failed to remove agent",variant:"destructive"})}finally{se(!1)}}},$r=ve=>{const ze=ve.trim().split(" ");return ze.length>1?ze[ze.length-1].toLowerCase():ve.toLowerCase()},es=ve=>{Je===ve?Se(rt==="asc"?"desc":"asc"):(lt(ve),Se("asc"))},an=ve=>Je!==ve?e.jsx(ud,{className:"ml-1 h-4 w-4"}):rt==="asc"?e.jsx(gu,{className:"ml-1 h-4 w-4"}):e.jsx(Oh,{className:"ml-1 h-4 w-4"}),Ha=n.filter(ve=>{if(u==="active"&&!ve.claimed||u==="pending"&&ve.claimed)return!1;if(!i)return!0;const ze=i.toLowerCase();return ve.name.toLowerCase().includes(ze)||ve.email.toLowerCase().includes(ze)}),Xn=[...Ha].sort((ve,ze)=>{if(!Je)return 0;let Qe=0;return Je==="name"?Qe=$r(ve.name).localeCompare($r(ze.name)):Je==="status"&&(Qe=ve.claimed===ze.claimed?0:ve.claimed?-1:1),rt==="asc"?Qe:-Qe});Ha.filter(ve=>ve.claimed&&!Kr(ve.id));const Ir=ve=>{y(ze=>{const Qe=new Set(ze);return Qe.has(ve)?Qe.delete(ve):Qe.add(ve),Qe})},_i=()=>{f.size===Xn.length?y(new Set):y(new Set(Xn.map(ve=>ve.id)))},rl=()=>{y(new Set)},Ni=async()=>{const ve=Array.from(f);if(ve.length===0)return;b(!0);let ze=0,Qe=0;try{const{data:{session:Ct}}=await G.auth.getSession();for(const Nt of ve)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ct==null?void 0:Ct.access_token}`},body:JSON.stringify({userId:Nt})})).ok?ze++:Qe++}catch{Qe++}ze>0?s({title:"Success",description:`Welcome emails sent to ${ze} agent${ze>1?"s":""}${Qe>0?` (${Qe} failed)`:""}`}):s({title:"Error",description:"Failed to send welcome emails",variant:"destructive"}),rl()}catch(Ct){console.error("Error bulk sending welcome emails:",Ct),s({title:"Error",description:Ct.message||"Failed to send welcome emails",variant:"destructive"})}finally{b(!1)}};return o?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Agents"}),e.jsx(fr,{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(Bh,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(K,{variant:"outline",onClick:()=>Q(!0),children:[e.jsx(Yv,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(K,{onClick:()=>S(!0),children:[e.jsx(Pc,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-4 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search agents...",value:i,onChange:ve=>c(ve.target.value),className:"pl-9"})]}),e.jsxs(rr,{value:u,onValueChange:ve=>p(ve),children:[e.jsx(tr,{className:"w-[160px]",children:e.jsx(nr,{placeholder:"Filter by status"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Agents"}),e.jsx(Tt,{value:"active",children:"Active"}),e.jsx(Tt,{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 ze=n.filter(Qe=>f.has(Qe.id)&&Qe.email).map(Qe=>({email:Qe.email,name:Qe.name}));sessionStorage.setItem("campaign_direct_recipients",JSON.stringify(ze)),r("/admin/email-campaigns/new?directMode=1",{state:{directRecipients:ze}})},disabled:_,children:[e.jsx(bp,{className:"mr-2 h-4 w-4"}),"Email Agents (",f.size,")"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:Ni,disabled:_,children:[e.jsx(br,{className:"mr-2 h-4 w-4"}),_?"Sending...":"Resend Welcome Email"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:rl,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"w-[40px]",children:e.jsx(Yo,{checked:Xn.length>0&&f.size===Xn.length,onCheckedChange:_i,"aria-label":"Select all"})}),e.jsx(bt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>es("name"),children:["Name (Last)",an("name")]})}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>es("status"),children:["Status",an("status")]})}),e.jsx(bt,{children:"Actions"})]})}),e.jsx(Pn,{children:Xn.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):Xn.map(ve=>e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsx(Yo,{checked:f.has(ve.id),onCheckedChange:()=>Ir(ve.id),"aria-label":`Select ${ve.name}`})}),e.jsx(dt,{className:"font-medium",children:ve.name}),e.jsx(dt,{children:ve.email}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[ve.claimed?e.jsx(nt,{variant:"default",children:"Active"}):e.jsx(nt,{variant:"secondary",children:"Pending"}),Kr(ve.id)&&e.jsxs(nt,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(dL,{className:"mr-1 h-3 w-3"}),"Manager"]}),w[ve.id]&&e.jsxs(nt,{variant:"outline",className:"text-xs",children:[e.jsx(mr,{className:"mr-1 h-3 w-3"}),"Asst: ",w[ve.id].name||w[ve.id].email]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{Ue(ve),$e(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:e.jsx(Zd,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Dn(ve),title:"Edit agent",children:e.jsx($a,{className:"h-4 w-4"})}),!ve.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>As(ve.id),title:"Resend welcome email",children:e.jsx(br,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Gn(ve),title:"Claim account for agent",disabled:Xt===ve.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(zb,{className:"h-4 w-4"})})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Yn(ve),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:e.jsx(vh,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Ps(ve.email,ve.name),title:"Send password reset email",children:e.jsx(q4,{className:"h-4 w-4"})}),Kr(ve.id)&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>qa(ve.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(Bh,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>ar(ve),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},ve.id))})]})})]})]}),e.jsx(_s,{open:N,onOpenChange:S,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Add New Agent"}),e.jsx(Zr,{children:"Create a new agent account. They'll receive an email to set up their account."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"name",children:"Name"}),e.jsx(Fe,{id:"name",value:L.name,onChange:ve=>R({...L,name:ve.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"email",children:"Email"}),e.jsx(Fe,{id:"email",type:"email",value:L.email,onChange:ve=>R({...L,email:ve.target.value}),placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(Fe,{id:"phone",type:"tel",value:L.phone,onChange:ve=>R({...L,phone:ve.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"password",children:"Temporary Password"}),e.jsx(Fe,{id:"password",type:"password",value:L.password,onChange:ve=>R({...L,password:ve.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(K,{onClick:jt,disabled:T,children:T?"Creating...":"Create Agent"})]})]})}),e.jsx(_s,{open:$,onOpenChange:q,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Remove Agent"}),e.jsxs(Zr,{children:["Are you sure you want to remove ",e.jsx("strong",{children:U==null?void 0:U.name})," from your brokerage? This will revoke their access to the dashboard."]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Zt,disabled:X,children:X?"Removing...":"Remove Agent"})]})]})}),e.jsx(Met,{open:ee,onOpenChange:Q,fixedBrokerageId:t,onSuccess:Ms}),e.jsx(_s,{open:de,onOpenChange:re,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Add Brokerage Manager"}),e.jsx(Zr,{children:"Promote an existing active agent to brokerage manager. They will be able to manage agents and view analytics."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(_e,{children:"Select Agent"}),e.jsxs(Lo,{open:ke,onOpenChange:We,children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":ke,className:"w-full justify-between",children:[ne?((sc=n.find(ve=>ve.id===ne))==null?void 0:sc.name)+" ("+((Vt=n.find(ve=>ve.id===ne))==null?void 0:Vt.email)+")":"Select an agent to promote...",e.jsx(xg,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Eo,{className:"w-full p-0",align:"start",children:e.jsxs(Mg,{children:[e.jsx(Tg,{placeholder:"Search by name or email..."}),e.jsxs(Ag,{className:"max-h-[200px]",children:[e.jsx(Eg,{children:"No eligible agents found."}),e.jsx(Pg,{children:n.filter(ve=>!Kr(ve.id)).map(ve=>e.jsxs(up,{value:`${ve.name} ${ve.email}`,onSelect:()=>{le(ve.id),We(!1)},children:[e.jsx(ma,{className:`mr-2 h-4 w-4 ${ne===ve.id?"opacity-100":"opacity-0"}`}),ve.name," (",ve.email,")"]},ve.id))})]})]})})]}),n.filter(ve=>!Kr(ve.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>re(!1),children:"Cancel"}),e.jsx(K,{onClick:pa,disabled:he||!ne,children:he?"Adding...":"Add as Manager"})]})]})}),e.jsx(_s,{open:be,onOpenChange:Me,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Edit Agent"}),e.jsxs(Zr,{children:["Update profile information for ",Ae==null?void 0:Ae.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"edit-name",children:"Name"}),e.jsx(Fe,{id:"edit-name",value:Te.name,onChange:ve=>qe({...Te,name:ve.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"edit-email",children:"Email"}),e.jsx(Fe,{id:"edit-email",type:"email",value:Te.email,onChange:ve=>qe({...Te,email:ve.target.value}),placeholder:"agent@example.com"}),Te.email.trim().toLowerCase()!==(Ae==null?void 0:Ae.email.toLowerCase())&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Changing email will update their login credentials"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(Fe,{id:"edit-phone",type:"tel",value:Te.phone,onChange:ve=>qe({...Te,phone:ve.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Me(!1),children:"Cancel"}),e.jsx(K,{onClick:Va,disabled:ct||Rt,children:Rt?"Updating email...":ct?"Saving...":"Save Changes"})]})]})}),ot&&e.jsx(Tet,{open:it,onOpenChange:ve=>{$e(ve),ve||Ue(null)},userId:ot.id,userName:ot.name}),e.jsx(_s,{open:Ke,onOpenChange:Xe,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Set Password"}),e.jsxs(Zr,{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(_e,{htmlFor:"new-password",children:"New Password"}),e.jsx(Fe,{id:"new-password",type:"password",value:tt,onChange:ve=>Et(ve.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(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Xe(!1),children:"Cancel"}),e.jsx(K,{onClick:mn,disabled:qt||!tt||tt.length<6,children:qt?"Setting...":"Set Password"})]})]})})]})},evs={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},tvs={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},svs=t=>{switch(t){case"academy_video":return e.jsx(Nn,{className:"h-4 w-4"});case"template":return e.jsx(In,{className:"h-4 w-4"});case"toolbox":return e.jsx(In,{className:"h-4 w-4"});case"newsletter":return e.jsx(s1,{className:"h-4 w-4"});case"social_swag":return e.jsx(hn,{className:"h-4 w-4"});case"event":return e.jsx(on,{className:"h-4 w-4"});default:return e.jsx(rn,{className:"h-4 w-4"})}},rvs=({brokerageId:t})=>{const{toast:s}=Ra(),[r,n]=C.useState([]),[a,o]=C.useState([]),[l,i]=C.useState([]),[c,u]=C.useState(!0),[p,f]=C.useState(null);C.useEffect(()=>{y()},[t]);const y=async()=>{try{u(!0);const{data:w,error:j}=await G.from("profiles").select("id, name, email").eq("brokerage_id",t);if(j)throw j;const N=w.map(X=>X.id),S=new Map(w.map(X=>[X.id,X]));if(N.length===0){n([]),o([]),i([]);return}const{data:T,error:I}=await G.from("activity_logs").select("*").in("user_id",N).order("launched_at",{ascending:!1});if(I)throw I;const L=T.map(X=>{var se,ee;return{id:X.id,user_id:X.user_id,app_name:X.app_name,launched_at:X.launched_at,user_name:((se=S.get(X.user_id))==null?void 0:se.name)||"Unknown",user_email:((ee=S.get(X.user_id))==null?void 0:ee.email)||"Unknown"}});n(L);const{data:R,error:$}=await G.from("content_engagement_logs").select("*").in("user_id",N).order("created_at",{ascending:!1});if($)throw $;const q=(R||[]).map(X=>{var se,ee;return{id:X.id,user_id:X.user_id,resource_type:X.resource_type,resource_id:X.resource_id,resource_title:X.resource_title,action_type:X.action_type,created_at:X.created_at,user_name:((se=S.get(X.user_id))==null?void 0:se.name)||"Unknown",user_email:((ee=S.get(X.user_id))==null?void 0:ee.email)||"Unknown"}});o(q);const U=new Map;w.forEach(X=>{U.set(X.id,{user_id:X.id,user_name:X.name,user_email:X.email,app_launches:0,content_views:0,last_activity:""})}),L.forEach(X=>{const se=U.get(X.user_id);se&&(se.app_launches++,(!se.last_activity||new Date(X.launched_at)>new Date(se.last_activity))&&(se.last_activity=X.launched_at))}),q.forEach(X=>{const se=U.get(X.user_id);se&&(se.content_views++,(!se.last_activity||new Date(X.created_at)>new Date(se.last_activity))&&(se.last_activity=X.created_at))});const V=Array.from(U.values()).filter(X=>X.app_launches>0||X.content_views>0).sort((X,se)=>new Date(se.last_activity).getTime()-new Date(X.last_activity).getTime());i(V)}catch(w){console.error("Error loading activity:",w),s({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{u(!1)}},_=w=>r.filter(j=>j.user_id===w),b=w=>a.filter(j=>j.user_id===w);return c?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Agent Activity"}),e.jsx(fr,{children:"Track app usage and content engagement - click an agent for details"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Agent"}),e.jsx(bt,{className:"text-center",children:"App Launches"}),e.jsx(bt,{className:"text-center",children:"Content Views"}),e.jsx(bt,{children:"Last Active"})]})}),e.jsx(Pn,{children:l.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(w=>e.jsxs(ks,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f({id:w.user_id,name:w.user_name,email:w.user_email}),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:w.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:w.user_email})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(wl,{className:"h-3 w-3"}),w.app_launches]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(In,{className:"h-3 w-3"}),w.content_views]})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:w.last_activity&&Yd(new Date(w.last_activity),{addSuffix:!0})})]},w.user_id))})]})})})]}),e.jsx(_s,{open:!!p,onOpenChange:w=>!w&&f(null),children:e.jsxs(vs,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{children:[p==null?void 0:p.name,"'s Activity"]}),e.jsx(Zr,{children:p==null?void 0:p.email})]}),e.jsxs(Aa,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(ja,{className:"grid w-full grid-cols-2",children:[e.jsx(js,{value:"content",children:"Content Engagement"}),e.jsx(js,{value:"apps",children:"App Launches"})]}),e.jsx($s,{value:"content",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Resource"}),e.jsx(bt,{children:"Type"}),e.jsx(bt,{children:"Action"}),e.jsx(bt,{children:"Time"})]})}),e.jsx(Pn,{children:p&&b(p.id).length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):p&&b(p.id).map(w=>e.jsxs(ks,{children:[e.jsx(dt,{className:"max-w-[200px] truncate font-medium",children:w.resource_title}),e.jsx(dt,{children:e.jsxs(nt,{variant:"outline",className:"gap-1",children:[svs(w.resource_type),evs[w.resource_type]||w.resource_type]})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:tvs[w.action_type]||w.action_type})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Yd(new Date(w.created_at),{addSuffix:!0})})]},w.id))})]})})}),e.jsx($s,{value:"apps",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"App"}),e.jsx(bt,{children:"Time"})]})}),e.jsx(Pn,{children:p&&_(p.id).length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):p&&_(p.id).map(w=>e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsx(nt,{variant:"outline",children:w.app_name})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:Yd(new Date(w.launched_at),{addSuffix:!0})})]},w.id))})]})})})]})]})})]})},nvs=({brokerageId:t})=>{const{toast:s}=Ra(),[r,n]=C.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=C.useState(!0);C.useEffect(()=>{l()},[t]);const l=async()=>{try{o(!0);const{data:i,error:c}=await G.from("profiles").select("id").eq("brokerage_id",t);if(c)throw c;const u=i.map(L=>L.id),p=u.length;if(u.length===0){o(!1);return}const{data:f,error:y}=await G.from("profiles").select("id, email").in("id",u);if(y)throw y;const{count:_}=await G.from("profiles").select("*",{count:"exact",head:!0}).eq("brokerage_id",t).not("last_login","is",null),b=_||0,w=p-b,{count:j}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u),N=new Date;N.setDate(N.getDate()-7);const{count:S}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",N.toISOString()),T=new Date;T.setMonth(T.getMonth()-1);const{count:I}=await G.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",T.toISOString());n({totalAgents:p,activeAgents:b,pendingAgents:w,totalLaunches:j||0,launchesThisWeek:S||0,launchesThisMonth:I||0})}catch(i){console.error("Error loading analytics:",i),s({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{o(!1)}};return a?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalAgents}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.activeAgents," active, ",r.pendingAgents," pending"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(vi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.activeAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.totalAgents>0?`${Math.round(r.activeAgents/r.totalAgents*100)}% of total`:"0% of total"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(Tn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.pendingAgents}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(gp,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.totalLaunches}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"This Week"}),e.jsx(gp,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"This Month"}),e.jsx(gp,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Oe,{children:[e.jsx("div",{className:"text-2xl font-bold",children:r.launchesThisMonth}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]})]})},avs=({brokerageId:t})=>{const[s,r]=C.useState([]),[n,a]=C.useState(!0),[o,l]=C.useState(!1),[i,c]=C.useState(!1),[u,p]=C.useState({description:"",maxUses:""});C.useEffect(()=>{f()},[t]);const f=async()=>{try{const{data:N,error:S}=await G.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(S)throw S;r(N||[])}catch(N){console.error("Error loading invite codes:",N),me.error("Failed to load invite links")}finally{a(!1)}},y=()=>Math.random().toString(36).substring(2,8).toUpperCase(),_=async()=>{l(!0);try{const N=y(),{error:S}=await G.from("invite_codes").insert({code:N,description:u.description||null,max_uses:u.maxUses?parseInt(u.maxUses):null,brokerage_id:t,is_active:!0});if(S)throw S;me.success("Invite link created!"),c(!1),p({description:"",maxUses:""}),f()}catch(N){console.error("Error creating invite code:",N),me.error("Failed to create invite link")}finally{l(!1)}},b=async N=>{try{const{error:S}=await G.from("invite_codes").delete().eq("id",N);if(S)throw S;me.success("Invite link deleted"),r(s.filter(T=>T.id!==N))}catch(S){console.error("Error deleting invite code:",S),me.error("Failed to delete invite link")}},w=async(N,S)=>{try{const{error:T}=await G.from("invite_codes").update({is_active:!S}).eq("id",N);if(T)throw T;r(s.map(I=>I.id===N?{...I,is_active:!S}:I)),me.success(`Invite link ${S?"deactivated":"activated"}`)}catch(T){console.error("Error toggling invite code:",T),me.error("Failed to update invite link")}},j=N=>{const S=`${window.location.origin}/join?code=${N}`;navigator.clipboard.writeText(S),me.success("Link copied to clipboard!")};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-8",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Vo,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(fr,{children:"Create shareable links for agents to join your brokerage"})]}),e.jsxs(_s,{open:i,onOpenChange:c,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Create Invite Link"}),e.jsx(Zr,{children:"Create a new invite link for agents to join your brokerage"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"description",children:"Description (optional)"}),e.jsx(Fe,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:u.description,onChange:N=>p({...u,description:N.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(Fe,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:u.maxUses,onChange:N=>p({...u,maxUses:N.target.value})})]}),e.jsx(K,{onClick:_,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Invite Link"})]})]})]})]}),e.jsx(Oe,{children:s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Vo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No invite links yet"}),e.jsx("p",{className:"text-sm",children:"Create one to start inviting agents"})]}):e.jsx("div",{className:"space-y-3",children:s.map(N=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-sm font-mono bg-muted px-2 py-0.5 rounded",children:N.code}),e.jsx(nt,{variant:N.is_active?"default":"secondary",children:N.is_active?"Active":"Inactive"})]}),N.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:N.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[N.uses_count," uses",N.max_uses&&` / ${N.max_uses} max`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>j(N.code),title:"Copy link",children:e.jsx(mi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(N.id,N.is_active),title:N.is_active?"Deactivate":"Activate",children:N.is_active?"Disable":"Enable"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(N.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(jr,{className:"h-4 w-4"})})]})]},N.id))})})]})},ivs=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,c]=C.useState(""),[u,p]=C.useState([]),[f,y]=C.useState(""),[_,b]=C.useState(!1),w=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),j=()=>{const I=i.trim().toLowerCase();if(I&&w(I)&&!u.includes(I)){if(u.length>=10){me.error("Maximum 10 emails per invite");return}p([...u,I]),c("")}else I&&!w(I)?me.error("Please enter a valid email address"):u.includes(I)&&me.error("Email already added")},N=I=>{p(u.filter(L=>L!==I))},S=I=>{(I.key==="Enter"||I.key===",")&&(I.preventDefault(),j())},T=async()=>{if(u.length===0){me.error("Please add at least one email address");return}b(!0);try{const{data:I,error:L}=await G.functions.invoke("send-referral-invite",{body:{emails:u,personalMessage:f.trim()||void 0,referralCode:r,brokerageId:n,senderName:a,brokerageName:o}});if(L)throw L;I.successCount===I.totalCount?me.success(`${I.successCount} invite${I.successCount>1?"s":""} sent successfully!`):me.warning(`${I.successCount} of ${I.totalCount} invites sent. Some failed.`),p([]),y(""),s(!1),l==null||l()}catch(I){console.error("Error sending invites:",I),me.error("Failed to send invites. Please try again.")}finally{b(!1)}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-[550px]",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5 text-primary"}),"Invite Broker Friends"]}),e.jsx(Zr,{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(bo,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:"Earn $25/month for each referral!"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"When they sign up and stay for 30 days, you save on your membership forever."})]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"email",children:"Email Addresses (up to 10)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{id:"email",type:"email",placeholder:"Enter email and press Enter",value:i,onChange:I=>c(I.target.value),onKeyDown:S,onBlur:j}),e.jsx(K,{type:"button",variant:"secondary",onClick:j,children:"Add"})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:u.map(I=>e.jsxs(nt,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[I,e.jsx("button",{type:"button",onClick:()=>N(I),className:"ml-1 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Ur,{className:"h-3 w-3"})})]},I))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"message",children:"Personal Message (optional)"}),e.jsx(Ar,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:f,onChange:I=>y(I.target.value),rows:3,maxLength:500}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[f.length,"/500 characters"]})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),"What they'll receive:"]}),e.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Beautiful branded email from you"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Your personal message (if added)"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Key LevelUp features for brokerages"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Direct signup link with your referral code"]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:T,disabled:u.length===0||_,children:_?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent mr-2"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oa,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},ovs=({brokerageId:t,refreshTrigger:s})=>{const[r,n]=C.useState([]),[a,o]=C.useState(!0);C.useEffect(()=>{l()},[t,s]);const l=async()=>{try{const{data:c,error:u}=await G.from("referral_invites").select("*").eq("referrer_brokerage_id",t).order("sent_at",{ascending:!1}).limit(20);if(u)throw u;n(c||[])}catch(c){console.error("Error fetching invites:",c)}finally{o(!1)}},i=c=>{switch(c){case"signed_up":return e.jsxs(nt,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(vi,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(nt,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx($c,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),"Pending"]})}};return a?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):r.length===0?e.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[e.jsx(br,{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 ",ys(new Date(c.sent_at),"MMM d, yyyy")]})]}),i(c.status)]},c.id))]})},lvs=()=>{const{brokerageId:t,user:s}=Ws(),[r,n]=C.useState(null),[a,o]=C.useState(""),[l,i]=C.useState(""),[c,u]=C.useState([]),[p,f]=C.useState(!0),[y,_]=C.useState(!1),[b,w]=C.useState(0);C.useEffect(()=>{t&&j()},[t]);const j=async()=>{try{const[R,$]=await Promise.all([G.from("brokerages").select("name").eq("id",t).single(),s?G.from("profiles").select("name").eq("id",s.id).single():Promise.resolve({data:null})]);R.data&&o(R.data.name),$.data&&i($.data.name||"A LevelUp Member");const{data:q}=await G.from("referral_codes").select("code").eq("brokerage_id",t).single();if(q)n(q.code);else{const V=`REF${t==null?void 0:t.slice(0,8).toUpperCase()}`;await G.from("referral_codes").insert({brokerage_id:t,code:V}),n(V)}const{data:U}=await G.from("referrals").select(` *, referred_user:profiles!referred_user_id(name, email), referred_brokerage:brokerages!referred_brokerage_id(name) `).eq("referrer_brokerage_id",t).order("created_at",{ascending:!1});u(U||[])}catch(R){console.error("Error fetching referral data:",R)}finally{f(!1)}},N=()=>{const R=`https://dashboard.relevelup.com/?ref=${r}`;navigator.clipboard.writeText(R),me.success("Referral link copied to clipboard!")},S=c.filter(R=>R.status==="qualified").length,T=c.filter(R=>R.status==="pending").length,I=S*25,L=Math.max(0,Math.ceil((299-I)/25));return p?null:e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-primary/10 via-primary/5 to-background border-b",children:e.jsxs("div",{className:"px-6 py-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"bg-primary/20 rounded-full p-2",children:e.jsx(bo,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold",children:"Referral Rewards Program"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Earn $25/month off your membership for every broker you refer"})]})]}),e.jsx("div",{className:"mt-4 bg-background/80 rounded-lg p-4 border",children:e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-3xl font-bold text-primary",children:["$",I]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Savings"})]}),I>0&&e.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[e.jsx(vi,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Active"})]})]}),L>0&&I<299&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Refer ",L," more = ",e.jsx("span",{className:"text-primary",children:"FREE membership!"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your membership could cost $0/month"})]}),I>=299&&e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(hn,{className:"h-5 w-5"}),e.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),e.jsxs(Oe,{className:"pt-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs(K,{onClick:()=>_(!0),className:"w-full",size:"lg",children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(K,{onClick:N,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(mi,{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(Td,{className:"h-5 w-5 mx-auto text-green-600 mb-1"}),e.jsxs("p",{className:"text-2xl font-bold text-green-700 dark:text-green-400",children:["$",I]}),e.jsx("p",{className:"text-xs text-green-600 dark:text-green-500",children:"Monthly Savings"})]}),e.jsxs("div",{className:"text-center p-4 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsx(mr,{className:"h-5 w-5 mx-auto text-primary mb-1"}),e.jsx("p",{className:"text-2xl font-bold",children:S}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified Referrals"})]}),e.jsxs("div",{className:"text-center p-4 bg-amber-50 dark:bg-amber-950/20 rounded-lg border border-amber-200 dark:border-amber-900",children:[e.jsx(Tn,{className:"h-5 w-5 mx-auto text-amber-600 mb-1"}),e.jsx("p",{className:"text-2xl font-bold text-amber-700 dark:text-amber-400",children:T}),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(ovs,{brokerageId:t,refreshTrigger:b}),c.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Your Referrals"}),c.slice(0,5).map(R=>{var $,q;return e.jsxs("div",{className:"flex items-center justify-between p-2.5 bg-muted/30 rounded-lg",children:[e.jsx("span",{className:"text-sm truncate",children:(($=R.referred_brokerage)==null?void 0:$.name)||((q=R.referred_user)==null?void 0:q.email)||"Pending setup"}),e.jsxs(nt,{variant:R.status==="qualified"?"default":R.status==="pending"?"secondary":"destructive",className:R.status==="qualified"?"bg-green-600":"",children:[R.status==="qualified"&&e.jsx(vi,{className:"h-3 w-3 mr-1"}),R.status]})]},R.id)})]})]})]}),e.jsx(ivs,{open:y,onOpenChange:_,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>w(R=>R+1)})]})},cvs=({brokerageId:t})=>{const s=Pr(),{teams:r,isLoading:n}=QS(t),{data:a,isLoading:o}=wt({queryKey:["team-aggregate-stats",t,r.map(p=>p.id)],queryFn:async()=>{if(r.length===0)return[];const p=r.map(R=>R.id),{data:f}=await G.from("team_members").select("team_id, user_id, role").in("team_id",p);if(!f||f.length===0)return r.map(R=>({team_id:R.id,team_name:R.name,member_count:0,leader_name:null,leader_avatar:null,total_contacts:0,total_deals:0,total_videos:0}));const y=f.map(R=>R.user_id),_=f.filter(R=>R.role==="team_leader").map(R=>R.user_id),{data:b}=await G.from("profiles").select("id, name, avatar_url").in("id",_),w=new Map((b||[]).map(R=>[R.id,R])),{data:j}=await G.from("innercircle_contacts").select("owner_user_id").in("owner_user_id",y),{data:N}=await G.from("deal_pipeline").select("owner_user_id").in("owner_user_id",y),{data:S}=await G.from("agent_videos").select("owner_user_id").in("owner_user_id",y).eq("is_deleted",!1),T=new Map;(j||[]).forEach(R=>{T.set(R.owner_user_id,(T.get(R.owner_user_id)||0)+1)});const I=new Map;(N||[]).forEach(R=>{I.set(R.owner_user_id,(I.get(R.owner_user_id)||0)+1)});const L=new Map;return(S||[]).forEach(R=>{L.set(R.owner_user_id,(L.get(R.owner_user_id)||0)+1)}),r.map(R=>{const $=f.filter(Q=>Q.team_id===R.id),q=$.find(Q=>Q.role==="team_leader"),U=q?w.get(q.user_id):null,V=$.map(Q=>Q.user_id),X=V.reduce((Q,de)=>Q+(T.get(de)||0),0),se=V.reduce((Q,de)=>Q+(I.get(de)||0),0),ee=V.reduce((Q,de)=>Q+(L.get(de)||0),0);return{team_id:R.id,team_name:R.name,member_count:$.length,leader_name:(U==null?void 0:U.name)||null,leader_avatar:(U==null?void 0:U.avatar_url)||null,total_contacts:X,total_deals:se,total_videos: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(It,{children:e.jsx(xs,{className:"h-5 w-32"})}),e.jsx(Oe,{children:e.jsx(xs,{className:"h-24 w-full"})})]},p))});if(r.length===0)return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(mr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create teams to organize your agents and track their performance."}),e.jsx(K,{onClick:()=>s("/brokerage/teams"),children:"Manage Teams"})]})});const i=(a||[]).reduce((p,f)=>p+f.member_count,0),c=(a||[]).reduce((p,f)=>p+f.total_contacts,0),u=(a||[]).reduce((p,f)=>p+f.total_deals,0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 grid-cols-2 md:grid-cols-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(mr,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(mr,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(B4,{className:"h-4 w-4"})," Total Contacts"]}),e.jsx("p",{className:"text-2xl font-bold",children:c.toLocaleString()})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Rh,{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(It,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ot,{className:"text-lg",children:p.team_name}),e.jsxs(nt,{variant:"secondary",children:[p.member_count," members"]})]}),p.leader_name&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs(yn,{className:"h-6 w-6",children:[e.jsx(Da,{src:p.leader_avatar||""}),e.jsx(vn,{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(Sm,{className:"h-3 w-3 text-amber-500"}),p.leader_name]})]})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_contacts.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Contacts"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_deals.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Deals"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-semibold",children:p.total_videos.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]},p.team_id))}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{variant:"outline",onClick:()=>s("/brokerage/teams"),children:"Manage Teams →"})})]})},dvs=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Ws(),i=Pr(),{toast:c}=Ra(),[u,p]=C.useState(""),[f,y]=C.useState(!0),_=o||(a.length>0?a[0].id:r);C.useEffect(()=>{if(!t||!s&&!n){i("/dashboard");return}!o&&a.length>0&&l(a[0].id),_?b():a.length===0&&!r&&y(!1)},[t,s,n,_,i,a,o]);const b=async()=>{if(!_){y(!1);return}try{const{data:w,error:j}=await G.from("brokerages").select("name").eq("id",_).single();if(j)throw j;p(w.name)}catch(w){console.error("Error loading brokerage info:",w),c({title:"Error",description:"Failed to load brokerage information",variant:"destructive"})}finally{y(!1)}};return f?e.jsx(Es,{title:"Manage Brokerages",description:"Loading brokerage information...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):_?e.jsx(Es,{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(rr,{value:o||"",onValueChange:l,children:[e.jsxs(tr,{className:"w-[280px]",children:[e.jsx(La,{className:"mr-2 h-4 w-4"}),e.jsx(nr,{placeholder:"Select brokerage"})]}),e.jsx(sr,{children:a.map(w=>e.jsx(Tt,{value:w.id,children:w.name},w.id))})]})]}),e.jsxs(Aa,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(ja,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[e.jsx(js,{value:"agents",children:"Agents"}),e.jsx(js,{value:"teams",children:"Teams"}),e.jsx(js,{value:"invite",children:"Invite Links"}),e.jsx(js,{value:"referrals",children:"Referrals"}),e.jsx(js,{value:"leaderboard",children:"Leaderboard"}),e.jsx(js,{value:"activity",children:"Activity"}),e.jsx(js,{value:"analytics",children:"Analytics"}),e.jsx(js,{value:"shares",children:"Shares"})]}),e.jsx($s,{value:"agents",className:"space-y-4",children:e.jsx(J0s,{brokerageId:_})}),e.jsx($s,{value:"teams",className:"space-y-4",children:e.jsx(cvs,{brokerageId:_})}),e.jsx($s,{value:"invite",className:"space-y-4",children:e.jsx(avs,{brokerageId:_})}),e.jsx($s,{value:"referrals",className:"space-y-4",children:e.jsx(lvs,{})}),e.jsx($s,{value:"leaderboard",className:"space-y-4",children:e.jsx(HJe,{brokerageId:_,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx($s,{value:"activity",className:"space-y-4",children:e.jsx(rvs,{brokerageId:_})}),e.jsx($s,{value:"analytics",className:"space-y-4",children:e.jsx(nvs,{brokerageId:_})}),e.jsx($s,{value:"shares",className:"space-y-4",children:e.jsx(ctt,{brokerageOnly:!0,brokerageId:_})})]})]})}):e.jsx(Es,{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(La,{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 uvs({brokerageId:t,canManage:s}){const{user:r}=Ws(),[n,a]=C.useState([]),[o,l]=C.useState(!0),[i,c]=C.useState(!1),[u,p]=C.useState(null),[f,y]=C.useState(null),[_,b]=C.useState(!1),[w,j]=C.useState(""),[N,S]=C.useState(""),[T,I]=C.useState(!1),L=async()=>{try{const{data:V,error:X}=await G.from("brokerage_announcements").select("*").eq("brokerage_id",t).order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1});if(X)throw X;const se=V;if(se&&se.length>0){const ee=[...new Set(se.map(ne=>ne.created_by))],{data:Q}=await G.from("profiles").select("id, name, avatar_url").in("id",ee),de=new Map((Q==null?void 0:Q.map(ne=>[ne.id,ne]))||[]),re=se.map(ne=>({...ne,author:de.get(ne.created_by)||{name:"Unknown",avatar_url:null}}));a(re)}else a([])}catch(V){console.error("Error fetching announcements:",V)}finally{l(!1)}};C.useEffect(()=>{L()},[t]);const R=()=>{j(""),S(""),I(!1),p(null)},$=V=>{V?(p(V),j(V.title),S(V.content),I(V.is_pinned)):R(),c(!0)},q=async()=>{if(!w.trim()||!N.trim()){me.error("Please fill in all fields");return}b(!0);try{if(u){const{error:V}=await G.from("brokerage_announcements").update({title:w.trim(),content:N.trim(),is_pinned:T,pinned_at:T?new Date().toISOString():null}).eq("id",u.id);if(V)throw V;me.success("Announcement updated")}else{const{error:V}=await G.from("brokerage_announcements").insert({brokerage_id:t,created_by:r==null?void 0:r.id,title:w.trim(),content:N.trim(),is_pinned:T,pinned_at:T?new Date().toISOString():null});if(V)throw V;me.success("Announcement created")}c(!1),R(),L()}catch(V){console.error("Error saving announcement:",V),me.error("Failed to save announcement")}finally{b(!1)}},U=async()=>{if(f)try{const{error:V}=await G.from("brokerage_announcements").delete().eq("id",f);if(V)throw V;me.success("Announcement deleted"),L()}catch(V){console.error("Error deleting announcement:",V),me.error("Failed to delete announcement")}finally{y(null)}};return o?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(bp,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:e.jsx("div",{className:"h-20 bg-muted rounded"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(bp,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(K,{size:"sm",onClick:()=>$(),className:"gap-1",children:[e.jsx(Zs,{className:"h-4 w-4"}),"New"]})]}),e.jsx(Oe,{children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No announcements yet"}):e.jsx("div",{className:"space-y-4",children:n.map(V=>{var X,se,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(Ob,{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(yn,{className:"h-5 w-5",children:[e.jsx(Da,{src:((X=V.author)==null?void 0:X.avatar_url)||void 0}),e.jsx(vn,{className:"text-[10px]",children:((ee=(se=V.author)==null?void 0:se.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:ys(new Date(V.created_at),"MMM d, yyyy")})]})]}),s&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>$(V),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>y(V.id),children:e.jsx(jr,{className:"h-4 w-4"})})]})]})},V.id)})})})]}),e.jsx(_s,{open:i,onOpenChange:c,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:u?"Edit Announcement":"New Announcement"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title"}),e.jsx(Fe,{id:"title",value:w,onChange:V=>j(V.target.value),placeholder:"Announcement title..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"content",children:"Content"}),e.jsx(Ar,{id:"content",value:N,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(Br,{id:"pinned",checked:T,onCheckedChange:I}),e.jsxs(_e,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[e.jsx(Ob,{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:q,disabled:_,children:_?"Saving...":u?"Update":"Create"})]})]})]})}),e.jsx(gc,{open:!!f,onOpenChange:()=>y(null),children:e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Delete Announcement"}),e.jsx(Gl,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function hvs({brokerageId:t}){const[s,r]=C.useState([]),[n,a]=C.useState(!0),[o,l]=C.useState(""),[i,c]=C.useState(new Set);C.useEffect(()=>{(async()=>{try{const{data:f,error:y}=await G.from("profiles").select("id, name, email, phone, avatar_url, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url").eq("brokerage_id",t).order("name");if(y)throw y;if(r(f||[]),f&&f.length>0){const _=f.map(w=>w.id),{data:b}=await G.from("agent_assistant_assignments").select("agent_id").in("agent_id",_);b&&c(new Set(b.map(w=>w.agent_id)))}}catch(f){console.error("Error fetching agents:",f)}finally{a(!1)}})()},[t]);const u=s.filter(p=>{var f,y;return p.name.toLowerCase().includes(o.toLowerCase())||p.email.toLowerCase().includes(o.toLowerCase())||((f=p.title)==null?void 0:f.toLowerCase().includes(o.toLowerCase()))||((y=p.areas_served)==null?void 0:y.toLowerCase().includes(o.toLowerCase()))});return n?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[1,2,3,4].map(p=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-48 bg-muted rounded-lg"})},p))})})]}):e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5 text-primary"}),"Agent Roster",e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",s.length,")"]})]}),e.jsxs("div",{className:"relative w-full sm:w-64",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search agents...",value:o,onChange:p=>l(p.target.value),className:"pl-9"})]})]}),e.jsx(Oe,{children:u.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:o?"No agents match your search":"No agents in this brokerage yet"}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:u.map(p=>e.jsx(mvs,{agent:p,hasAssistant:i.has(p.id)},p.id))})})]})}function mvs({agent:t,hasAssistant:s}){const r=t.name.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2);return e.jsxs("div",{className:"group relative bg-card border rounded-xl p-4 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex flex-col items-center text-center mb-3",children:[e.jsxs(yn,{className:"h-20 w-20 mb-3 ring-2 ring-background shadow-md",children:[e.jsx(Da,{src:t.avatar_url||void 0,alt:t.name}),e.jsx(vn,{className:"text-lg bg-primary/10 text-primary",children:r})]}),e.jsx("h3",{className:"font-semibold text-sm leading-tight",children:t.name}),t.title&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:t.title}),s&&e.jsx(nt,{variant:"outline",className:"text-[10px] mt-1",children:"Has Assistant"})]}),t.bio&&e.jsx("p",{className:"text-xs text-muted-foreground text-center line-clamp-2 mb-3",children:t.bio}),e.jsxs("div",{className:"space-y-1.5 mb-3",children:[t.areas_served&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Ui,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t.areas_served})]}),t.years_experience&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center",children:[t.years_experience," ",t.years_experience===1?"year":"years"," experience"]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.phone&&e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:e.jsx("a",{href:`tel:${t.phone}`,title:`Call ${t.name}`,children:e.jsx(ea,{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(br,{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(_p,{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(yu,{className:"h-4 w-4"})})})]})]})}function pvs({brokerageId:t}){const[s,r]=C.useState([]),[n,a]=C.useState(!0);if(C.useEffect(()=>{(async()=>{try{const{data:c,error:u}=await G.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!c||c.length===0){r([]),a(!1);return}const p=c.map(w=>w.id),{data:f,error:y}=await G.from("agent_attendance_stats").select("user_id, total_points").in("user_id",p).order("total_points",{ascending:!1});if(y)throw y;const _=new Map(c.map(w=>[w.id,w])),b=(f||[]).filter(w=>w.total_points>0).map(w=>{const j=_.get(w.user_id);return{user_id:w.user_id,total_points:w.total_points,name:(j==null?void 0:j.name)||"Unknown",avatar_url:(j==null?void 0:j.avatar_url)||null}});r(b)}catch(c){console.error("Error fetching leaderboard:",c)}finally{a(!1)}})()},[t]),n)return e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(mo,{className:"h-5 w-5"}),"Team Leaderboard"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"animate-pulse space-y-3",children:[1,2,3].map(i=>e.jsx("div",{className:"h-12 bg-muted rounded"},i))})})]});const o=i=>i===1?"text-yellow-500":i===2?"text-gray-400":i===3?"text-amber-600":"text-muted-foreground",l=i=>i<=3?e.jsx(e1,{className:At("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(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(mo,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),e.jsx(Oe,{children:s.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No points earned yet. Attend events to earn points!"}):e.jsx("div",{className:"space-y-2",children:s.slice(0,10).map((i,c)=>{const u=i.name.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2),p=c+1;return e.jsxs("div",{className:At("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(yn,{className:"h-8 w-8",children:[e.jsx(Da,{src:i.avatar_url||void 0}),e.jsx(vn,{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 fvs({brokerageId:t}){const s=Pr(),[r,n]=C.useState([]),[a,o]=C.useState(!0);C.useEffect(()=>{(async()=>{try{const{data:c,error:u}=await G.from("profiles").select("id, name, avatar_url").eq("brokerage_id",t);if(u)throw u;if(!c||c.length===0){n([]),o(!1);return}const p=c.map(w=>w.id),f=new Map(c.map(w=>[w.id,w])),{data:y,error:_}=await G.from("listings").select(` id, slug, property_address, city, price, property_type, agent_id, listing_photos(photo_url) `).in("agent_id",p).eq("status","active").order("created_at",{ascending:!1}).limit(6);if(_)throw _;const b=(y||[]).map(w=>({id:w.id,slug:w.slug,property_address:w.property_address,city:w.city,price:w.price,property_type:w.property_type,agent_id:w.agent_id,agent:f.get(w.agent_id)||null,photos:w.listing_photos||[]}));n(b)}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(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Rn,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[1,2].map(i=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-32 bg-muted rounded-lg"})},i))})})]}):e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Rn,{className:"h-5 w-5 text-primary"}),"Brokerage Listings"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>s("/mission-control/listings"),className:"gap-1",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Listing"]})]}),e.jsxs(Oe,{children:[r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Rn,{className:"h-10 w-10 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No active listings from your brokerage yet"}),e.jsxs(K,{size:"sm",onClick:()=>s("/mission-control/listings/new"),className:"gap-1",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Your First Listing"]})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:r.map(i=>e.jsxs("div",{onClick:()=>window.open(`https://listings.relevelup.com/${i.slug||i.id}`,"_blank"),className:"group cursor-pointer border rounded-lg overflow-hidden hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"relative h-24 bg-muted",children:[i.photos&&i.photos.length>0?e.jsx("img",{src:i.photos[0].photo_url,alt:i.property_address||"Listing",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Rn,{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(rn,{className:"h-3 w-3 ml-1"})]})]})]})}function gvs(){const{user:t,isAdmin:s,isBrokerageManager:r}=Ws(),n=Pr(),[a,o]=C.useState(!0),[l,i]=C.useState(null),[c,u]=C.useState(""),[p,f]=C.useState(0),[y,_]=C.useState(!1),[b,w]=C.useState(!1);return C.useEffect(()=>{(async()=>{if(t)try{const{data:N}=await G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(N!=null&&N.brokerage_id)){o(!1);return}i(N.brokerage_id);const{data:S}=await G.from("brokerages").select("name").eq("id",N.brokerage_id).maybeSingle();S&&u(S.name);const{count:T}=await G.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",N.brokerage_id);if(f(T||0),s)_(!0),w(!0);else if(r){const{data:I}=await G.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",N.brokerage_id).maybeSingle();_(!!I),w(!!I)}}catch(N){console.error("Error fetching brokerage info:",N)}finally{o(!1)}})()},[t,s,r]),a?e.jsx(Es,{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(Es,{title:c||"My Brokerage",description:"Team Hub",children:e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-lg px-4 py-2",children:[e.jsx(mr,{className:"h-5 w-5 text-primary"}),e.jsxs("span",{className:"font-medium",children:[p," ",p===1?"Agent":"Agents"]})]}),b&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>n("/brokerage-content"),children:[e.jsx(gh,{className:"h-4 w-4 mr-2"}),"Brokerage Content"]}),e.jsxs(K,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(Rn,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})]}),e.jsx(uvs,{brokerageId:l,canManage:y}),e.jsx(hvs,{brokerageId:l}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(pvs,{brokerageId:l}),e.jsx(fvs,{brokerageId:l})]})]})}):e.jsx(Es,{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(La,{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 xvs(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 yvs(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 dFe={video:{icon:wl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:In,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:sl,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:on,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Ql,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function vvs({item:t,canManage:s}){const[r,n]=C.useState(!1),[a,o]=C.useState(null),l=CIt(),i=Pr(),c=dFe[t.content_type]||dFe.link,u=c.icon,p=C.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?xvs(t.url):null,[t]);C.useEffect(()=>{p||!t.url||t.content_type!=="video"||!yvs(t.url)||fetch(`https://www.youtube.com/oembed?url=${encodeURIComponent(t.url)}&format=json`).then(b=>b.ok?b.json():null).then(b=>{b!=null&&b.thumbnail_url&&o(b.thumbnail_url)}).catch(()=>{})},[t.url,t.content_type,p]);const f=p||a,y=()=>{i(`/brokerage-content/${t.id}`)},_=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:y,children:[f?e.jsx("div",{className:"aspect-video bg-muted/50 overflow-hidden",children:e.jsx("img",{src:f,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",referrerPolicy:"no-referrer"})}):e.jsx("div",{className:"aspect-video bg-muted/30 flex items-center justify-center",children:e.jsx(u,{className:"h-12 w-12 text-muted-foreground/30"})}),e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs(nt,{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(nt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:[t.category.icon," ",t.category.name]})]}),e.jsx("h3",{className:"font-semibold text-sm text-foreground group-hover:text-primary transition-colors truncate",children:t.title}),t.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:t.description}),t.content_type==="event"&&t.event_date&&e.jsxs("p",{className:"text-xs text-primary mt-2 font-medium",children:["📅 ",ys(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",ys(new Date(t.created_at),"MMM d, yyyy")]})]}),s&&e.jsxs(ju,{children:[e.jsx(ku,{asChild:!0,onClick:b=>b.stopPropagation(),children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(ag,{className:"h-4 w-4"})})}),e.jsx(Jd,{align:"end",children:e.jsxs(Ta,{onClick:b=>{b.stopPropagation(),n(!0)},className:"text-destructive",children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(gc,{open:r,onOpenChange:n,children:e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Delete Content"}),e.jsxs(Gl,{children:['Are you sure you want to delete "',t.title,'"? This cannot be undone.']})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:_,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function _vs(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 uFe=[{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 bvs({brokerageId:t,categories:s}){var je;const{user:r}=Ws(),[n,a]=C.useState(!1),[o,l]=C.useState(!1),[i,c]=C.useState(""),[u,p]=C.useState("📁"),[f,y]=C.useState(!1);C.useRef(null);const[_,b]=C.useState("video"),[w,j]=C.useState(""),[N,S]=C.useState(""),[T,I]=C.useState(""),[L,R]=C.useState(""),[$,q]=C.useState(""),[U,V]=C.useState(""),[X,se]=C.useState(""),ee=SIt(),Q=MIt(t),de=TIt(),re=AIt(t),ne=()=>{b("video"),j(""),S(""),I(""),R(""),q(""),V(""),se("")},le=async(ke,We)=>{var Me;const be=(Me=ke.target.files)==null?void 0:Me[0];if(be){y(!0);try{const Ae=be.name.split(".").pop(),Re=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${Ae}`,{error:Te}=await G.storage.from("brokerage-content").upload(Re,be);if(Te)throw Te;const{data:{publicUrl:qe}}=G.storage.from("brokerage-content").getPublicUrl(Re);We==="file"?(R(qe),_==="graphic"&&!$&&q(qe)):q(qe),me.success("File uploaded")}catch(Ae){me.error(Ae.message||"Upload failed")}finally{y(!1)}}},he=async()=>{if(!w.trim()){me.error("Title is required");return}if(r)try{await ee.mutateAsync({brokerage_id:t,category_id:X||null,content_type:_,title:w.trim(),description:N.trim()||null,url:T.trim()||null,file_url:L.trim()||null,thumbnail_url:$.trim()||null,event_date:U?new Date(U).toISOString():null,created_by:r.id}),me.success("Content added!"),ne(),a(!1)}catch(ke){me.error(ke.message||"Failed to add content")}},we=async()=>{if(i.trim())try{await Q.mutateAsync({name:i.trim(),icon:u,sort_order:s.length}),c(""),p("📁"),me.success("Category created")}catch(ke){me.error(ke.message||"Failed to create category")}},ye=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(_s,{open:n,onOpenChange:a,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Content"]})}),e.jsxs(vs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Add Brokerage Content"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Content Type"}),e.jsxs(rr,{value:_,onValueChange:b,children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:uFe.map(ke=>e.jsx(Tt,{value:ke.value,children:ke.label},ke.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(je=uFe.find(ke=>ke.value===_))==null?void 0:je.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Category"}),e.jsxs(rr,{value:X,onValueChange:se,children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select category (optional)"})}),e.jsx(sr,{children:s.map(ke=>e.jsxs(Tt,{value:ke.id,children:[ke.icon," ",ke.name]},ke.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Title *"}),e.jsx(Fe,{value:w,onChange:ke=>j(ke.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Description"}),e.jsx(Ar,{value:N,onChange:ke=>S(ke.target.value),placeholder:"Brief description...",rows:2})]}),["video","link","graphic","event"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:_==="video"?"Video URL":_==="graphic"?"Canva / Image URL":_==="event"?"Event Link (Zoom, etc.)":"URL"}),e.jsx(Fe,{value:T,onChange:ke=>{const We=ke.target.value;if(I(We),_==="video"&&!$){const be=_vs(We);be&&q(be)}},placeholder:"https://..."})]}),["pdf","graphic"].includes(_)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:_==="pdf"?"Upload PDF":"Upload Image"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{type:"file",accept:_==="pdf"?".pdf,.doc,.docx":"image/*",onChange:ke=>le(ke,"file"),disabled:f}),f&&e.jsx(Ss,{className:"h-4 w-4 animate-spin"})]}),L&&e.jsx("p",{className:"text-xs text-green-600",children:"✓ File uploaded"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Thumbnail Image (optional)"}),e.jsx(Fe,{type:"file",accept:"image/*",onChange:ke=>le(ke,"thumbnail"),disabled:f}),$&&e.jsxs("div",{className:"relative w-20 h-20 rounded overflow-hidden",children:[e.jsx("img",{src:$,className:"w-full h-full object-cover",alt:"thumb"}),e.jsx("button",{onClick:()=>q(""),className:"absolute top-0 right-0 bg-background/80 rounded-bl p-0.5",children:e.jsx(Ur,{className:"h-3 w-3"})})]})]}),_==="event"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Event Date & Time"}),e.jsx(Fe,{type:"datetime-local",value:U,onChange:ke=>V(ke.target.value)})]}),e.jsxs(K,{onClick:he,disabled:ee.isPending||!w.trim(),className:"w-full",children:[ee.isPending?e.jsx(Ss,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Content"]})]})]})]}),e.jsxs(_s,{open:o,onOpenChange:l,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",children:[e.jsx(Jl,{className:"h-4 w-4 mr-2"}),"Categories"]})}),e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Manage Categories"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[s.length===0&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No categories yet"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ye,disabled:re.isPending,children:[re.isPending?e.jsx(Ss,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Default Categories"]})]}),s.map(ke=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border",children:[e.jsxs("span",{className:"text-sm",children:[ke.icon," ",ke.name]}),!ke.is_default&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:async()=>{await de.mutateAsync(ke.id),me.success("Category deleted")},children:e.jsx(Ur,{className:"h-4 w-4"})})]},ke.id)),e.jsxs("div",{className:"flex gap-2 pt-2 border-t",children:[e.jsx(Fe,{value:u,onChange:ke=>p(ke.target.value),className:"w-14 text-center",maxLength:2}),e.jsx(Fe,{value:i,onChange:ke=>c(ke.target.value),placeholder:"New category name",className:"flex-1",onKeyDown:ke=>ke.key==="Enter"&&we()}),e.jsx(K,{size:"sm",onClick:we,disabled:!i.trim(),children:"Add"})]})]})]})]})]})}function wvs(){const{user:t,isAdmin:s,isBrokerageManager:r}=Ws(),[n,a]=C.useState(!0),[o,l]=C.useState(null),[i,c]=C.useState(""),[u,p]=C.useState(!1),[f,y]=C.useState(null),[_,b]=C.useState("");C.useEffect(()=>{(async()=>{if(t)try{const{data:I}=await G.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(I!=null&&I.brokerage_id)){a(!1);return}l(I.brokerage_id);const{data:L}=await G.from("brokerages").select("name").eq("id",I.brokerage_id).maybeSingle();if(L&&c(L.name),s)p(!0);else if(r){const{data:R}=await G.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",I.brokerage_id).maybeSingle();p(!!R)}}catch(I){console.error("Error fetching brokerage info:",I)}finally{a(!1)}})()},[t,s,r]);const{data:w=[]}=jIt(o),{data:j=[],isLoading:N}=kIt(o,f),S=C.useMemo(()=>{if(!_.trim())return j;const T=_.toLowerCase();return j.filter(I=>{var L;return I.title.toLowerCase().includes(T)||((L=I.description)==null?void 0:L.toLowerCase().includes(T))||I.content_type.toLowerCase().includes(T)})},[j,_]);return n?e.jsx(Es,{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(Es,{title:`${i} Content`,description:"Brokerage Content Hub",children:e.jsxs("div",{className:"space-y-6",children:[u&&o&&e.jsx(bvs,{brokerageId:o,categories:w}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search content...",value:_,onChange:T=>b(T.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:()=>y(null),children:"All"}),w.map(T=>e.jsxs(K,{variant:f===T.id?"default":"outline",size:"sm",onClick:()=>y(T.id),children:[e.jsx("span",{className:"mr-1",children:T.icon}),T.name]},T.id))]})]}),N?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):S.length===0?e.jsx(Ee,{className:"bg-muted/30 border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Cm,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:_.trim()?"No matching content found":"No content yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:_.trim()?"Try a different search term or category.":u?"Add your first piece of content above.":"Your brokerage hasn't added content yet."})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:S.map(T=>e.jsx(vvs,{item:T,canManage:u},T.id))})]})}):e.jsx(Es,{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(La,{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 hFe={video:{icon:wl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:In,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:sl,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:on,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:Ql,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function jvs(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 kvs(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function Nvs(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function Svs(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function Cvs(){const{contentId:t}=Po(),{data:s,isLoading:r}=wt({queryKey:["brokerage-content-detail",t],queryFn:async()=>{const{data:u,error:p}=await G.from("brokerage_content").select(` *, category:brokerage_content_categories(*) `).eq("id",t).single();if(p)throw p;return u},enabled:!!t});if(r)return e.jsx(Es,{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(Es,{title:"Brokerage Content",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(La,{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(So,{to:"/brokerage-content",children:"Back to Content"})})]})});const n=hFe[s.content_type]||hFe.link,a=n.icon,o=s.url||s.file_url,l=o&&kvs(o)?jvs(o):null,i=o&&Nvs(o)?Svs(o):null,c=l||i;return e.jsx(Es,{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(So,{to:"/brokerage-content",children:[e.jsx(di,{className:"h-4 w-4"}),"Back to Content"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(nt,{variant:"secondary",className:`text-xs px-2 py-0.5 ${n.color}`,children:[e.jsx(a,{className:"h-3 w-3 mr-1"}),n.label]}),s.category&&e.jsxs(nt,{variant:"outline",className:"text-xs px-2 py-0.5",children:[s.category.icon," ",s.category.name]}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:["Added ",ys(new Date(s.created_at),"MMMM d, yyyy")]})]}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),c&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"relative w-full bg-black",style:{paddingTop:"56.25%"},children:e.jsx("iframe",{src:c,className:"absolute top-0 left-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:s.title})})}),s.content_type==="graphic"&&s.file_url&&!c&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("img",{src:s.file_url,alt:s.title,className:"w-full max-h-[600px] object-contain bg-muted"})}),!c&&s.content_type!=="graphic"&&s.thumbnail_url&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("img",{src:s.thumbnail_url,alt:s.title,className:"w-full max-h-[400px] object-cover"})}),s.description&&e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})})}),s.content_type==="event"&&s.event_date&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(on,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Event Date"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:ys(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(ki,{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(rn,{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 Mvs(){const t=Pr(),[s,r]=C.useState(""),[n,a]=C.useState("grid"),{data:o,isLoading:l}=wt({queryKey:["newsletters"],queryFn:async()=>{const{data:T,error:I}=await G.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(I)throw I;return T}}),{data:i}=wt({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:T}=await G.from("newsletter_likes").select("newsletter_id");return T||[]}}),{data:c}=wt({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:T}=await G.from("newsletter_comments").select("newsletter_id");return T||[]}}),{data:u}=wt({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[T,I,L,R]=await Promise.all([G.from("newsletter_canva_links").select("newsletter_id"),G.from("newsletter_pdfs").select("newsletter_id"),G.from("newsletter_videos").select("newsletter_id"),G.from("newsletter_drive_links").select("newsletter_id")]);return{canva:T.data||[],pdfs:I.data||[],videos:L.data||[],drives:R.data||[]}}}),p=T=>(i==null?void 0:i.filter(I=>I.newsletter_id===T).length)||0,f=T=>(c==null?void 0:c.filter(I=>I.newsletter_id===T).length)||0,y=T=>{var I;return((I=u==null?void 0:u.canva)==null?void 0:I.filter(L=>L.newsletter_id===T).length)||0},_=T=>{var I;return((I=u==null?void 0:u.pdfs)==null?void 0:I.filter(L=>L.newsletter_id===T).length)||0},b=T=>{var I;return((I=u==null?void 0:u.videos)==null?void 0:I.filter(L=>L.newsletter_id===T).length)||0},w=T=>{var I;return((I=u==null?void 0:u.drives)==null?void 0:I.filter(L=>L.newsletter_id===T).length)||0},j=T=>y(T)+_(T)+b(T)+w(T),N=o==null?void 0:o.filter(T=>{var I;return T.title.toLowerCase().includes(s.toLowerCase())||((I=T.description)==null?void 0:I.toLowerCase().includes(s.toLowerCase()))}),S=T=>{t(`/newsletters/${T}`)};return e.jsx(Es,{title:"Newsletter Content",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-bold text-foreground text-5xl",children:"Newsletter Content"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Monthly newsletter templates and resources"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search newsletters...",value:s,onChange:T=>r(T.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(lf,{className:"h-4 w-4"})}),e.jsx(K,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:e.jsx(Mm,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[(N==null?void 0:N.length)||0," item",(N==null?void 0:N.length)!==1?"s":""," found"]}),l&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(8)].map((T,I)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-0",children:[e.jsx(xs,{className:"aspect-[3/2] w-full"}),e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsx(xs,{className:"h-5 w-3/4"}),e.jsx(xs,{className:"h-4 w-full"})]})]})},I))}),!l&&(N==null?void 0:N.length)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(In,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("div",{className:"text-muted-foreground mb-4",children:s?"No newsletters match your search":"No newsletters available yet"}),s&&e.jsx(K,{variant:"outline",onClick:()=>r(""),children:"Clear Search"})]}),!l&&N&&N.length>0&&e.jsx("div",{className:n==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-3",children:N.map(T=>{const I=j(T.id),L=y(T.id),R=_(T.id),$=b(T.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(T.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:T.preview_image_url?e.jsx("img",{src:T.preview_image_url,alt:T.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(In,{className:"h-16 w-16"})})}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:T.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[e.jsx(on,{className:"h-3 w-3"}),ys(new Date(T.publish_date),"MMM d, yyyy")]})]}),T.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:T.description.replace(/<[^>]*>/g,"")}),I>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[L>0&&e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Ql,{className:"h-3 w-3"})," ",L," Template",L>1?"s":""]}),R>0&&e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(ki,{className:"h-3 w-3"})," ",R," PDF",R>1?"s":""]}),$>0&&e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(wl,{className:"h-3 w-3"})," ",$," Video",$>1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground pt-1 border-t border-border/50",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gu,{className:"h-3 w-3"})," ",p(T.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ec,{className:"h-3 w-3"})," ",f(T.id)]})]})]})]},T.id):e.jsx(Ee,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>S(T.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:T.preview_image_url?e.jsx("img",{src:T.preview_image_url,alt:T.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground min-h-[100px]",children:e.jsx(In,{className:"h-10 w-10"})})}),e.jsxs(Oe,{className:"p-4 flex-1 flex flex-col justify-center gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:T.title}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:[e.jsx(on,{className:"h-3 w-3"}),ys(new Date(T.publish_date),"MMM d, yyyy")]})]}),T.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:T.description.replace(/<[^>]*>/g,"")}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[I>0&&e.jsxs("span",{children:[I," resource",I>1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gu,{className:"h-3 w-3"})," ",p(T.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ec,{className:"h-3 w-3"})," ",f(T.id)]})]})]})]})},T.id)})})]})})}function Tvs({rows:t}){if(!t||t.length===0)return null;const s=t.filter(r=>r.columns.some(n=>n.title||n.description||n.image_url));return s.length===0?null:e.jsx("div",{className:"space-y-6",children:s.map((r,n)=>{const a=r.columns.filter(o=>o.title||o.description||o.image_url);return a.length===0?null:e.jsx("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${a.length}, minmax(0, 1fr))`},children:a.map((o,l)=>e.jsxs(Ee,{className:"overflow-hidden border-border/50",children:[o.image_url&&e.jsx("img",{src:o.image_url,alt:o.title||"",className:"w-full h-40 object-cover"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[o.title&&e.jsx("h4",{className:"font-semibold text-foreground",children:o.title}),o.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:o.description})]})]},l))},n)})})}function Avs(){const{id:t}=Po(),s=Pr(),{user:r}=Ws(),{toast:n}=Ra(),a=ss(),{trackEngagement:o}=SO(),[l,i]=C.useState(""),{data:c,isLoading:u}=wt({queryKey:["newsletter",t],queryFn:async()=>{const{data:L,error:R}=await G.from("newsletter_content").select("*").eq("id",t).single();if(R)throw R;return L},enabled:!!t});C.useEffect(()=>{c&&o("newsletter",c.id,c.title,"view")},[c==null?void 0:c.id]);const{data:p}=wt({queryKey:["newsletter-drives",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_drive_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:f}=wt({queryKey:["newsletter-pdfs",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_pdfs").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:y}=wt({queryKey:["newsletter-videos",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_videos").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:_}=wt({queryKey:["newsletter-canva-links",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_canva_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:b}=wt({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_likes").select("*").eq("newsletter_id",t);return L||[]},enabled:!!t}),{data:w}=wt({queryKey:["newsletter-comments",t],queryFn:async()=>{const{data:L}=await G.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",t).order("created_at",{ascending:!1});return L||[]},enabled:!!t}),j=b==null?void 0:b.some(L=>L.user_id===(r==null?void 0:r.id)),N=Dt({mutationFn:async()=>{j?await G.from("newsletter_likes").delete().eq("newsletter_id",t).eq("user_id",r==null?void 0:r.id):await G.from("newsletter_likes").insert({newsletter_id:t,user_id:r==null?void 0:r.id})},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-likes",t]})}}),S=Dt({mutationFn:async L=>{const{error:R}=await G.from("newsletter_comments").insert({newsletter_id:t,user_id:r==null?void 0:r.id,content:L});if(R)throw R},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),i(""),n({title:"Comment added"})}}),T=Dt({mutationFn:async L=>{const{error:R}=await G.from("newsletter_comments").delete().eq("id",L);if(R)throw R},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),n({title:"Comment deleted"})}}),I=L=>{if(L.includes("player.mediadelivery.net")||L.includes("iframe.mediadelivery.net")){const R=L.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(R)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://iframe.mediadelivery.net/embed/${R[1]}/${R[2]}?autoplay=false`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}if(L.includes("youtube.com")||L.includes("youtu.be")){const R=L.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([^&\s]+)/);if(R)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${R[1]}`,className:"absolute inset-0 w-full h-full rounded-lg",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}return e.jsxs("a",{href:L,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(wl,{className:"h-4 w-4"})," Watch Video"]})};return u?e.jsx(Es,{title:"",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-8 w-32"}),e.jsx(xs,{className:"h-64 w-full"}),e.jsx(xs,{className:"h-32 w-full"})]})}):c?e.jsx(Es,{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(di,{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:ys(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(Tvs,{rows:c.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(qA,{resourceType:"newsletter",resourceId:c.id,resourceTitle:c.title}),e.jsxs(K,{variant:j?"default":"outline",size:"sm",onClick:()=>N.mutate(),children:[e.jsx(Ii,{className:`h-4 w-4 mr-1 ${j?"fill-current":""}`}),(b==null?void 0:b.length)||0," ",(b==null?void 0:b.length)===1?"Like":"Likes"]})]}),_&&_.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Canva Templates"})}),e.jsx(Oe,{className:"space-y-2",children:_.map(L=>e.jsxs("a",{href:L.canva_share_link,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",c.id,c.title,"click_canva"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(Ql,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(rn,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},L.id))})]}),p&&p.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Google Drive Files"})}),e.jsx(Oe,{className:"space-y-2",children:p.map(L=>e.jsxs("a",{href:L.drive_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",c.id,c.title,"click_link"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(rn,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:L.title})]},L.id))})]}),f&&f.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(Oe,{className:"space-y-2",children:f.map(L=>e.jsxs("a",{href:L.file_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>o("newsletter",c.id,c.title,"click_pdf"),className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted transition-colors",children:[e.jsx(In,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:L.name}),e.jsx(ki,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]}),y&&y.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Videos"})}),e.jsx(Oe,{className:"space-y-6",children:y.map(L=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:L.title}),I(L.video_url)]},L.id))})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"text-lg",children:["Comments (",(w==null?void 0:w.length)||0,")"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Ar,{placeholder:"Write a comment...",value:l,onChange:L=>i(L.target.value),className:"flex-1"}),e.jsx(K,{onClick:()=>l.trim()&&S.mutate(l),disabled:!l.trim()||S.isPending,children:e.jsx(oa,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:w==null?void 0:w.map(L=>{var R,$,q;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(yn,{className:"h-8 w-8",children:e.jsx(vn,{children:(($=(R=L.profiles)==null?void 0:R.name)==null?void 0:$[0])||"U"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium text-sm",children:((q=L.profiles)==null?void 0:q.name)||"User"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(new Date(L.created_at),"MMM d, yyyy")}),L.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>T.mutate(L.id),children:e.jsx(jr,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:L.content})]})]},L.id)})})]})]})]})}):e.jsx(Es,{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 Evs({rows:t,onChange:s}){const[r,n]=C.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,y)=>{const _=[...t];_[u]={..._[u],columns:_[u].columns.map((b,w)=>w===p?{...b,[f]:y}:b)},s(_)},i=async(u,p,f)=>{var b;const y=(b=f.target.files)==null?void 0:b[0];if(!y)return;const _=`${u}-${p}`;n(_);try{const w=`content-blocks/${Date.now()}-${y.name}`,{error:j}=await G.storage.from("newsletter-content").upload(w,y);if(!j){const{data:N}=G.storage.from("newsletter-content").getPublicUrl(w);l(u,p,"image_url",N.publicUrl)}}finally{n(null)}},c=(u,p)=>{l(u,p,"image_url","")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-base font-medium",children:"Content Blocks (3-Column Rows)"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:a,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Row"]})]}),t.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No content block rows yet. Add a row to create a 3-column layout."}),t.map((u,p)=>e.jsxs(Ee,{className:"relative",children:[e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>o(p),children:e.jsx(Ur,{className:"h-4 w-4"})}),e.jsxs(Oe,{className:"p-4 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(yh,{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,y)=>{const _=`${p}-${y}`;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 ",y+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,y),children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{children:[e.jsx(Fe,{type:"file",accept:"image/*",className:"hidden",id:`block-img-${_}`,onChange:b=>i(p,y,b)}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"w-full text-xs h-8",disabled:r===_,asChild:!0,children:e.jsx("label",{htmlFor:`block-img-${_}`,className:"cursor-pointer",children:r===_?"Uploading...":e.jsxs(e.Fragment,{children:[e.jsx(cl,{className:"h-3 w-3 mr-1"})," Image"]})})})]}),e.jsx(Fe,{placeholder:"Title",value:f.title,onChange:b=>l(p,y,"title",b.target.value),className:"h-8 text-sm"}),e.jsx(Ar,{placeholder:"Description",value:f.description,onChange:b=>l(p,y,"description",b.target.value),className:"text-sm min-h-[60px] resize-none"})]},y)})})]})]},p))]})}function Pvs(){const{toast:t}=Ra(),s=ss(),[r,n]=C.useState(!1),[a,o]=C.useState(null),[l,i]=C.useState({title:"",description:"",publish_date:ys(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[c,u]=C.useState(null),[p,f]=C.useState(null),[y,_]=C.useState([]),[b,w]=C.useState([]),[j,N]=C.useState([]),[S,T]=C.useState([]),[I,L]=C.useState([]),[R,$]=C.useState([]),[q,U]=C.useState(!1),{data:V,isLoading:X}=wt({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:be,error:Me}=await G.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Me)throw Me;return be}}),se=Dt({mutationFn:async be=>{const{data:Me,error:Ae}=await G.from("newsletter_content").insert({title:be.title,description:be.description||null,preview_image_url:be.preview_image_url,publish_date:be.publish_date,is_published:be.is_published,content_blocks:be.content_blocks}).select().single();if(Ae)throw Ae;return Me},onSuccess:async be=>{await de(be.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),be.is_published&&fUt(be.title,be.id),le()},onError:be=>{t({title:"Error creating newsletter",description:be.message,variant:"destructive"})}}),ee=Dt({mutationFn:async be=>{const{error:Me}=await G.from("newsletter_content").update({title:be.title,description:be.description||null,preview_image_url:be.preview_image_url,publish_date:be.publish_date,is_published:be.is_published,content_blocks:be.content_blocks}).eq("id",be.id);if(Me)throw Me;return be.id},onSuccess:async be=>{await de(be),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),le()},onError:be=>{t({title:"Error updating newsletter",description:be.message,variant:"destructive"})}}),Q=Dt({mutationFn:async be=>{const{error:Me}=await G.from("newsletter_content").delete().eq("id",be);if(Me)throw Me},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter deleted successfully"})},onError:be=>{t({title:"Error deleting newsletter",description:be.message,variant:"destructive"})}}),de=async be=>{await G.from("newsletter_drive_links").delete().eq("newsletter_id",be),await G.from("newsletter_pdfs").delete().eq("newsletter_id",be),await G.from("newsletter_videos").delete().eq("newsletter_id",be),await G.from("newsletter_canva_links").delete().eq("newsletter_id",be);for(const Me of R){const Ae=`${be}/${Date.now()}-${Me.file.name}`,{error:Re}=await G.storage.from("newsletter-content").upload(Ae,Me.file);if(!Re){const{data:Te}=G.storage.from("newsletter-content").getPublicUrl(Ae);b.push({name:Me.name,file_url:Te.publicUrl,file_size:Me.file.size,sort_order:b.length})}}y.length>0&&await G.from("newsletter_drive_links").insert(y.map((Me,Ae)=>({newsletter_id:be,title:Me.title,drive_url:Me.drive_url,sort_order:Ae}))),b.length>0&&await G.from("newsletter_pdfs").insert(b.map((Me,Ae)=>({newsletter_id:be,name:Me.name,file_url:Me.file_url,file_size:Me.file_size||null,sort_order:Ae}))),j.length>0&&await G.from("newsletter_videos").insert(j.map((Me,Ae)=>({newsletter_id:be,title:Me.title,video_url:Me.video_url,sort_order:Ae}))),S.length>0&&await G.from("newsletter_canva_links").insert(S.map((Me,Ae)=>({newsletter_id:be,title:Me.title,canva_share_link:Me.canva_share_link,sort_order:Ae})))},re=async be=>{o(be),i({title:be.title,description:be.description||"",publish_date:ys(new Date(be.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:be.is_published}),f(be.preview_image_url),L(be.content_blocks||[]);const[Me,Ae,Re,Te]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",be.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",be.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",be.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",be.id).order("sort_order")]);_(Me.data||[]),w(Ae.data||[]),N(Re.data||[]),T(Te.data||[]),$([]),n(!0)},ne=async be=>{const[Me,Ae,Re,Te]=await Promise.all([G.from("newsletter_drive_links").select("*").eq("newsletter_id",be.id).order("sort_order"),G.from("newsletter_pdfs").select("*").eq("newsletter_id",be.id).order("sort_order"),G.from("newsletter_videos").select("*").eq("newsletter_id",be.id).order("sort_order"),G.from("newsletter_canva_links").select("*").eq("newsletter_id",be.id).order("sort_order")]);o(null),i({title:`${be.title} (Copy)`,description:be.description||"",publish_date:ys(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),f(be.preview_image_url),L(be.content_blocks||[]),_((Me.data||[]).map(({id:qe,...ct})=>ct)),w((Ae.data||[]).map(({id:qe,...ct})=>ct)),N((Re.data||[]).map(({id:qe,...ct})=>ct)),T((Te.data||[]).map(({id:qe,...ct})=>ct)),$([]),n(!0)},le=()=>{n(!1),o(null),i({title:"",description:"",publish_date:ys(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),f(null),_([]),w([]),N([]),T([]),L([]),$([])},he=async be=>{var Ae;const Me=(Ae=be.target.files)==null?void 0:Ae[0];Me&&(u(Me),f(URL.createObjectURL(Me)))},we=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}U(!0);let be=p;if(c){const Me=`previews/${Date.now()}-${c.name}`,{error:Ae}=await G.storage.from("newsletter-content").upload(Me,c);if(!Ae){const{data:Re}=G.storage.from("newsletter-content").getPublicUrl(Me);be=Re.publicUrl}}a?ee.mutate({id:a.id,...l,preview_image_url:be,content_blocks:I}):se.mutate({...l,preview_image_url:be,content_blocks:I}),U(!1)},ye=()=>_([...y,{title:"",drive_url:"",sort_order:y.length}]),je=()=>N([...j,{title:"",video_url:"",sort_order:j.length}]),ke=()=>T([...S,{title:"",canva_share_link:"",sort_order:S.length}]),We=be=>{const Me=be.target.files;if(!Me)return;const Ae=Array.from(Me).map(Re=>({file:Re,name:Re.name.replace(/\.[^/.]+$/,"")}));$([...R,...Ae])};return e.jsx(Es,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{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(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.length)||0})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.filter(be=>be.is_published).length)||0})})]})]}),e.jsxs(_s,{open:r,onOpenChange:be=>!be&&le(),children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"})," Add Newsletter"]})}),e.jsxs(vs,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:a?"Edit Newsletter":"Add Newsletter"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Title *"}),e.jsx(Fe,{value:l.title,onChange:be=>i({...l,title:be.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Publish Date"}),e.jsx(Fe,{type:"datetime-local",value:l.publish_date,onChange:be=>i({...l,publish_date:be.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(iy,{content:l.description,onChange:be=>i({...l,description:be}),placeholder:"Newsletter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Preview Image"}),e.jsxs("div",{className:"flex items-center gap-4",children:[p&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:p,alt:"Preview",className:"h-20 w-32 object-cover rounded-md"}),e.jsx(K,{type:"button",variant:"destructive",size:"icon",className:"absolute -top-2 -right-2 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{u(null),f(null)},children:e.jsx(Ur,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(Fe,{type:"file",accept:"image/*",onChange:he,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(ni,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:l.is_published,onCheckedChange:be=>i({...l,is_published:be})}),e.jsx(_e,{children:"Published"})]}),e.jsx(Evs,{rows:I,onChange:L}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-base font-medium",children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ke,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),S.map((be,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Fe,{placeholder:"Link title",value:be.title,onChange:Ae=>{const Re=[...S];Re[Me].title=Ae.target.value,T(Re)},className:"w-1/3"}),e.jsx(Fe,{placeholder:"Canva share link",value:be.canva_share_link,onChange:Ae=>{const Re=[...S];Re[Me].canva_share_link=Ae.target.value,T(Re)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>T(S.filter((Ae,Re)=>Re!==Me)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Me))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-base font-medium",children:"Google Drive Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:ye,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),y.map((be,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Fe,{placeholder:"Link title",value:be.title,onChange:Ae=>{const Re=[...y];Re[Me].title=Ae.target.value,_(Re)},className:"w-1/3"}),e.jsx(Fe,{placeholder:"Google Drive URL",value:be.drive_url,onChange:Ae=>{const Re=[...y];Re[Me].drive_url=Ae.target.value,_(Re)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>_(y.filter((Ae,Re)=>Re!==Me)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Me))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-base font-medium",children:"PDF Files"}),e.jsxs("div",{children:[e.jsx(Fe,{type:"file",accept:".pdf",multiple:!0,onChange:We,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(ni,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),b.map((be,Me)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:be.name}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>w(b.filter((Ae,Re)=>Re!==Me)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},`existing-${Me}`)),R.map((be,Me)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{value:be.name,onChange:Ae=>{const Re=[...R];Re[Me].name=Ae.target.value,$(Re)},className:"flex-1 h-8",placeholder:"PDF name"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"(new)"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>$(R.filter((Ae,Re)=>Re!==Me)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},`pending-${Me}`))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-base font-medium",children:"Video Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:je,children:[e.jsx(Zs,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),j.map((be,Me)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Fe,{placeholder:"Video title",value:be.title,onChange:Ae=>{const Re=[...j];Re[Me].title=Ae.target.value,N(Re)},className:"w-1/3"}),e.jsx(Fe,{placeholder:"Video URL",value:be.video_url,onChange:Ae=>{const Re=[...j];Re[Me].video_url=Ae.target.value,N(Re)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>N(j.filter((Ae,Re)=>Re!==Me)),children:e.jsx(Ur,{className:"h-4 w-4"})})]},Me))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:le,children:"Cancel"}),e.jsx(K,{onClick:we,disabled:q||se.isPending||ee.isPending,children:q?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:X?e.jsx(ks,{children:e.jsx(dt,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(V==null?void 0:V.length)===0?e.jsx(ks,{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(be=>e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[be.preview_image_url?e.jsx("img",{src:be.preview_image_url,alt:be.title,className:"w-10 h-10 rounded object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:e.jsx(In,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:be.title}),be.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:be.description.replace(/<[^>]*>/g,"")})]})]})}),e.jsx(dt,{children:ys(new Date(be.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 ${be.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:be.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(be),title:"Edit",children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ne(be),title:"Duplicate",children:e.jsx(mi,{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(be.id)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},be.id))})]})})})]})})}const mFe={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 Ivs(){const{user:t}=Ws(),{toast:s}=Ra(),r=Pr(),n=ss(),[a,o]=C.useState(""),[l,i]=C.useState("popular"),[c,u]=C.useState(!1),[p,f]=C.useState(""),[y,_]=C.useState(""),[b,w]=C.useState(!1),{data:j=[],isLoading:N}=wt({queryKey:["wishlist-items",l,b],queryFn:async()=>{let R=G.from("wishlist_items").select("*");b&&t&&(R=R.eq("user_id",t.id)),l==="latest"?R=R.order("created_at",{ascending:!1}):l==="popular"?R=R.order("vote_count",{ascending:!1}):l==="trending"&&(R=R.order("vote_count",{ascending:!1}));const{data:$,error:q}=await R;if(q)throw q;const U=[...new Set(($==null?void 0:$.map(re=>re.user_id))||[])],{data:V}=await G.from("profiles").select("id, name").in("id",U),X=new Map((V==null?void 0:V.map(re=>[re.id,re]))||[]);let se=[];if(t){const{data:re}=await G.from("wishlist_votes").select("item_id").eq("user_id",t.id);se=(re==null?void 0:re.map(ne=>ne.item_id))||[]}const ee=($==null?void 0:$.map(re=>re.id))||[],{data:Q}=await G.from("wishlist_comments").select("item_id").in("item_id",ee),de=new Map;return Q==null||Q.forEach(re=>{de.set(re.item_id,(de.get(re.item_id)||0)+1)}),$==null?void 0:$.map(re=>{const ne=X.get(re.user_id),le=(ne==null?void 0:ne.name)||"Unknown";return{...re,user_name:le,user_initials:le.split(" ").map(he=>he[0]).join("").toUpperCase().slice(0,2),has_voted:se.includes(re.id),comment_count:de.get(re.id)||0}})}}),S=Dt({mutationFn:async({title:R,description:$})=>{const{error:q}=await G.from("wishlist_items").insert({user_id:t.id,title:R,description:$});if(q)throw q},onSuccess:()=>{n.invalidateQueries({queryKey:["wishlist-items"]}),u(!1),f(""),_(""),s({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:R=>{s({title:"Error",description:R.message,variant:"destructive"})}}),T=Dt({mutationFn:async({itemId:R,hasVoted:$})=>{if($){const{error:q}=await G.from("wishlist_votes").delete().eq("item_id",R).eq("user_id",t.id);if(q)throw q;return{itemId:R,wasAdded:!1}}else{const{error:q}=await G.from("wishlist_votes").insert({item_id:R,user_id:t.id});if(q)throw q;return{itemId:R,wasAdded:!0}}},onSuccess:async R=>{if(n.invalidateQueries({queryKey:["wishlist-items"]}),R!=null&&R.wasAdded){const $=j.find(U=>U.id===R.itemId),q=(($==null?void 0:$.vote_count)||0)+1;G.functions.invoke("wishlist-notify",{body:{itemId:R.itemId,voteCount:q}}).catch(console.error)}},onError:R=>{s({title:"Error",description:R.message,variant:"destructive"})}}),I=j.filter(R=>R.title.toLowerCase().includes(a.toLowerCase())||R.description.toLowerCase().includes(a.toLowerCase())),L=()=>{if(!p.trim()||!y.trim()){s({title:"Error",description:"Please fill in both title and description.",variant:"destructive"});return}S.mutate({title:p.trim(),description:y.trim()})};return e.jsx(Es,{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(Ib,{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(_s,{open:c,onOpenChange:u,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Idea"]})}),e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Submit a New Idea"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title"}),e.jsx(Fe,{id:"title",placeholder:"Give your idea a clear title...",value:p,onChange:R=>f(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",placeholder:"Describe your idea in detail. What problem does it solve? How would it help agents?",value:y,onChange:R=>_(R.target.value),rows:4})]}),e.jsx(K,{onClick:L,className:"w-full",disabled:S.isPending,children:S.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Idea"})]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search ideas...",value:a,onChange:R=>o(R.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Aa,{value:l,onValueChange:R=>i(R),children:e.jsxs(ja,{children:[e.jsx(js,{value:"popular",children:"Most Popular"}),e.jsx(js,{value:"latest",children:"Latest"}),e.jsx(js,{value:"trending",children:"Trending"})]})})})]}),e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsx(K,{variant:b?"default":"outline",size:"sm",onClick:()=>w(!b),children:b?"Show All Ideas":"My Ideas"})}),N?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Ss,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):I.length===0?e.jsxs("div",{className:"text-center py-12 bg-muted/30 rounded-lg",children:[e.jsx(Ib,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No ideas yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Be the first to submit an idea!"}),e.jsxs(K,{onClick:()=>u(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Idea"]})]}):e.jsx("div",{className:"space-y-3",children:I.map(R=>e.jsx("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>r(`/wishlist/${R.id}`),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:$=>{$.stopPropagation(),T.mutate({itemId:R.id,hasVoted:R.has_voted||!1})},className:At("flex flex-col items-center justify-center min-w-[50px] py-2 px-3 rounded-lg border transition-colors",R.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(gu,{className:At("h-4 w-4",R.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:R.vote_count})]}),e.jsx(yn,{className:"h-10 w-10 bg-primary/20",children:e.jsx(vn,{className:"bg-primary/20 text-primary text-sm font-medium",children:R.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:R.title}),e.jsx(nt,{className:At("text-xs",mFe[R.status].color),children:mFe[R.status].label})]}),e.jsx("p",{className:"text-muted-foreground text-sm line-clamp-2",children:R.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:R.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(R.created_at).toLocaleDateString()})]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(po,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:R.comment_count})]})]})},R.id))})]})})}const pFe={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 Lvs(){const{itemId:t}=Po(),s=Pr(),{user:r}=Ws(),{toast:n}=Ra(),a=ss(),[o,l]=C.useState(""),{data:i=!1}=wt({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:j,error:N}=await G.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!N&&!!j},enabled:!!r}),{data:c,isLoading:u}=wt({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:j,error:N}=await G.from("wishlist_items").select("*").eq("id",t).single();if(N)throw N;const{data:S}=await G.from("profiles").select("name").eq("id",j.user_id).single();let T=!1;if(r){const{data:I}=await G.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();T=!!I}return{...j,user_name:(S==null?void 0:S.name)||"Unknown",user_initials:((S==null?void 0:S.name)||"U").split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),has_voted:T}}}),{data:p=[],isLoading:f}=wt({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:j,error:N}=await G.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(N)throw N;const S=[...new Set((j==null?void 0:j.map(L=>L.user_id))||[])],{data:T}=await G.from("profiles").select("id, name").in("id",S),I=new Map((T==null?void 0:T.map(L=>[L.id,L]))||[]);return j==null?void 0:j.map(L=>{const R=I.get(L.user_id),$=(R==null?void 0:R.name)||"Unknown";return{...L,user_name:$,user_initials:$.split(" ").map(q=>q[0]).join("").toUpperCase().slice(0,2)}})}}),y=Dt({mutationFn:async j=>{if(j){const{error:N}=await G.from("wishlist_votes").delete().eq("item_id",t).eq("user_id",r.id);if(N)throw N;return{wasAdded:!1}}else{const{error:N}=await G.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(N)throw N;return{wasAdded:!0}}},onSuccess:async j=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),j!=null&&j.wasAdded&&c){const N=(c.vote_count||0)+1;G.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:N}}).catch(console.error)}},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),_=Dt({mutationFn:async j=>{const{error:N}=await G.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:j});if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),b=Dt({mutationFn:async j=>{const{error:N}=await G.from("wishlist_comments").delete().eq("id",j);if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:j=>{n({title:"Error",description:j.message,variant:"destructive"})}}),w=()=>{o.trim()&&_.mutate(o.trim())};return u?e.jsx(Es,{title:"Wishlist",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(xs,{className:"h-8 w-32 mb-6"}),e.jsx(xs,{className:"h-48 w-full mb-6"}),e.jsx(xs,{className:"h-32 w-full"})]})}):c?e.jsx(Es,{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(di,{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:()=>y.mutate(c.has_voted),className:At("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(gu,{className:At("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(nt,{className:At("text-xs",pFe[c.status].color),children:pFe[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(yn,{className:"h-6 w-6",children:e.jsx(vn,{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(Ple,{placeholder:i?"Share your thoughts... Use # to link templates":"Share your thoughts on this idea...",value:o,onChange:l,minHeight:"60px",mentionFormat:"encoded",enableTemplateMentions:i}),e.jsx(K,{onClick:w,disabled:!o.trim()||_.isPending,size:"icon",className:"h-auto",children:_.isPending?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(oa,{className:"h-4 w-4"})})]}),f?e.jsx("div",{className:"space-y-4",children:[1,2].map(j=>e.jsx(xs,{className:"h-20 w-full"},j))}):p.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No comments yet. Be the first to share your thoughts!"}):e.jsx("div",{className:"space-y-4",children:p.map(j=>e.jsxs("div",{className:"flex gap-3 p-3 bg-muted/30 rounded-lg",children:[e.jsx(yn,{className:"h-8 w-8",children:e.jsx(vn,{className:"bg-primary/20 text-primary text-xs",children:j.user_initials})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-sm",children:j.user_name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(j.created_at).toLocaleDateString()})]}),e.jsx(fNe,{content:j.content,className:"text-sm text-foreground"})]}),(r==null?void 0:r.id)===j.user_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>b.mutate(j.id),children:e.jsx(jr,{className:"h-4 w-4"})})]},j.id))})]})]})}):e.jsx(Es,{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 fFe={open:{label:"Open",color:"bg-blue-100 text-blue-800"},under_review:{label:"Under Review",color:"bg-yellow-100 text-yellow-800"},planned:{label:"Planned",color:"bg-purple-100 text-purple-800"},in_progress:{label:"In Progress",color:"bg-orange-100 text-orange-800"},launched:{label:"Launched",color:"bg-green-100 text-green-800"},declined:{label:"Declined",color:"bg-gray-100 text-gray-800"}},gFe=["open","under_review","planned","in_progress","launched","declined"];function Dvs(){const{toast:t}=Ra(),s=Pr(),r=ss(),[n,a]=C.useState(""),[o,l]=C.useState("all"),[i,c]=C.useState(!1),[u,p]=C.useState(null),{data:f=[],isLoading:y}=wt({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:N,error:S}=await G.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(S)throw S;const T=[...new Set((N==null?void 0:N.map(U=>U.user_id))||[])],{data:I}=await G.from("profiles").select("id, name, email").in("id",T),L=new Map((I==null?void 0:I.map(U=>[U.id,U]))||[]),R=(N==null?void 0:N.map(U=>U.id))||[],{data:$}=await G.from("wishlist_comments").select("item_id").in("item_id",R),q=new Map;return $==null||$.forEach(U=>{q.set(U.item_id,(q.get(U.item_id)||0)+1)}),N==null?void 0:N.map(U=>{const V=L.get(U.user_id);return{...U,user_name:(V==null?void 0:V.name)||"Unknown",user_email:(V==null?void 0:V.email)||"",comment_count:q.get(U.id)||0}})}}),_=Dt({mutationFn:async({itemId:N,status:S})=>{const{error:T}=await G.from("wishlist_items").update({status:S}).eq("id",N);if(T)throw T},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),t({title:"Status updated!"})},onError:N=>{t({title:"Error",description:N.message,variant:"destructive"})}}),b=Dt({mutationFn:async N=>{const{error:S}=await G.from("wishlist_items").delete().eq("id",N);if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),c(!1),p(null),t({title:"Item deleted!"})},onError:N=>{t({title:"Error",description:N.message,variant:"destructive"})}}),w=f.filter(N=>{const S=N.title.toLowerCase().includes(n.toLowerCase())||N.description.toLowerCase().includes(n.toLowerCase())||N.user_name.toLowerCase().includes(n.toLowerCase()),T=o==="all"||N.status===o;return S&&T}),j={total:f.length,open:f.filter(N=>N.status==="open").length,inProgress:f.filter(N=>N.status==="in_progress").length,launched:f.filter(N=>N.status==="launched").length,highVotes:f.filter(N=>N.vote_count>=10).length};return e.jsx(Es,{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(di,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Wishlist Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Review and manage community ideas"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Ideas"}),e.jsx("p",{className:"text-2xl font-bold",children:j.total})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Open"}),e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:j.open})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"In Progress"}),e.jsx("p",{className:"text-2xl font-bold text-orange-600",children:j.inProgress})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Launched"}),e.jsx("p",{className:"text-2xl font-bold text-green-600",children:j.launched})]}),e.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"10+ Votes"}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:j.highVotes})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search ideas, users...",value:n,onChange:N=>a(N.target.value),className:"pl-10"})]}),e.jsxs(rr,{value:o,onValueChange:N=>l(N),children:[e.jsx(tr,{className:"w-[180px]",children:e.jsx(nr,{placeholder:"Filter by status"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Statuses"}),gFe.map(N=>e.jsx(Tt,{value:N,children:fFe[N].label},N))]})]})]}),y?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(N=>e.jsx(xs,{className:"h-16 w-full"},N))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"w-[60px]",children:"Votes"}),e.jsx(bt,{children:"Title"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Submitted By"}),e.jsx(bt,{className:"hidden sm:table-cell",children:"Comments"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(Pn,{children:w.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):w.map(N=>e.jsxs(ks,{className:At(N.vote_count>=10&&"bg-primary/5"),children:[e.jsx(dt,{children:e.jsx(nt,{variant:N.vote_count>=10?"default":"secondary",children:N.vote_count})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium line-clamp-1",children:N.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:N.description})]})}),e.jsx(dt,{className:"hidden md:table-cell",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:N.user_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:N.user_email})]})}),e.jsx(dt,{className:"hidden sm:table-cell",children:N.comment_count}),e.jsx(dt,{children:e.jsxs(rr,{value:N.status,onValueChange:S=>_.mutate({itemId:N.id,status:S}),children:[e.jsx(tr,{className:"w-[140px] h-8",children:e.jsx(nr,{})}),e.jsx(sr,{children:gFe.map(S=>e.jsx(Tt,{value:S,children:fFe[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/${N.id}`,"_blank"),children:e.jsx(rn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{p(N.id),c(!0)},children:e.jsx(jr,{className:"h-4 w-4"})})]})})]},N.id))})]})}),e.jsx(_s,{open:i,onOpenChange:c,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Delete Wishlist Item"})}),e.jsx("p",{className:"text-muted-foreground",children:"Are you sure you want to delete this idea? This will also delete all votes and comments."}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:()=>u&&b.mutate(u),disabled:b.isPending,children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function Ovs(){const{user:t}=Ws(),[s,r]=C.useState([]),[n,a]=C.useState(!0),[o,l]=C.useState(!1),[i,c]=C.useState(null),[u,p]=C.useState(!1),[f,y]=C.useState(null),[_,b]=C.useState(""),[w,j]=C.useState(""),[N,S]=C.useState(""),[T,I]=C.useState(""),[L,R]=C.useState(""),[$,q]=C.useState(!1),[U,V]=C.useState(""),[X,se]=C.useState("once"),[ee,Q]=C.useState([]),[de,re]=C.useState([]),[ne,le]=C.useState(!1),[he,we]=C.useState(!1),[ye,je]=C.useState([]),[ke,We]=C.useState({total:0,dismissed:0});C.useEffect(()=>{be()},[]);const be=async()=>{const{data:Ke,error:Xe}=await G.from("levelup_briefs").select("*").order("created_at",{ascending:!1});Xe?(me.error("Failed to fetch briefs"),console.error(Xe)):r(Ke||[]),a(!1)},Me=()=>{b(""),j(""),S(""),I(""),R(""),q(!1),V(new Date().toISOString().slice(0,16)),se("once"),Q([]),re([]),c(null)},Ae=()=>{Me(),l(!0)},Re=async Ke=>{c(Ke),b(Ke.title),j(Ke.description||""),S(Ke.video_url||""),I(Ke.graphic_url||""),R(Ke.graphic_link_url||""),q(Ke.is_published),V(Ke.publish_date.slice(0,16)),se(Ke.show_frequency);const{data:Xe}=await G.from("levelup_brief_links").select("*").eq("brief_id",Ke.id).order("sort_order");Q((Xe==null?void 0:Xe.map(Ye=>({title:Ye.title,url:Ye.url})))||[]);const{data:He}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Ke.id).order("sort_order");if(He){const Ye=[];for(const tt of He){const{data:Et}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",tt.id).order("sort_order");Ye.push({question:tt.question,poll_type:tt.poll_type,options:(Et==null?void 0:Et.map(qt=>qt.option_text))||[]})}re(Ye)}l(!0)},Te=async Ke=>{var He;const Xe=(He=Ke.target.files)==null?void 0:He[0];if(Xe){le(!0);try{const Ye=await G.functions.invoke("bunny-upload",{body:{action:"create",title:Xe.name.replace(/\.[^/.]+$/,"")}});if(Ye.error)throw Ye.error;const{videoId:tt,libraryId:Et}=Ye.data,qt=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:tt}});if(qt.error)throw qt.error;const{uploadUrl:ms,apiKey:Xt}=qt.data,rs=new XMLHttpRequest;await new Promise((Ms,jt)=>{rs.upload.addEventListener("progress",As=>{if(As.lengthComputable){const Ps=Math.round(As.loaded/As.total*100);console.log("Upload progress:",Ps)}}),rs.addEventListener("load",()=>{rs.status>=200&&rs.status<300?Ms():jt(new Error(`Upload failed with status ${rs.status}`))}),rs.addEventListener("error",()=>jt(new Error("Upload failed"))),rs.open("PUT",ms),rs.setRequestHeader("AccessKey",Xt),rs.send(Xe)});const ps=`https://player.mediadelivery.net/embed/${Et}/${tt}`;S(ps),me.success("Video uploaded successfully! It may take a few minutes to process.")}catch(Ye){console.error("Upload error:",Ye),me.error("Failed to upload video")}finally{le(!1)}}},qe=async()=>{if(!_.trim()){me.error("Title is required");return}try{let Ke;if(i){const{error:Xe}=await G.from("levelup_briefs").update({title:_,description:w||null,video_url:N||null,graphic_url:T||null,graphic_link_url:L||null,is_published:$,publish_date:U,show_frequency:X}).eq("id",i.id);if(Xe)throw Xe;Ke=i.id,await G.from("levelup_brief_links").delete().eq("brief_id",Ke);const{data:He}=await G.from("levelup_brief_polls").select("id").eq("brief_id",Ke);if(He)for(const Ye of He)await G.from("levelup_brief_poll_options").delete().eq("poll_id",Ye.id);await G.from("levelup_brief_polls").delete().eq("brief_id",Ke)}else{const{data:Xe,error:He}=await G.from("levelup_briefs").insert({title:_,description:w||null,video_url:N||null,graphic_url:T||null,graphic_link_url:L||null,is_published:$,publish_date:U,show_frequency:X,created_by:t==null?void 0:t.id}).select().single();if(He)throw He;Ke=Xe.id}if(ee.length>0){const Xe=ee.map((He,Ye)=>({brief_id:Ke,title:He.title,url:He.url,sort_order:Ye}));await G.from("levelup_brief_links").insert(Xe)}for(let Xe=0;Xe0){const Et=He.options.map((qt,ms)=>({poll_id:Ye.id,option_text:qt,sort_order:ms}));await G.from("levelup_brief_poll_options").insert(Et)}}me.success(i?"Brief updated":"Brief created"),l(!1),Me(),be()}catch(Ke){console.error("Error saving brief:",Ke),me.error("Failed to save brief")}},ct=async Ke=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:Xe}=await G.from("levelup_briefs").delete().eq("id",Ke);if(Xe)throw Xe;me.success("Brief deleted"),be()}catch(Xe){console.error("Error deleting brief:",Xe),me.error("Failed to delete brief")}},De=async Ke=>{y(Ke);const{count:Xe}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ke.id),{count:He}=await G.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ke.id).not("dismissed_at","is",null);We({total:Xe||0,dismissed:He||0});const{data:Ye}=await G.from("levelup_brief_polls").select("*").eq("brief_id",Ke.id).order("sort_order");if(Ye){const tt=[];for(const Et of Ye){const{data:qt}=await G.from("levelup_brief_poll_options").select("*").eq("poll_id",Et.id).order("sort_order"),{data:ms}=await G.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",Et.id),Xt=[...new Set((ms==null?void 0:ms.map(As=>As.user_id))||[])];let rs={};if(Xt.length>0){const{data:As}=await G.from("profiles").select("id, name, email").in("id",Xt);As&&As.forEach(Ps=>{rs[Ps.id]=Ps.name||Ps.email||"Unknown"})}const ps=(ms||[]).map(As=>({optionId:As.option_id,userName:rs[As.user_id]||"Unknown",userId:As.user_id})),Ms={};let jt=0;qt&&qt.forEach(As=>{const Ps=(ms==null?void 0:ms.filter(ar=>ar.option_id===As.id).length)||0;Ms[As.id]=Ps,jt+=Ps}),tt.push({...Et,options:qt||[],results:Ms,respondents:ps,totalResponses:Et.poll_type==="single"?new Set(ms==null?void 0:ms.map(As=>As.user_id)).size:jt})}je(tt)}p(!0)},Rt=()=>{Q([...ee,{title:"",url:""}])},pe=(Ke,Xe,He)=>{const Ye=[...ee];Ye[Ke][Xe]=He,Q(Ye)},Je=Ke=>{Q(ee.filter((Xe,He)=>He!==Ke))},lt=()=>{re([...de,{question:"",poll_type:"single",options:["",""]}])},rt=(Ke,Xe)=>{const He=[...de];He[Ke].question=Xe,re(He)},Se=(Ke,Xe)=>{const He=[...de];He[Ke].poll_type=Xe,re(He)},it=Ke=>{const Xe=[...de];Xe[Ke].options.push(""),re(Xe)},$e=(Ke,Xe,He)=>{const Ye=[...de];Ye[Ke].options[Xe]=He,re(Ye)},ot=(Ke,Xe)=>{const He=[...de];He[Ke].options=He[Ke].options.filter((Ye,tt)=>tt!==Xe),re(He)},Ue=Ke=>{re(de.filter((Xe,He)=>He!==Ke))};return e.jsxs(Es,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:e.jsxs(K,{onClick:Ae,children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Frequency"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:n?e.jsx(ks,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(Ke=>e.jsxs(ks,{children:[e.jsx(dt,{className:"font-medium",children:Ke.title}),e.jsx(dt,{children:e.jsx(nt,{variant:Ke.is_published?"default":"secondary",children:Ke.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"capitalize",children:Ke.show_frequency.replace("_"," ")}),e.jsx(dt,{children:ys(new Date(Ke.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:()=>De(Ke),children:e.jsx(xl,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Re(Ke),children:e.jsx(rd,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ct(Ke.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},Ke.id))})]})})})]}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:i?"Edit Brief":"Create New Brief"})}),e.jsxs(Aa,{defaultValue:"content",className:"w-full",children:[e.jsxs(ja,{className:"grid w-full grid-cols-4",children:[e.jsx(js,{value:"content",children:"Content"}),e.jsx(js,{value:"media",children:"Media"}),e.jsx(js,{value:"links",children:"Links"}),e.jsx(js,{value:"polls",children:"Polls"})]}),e.jsxs($s,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Title *"}),e.jsx(Fe,{value:_,onChange:Ke=>b(Ke.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(iy,{content:w,onChange:Ke=>j(Ke),placeholder:"Brief overview for agents...",minHeight:"120px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Publish Date"}),e.jsx(Fe,{type:"datetime-local",value:U,onChange:Ke=>V(Ke.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Show Frequency"}),e.jsxs(rr,{value:X,onValueChange:se,children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"once",children:"Once (until dismissed)"}),e.jsx(Tt,{value:"every_login",children:"Every login"}),e.jsx(Tt,{value:"daily",children:"Daily"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Br,{checked:$,onCheckedChange:q}),e.jsx(_e,{children:"Publish immediately"})]})]}),e.jsxs($s,{value:"media",className:"space-y-6 mt-4",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Video (optional)"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Upload Video to Bunny.net"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Fe,{type:"file",accept:"video/*",onChange:Te,disabled:ne})}),ne&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Or paste embed URL"}),e.jsx(Fe,{value:N,onChange:Ke=>S(Ke.target.value),placeholder:"https://iframe.mediadelivery.net/embed/..."})]}),N&&e.jsx("div",{className:"aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:N,className:"w-full h-full",allow:"autoplay; fullscreen",allowFullScreen:!0})})]}),e.jsxs("div",{className:"border-t pt-4 space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Graphic / Image (optional)"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Upload Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Fe,{type:"file",accept:"image/*",onChange:async Ke=>{var He;const Xe=(He=Ke.target.files)==null?void 0:He[0];if(Xe){we(!0);try{const Ye=Xe.name.split(".").pop(),tt=`brief-graphics/${Date.now()}.${Ye}`,{error:Et}=await G.storage.from("banner-images").upload(tt,Xe,{upsert:!0});if(Et)throw Et;const{data:qt}=G.storage.from("banner-images").getPublicUrl(tt);I(qt.publicUrl),me.success("Image uploaded!")}catch(Ye){console.error(Ye),me.error("Failed to upload image")}finally{we(!1)}}},disabled:he})}),he&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Or paste Image URL"}),e.jsx(Fe,{value:T,onChange:Ke=>I(Ke.target.value),placeholder:"https://example.com/image.png"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Click-through Link (optional)"}),e.jsx(Fe,{value:L,onChange:Ke=>R(Ke.target.value),placeholder:"https://example.com/landing-page"})]}),T&&e.jsx("div",{className:"rounded-lg overflow-hidden bg-muted border",children:e.jsx("img",{src:T,alt:"Brief graphic preview",className:"w-full object-contain max-h-64"})})]})]}),e.jsxs($s,{value:"links",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(_e,{children:"Quick Links"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:Rt,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),ee.map((Ke,Xe)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(Fe,{value:Ke.title,onChange:He=>pe(Xe,"title",He.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(Fe,{value:Ke.url,onChange:He=>pe(Xe,"url",He.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Je(Xe),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]},Xe)),ee.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No links added yet"})]}),e.jsxs($s,{value:"polls",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(_e,{children:"Polls"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:lt,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),de.map((Ke,Xe)=>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(Fe,{value:Ke.question,onChange:He=>rt(Xe,He.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(rr,{value:Ke.poll_type,onValueChange:He=>Se(Xe,He),children:[e.jsx(tr,{className:"w-32",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"single",children:"Single"}),e.jsx(Tt,{value:"multi",children:"Multi-select"})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ue(Xe),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]}),e.jsxs("div",{className:"space-y-2 pl-4",children:[Ke.options.map((He,Ye)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:He,onChange:tt=>$e(Xe,Ye,tt.target.value),placeholder:`Option ${Ye+1}`}),Ke.options.length>2&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ot(Xe,Ye),children:e.jsx(jr,{className:"h-4 w-4 text-muted-foreground"})})]},Ye)),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>it(Xe),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},Xe)),de.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls added yet"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:qe,children:i?"Update Brief":"Create Brief"})]})]})}),e.jsx(_s,{open:u,onOpenChange:p,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:["Results: ",f==null?void 0:f.title]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-2xl font-bold",children:ke.total})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-2xl font-bold",children:ke.dismissed})})]})]}),ye.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Poll Results"}),ye.map(Ke=>e.jsxs(Ee,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:Ke.question}),e.jsx("div",{className:"space-y-2",children:Ke.options.map(Xe=>{const He=Ke.results[Xe.id]||0,Ye=Ke.totalResponses>0?Math.round(He/Ke.totalResponses*100):0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:Xe.option_text}),e.jsxs("span",{className:"text-muted-foreground",children:[He," (",Ye,"%)"]})]}),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:`${Ye}%`}})}),He>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(Ke.respondents||[]).filter(tt=>tt.optionId===Xe.id).map((tt,Et)=>e.jsx(nt,{variant:"secondary",className:"text-xs font-normal",children:tt.userName},Et))})]},Xe.id)})})]},Ke.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const Rvs=()=>{const{user:t}=Ws(),{toast:s}=Ra(),r=ss(),[n,a]=C.useState(!1),[o,l]=C.useState(null),[i,c]=C.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=C.useState(null),[f,y]=C.useState(""),{data:_=[],isLoading:b}=wt({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:L,error:R}=await G.from("additional_services").select("*").order("publish_date",{ascending:!1});if(R)throw R;return L}}),w=Dt({mutationFn:async L=>{let R=L.existingImageUrl;if(L.image){const q=L.image.name.split(".").pop(),U=`${Date.now()}-${Math.random().toString(36).substring(7)}.${q}`,{error:V}=await G.storage.from("service-images").upload(U,L.image);if(V)throw V;const{data:X}=G.storage.from("service-images").getPublicUrl(U);R=X.publicUrl}const $={name:L.item.name,description:L.item.description||null,preview_image_url:R,signup_link_url:L.item.signup_link_url,publish_date:L.item.publish_date?new Date(L.item.publish_date).toISOString():new Date().toISOString(),is_published:L.item.is_published,created_by:t==null?void 0:t.id};if(L.itemId){const{error:q}=await G.from("additional_services").update($).eq("id",L.itemId);if(q)throw q}else{const{error:q}=await G.from("additional_services").insert($);if(q)throw q}},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:o?"Service updated":"Service created"}),a(!1),N()},onError:L=>{s({title:"Error saving service",description:L.message,variant:"destructive"})}}),j=Dt({mutationFn:async L=>{const{error:R}=await G.from("additional_services").delete().eq("id",L);if(R)throw R},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:"Service deleted"})},onError:L=>{s({title:"Error deleting service",description:L.message,variant:"destructive"})}}),N=()=>{c({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),y(""),l(null)},S=L=>{l(L),c({name:L.name,description:L.description||"",signup_link_url:L.signup_link_url,publish_date:L.publish_date?new Date(L.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:L.is_published}),y(L.preview_image_url||""),a(!0)},T=L=>{var $;const R=($=L.target.files)==null?void 0:$[0];R&&(p(R),y(URL.createObjectURL(R)))},I=L=>{if(L.preventDefault(),!i.name.trim()){s({title:"Name is required",variant:"destructive"});return}if(!i.signup_link_url.trim()){s({title:"Signup link URL is required",variant:"destructive"});return}w.mutate({item:i,image:u,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return e.jsx(Es,{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(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.filter(L=>L.is_published).length})})]})]}),e.jsxs(_s,{open:n,onOpenChange:L=>{a(L),L||N()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Service"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:o?"Edit Service":"Add New Service"})}),e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"name",children:"Name *"}),e.jsx(Fe,{id:"name",value:i.name,onChange:L=>c({...i,name:L.target.value}),placeholder:"Enter service name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(iy,{content:i.description,onChange:L=>c({...i,description:L}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"signup_link_url",children:"Signup Link URL *"}),e.jsx(Fe,{id:"signup_link_url",type:"url",value:i.signup_link_url,onChange:L=>c({...i,signup_link_url:L.target.value}),placeholder:"https://example.com/signup"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(Fe,{id:"publish_date",type:"date",value:i.publish_date,onChange:L=>c({...i,publish_date:L.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Br,{id:"is_published",checked:i.is_published,onCheckedChange:L=>c({...i,is_published:L})}),e.jsx(_e,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Preview Image"}),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),y("")},children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(cl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx(Fe,{type:"file",accept:"image/*",onChange:T,className:"cursor-pointer"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:b?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No services yet. Click "Add Service" to create your first one.'}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"w-16",children:"Preview"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Signup Link"}),e.jsx(bt,{children:"Publish Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:_.map(L=>e.jsxs(ks,{children:[e.jsx(dt,{children:L.preview_image_url?e.jsx("img",{src:L.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(cl,{className:"h-5 w-5 text-muted-foreground"})})}),e.jsx(dt,{className:"font-medium",children:L.name}),e.jsx(dt,{children:e.jsxs("a",{href:L.signup_link_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:[e.jsx(rn,{className:"h-3 w-3"}),"Link"]})}),e.jsx(dt,{children:new Date(L.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(nt,{variant:L.is_published?"default":"secondary",children:L.is_published?"Published":"Draft"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>S(L),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&j.mutate(L.id)},children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},L.id))})]})})})]})})};function Fvs(){const{toast:t}=Ra(),[s,r]=C.useState([]),[n,a]=C.useState(!0),[o,l]=C.useState(!1),[i,c]=C.useState(!1),[u,p]=C.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});C.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:j,error:N}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(N)throw N;r(j.coupons||[])}catch(j){console.error("Error fetching coupons:",j),t({title:"Error",description:"Failed to load coupons",variant:"destructive"})}finally{a(!1)}},y=async()=>{if(!u.name){t({title:"Error",description:"Please enter a coupon name",variant:"destructive"});return}if(u.discountType==="percent"&&!u.percentOff){t({title:"Error",description:"Please enter a percent off value",variant:"destructive"});return}if(u.discountType==="amount"&&!u.amountOff){t({title:"Error",description:"Please enter an amount off value",variant:"destructive"});return}if(u.duration==="repeating"&&!u.durationInMonths){t({title:"Error",description:"Please enter duration in months",variant:"destructive"});return}l(!0);try{const j={action:"create",name:u.name,duration:u.duration,promotion_code:u.promotionCode.trim()||void 0};u.discountType==="percent"?j.percent_off=parseFloat(u.percentOff):(j.amount_off=Math.round(parseFloat(u.amountOff)*100),j.currency="usd"),u.duration==="repeating"&&(j.duration_in_months=parseInt(u.durationInMonths));const{data:N,error:S}=await G.functions.invoke("stripe-manage-coupons",{body:j});if(S)throw S;t({title:"Success",description:"Coupon created successfully"}),c(!1),p({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),f()}catch(j){console.error("Error creating coupon:",j),t({title:"Error",description:j.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},_=async j=>{if(confirm("Are you sure you want to delete this coupon?"))try{const{error:N}=await G.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:j}});if(N)throw N;t({title:"Success",description:"Coupon deleted successfully"}),f()}catch(N){console.error("Error deleting coupon:",N),t({title:"Error",description:N.message||"Failed to delete coupon",variant:"destructive"})}},b=j=>j.percent_off?`${j.percent_off}% off`:j.amount_off?`$${(j.amount_off/100).toFixed(2)} off`:"N/A",w=j=>{switch(j.duration){case"once":return"Once";case"forever":return"Forever";case"repeating":return`${j.duration_in_months} months`;default:return j.duration}};return e.jsx(Es,{title:"Subscription Discounts",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:e.jsxs(_s,{open:i,onOpenChange:c,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Create New Coupon"}),e.jsx(Zr,{children:"Create a discount coupon that can be applied to subscriptions"})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Promotion Code (what users will type)"}),e.jsx(Fe,{placeholder:"e.g., BROKERAGE50",value:u.promotionCode,onChange:j=>p({...u,promotionCode:j.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")}),className:"font-mono uppercase"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters and numbers only. This is the code users enter at checkout."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Coupon Name (internal label)"}),e.jsx(Fe,{placeholder:"e.g., 50% Off Brokerage Launch",value:u.name,onChange:j=>p({...u,name:j.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Discount Type"}),e.jsxs(rr,{value:u.discountType,onValueChange:j=>{const N=j==="amount"&&u.duration==="forever"?"once":u.duration;p({...u,discountType:j,duration:N})},children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(_M,{className:"mr-2 h-4 w-4"}),"Percentage Off"]})}),e.jsx(Tt,{value:"amount",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(Td,{className:"mr-2 h-4 w-4"}),"Fixed Amount Off"]})})]})]})]}),u.discountType==="percent"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Percent Off"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{type:"number",min:"1",max:"100",placeholder:"20",value:u.percentOff,onChange:j=>p({...u,percentOff:j.target.value})}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Amount Off (USD)"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"$"}),e.jsx(Fe,{type:"number",min:"1",placeholder:"10.00",className:"pl-7",value:u.amountOff,onChange:j=>p({...u,amountOff:j.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Duration"}),e.jsxs(rr,{value:u.duration,onValueChange:j=>p({...u,duration:j}),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"once",children:"Once (first payment only)"}),e.jsx(Tt,{value:"repeating",children:"Multiple months"}),e.jsxs(Tt,{value:"forever",disabled:u.discountType==="amount",children:["Forever ",u.discountType==="amount"&&"(% discounts only)"]})]})]}),u.discountType==="amount"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:'Note: "Forever" duration is only available for percentage-based discounts.'})]}),u.duration==="repeating"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Number of Months"}),e.jsx(Fe,{type:"number",min:"1",placeholder:"3",value:u.durationInMonths,onChange:j=>p({...u,durationInMonths:j.target.value})})]}),e.jsx(K,{onClick:y,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Active Coupons"}),e.jsx(fr,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),e.jsx(Oe,{children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ss,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):s.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No coupons created yet. Create your first coupon to get started."}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Promo Code"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Discount"}),e.jsx(bt,{children:"Duration"}),e.jsx(bt,{children:"Redemptions"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:s.map(j=>{var N;return e.jsxs(ks,{children:[e.jsx(dt,{className:"font-mono font-medium",children:((N=j.promotion_codes)==null?void 0:N.length)>0?j.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(dt,{children:j.name||"-"}),e.jsx(dt,{children:b(j)}),e.jsx(dt,{children:w(j)}),e.jsx(dt,{children:j.times_redeemed}),e.jsx(dt,{children:e.jsx(nt,{variant:j.valid?"default":"secondary",children:j.valid?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(j.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})})]},j.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"How to Use Coupons"})}),e.jsxs(Oe,{className:"text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{children:"1. Create a coupon above with your desired discount."}),e.jsx("p",{children:'2. Share the coupon code (shown in the "Code" column) with users.'}),e.jsx("p",{children:"3. Users can enter the code during checkout to receive the discount."}),e.jsx("p",{children:"4. Alternatively, you can create a promotion code in Stripe dashboard for public-facing promotions."})]})]})]})})}const sye={prod_Tc07cYplXUGNkm:{name:"Individual Agent",price:"$39/mo",type:"individual"},prod_Tc08MupgoVySDG:{name:"Brokerage (Under 25)",price:"$299/mo",type:"brokerage"},prod_Tc09N1tJ4RrAFn:{name:"Brokerage (Over 25)",price:"$499/mo",type:"brokerage"}};function zvs(){const[t,s]=C.useState(""),[r,n]=C.useState("all"),[a,o]=C.useState(null),{data:l,isLoading:i,refetch:c}=wt({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:b,error:w}=await G.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(w)throw w;return b}}),{data:u}=wt({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:b,error:w}=await G.from("brokerages").select("*").order("name");if(w)throw w;return await Promise.all((b||[]).map(async N=>{const{data:S}=await G.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",N.id),{data:T}=await G.from("user_roles").select("user_id").eq("role","brokerage_manager"),I=(T==null?void 0:T.map($=>$.user_id))||[],L=(S==null?void 0:S.filter($=>I.includes($.id)))||[],R=(S==null?void 0:S.length)||0;return{...N,managers:L,agentCount:R}}))}}),p=b=>{if(b.is_grandfathered)return{status:"Grandfathered",badge:"Legacy",variant:"secondary"};if(b.brokerage_id&&!b.subscription_product_id)return{status:"Brokerage",badge:"Team Member",variant:"outline"};if(b.is_trial&&b.trial_expires_at)return new Date(b.trial_expires_at)>new Date?{status:"Trial",badge:"Active Trial",variant:"default"}:{status:"Trial Expired",badge:"Expired",variant:"destructive"};if(b.subscription_status==="active"||b.subscription_status==="trialing"){const w=sye[b.subscription_product_id];return{status:(w==null?void 0:w.name)||"Active",badge:b.subscription_status==="trialing"?"Trial":"Active",variant:"default"}}return b.subscription_status==="canceled"||b.subscription_status==="past_due"?{status:"Canceled",badge:"Inactive",variant:"destructive"}:{status:"None",badge:"No Subscription",variant:"outline"}},f=l==null?void 0:l.filter(b=>{var j,N;if(!(((j=b.name)==null?void 0:j.toLowerCase().includes(t.toLowerCase()))||((N=b.email)==null?void 0:N.toLowerCase().includes(t.toLowerCase()))))return!1;switch(p(b),r){case"active":return b.subscription_status==="active";case"trialing":return b.subscription_status==="trialing"||b.is_trial&&new Date(b.trial_expires_at)>new Date;case"grandfathered":return b.is_grandfathered;case"brokerage":return b.brokerage_id&&!b.subscription_product_id&&!b.is_grandfathered;case"expired":return b.subscription_status==="canceled"||b.subscription_status==="past_due"||b.is_trial&&new Date(b.trial_expires_at)<=new Date;case"none":return!b.subscription_status||b.subscription_status==="none";default:return!0}}),y={totalUsers:(l==null?void 0:l.length)||0,activeSubscriptions:(l==null?void 0:l.filter(b=>b.subscription_status==="active").length)||0,trials:(l==null?void 0:l.filter(b=>b.subscription_status==="trialing"||b.is_trial&&new Date(b.trial_expires_at)>new Date).length)||0,grandfathered:(l==null?void 0:l.filter(b=>b.is_grandfathered).length)||0,brokerageMembers:(l==null?void 0:l.filter(b=>b.brokerage_id&&!b.subscription_product_id&&!b.is_grandfathered).length)||0,individualSubscribers:(l==null?void 0:l.filter(b=>b.subscription_status==="active"&&b.subscription_product_id==="prod_Tc07cYplXUGNkm").length)||0,brokerageSubscribers:(l==null?void 0:l.filter(b=>b.subscription_status==="active"&&(b.subscription_product_id==="prod_Tc08MupgoVySDG"||b.subscription_product_id==="prod_Tc09N1tJ4RrAFn")).length)||0},_=b=>{window.open(`https://dashboard.stripe.com/customers/${b}`,"_blank")};return e.jsx(Es,{title:"Subscription Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{title:"Subscription Management",description:"Track and manage all subscriptions",children:e.jsxs(K,{onClick:()=>c(),variant:"outline",size:"sm",children:[e.jsx(Bo,{className:"h-4 w-4 mr-2"}),"Refresh"]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Users"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:y.totalUsers})]})}),e.jsx(Ee,{className:"border-green-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yg,{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:y.activeSubscriptions})]})}),e.jsx(Ee,{className:"border-blue-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Trials"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1 text-blue-600",children:y.trials})]})}),e.jsx(Ee,{className:"border-purple-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Sm,{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:y.grandfathered})]})}),e.jsx(Ee,{className:"border-orange-500/50",children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(La,{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:y.brokerageMembers})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zb,{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:y.individualSubscribers})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(La,{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:y.brokerageSubscribers})]})})]}),e.jsxs(Aa,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(ja,{children:[e.jsx(js,{value:"users",children:"All Users"}),e.jsx(js,{value:"brokerages",children:"Brokerages"})]}),e.jsxs($s,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name or email...",value:t,onChange:b=>s(b.target.value),className:"pl-9"})]}),e.jsxs(rr,{value:r,onValueChange:b=>n(b),children:[e.jsx(tr,{className:"w-[200px]",children:e.jsx(nr,{placeholder:"Filter by status"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Users"}),e.jsx(Tt,{value:"active",children:"Active Subscriptions"}),e.jsx(Tt,{value:"trialing",children:"Trials"}),e.jsx(Tt,{value:"grandfathered",children:"Grandfathered"}),e.jsx(Tt,{value:"brokerage",children:"Brokerage Members"}),e.jsx(Tt,{value:"expired",children:"Expired/Canceled"}),e.jsx(Tt,{value:"none",children:"No Subscription"})]})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"User"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Plan"}),e.jsx(bt,{children:"Brokerage"}),e.jsx(bt,{children:"End Date"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:i?e.jsx(ks,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(f==null?void 0:f.length)===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):f==null?void 0:f.map(b=>{var N,S;const w=p(b),j=sye[b.subscription_product_id];return e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:b.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:b.email})]})}),e.jsx(dt,{children:e.jsx(nt,{variant:w.variant,children:w.badge})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm",children:b.is_grandfathered?"Legacy Access":b.brokerage_id&&!b.subscription_product_id?"Brokerage Subscription":(j==null?void 0:j.name)||w.status})}),e.jsx(dt,{children:(N=b.brokerages)!=null&&N.name?e.jsx("span",{className:"text-sm",children:b.brokerages.name}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),e.jsx(dt,{children:b.subscription_end_date?e.jsx("span",{className:"text-sm",children:ys(new Date(b.subscription_end_date),"MMM d, yyyy")}):b.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",ys(new Date(b.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:[b.stripe_customer_id&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(b.stripe_customer_id),children:e.jsx(rn,{className:"h-4 w-4"})}),e.jsxs(_s,{children:[e.jsx(Fi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",onClick:()=>o(b),children:"Details"})}),e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Subscription Details"}),e.jsxs(Zr,{children:[b.name," (",b.email,")"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Status"}),e.jsx(nt,{variant:w.variant,className:"mt-1",children:w.badge})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Plan"}),e.jsx("p",{className:"font-medium",children:b.is_grandfathered?"Grandfathered (Legacy)":b.brokerage_id&&!b.subscription_product_id?"Brokerage Subscription":(j==null?void 0:j.name)||"None"})]}),b.brokerage_id&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Brokerage"}),e.jsx("p",{className:"font-medium",children:((S=b.brokerages)==null?void 0:S.name)||"Unknown"})]}),b.subscription_end_date&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Current Period End"}),e.jsx("p",{className:"font-medium",children:ys(new Date(b.subscription_end_date),"MMMM d, yyyy")})]}),b.trial_expires_at&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Trial Expires"}),e.jsx("p",{className:"font-medium",children:ys(new Date(b.trial_expires_at),"MMMM d, yyyy")})]}),b.stripe_customer_id&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Stripe Customer ID"}),e.jsx("p",{className:"font-mono text-sm",children:b.stripe_customer_id})]})]}),b.stripe_customer_id&&e.jsxs(K,{className:"w-full",onClick:()=>_(b.stripe_customer_id),children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},b.id)})})]})})})]}),e.jsx($s,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:u==null?void 0:u.map(b=>{var j,N;const w=(j=b.managers)==null?void 0:j.some(S=>S.subscription_status==="active"&&(S.subscription_product_id==="prod_Tc08MupgoVySDG"||S.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(Ee,{children:[e.jsx(It,{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(La,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:b.name}),e.jsxs(fr,{children:[b.agentCount," agents"]})]})]}),e.jsx(nt,{variant:w?"default":"outline",children:w?"Active Subscription":"No Active Subscription"})]})}),e.jsx(Oe,{children:((N=b.managers)==null?void 0:N.length)>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Managers:"}),b.managers.map(S=>{const T=sye[S.subscription_product_id];return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.email})]}),e.jsx("div",{className:"text-right",children:T?e.jsxs("div",{children:[e.jsx(nt,{variant:"default",children:T.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:T.price})]}):e.jsx(nt,{variant:"outline",children:"No Subscription"})})]},S.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},b.id)})})})]})]})})}function Bvs(){const[t,s]=C.useState([]),[r,n]=C.useState(!0),[a,o]=C.useState(""),[l,i]=C.useState("all"),[c,u]=C.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});C.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:b,error:w}=await G.from("referrals").select(` *, referrer_brokerage:brokerages!referrer_brokerage_id(name), referred_brokerage:brokerages!referred_brokerage_id(name), referred_user:profiles!referred_user_id(name, email) `).order("created_at",{ascending:!1});if(w)throw w;s(b||[]);const j=(b==null?void 0:b.filter(T=>T.status==="qualified").length)||0,N=(b==null?void 0:b.filter(T=>T.status==="pending").length)||0,S=(b==null?void 0:b.filter(T=>T.status==="cancelled").length)||0;u({total:(b==null?void 0:b.length)||0,qualified:j,pending:N,cancelled:S,totalDiscounts:j*25})}catch(b){console.error("Error fetching referrals:",b),me.error("Failed to load referrals")}finally{n(!1)}},f=async()=>{try{me.loading("Processing qualifications...");const{error:b}=await G.functions.invoke("process-referral-qualifications");if(b)throw b;me.dismiss(),me.success("Qualifications processed successfully"),p()}catch(b){me.dismiss(),console.error("Error processing qualifications:",b),me.error("Failed to process qualifications")}},y=t.filter(b=>{var N,S,T,I,L,R;const w=((S=(N=b.referrer_brokerage)==null?void 0:N.name)==null?void 0:S.toLowerCase().includes(a.toLowerCase()))||((I=(T=b.referred_brokerage)==null?void 0:T.name)==null?void 0:I.toLowerCase().includes(a.toLowerCase()))||((R=(L=b.referred_user)==null?void 0:L.email)==null?void 0:R.toLowerCase().includes(a.toLowerCase())),j=l==="all"||b.status===l;return w&&j}),_=b=>{switch(b){case"qualified":return e.jsxs(nt,{className:"bg-green-100 text-green-800",children:[e.jsx(vi,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(nt,{variant:"secondary",children:[e.jsx(Tn,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(nt,{variant:"destructive",children:[e.jsx($c,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(nt,{children:b})}};return e.jsx(Es,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{title:"Referral Program",description:"Track and manage brokerage referrals",children:e.jsxs(K,{onClick:f,variant:"outline",children:[e.jsx(Bo,{className:"h-4 w-4 mr-2"}),"Process Qualifications"]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Referrals"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(vi,{className:"h-5 w-5 text-green-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.qualified}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5 text-amber-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.pending}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pending"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($c,{className:"h-5 w-5 text-red-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:c.cancelled}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Cancelled"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Td,{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(It,{children:[e.jsx(Ot,{children:"All Referrals"}),e.jsx(fr,{children:"View and manage all referral relationships"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by brokerage or email...",value:a,onChange:b=>o(b.target.value),className:"pl-10"})]}),e.jsxs(rr,{value:l,onValueChange:i,children:[e.jsx(tr,{className:"w-[180px]",children:e.jsx(nr,{placeholder:"Filter by status"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Statuses"}),e.jsx(Tt,{value:"pending",children:"Pending"}),e.jsx(Tt,{value:"qualified",children:"Qualified"}),e.jsx(Tt,{value:"cancelled",children:"Cancelled"})]})]})]}),r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Referrer"}),e.jsx(bt,{children:"Referred"}),e.jsx(bt,{children:"Signup Date"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Qualified Date"}),e.jsx(bt,{children:"Discount"})]})}),e.jsx(Pn,{children:y.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):y.map(b=>{var w,j,N,S;return e.jsxs(ks,{children:[e.jsx(dt,{className:"font-medium",children:((w=b.referrer_brokerage)==null?void 0:w.name)||"Unknown"}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{children:((j=b.referred_brokerage)==null?void 0:j.name)||((N=b.referred_user)==null?void 0:N.name)||"Pending setup"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(S=b.referred_user)==null?void 0:S.email})]})}),e.jsx(dt,{children:ys(new Date(b.signup_date),"MMM d, yyyy")}),e.jsx(dt,{children:_(b.status)}),e.jsx(dt,{children:b.qualified_date?ys(new Date(b.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(dt,{children:b.discount_applied?e.jsx(nt,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},b.id)})})]})]})]})]})})}const rye=[{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"}],$vs=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function qvs(){const[t,s]=C.useState([]),[r,n]=C.useState(!0),[a,o]=C.useState(!1),[l,i]=C.useState(null),[c,u]=C.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});C.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:S,error:T}=await G.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(T)throw T;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)},y=S=>{i(S),u({title:S.title,description:S.description||"",action_type:S.action_type,target_role:S.target_role,is_active:S.is_active}),o(!0)},_=async()=>{if(!c.title.trim()){me.error("Title is required");return}try{if(l){const{error:S}=await G.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(I=>I.target_role===c.target_role).reduce((I,L)=>Math.max(I,L.sort_order),-1),{error:T}=await G.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(T)throw T;me.success("Checklist item created")}o(!1),p()}catch(S){console.error("Error saving checklist item:",S),me.error("Failed to save checklist item")}},b=async S=>{if(confirm("Are you sure you want to delete this checklist item?"))try{const{error:T}=await G.from("onboarding_checklist_items").delete().eq("id",S);if(T)throw T;me.success("Checklist item deleted"),p()}catch(T){console.error("Error deleting checklist item:",T),me.error("Failed to delete checklist item")}},w=async S=>{try{const{error:T}=await G.from("onboarding_checklist_items").update({is_active:!S.is_active}).eq("id",S.id);if(T)throw T;me.success(S.is_active?"Item deactivated":"Item activated"),p()}catch(T){console.error("Error toggling item:",T),me.error("Failed to update item")}},j=t.filter(S=>S.target_role==="brokerage_manager"),N=t.filter(S=>S.target_role==="agent");return e.jsxs(Es,{title:"Onboarding Checklist",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Onboarding Checklist"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage checklist items shown to new users on their dashboard"})]}),e.jsxs(K,{onClick:f,className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Add Item"]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(nt,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(Oe,{children:j.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"w-12",children:"#"}),e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Action Type"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:j.map((S,T)=>{var I;return e.jsxs(ks,{children:[e.jsx(dt,{className:"text-muted-foreground",children:T+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(nt,{variant:"outline",children:((I=rye.find(L=>L.value===S.action_type))==null?void 0:I.label)||S.action_type})}),e.jsx(dt,{children:e.jsx(Br,{checked:S.is_active,onCheckedChange:()=>w(S)})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>y(S),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(S.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(nt,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx(Oe,{children:N.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for agents"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"w-12",children:"#"}),e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Action Type"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:N.map((S,T)=>{var I;return e.jsxs(ks,{children:[e.jsx(dt,{className:"text-muted-foreground",children:T+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(nt,{variant:"outline",children:((I=rye.find(L=>L.value===S.action_type))==null?void 0:I.label)||S.action_type})}),e.jsx(dt,{children:e.jsx(Br,{checked:S.is_active,onCheckedChange:()=>w(S)})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>y(S),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(S.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},S.id)})})]})})]})]}),e.jsx(_s,{open:a,onOpenChange:o,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:l?"Edit Checklist Item":"Add Checklist Item"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title *"}),e.jsx(Fe,{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(_e,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{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(_e,{children:"Target Role"}),e.jsxs(rr,{value:c.target_role,onValueChange:S=>u({...c,target_role:S}),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:$vs.map(S=>e.jsx(Tt,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Action Type"}),e.jsxs(rr,{value:c.action_type,onValueChange:S=>u({...c,action_type:S}),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:rye.map(S=>e.jsx(Tt,{value:S.value,children:S.label},S.value))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_active",checked:c.is_active,onCheckedChange:S=>u({...c,is_active:S})}),e.jsx(_e,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:_,children:l?"Save Changes":"Create Item"})]})]})})]})}function Uvs(){const[t,s]=C.useState(""),[r,n]=C.useState("all"),[a,o]=C.useState("name"),[l,i]=C.useState("asc"),[c,u]=C.useState(""),[p,f]=C.useState(""),[y,_]=C.useState(""),[b,w]=C.useState(""),{data:j}=wt({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:V,error:X}=await G.from("brokerages").select("id, name").order("name");if(X)throw X;return V}}),N=async V=>{let se=[],ee=0,Q=!0;for(;Q;){const{data:de,error:re}=await V(ee,ee+1e3-1);if(re)throw re;de&&de.length>0?(se=[...se,...de],ee+=1e3,Q=de.length===1e3):Q=!1}return se},{data:S,isLoading:T}=wt({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const V=await N((Re,Te)=>G.from("profiles").select("id, name, email, brokerage_id, created_at").range(Re,Te)),{data:X}=await G.from("brokerages").select("id, name"),se=new Map((X==null?void 0:X.map(Re=>[Re.id,Re.name]))||[]),[{data:ee},{data:Q},{data:de},{data:re},{data:ne},{data:le},{data:he}]=await Promise.all([G.rpc("get_admin_contact_counts"),G.rpc("get_admin_video_counts"),G.rpc("get_admin_popby_counts"),G.rpc("get_admin_listing_counts"),G.rpc("get_admin_deal_counts"),G.rpc("get_admin_portal_counts"),G.rpc("get_admin_sendable_card_counts")]),we=new Map;ee==null||ee.forEach(Re=>we.set(Re.owner_user_id,Re.contact_count));const ye=new Map;Q==null||Q.forEach(Re=>ye.set(Re.owner_user_id,Re.video_count));const je=new Map;de==null||de.forEach(Re=>je.set(Re.owner_user_id,Re.popby_count));const ke=new Map;re==null||re.forEach(Re=>ke.set(Re.agent_id,Re.listing_count));const We=new Map;ne==null||ne.forEach(Re=>We.set(Re.owner_user_id,Re.deal_count));const be=new Map;le==null||le.forEach(Re=>be.set(Re.owner_user_id,{total:Re.portal_count,active:Re.active_portal_count}));const Me=new Map;return he==null||he.forEach(Re=>Me.set(Re.owner_user_id,{total:Re.card_count,sent:Re.sent_card_count,views:Re.total_card_views})),V.map(Re=>{const Te=be.get(Re.id),qe=Me.get(Re.id);return{id:Re.id,name:Re.name||"Unknown",email:Re.email||"",brokerage_id:Re.brokerage_id,brokerage_name:Re.brokerage_id&&se.get(Re.brokerage_id)||null,contact_count:we.get(Re.id)||0,video_count:ye.get(Re.id)||0,popby_count:je.get(Re.id)||0,listing_count:ke.get(Re.id)||0,deal_count:We.get(Re.id)||0,portal_count:(Te==null?void 0:Te.total)||0,active_portal_count:(Te==null?void 0:Te.active)||0,card_count:(qe==null?void 0:qe.total)||0,sent_card_count:(qe==null?void 0:qe.sent)||0,total_card_views:(qe==null?void 0:qe.views)||0,created_at:Re.created_at}})}}),I=C.useMemo(()=>{if(!S)return[];let V=S.filter(X=>{const se=t.toLowerCase(),ee=!t||X.name.toLowerCase().includes(se)||X.email.toLowerCase().includes(se),Q=r==="all"||r==="none"&&!X.brokerage_id||X.brokerage_id===r,de=parseInt(c)||0,re=parseInt(p)||0,ne=parseInt(y)||0,le=parseInt(b)||0,he=X.contact_count>=de&&X.video_count>=re&&X.popby_count>=ne&&X.listing_count>=le;return ee&&Q&&he});return V.sort((X,se)=>{let ee=0;return a==="name"?ee=X.name.localeCompare(se.name):ee=X[a]-se[a],l==="asc"?ee:-ee}),V},[S,t,r,a,l,c,p,y,b]),L=V=>{a===V?i(l==="asc"?"desc":"asc"):(o(V),i("desc"))},R=()=>{const V=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],X=I.map(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]),se=[V.join(","),...X.map(re=>re.map(ne=>`"${ne}"`).join(","))].join(` `),ee=new Blob([se],{type:"text/csv"}),Q=URL.createObjectURL(ee),de=document.createElement("a");de.href=Q,de.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,de.click(),URL.revokeObjectURL(Q)},$=C.useMemo(()=>I.length?I.reduce((V,X)=>({contacts:V.contacts+X.contact_count,videos:V.videos+X.video_count,popbys:V.popbys+X.popby_count,listings:V.listings+X.listing_count,deals:V.deals+X.deal_count,portals:V.portals+X.portal_count,activePortals:V.activePortals+X.active_portal_count,cards:V.cards+X.card_count,sentCards:V.sentCards+X.sent_card_count,cardViews:V.cardViews+X.total_card_views}),{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0}):{contacts:0,videos:0,popbys:0,listings:0,deals:0,portals:0,activePortals:0,cards:0,sentCards:0,cardViews:0},[I]),q=C.useMemo(()=>I.length?{portals:I.filter(V=>V.portal_count>0).length,cards:I.filter(V=>V.card_count>0).length}:{portals:0,cards:0},[I]),U=({field:V,children:X})=>e.jsx(bt,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>L(V),children:e.jsxs("div",{className:"flex items-center gap-1",children:[X,e.jsx(ud,{className:`h-3 w-3 ${a===V?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(x2,{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(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Zv,{className:"h-4 w-4 text-blue-500"}),"Client Portals"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:q.portals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:$.portals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Portals"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:$.activePortals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Active Portals"})]})]})})]}),e.jsxs(Ee,{className:"border-violet-500/20 bg-gradient-to-br from-violet-500/5 to-transparent",children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(br,{className:"h-4 w-4 text-violet-500"}),"Card Studio"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-4 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:q.cards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:$.cards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Created"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:$.sentCards}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Sent"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:$.cardViews}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Views"})]})]})})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(fr,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:R,children:[e.jsx(ki,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-6",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name or email...",value:t,onChange:V=>s(V.target.value),className:"pl-9"})]})}),e.jsx("div",{children:e.jsxs(rr,{value:r,onValueChange:n,children:[e.jsxs(tr,{children:[e.jsx(La,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(nr,{placeholder:"Brokerage"})]}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Brokerages"}),e.jsx(Tt,{value:"none",children:"No Brokerage"}),j==null?void 0:j.map(V=>e.jsx(Tt,{value:V.id,children:V.name},V.id))]})]})}),e.jsx("div",{children:e.jsx(Fe,{type:"number",placeholder:"Min contacts",value:c,onChange:V=>u(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Fe,{type:"number",placeholder:"Min videos",value:p,onChange:V=>f(V.target.value),min:"0"})}),e.jsx("div",{children:e.jsx(Fe,{type:"number",placeholder:"Min popbys",value:y,onChange:V=>_(V.target.value),min:"0"})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-8 text-sm",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:I.length}),e.jsx("div",{className:"text-muted-foreground",children:"Users"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.contacts.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Contacts"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.videos.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Videos"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.popbys.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Popbys"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.listings.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Listings"})]}),e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.deals.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Deals"})]}),e.jsxs("div",{className:"bg-blue-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.portals.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Portals"})]}),e.jsxs("div",{className:"bg-violet-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:$.cards.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Cards"})]})]}),T?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(Ss,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(U,{field:"name",children:"Name"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Brokerage"}),e.jsx(U,{field:"contact_count",children:"Contacts"}),e.jsx(U,{field:"video_count",children:"Videos"}),e.jsx(U,{field:"popby_count",children:"Popbys"}),e.jsx(U,{field:"listing_count",children:"Listings"}),e.jsx(U,{field:"deal_count",children:"Deals"}),e.jsx(U,{field:"portal_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Zv,{className:"h-3 w-3 text-blue-500"}),"Portals"]})}),e.jsx(U,{field:"card_count",children:e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(br,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),e.jsx(Pn,{children:I.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):I.map(V=>e.jsxs(ks,{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(nt,{variant:"secondary",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{children:e.jsx(nt,{variant:V.contact_count>0?"default":"outline",children:V.contact_count})}),e.jsx(dt,{children:e.jsx(nt,{variant:V.video_count>0?"default":"outline",children:V.video_count})}),e.jsx(dt,{children:e.jsx(nt,{variant:V.popby_count>0?"default":"outline",children:V.popby_count})}),e.jsx(dt,{children:e.jsx(nt,{variant:V.listing_count>0?"default":"outline",children:V.listing_count})}),e.jsx(dt,{children:e.jsx(nt,{variant:V.deal_count>0?"default":"outline",children:V.deal_count})}),e.jsx(dt,{children:V.portal_count>0?e.jsxs(hd,{children:[e.jsx(md,{children:e.jsxs(nt,{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(Uc,{children:[e.jsxs("p",{children:[V.portal_count," total portals"]}),e.jsxs("p",{children:[V.active_portal_count," currently active"]})]})]}):e.jsx(nt,{variant:"outline",children:"0"})}),e.jsx(dt,{children:V.card_count>0?e.jsxs(hd,{children:[e.jsx(md,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(nt,{variant:"default",className:"bg-violet-600 hover:bg-violet-700",children: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(oa,{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(va,{className:"h-3 w-3"}),V.total_card_views]})]})}),e.jsxs(Uc,{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(nt,{variant:"outline",children:"0"})})]},V.id))})]})})]})]})]})})}function Vvs(){Ra(),ss();const[t,s]=C.useState("user-analytics"),{data:r}=wt({queryKey:["admin-feature-flags"],queryFn:async()=>{const{data:_,error:b}=await G.from("feature_flags").select("*").order("key");if(b)throw b;return _}}),{data:n,isLoading:a}=wt({queryKey:["admin-relationship-types"],queryFn:async()=>{const{data:_,error:b}=await G.from("relationship_types").select("*").order("sort_order");if(b)throw b;return _}}),{data:o,isLoading:l}=wt({queryKey:["admin-action-types"],queryFn:async()=>{const{data:_,error:b}=await G.from("action_types").select("*").order("sort_order");if(b)throw b;return _}}),{data:i,isLoading:c}=wt({queryKey:["admin-action-scripts"],queryFn:async()=>{const{data:_,error:b}=await G.from("action_scripts").select("*, action_type:action_types(*)");if(b)throw b;return _}}),{data:u,isLoading:p}=wt({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:_,error:b}=await G.from("touchpoint_plans").select("*").order("name");if(b)throw b;return _}}),{data:f,isLoading:y}=wt({queryKey:["admin-popby-items"],queryFn:async()=>{const{data:_,error:b}=await G.from("popby_items").select("*").is("owner_user_id",null).order("name");if(b)throw b;return _}});return e.jsx(Es,{title:"Agent OS Control Center",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(Aa,{value:t,onValueChange:s,children:[e.jsxs(ja,{className:"grid w-full grid-cols-9",children:[e.jsxs(js,{value:"user-analytics",className:"gap-2",children:[e.jsx(xl,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),e.jsxs(js,{value:"relationship-types",className:"gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),e.jsxs(js,{value:"action-types",className:"gap-2",children:[e.jsx(ea,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),e.jsxs(js,{value:"scripts",className:"gap-2",children:[e.jsx(In,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(js,{value:"video-scripts",className:"gap-2",children:[e.jsx(Fu,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),e.jsxs(js,{value:"plans",className:"gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),e.jsxs(js,{value:"popbys",className:"gap-2",children:[e.jsx(bo,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(js,{value:"settings",className:"gap-2",children:[e.jsx(Jl,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),e.jsxs(js,{value:"feature-flags",className:"gap-2",children:[e.jsx(Xv,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Flags"})]})]}),e.jsx($s,{value:"user-analytics",className:"mt-6",children:e.jsx(Uvs,{})}),e.jsx($s,{value:"relationship-types",className:"mt-6",children:e.jsx(Hvs,{types:n||[],isLoading:a})}),e.jsx($s,{value:"action-types",className:"mt-6",children:e.jsx(Wvs,{types:o||[],isLoading:l})}),e.jsx($s,{value:"scripts",className:"mt-6",children:e.jsx(Gvs,{scripts:i||[],actionTypes:o||[],isLoading:c})}),e.jsx($s,{value:"video-scripts",className:"mt-6",children:e.jsx(Xvs,{})}),e.jsx($s,{value:"plans",className:"mt-6",children:e.jsx(Kvs,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:p})}),e.jsx($s,{value:"popbys",className:"mt-6",children:e.jsx(Yvs,{items:f||[],isLoading:y})}),e.jsx($s,{value:"settings",className:"mt-6",children:e.jsx(Qvs,{})}),e.jsx($s,{value:"feature-flags",className:"mt-6",children:e.jsx(Zvs,{flags:r||[]})})]})]})})}function Hvs({types:t,isLoading:s}){const{toast:r}=Ra(),n=ss(),[a,o]=C.useState(null),[l,i]=C.useState(!1),c=Dt({mutationFn:async p=>{if(p.id){const{error:f}=await G.from("relationship_types").update({name:p.name,description:p.description,icon:p.icon}).eq("id",p.id);if(f)throw f}else{const{error:f}=await G.from("relationship_types").insert([{name:p.name,description:p.description,icon:p.icon,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-relationship-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await G.from("relationship_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-relationship-types"]})};return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Relationship Types"}),e.jsx(fr,{children:"Define the relationship categories for InnerCircle contacts"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Type"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ss,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"w-12"}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(p=>e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsx(yh,{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(Br,{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($a,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsxs(Ns,{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(_e,{htmlFor:"name",children:"Name"}),e.jsx(Fe,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"icon",children:"Icon"}),e.jsx(Fe,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., star, heart, user"})]})]}),e.jsxs(Vn,{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(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Wvs({types:t,isLoading:s}){const{toast:r}=Ra(),n=ss(),[a,o]=C.useState(null),[l,i]=C.useState(!1),c=Dt({mutationFn:async p=>{if(p.id){const{error:f}=await G.from("action_types").update({name:p.name,description:p.description,icon:p.icon,color:p.color}).eq("id",p.id);if(f)throw f}else{const{error:f}=await G.from("action_types").insert([{name:p.name,description:p.description,icon:p.icon,color:p.color,sort_order:t.length}]);if(f)throw f}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-action-types"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:p=>{r({title:"Error",description:p.message,variant:"destructive"})}}),u=async p=>{await G.from("action_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-action-types"]})};return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Action Types"}),e.jsx(fr,{children:"Define the types of touchpoint actions agents can take"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Action"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ss,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{children:"Color"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(p=>e.jsxs(ks,{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(Br,{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($a,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsxs(Ns,{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(_e,{htmlFor:"name",children:"Name"}),e.jsx(Fe,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"icon",children:"Icon"}),e.jsx(Fe,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., phone, message"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"color",children:"Color"}),e.jsx(Fe,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(Vn,{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(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Gvs({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=Ra(),a=ss(),[o,l]=C.useState(null),[i,c]=C.useState(!1),u=Dt({mutationFn:async f=>{if(f.id){const{error:y}=await G.from("action_scripts").update({title:f.title,action_type_id:f.action_type_id,tone:f.tone,script_body:f.script_body,active:f.active}).eq("id",f.id);if(y)throw y}else{const{error:y}=await G.from("action_scripts").insert([{title:f.title,action_type_id:f.action_type_id,tone:f.tone,script_body:f.script_body,active:!0}]);if(y)throw y}},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:y}=await G.from("action_scripts").delete().eq("id",f);if(y)throw y},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),n({title:"Deleted successfully"})}});return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Script Library"}),e.jsx(fr,{children:"Create and manage scripts for each action type"})]}),e.jsxs(K,{onClick:()=>{l(null),c(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ss,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Action Type"}),e.jsx(bt,{children:"Tone"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(f=>{var y;return e.jsxs(ks,{children:[e.jsx(dt,{className:"font-medium",children:f.title}),e.jsx(dt,{children:e.jsx(nt,{variant:"outline",children:((y=f.action_type)==null?void 0:y.name)||"Unknown"})}),e.jsx(dt,{className:"text-muted-foreground",children:f.tone}),e.jsx(dt,{children:e.jsx(nt,{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($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutate(f.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})]},f.id)})})]})}),e.jsx(_s,{open:i,onOpenChange:c,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:[o?"Edit":"Add"," Script"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const y=new FormData(f.currentTarget);u.mutate({id:o==null?void 0:o.id,title:y.get("title"),action_type_id:y.get("action_type_id"),tone:y.get("tone"),script_body:y.get("script_body"),active:!0})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"title",children:"Title"}),e.jsx(Fe,{id:"title",name:"title",defaultValue:o==null?void 0:o.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"action_type_id",children:"Action Type"}),e.jsxs(rr,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select action type"})}),e.jsx(sr,{children:s.map(f=>e.jsx(Tt,{value:f.id,children:f.name},f.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"tone",children:"Tone (optional)"}),e.jsx(Fe,{id:"tone",name:"tone",defaultValue:(o==null?void 0:o.tone)||"",placeholder:"e.g., Friendly, Professional, Casual"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Ar,{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(Vn,{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(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Kvs({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=Ra(),o=ss(),[l,i]=C.useState(null),[c,u]=C.useState(!1),[p,f]=C.useState(null),[y,_]=C.useState(!1),[b,w]=C.useState(null),[j,N]=C.useState(null),{data:S}=wt({queryKey:["plan-items",p],queryFn:async()=>{if(!p)return[];const{data:U,error:V}=await G.from("touchpoint_plan_items").select("*").eq("plan_id",p).order("month_number");if(V)throw V;return U},enabled:!!p}),T=Dt({mutationFn:async U=>{if(U.id){const{error:V}=await G.from("touchpoint_plans").update({name:U.name,description:U.description,active:U.active}).eq("id",U.id);if(V)throw V}else{const{error:V}=await G.from("touchpoint_plans").insert([{name:U.name,description:U.description,active:!0}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-touchpoint-plans"]}),u(!1),i(null),a({title:"Saved successfully"})},onError:U=>{a({title:"Error",description:U.message,variant:"destructive"})}}),I=Dt({mutationFn:async U=>{if(U.id){const{error:V}=await G.from("touchpoint_plan_items").update({action_type_id:U.action_type_id,default_script_id:U.default_script_id,notes:U.notes}).eq("id",U.id);if(V)throw V}else{const{error:V}=await G.from("touchpoint_plan_items").insert([{plan_id:U.plan_id,month_number:U.month_number,action_type_id:U.action_type_id,default_script_id:U.default_script_id,notes:U.notes}]);if(V)throw V}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]}),a({title:"Item saved"})}}),L=Dt({mutationFn:async U=>{const{error:V}=await G.from("touchpoint_plan_items").delete().eq("id",U);if(V)throw V},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]})}}),R=Dt({mutationFn:async U=>{const{data:V,error:X}=await G.from("action_scripts").insert([{...U,active:!0}]).select().single();if(X)throw X;return V},onSuccess:async U=>{o.invalidateQueries({queryKey:["admin-action-scripts"]}),b&&await I.mutateAsync({id:b.itemId,plan_id:p,month_number:b.month,action_type_id:b.actionTypeId,default_script_id:U.id}),_(!1),w(null),a({title:"Script created and assigned"})},onError:U=>{a({title:"Error",description:U.message,variant:"destructive"})}}),$=(U,V,X)=>{w({month:U,actionTypeId:V,itemId:X}),_(!0)},q=U=>r.find(V=>V.id===U);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Touchpoint Plans"}),e.jsx(fr,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),e.jsxs(K,{onClick:()=>{i(null),u(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Plan"]})]}),e.jsx(Oe,{children:n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ss,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(U=>e.jsxs(Ee,{className:`cursor-pointer transition-colors ${p===U.id?"border-primary":""}`,onClick:()=>f(U.id),children:[e.jsx(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ot,{className:"text-base",children:U.name}),e.jsx(K,{variant:"ghost",size:"icon",onClick:V=>{V.stopPropagation(),i(U),u(!0)},children:e.jsx($a,{className:"h-4 w-4"})})]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:U.description}),e.jsx(nt,{variant:U.active?"default":"secondary",className:"mt-2",children:U.active?"Active":"Inactive"})]})]},U.id))})})]}),p&&e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Plan Schedule"}),e.jsx(fr,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:12},(U,V)=>V+1).map(U=>{const V=S==null?void 0:S.find(ee=>ee.month_number===U),X=V!=null&&V.default_script_id?q(V.default_script_id):null,se=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 ",U]}),e.jsxs(rr,{value:(V==null?void 0:V.action_type_id)||"none",onValueChange:ee=>{ee==="none"&&V?L.mutate(V.id):ee!=="none"&&I.mutate({id:V==null?void 0:V.id,plan_id:p,month_number:U,action_type_id:ee,default_script_id:null})},children:[e.jsx(tr,{className:"w-40",children:e.jsx(nr,{placeholder:"No action"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"No action"}),s.filter(ee=>ee.active).map(ee=>e.jsx(Tt,{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(rr,{value:V.default_script_id||"none",onValueChange:ee=>{N(null),I.mutate({id:V.id,default_script_id:ee==="none"?null:ee})},children:[e.jsx(tr,{className:"w-56",children:e.jsx(nr,{placeholder:"Select script"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"No default script"}),se.map(ee=>e.jsxs(Tt,{value:ee.id,children:[ee.title," ",ee.tone&&`(${ee.tone})`]},ee.id))]})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>$(U,V.action_type_id,V.id),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"}),"New Script"]}),X&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N((j==null?void 0:j.id)===X.id?null:X),children:(j==null?void 0:j.id)===X.id?"Hide":"Preview"})]})]}),j&&(V==null?void 0:V.default_script_id)===j.id&&e.jsxs("div",{className:"ml-24 p-3 bg-muted rounded-lg text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(nt,{variant:"outline",children:j.title}),j.tone&&e.jsx(nt,{variant:"secondary",children:j.tone})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:j.script_body})]})]},U)})})})]}),e.jsx(_s,{open:c,onOpenChange:u,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:[l?"Edit":"Add"," Touchpoint Plan"]})}),e.jsxs("form",{onSubmit:U=>{U.preventDefault();const V=new FormData(U.currentTarget);T.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(_e,{htmlFor:"name",children:"Name"}),e.jsx(Fe,{id:"name",name:"name",defaultValue:l==null?void 0:l.name,required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(Vn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>u(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:T.isPending,children:[T.isPending&&e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),e.jsx(_s,{open:y,onOpenChange:_,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Create New Script"}),e.jsxs(Zr,{children:["Create a script for Month ",b==null?void 0:b.month,". Use ","{{FirstName}}",", ","{{LastName}}",", and ","{{AgentName}}"," as placeholders."]})]}),e.jsxs("form",{onSubmit:U=>{U.preventDefault();const V=new FormData(U.currentTarget);R.mutate({title:V.get("title"),action_type_id:b.actionTypeId,tone:V.get("tone"),script_body:V.get("script_body")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script_title",children:"Title"}),e.jsx(Fe,{id:"script_title",name:"title",placeholder:"e.g., Warm Check-In",required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script_tone",children:"Tone"}),e.jsx(Fe,{id:"script_tone",name:"tone",placeholder:"e.g., Friendly, Professional"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Ar,{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(Vn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:R.isPending,children:[R.isPending&&e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function Zvs({flags:t}){const{toast:s}=Ra(),r=ss(),n=async(a,o)=>{const{error:l}=await G.from("feature_flags").update({...o,updated_at:new Date().toISOString()}).eq("id",a.id);l?s({title:"Error",description:l.message,variant:"destructive"}):(r.invalidateQueries({queryKey:["admin-feature-flags"]}),s({title:"Flag updated"}))};return e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Feature Flags"}),e.jsx(fr,{children:"Control which features are enabled for members"})]}),e.jsx(Oe,{children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Flag"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Notes"}),e.jsx(bt,{children:"Last Updated"})]})}),e.jsx(Pn,{children:t.map(a=>e.jsxs(ks,{children:[e.jsx(dt,{className:"font-mono text-sm",children:a.key}),e.jsx(dt,{children:e.jsx(Br,{checked:a.enabled,onCheckedChange:o=>n(a,{enabled:o})})}),e.jsx(dt,{children:e.jsx(Fe,{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 Yvs({items:t,isLoading:s}){const{toast:r}=Ra(),n=ss(),[a,o]=C.useState(null),[l,i]=C.useState(!1),c=Dt({mutationFn:async f=>{if(f.id){const{error:y}=await G.from("popby_items").update({name:f.name,description:f.description}).eq("id",f.id);if(y)throw y}else{const{error:y}=await G.from("popby_items").insert([{name:f.name,description:f.description,owner_user_id:null}]);if(y)throw y}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),i(!1),o(null),r({title:"Saved successfully"})},onError:f=>{r({title:"Error",description:f.message,variant:"destructive"})}}),u=async f=>{await G.from("popby_items").update({is_active:!f.is_active}).eq("id",f.id),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]})},p=async f=>{await G.from("popby_items").delete().eq("id",f),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),r({title:"Deleted successfully"})};return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Popby Ideas"}),e.jsx(fr,{children:"Manage global popby ideas that all agents can see"})]}),e.jsxs(K,{onClick:()=>{o(null),i(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsx(Oe,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ss,{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(bo,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No popby ideas yet. Add your first one!"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(f=>e.jsxs(ks,{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(Br,{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($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p(f.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},f.id))})]})}),e.jsx(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:[a?"Edit":"Add"," Popby Idea"]})}),e.jsxs("form",{onSubmit:f=>{f.preventDefault();const y=new FormData(f.currentTarget);c.mutate({id:a==null?void 0:a.id,name:y.get("name"),description:y.get("description")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"name",children:"Name"}),e.jsx(Fe,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0,placeholder:"e.g., Homemade Cookies"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(Vn,{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(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Xvs(){var _;const{toast:t}=Ra(),s=ss(),[r,n]=C.useState(null),[a,o]=C.useState(!1),{data:l,isLoading:i}=wt({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:b,error:w}=await G.from("video_script_categories").select("*").order("sort_order");if(w)throw w;return b}}),{data:c,isLoading:u}=wt({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:b,error:w}=await G.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(w)throw w;return b}}),p=Dt({mutationFn:async b=>{var w,j;if(b.id){const{error:N}=await G.from("video_scripts").update({title:b.title,script_text:b.script_text,category_id:b.category_id,tags:((w=b.tags)==null?void 0:w.split(",").map(S=>S.trim()).filter(Boolean))||[]}).eq("id",b.id);if(N)throw N}else{const{error:N}=await G.from("video_scripts").insert([{title:b.title,script_text:b.script_text,category_id:b.category_id||null,tags:((j=b.tags)==null?void 0:j.split(",").map(S=>S.trim()).filter(Boolean))||[]}]);if(N)throw N}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-video-scripts"]}),o(!1),n(null),t({title:"Video script saved!"})},onError:b=>t({title:"Error",description:b.message,variant:"destructive"})}),f=async b=>{await G.from("video_scripts").update({is_active:!b.is_active}).eq("id",b.id),s.invalidateQueries({queryKey:["admin-video-scripts"]})},y=async b=>{confirm("Delete this video script?")&&(await G.from("video_scripts").delete().eq("id",b),s.invalidateQueries({queryKey:["admin-video-scripts"]}),t({title:"Script deleted"}))};return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Video Scripts"}),e.jsx(fr,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),e.jsxs(K,{onClick:()=>{n(null),o(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),e.jsx(Oe,{children:u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ss,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Title"}),e.jsx(bt,{children:"Category"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"w-24",children:"Actions"})]})}),e.jsx(Pn,{children:c==null?void 0:c.map(b=>{var w;return e.jsxs(ks,{children:[e.jsx(dt,{className:"font-medium",children:b.title}),e.jsx(dt,{className:"text-muted-foreground",children:((w=b.category)==null?void 0:w.name)||"Uncategorized"}),e.jsx(dt,{children:e.jsx(Br,{checked:b.is_active,onCheckedChange:()=>f(b)})}),e.jsxs(dt,{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{n(b),o(!0)},children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>y(b.id),children:e.jsx(jr,{className:"h-4 w-4"})})]})]},b.id)})})]})}),e.jsx(_s,{open:a,onOpenChange:o,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:[r?"Edit":"Add"," Video Script"]})}),e.jsxs("form",{onSubmit:b=>{b.preventDefault();const w=new FormData(b.currentTarget);p.mutate({id:r==null?void 0:r.id,title:w.get("title"),script_text:w.get("script_text"),category_id:w.get("category_id")||null,tags:w.get("tags")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"title",children:"Title"}),e.jsx(Fe,{id:"title",name:"title",defaultValue:r==null?void 0:r.title,required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"category_id",children:"Category"}),e.jsxs(rr,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select category"})}),e.jsx(sr,{children:l==null?void 0:l.map(b=>e.jsx(Tt,{value:b.id,children:b.name},b.id))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script_text",children:"Script Text"}),e.jsx(Ar,{id:"script_text",name:"script_text",defaultValue:r==null?void 0:r.script_text,rows:6,required:!0,placeholder:"Enter the teleprompter script..."})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"tags",children:"Tags (comma-separated)"}),e.jsx(Fe,{id:"tags",name:"tags",defaultValue:((_=r==null?void 0:r.tags)==null?void 0:_.join(", "))||"",placeholder:"birthday, follow-up, thank-you"})]})]}),e.jsxs(Vn,{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(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function Qvs(){const{toast:t}=Ra(),[s,r]=C.useState(""),[n,a]=C.useState(!0),[o,l]=C.useState(!1);C.useEffect(()=>{(async()=>{a(!0);try{const{data:u}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();u!=null&&u.value&&r(u.value)}catch(u){console.error("Error fetching settings:",u)}a(!1)})()},[]);const i=async()=>{l(!0);try{await G.from("settings").upsert({key:"mapbox_public_token",value:s.trim()}),t({title:"Mapbox token saved!"})}catch{t({title:"Error saving token",variant:"destructive"})}l(!1)};return n?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex justify-center py-8",children:e.jsx(Ss,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Ui,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(fr,{children:"Configure the map feature for popbys"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"mapbox-token",children:"Mapbox Public Token"}),e.jsx(Fe,{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(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(nt,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const Jvs=()=>{const[t,s]=C.useState(""),[r,n]=C.useState("grid"),a=Pr(),{data:o=[],isLoading:l}=wt({queryKey:["additional-services"],queryFn:async()=>{const{data:c,error:u}=await G.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(Es,{title:"Additional Services",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Additional Services"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Explore our additional services and offerings"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{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(lf,{className:"h-4 w-4"})}),e.jsx(K,{variant:r==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:e.jsx(Mm,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," service",i.length!==1?"s":""," found"]}),l&&e.jsx("div",{className:r==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:[...Array(4)].map((c,u)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(xs,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(xs,{className:"h-5 w-3/4 mb-2"}),e.jsx(xs,{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(hn,{className:"h-8 w-8"})})}),e.jsxs(Oe,{className:`p-4 flex flex-col ${r==="list"?"flex-1":""}`,children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:c.name}),c.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 flex-1",children:mde(c.description)})]})]},c.id))})]})})},e1s=()=>{const{serviceId:t}=Po(),s=Pr(),{data:r,isLoading:n}=wt({queryKey:["additional-service",t],queryFn:async()=>{const{data:a,error:o}=await G.from("additional_services").select("*").eq("id",t).eq("is_published",!0).single();if(o)throw o;return a},enabled:!!t});return n?e.jsx(Es,{title:"Loading...",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsx(xs,{className:"h-8 w-48"}),e.jsx(xs,{className:"h-64 w-full rounded-lg"}),e.jsx(xs,{className:"h-24 w-full"})]})}):r?e.jsx(Es,{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(di,{className:"h-4 w-4"}),"Back to Services"]}),e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"relative bg-muted",children:r.preview_image_url?e.jsx("img",{src:r.preview_image_url,alt:r.name,className:"w-full h-auto max-h-[500px] object-contain mx-auto"}):e.jsx("div",{className:"w-full h-64 flex items-center justify-center text-muted-foreground",children:e.jsx(hn,{className:"h-16 w-16"})})})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:r.name}),e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(on,{className:"h-4 w-4 mr-1"}),"Published ",ys(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(rn,{className:"h-5 w-5"}),"Sign Up Now"]})})]})})]})}):e.jsx(Es,{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(di,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},V6=[{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 t1s(){const[t,s]=C.useState(V6[0].id),r=V6.find(n=>n.id===t)||V6[0];return e.jsx(Es,{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(oM,{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(rr,{value:t,onValueChange:s,children:[e.jsx(tr,{className:"w-full",children:e.jsx(nr,{placeholder:"Select a tool"})}),e.jsx(sr,{children:V6.map(n=>e.jsx(Tt,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(Aa,{value:t,onValueChange:s,className:"w-full",children:e.jsx(ja,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:V6.map(n=>e.jsx(js,{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 xFe="agent-os-onboarding-completed",wz=[{icon:o0,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:wp,iconColor:"text-white",bgGradient:"from-pink-500 via-rose-500 to-red-500",title:"InnerCircle Home",description:"Your daily command center. See today's action items, track your momentum streak, and get a snapshot of your relationship health—all at a glance.",highlights:["Today's touchpoints and special dates","Momentum stats and streak tracking","Relationship health overview","Quick access to all features"]},{icon:mr,iconColor:"text-white",bgGradient:"from-blue-500 via-indigo-500 to-purple-500",title:"Contacts",description:"Import and organize your sphere of influence. Tag contacts by relationship type (Top 25, Past Clients, Referral Partners, etc.) to prioritize your outreach.",highlights:["Import contacts via CSV","Tag by relationship type","Track birthdays and home anniversaries","See relationship health scores"]},{icon:Md,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:bo,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:xl,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"]}],s1s=()=>{const[t,s]=C.useState(!1),[r,n]=C.useState(0),[a,o]=C.useState(!1);C.useEffect(()=>{if(!localStorage.getItem(xFe)){const b=setTimeout(()=>s(!0),500);return()=>clearTimeout(b)}},[]);const l=()=>{r{n(r+1),o(!1)},150)):c()},i=()=>{c()},c=()=>{localStorage.setItem(xFe,"true"),s(!1)},u=wz[r],p=u.icon,f=r===wz.length-1,y=_=>{_||c(),s(_)};return e.jsx(_s,{open:t,onOpenChange:y,children:e.jsxs(vs,{className:"sm:max-w-lg overflow-hidden p-0 gap-0",children:[e.jsxs("div",{className:`relative bg-gradient-to-br ${u.bgGradient} p-8 pb-12 transition-all duration-500`,children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx("div",{className:"absolute -top-4 -right-4 w-32 h-32 bg-white/10 rounded-full blur-2xl animate-pulse"}),e.jsx("div",{className:"absolute -bottom-8 -left-8 w-40 h-40 bg-white/10 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-64 h-64 bg-white/5 rounded-full blur-3xl"})]}),e.jsxs("div",{className:`relative mx-auto flex h-20 w-20 items-center justify-center transition-all duration-300 ${a?"scale-75 opacity-0":"scale-100 opacity-100"}`,children:[e.jsx("div",{className:"absolute inset-0 bg-white/20 rounded-2xl blur-xl"}),e.jsx("div",{className:"relative flex h-20 w-20 items-center justify-center rounded-2xl bg-white/20 backdrop-blur-sm border border-white/30 shadow-2xl",children:e.jsx(p,{className:`h-10 w-10 ${u.iconColor} drop-shadow-lg`})})]}),r===0&&e.jsxs("div",{className:"absolute top-4 right-4 px-3 py-1 rounded-full bg-white/20 backdrop-blur-sm border border-white/30 text-white text-xs font-medium flex items-center gap-1.5",children:[e.jsx(hn,{className:"h-3 w-3"}),"Beta"]})]}),e.jsxs("div",{className:"p-6 pt-4",children:[e.jsxs(Cs,{className:"text-center sm:text-center pb-2",children:[e.jsx(Ns,{className:`text-2xl font-bold transition-all duration-300 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.title}),e.jsx(Zr,{className:`text-base pt-2 transition-all duration-300 delay-75 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.description})]}),u.highlights&&e.jsx("div",{className:`space-y-2.5 py-4 transition-all duration-300 delay-100 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:u.highlights.map((_,b)=>e.jsxs("div",{className:"flex items-center gap-3 group",style:{transitionDelay:`${150+b*50}ms`},children:[e.jsx("div",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-gradient-to-br ${u.bgGradient} shadow-sm`,children:e.jsx(ma,{className:"h-3.5 w-3.5 text-white"})}),e.jsx("span",{className:"text-sm text-muted-foreground group-hover:text-foreground transition-colors",children:_})]},b))}),e.jsx("div",{className:"flex justify-center gap-2 py-4",children:wz.map((_,b)=>e.jsx("button",{onClick:()=>{b!==r&&(o(!0),setTimeout(()=>{n(b),o(!1)},150))},className:`h-2 rounded-full transition-all duration-300 ${b===r?"w-8 bg-gradient-to-r "+u.bgGradient:b{const{user:t}=Ws();return wt({queryKey:["contact-snoozes",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_snoozes").select("*").gte("snoozed_until",new Date().toISOString());if(r)throw r;return s},enabled:!!t})},n1s=()=>{const t=ss(),{user:s}=Ws();return Dt({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=kl(new Date,n);await G.from("contact_snoozes").delete().eq("contact_id",r);const{error:o}=await G.from("contact_snoozes").insert({contact_id:r,owner_user_id:s.id,snoozed_until:a.toISOString()});if(o)throw o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),t.invalidateQueries({queryKey:["today-actions"]}),t.invalidateQueries({queryKey:["popby-logs"]}),fn({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{fn({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},a1s=()=>{const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("contact_snoozes").delete().eq("contact_id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-snoozes"]}),fn({title:"Snooze cancelled"})},onError:s=>{fn({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},i1s=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function Lhe({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=C.useState(null),l=n1s(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},c=u=>ys(kl(new Date,u),"MMM d, yyyy");return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5"}),"Snooze Touch"]}),e.jsxs(Zr,{children:["Postpone the next scheduled touch for ",n,". Select how long to snooze."]})]}),e.jsx("div",{className:"space-y-3 py-4",children:i1s.map(u=>e.jsxs("button",{type:"button",onClick:()=>o(u.days),className:At("w-full flex items-center justify-between p-3 rounded-lg border transition-colors",a===u.days?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-accent/50"),children:[e.jsx("span",{className:"font-medium",children:u.label}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(on,{className:"h-3.5 w-3.5"}),"Until ",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 o1s={Crown:Sm,FileText:In,Users:mr,Globe:yp,Star:Kn,Phone:ea,MessageSquare:po,PenTool:Db,Video:Nn,Gift:bo};function l1s({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=Pr(),[c,u]=C.useState("name"),[p,f]=C.useState("asc"),[y,_]=C.useState(null),[b,w]=C.useState(""),j=L=>{c===L?f(R=>R==="asc"?"desc":"asc"):(u(L),f("asc"))},N=C.useMemo(()=>[...t].sort((L,R)=>{var q,U;let $=0;switch(c){case"name":{const V=`${L.contact.first_name} ${L.contact.last_name||""}`.toLowerCase(),X=`${R.contact.first_name} ${R.contact.last_name||""}`.toLowerCase();$=V.localeCompare(X);break}case"relationship_type":$=(L.relationshipTypeName||"").localeCompare(R.relationshipTypeName||"");break;case"action_type":$=(((q=L.actionType)==null?void 0:q.name)||"").localeCompare(((U=R.actionType)==null?void 0:U.name)||"");break;case"last_touch":$=(L.monthNumber||0)-(R.monthNumber||0);break}return p==="asc"?$:-$}),[t,c,p]),S=L=>o1s[L||"Phone"]||ea,T=({field:L,children:R})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>j(L),children:[R,c===L?p==="asc"?e.jsx(gu,{className:"ml-2 h-4 w-4"}):e.jsx(Oh,{className:"ml-2 h-4 w-4"}):e.jsx(ud,{className:"ml-2 h-4 w-4 opacity-50"})]}),I=(L,R,$)=>{_(L),w(`${R} ${$||""}`.trim())};return t.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No actions scheduled for today."}),e.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{className:"bg-muted/50",children:[e.jsx(bt,{className:"w-[180px]",children:e.jsx(T,{field:"name",children:"Contact"})}),e.jsx(bt,{className:"w-[130px]",children:e.jsx(T,{field:"relationship_type",children:"Type"})}),e.jsx(bt,{className:"w-[120px]",children:e.jsx(T,{field:"action_type",children:"Action"})}),e.jsx(bt,{className:"w-[130px]",children:"Phone"}),e.jsx(bt,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(Pn,{children:N.map((L,R)=>{var se,ee,Q,de,re,ne;const $=L.isSpecialDate,q=L.specialDateType,U=$?q==="birthday"?xh:Rn:S(((se=L.actionType)==null?void 0:se.icon)||null),V=L.contact.phone,X=L.contact.email;return e.jsxs(ks,{className:At("hover:bg-muted/50 transition-colors",$&&q==="birthday"&&"bg-pink-50/50 dark:bg-pink-950/20",$&&q==="anniversary"&&"bg-purple-50/50 dark:bg-purple-950/20"),children:[e.jsx(dt,{className:"font-medium",children:e.jsx("div",{children:e.jsxs("button",{onClick:()=>i(`/mission-control/contacts/${L.contact.id}`),className:"truncate max-w-[160px] text-left hover:text-primary hover:underline transition-colors",children:[L.contact.first_name," ",L.contact.last_name]})})}),e.jsx(dt,{children:L.relationshipTypeName?e.jsx(nt,{variant:"secondary",className:"text-xs",children:L.relationshipTypeName}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:e.jsx("div",{className:"flex items-center gap-1.5",children:$?e.jsx(nt,{className:At("gap-1",q==="birthday"&&"bg-pink-500 hover:bg-pink-600",q==="anniversary"&&"bg-purple-500 hover:bg-purple-600"),children:q==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(xh,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Rn,{className:"h-3 w-3"})," Anniversary"]})}):e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(U,{className:"h-3 w-3"}),(ee=L.actionType)==null?void 0:ee.name]})})}),e.jsx(dt,{children:V?e.jsx("span",{className:"text-sm font-mono",children:L.contact.phone}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[V&&e.jsx("a",{href:`tel:${L.contact.phone}`,className:"p-1.5 rounded bg-primary/10 hover:bg-primary/20 text-primary transition-colors",title:"Call",children:e.jsx(ea,{className:"h-3.5 w-3.5"})}),V&&e.jsx("a",{href:a(L.contact.phone,(Q=L.script)==null?void 0:Q.script_body,L.contact),className:"p-1.5 rounded bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-600 dark:text-emerald-400 transition-colors",title:"Text",children:e.jsx(po,{className:"h-3.5 w-3.5"})}),X&&(l?e.jsx("button",{onClick:()=>l({id:L.contact.id,first_name:L.contact.first_name,last_name:L.contact.last_name,email:L.contact.email}),className:"p-1.5 rounded bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 transition-colors",title:"Compose Email",children:e.jsx(br,{className:"h-3.5 w-3.5"})}):e.jsx("a",{href:o(L.contact.email,(de=L.script)==null?void 0:de.script_body,(re=L.script)==null?void 0:re.email_subject,(ne=L.actionType)==null?void 0:ne.name,L.contact),className:"p-1.5 rounded bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 transition-colors",title:"Email",children:e.jsx(br,{className:"h-3.5 w-3.5"})})),$&&e.jsxs("button",{onClick:()=>{const le=`${L.contact.first_name}${L.contact.last_name?" "+L.contact.last_name:""}`,he=q==="birthday"?"birthday":"home_anniversary",we=new URLSearchParams({cardType:he,contactId:L.contact.id,name:le,...L.contact.address?{address:L.contact.address}:{},...q==="anniversary"&&L.contact.home_anniversary?{date:L.contact.home_anniversary}:{}});i(`/mission-control/card-studio?${we.toString()}`)},className:At("h-7 px-2 rounded text-xs font-semibold flex items-center gap-1 transition-colors",q==="birthday"?"bg-pink-500/15 hover:bg-pink-500/25 text-pink-600 dark:text-pink-400":"bg-purple-500/15 hover:bg-purple-500/25 text-purple-600 dark:text-purple-400"),title:`Send ${q==="birthday"?"Birthday":"Anniversary"} Card`,children:[e.jsx(br,{className:"h-3.5 w-3.5"}),"Send Card"]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>I(L.contact.id,L.contact.first_name,L.contact.last_name),title:"Snooze",children:e.jsx(cf,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"default",size:"sm",className:"h-7 px-2 text-xs ml-1",onClick:()=>{var le;return s(L.contact.id,L.actionType.id,(le=L.script)==null?void 0:le.id)},disabled:n,children:[e.jsx(ha,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${L.contact.id}-${R}`)})})]})}),e.jsx(Lhe,{open:!!y,onOpenChange:L=>!L&&_(null),contactId:y||"",contactName:b})]})}function D0(){const{data:t,isLoading:s}=wt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:a,error:o}=await G.from("gmail_integrations").select("*").maybeSingle();if(o)throw o;return a}}),r=!!(t!=null&&t.is_active),n=(t==null?void 0:t.gmail_email)||null;return{isGmailConnected:r,gmailEmail:n,isLoading:s}}function c1s({onSelect:t}){const[s,r]=C.useState(null),{data:n=[],isLoading:a}=wt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:c,error:u}=await G.from("email_template_categories").select("*").order("sort_order");if(u)throw u;return c}}),{data:o=[],isLoading:l}=wt({queryKey:["agent-email-templates",s],queryFn:async()=>{let c=G.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(Ss,{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(Xl,{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(Ss,{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(Vi,{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(nt,{variant:"secondary",className:"text-[10px] shrink-0",children:c.tone})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:c.subject})]},c.id))})})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground px-1 mb-2",children:"Select a category"}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-1 pr-1",children:n.map(c=>e.jsxs("button",{onClick:()=>r(c.id),className:"w-full flex items-center justify-between p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"text-lg",children:c.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:c.name}),c.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:c.description})]})]}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},c.id))})]})}function I4e(){var a;const{user:t}=Ws(),{data:s,isLoading:r}=wt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,staleTime:60*1e3,queryFn:async()=>{var u,p,f,y;const[{data:o,error:l},{data:i,error:c}]=await Promise.all([G.from("mass_email_settings").select("reply_to_email, display_name").eq("user_id",t.id).maybeSingle(),G.from("profiles").select("email, name").eq("id",t.id).maybeSingle()]);if(l)throw l;if(c)throw c;return{reply_to_email:((u=o==null?void 0:o.reply_to_email)==null?void 0:u.trim())||((p=i==null?void 0:i.email)==null?void 0:p.trim())||null,display_name:((f=o==null?void 0:o.display_name)==null?void 0:f.trim())||((y=i==null?void 0:i.name)==null?void 0:y.trim())||null}}});return{isReady:!!((a=s==null?void 0:s.reply_to_email)!=null&&a.trim()),isLoading:r,settings:s}}const d1s=5*1024*1024,vv=50,u1s=["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 h1s(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function m1s(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 S_(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 iE({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const{user:c}=Ws(),u=ss(),{isReady:p,settings:f}=I4e(),y=!!n&&n.length>0,_=y&&p,b=y?n:r?[r]:[],w=b[0],j=y?Math.ceil(b.length/vv):1,N=y&&b.length>vv,[S,T]=C.useState((w==null?void 0:w.email)||""),[I,L]=C.useState(a),[R,$]=C.useState(o),[q,U]=C.useState(!1),[V,X]=C.useState(!1),[se,ee]=C.useState([]),[Q,de]=C.useState(a),[re,ne]=C.useState(o),[le,he]=C.useState("composing"),[we,ye]=C.useState(0),[je,ke]=C.useState(0),[We,be]=C.useState(0),[Me,Ae]=C.useState(0),Re=C.useRef(!1),[Te,qe]=C.useState(null);C.useEffect(()=>{t&&(T((w==null?void 0:w.email)||""),de(a),ne(o),L(S_(a,w||{first_name:""})),$(S_(o,w||{first_name:""})),X(!a&&!o),ee([]),he("composing"),ye(0),ke(0),be(0),Ae(0),Re.current=!1,qe(null))},[t,w,a,o]);const ct=async Xe=>{const He=Xe.target.files;if(!He)return;const Ye=se.reduce((Et,qt)=>Et+qt.size,0),tt=[];for(const Et of Array.from(He)){if(!u1s.includes(Et.type)){me.error(`${Et.name}: Unsupported file type`);continue}if(Ye+Et.size>d1s){me.error("Total attachments exceed 5MB limit");break}try{const qt=await m1s(Et);tt.push({name:Et.name,type:Et.type,size:Et.size,data:qt})}catch{me.error(`Failed to read ${Et.name}`)}}ee(Et=>[...Et,...tt]),Xe.target.value=""},De=Xe=>{ee(He=>He.filter((Ye,tt)=>tt!==Xe))},Rt=Xe=>{de(Xe.subject),ne(Xe.body),L(S_(Xe.subject,w||{first_name:""})),$(S_(Xe.body,w||{first_name:""})),X(!1)},pe=Xe=>Xe.split(/\n\n+/).map(He=>`

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

`).join(""),Je=async Xe=>{const He=S_(I,Xe),Ye=S_(R,Xe),tt=pe(Ye);try{if(_){const Et=(f==null?void 0:f.display_name)||"ReLevelUp",qt=`${Et.toLowerCase().replace(/[^a-z]/g,".")}@send.relevelup.com`,ms=`${Et} <${qt}>`,{data:Xt,error:rs}=await G.functions.invoke("ses-send-campaign",{body:{action:"test_send",to:Xe.email,from_email:ms,subject:He,body_html:tt,reply_to:(f==null?void 0:f.reply_to_email)||void 0}});if(rs)throw rs;if(!(Xt!=null&&Xt.success))throw new Error((Xt==null?void 0:Xt.error)||"Failed to send")}else{const{data:Et,error:qt}=await G.functions.invoke("gmail-send",{body:{to:Xe.email,subject:He,body:tt,contactId:Xe.id,attachments:se.map(({name:ms,type:Xt,data:rs})=>({name:ms,type:Xt,data:rs}))}});if(qt)throw qt;if(!(Et!=null&&Et.success))throw new Error((Et==null?void 0:Et.error)||"Failed to send")}return c&&await G.from("bulk_email_sends").insert({user_id:c.id,contact_id:Xe.id,contact_email:Xe.email,subject:He,source:_?"ses_bulk":"sphere_gaps"}),!0}catch(Et){return console.error("Send error:",Et),me.error("Failed to send to "+Xe.first_name+": "+(Et instanceof Error?Et.message:"Unknown error")),!1}},lt=()=>{const Xe=we*vv;return b.slice(Xe,Xe+vv)},rt=async()=>{if(!I||!R){me.error("Please fill in subject and message");return}const Xe=lt();U(!0),he("sending");let He=0,Ye=0;for(let Et=0;EtsetTimeout(ms,150));ke(Et=>Et+He),be(Et=>Et+Ye),U(!1),u.invalidateQueries({queryKey:["bulk-email-sends"]}),we>=j-1||Re.current?he("all_done"):he("batch_complete")},Se=async()=>{if(!I||!R){me.error("Please fill in subject and message");return}if(!y){U(!0);const Xe=await Je(w);U(!1),Xe&&(u.invalidateQueries({queryKey:["bulk-email-sends"]}),me.success("Email sent successfully!"),s(!1),i==null||i());return}await rt()},it=async()=>{ye(Xe=>Xe+1),Ae(0),await new Promise(Xe=>setTimeout(Xe,50)),await rt()};C.useEffect(()=>{},[we]);const $e=()=>{if(q){Re.current=!0;return}s(!1),i==null||i()},ot=we*vv,Ue=Math.min(ot+vv,b.length),Ke=y&&b.length>0?Math.round((je+We)/b.length*100):0;return e.jsx(_s,{open:t,onOpenChange:$e,children:e.jsxs(vs,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(br,{className:`h-5 w-5 ${_?"text-orange-500":"text-red-500"}`}),y?`Send to ${b.length} Contacts`:"Compose Email"]}),_?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,y&&le==="composing"&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Composing email for ",e.jsxs("span",{className:"font-medium",children:[b.length," contacts"]}),". You'll review each personalized email before sending."]})]}),le==="sending"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(Ss,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsxs("p",{className:"font-medium",children:["Sending batch ",we+1," of ",j,"..."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Me," of ",lt().length," in this batch"]})]}),e.jsx(Oi,{value:Me/lt().length*100,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Overall: ",je+We," / ",b.length]}),e.jsxs("span",{children:[je," sent • ",We," failed"]})]}),e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{Re.current=!0},children:"Stop Sending"})]}),le==="batch_complete"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(ha,{className:"h-8 w-8 text-emerald-500 mx-auto"}),e.jsxs("p",{className:"font-medium",children:["Batch ",we+1," Complete!"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[je," sent, ",We," failed so far"]})]}),e.jsx(Oi,{value:Ke,className:"h-2"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[b.length-je-We," contacts remaining (",j-we-1," batches left)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:$e,children:"Done for Now"}),e.jsxs(K,{className:"flex-1 gap-2",onClick:it,children:[e.jsx(oa,{className:"h-4 w-4"}),"Send Next ",Math.min(vv,b.length-Ue)," Contacts"]})]})]}),le==="all_done"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(ha,{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:[je," emails sent successfully",We>0&&e.jsxs("span",{className:"text-destructive",children:[" • ",We," failed"]})]})]}),e.jsx(K,{className:"w-full",onClick:$e,children:"Close"})]}),le==="composing"&&e.jsxs("div",{className:"space-y-4",children:[V?e.jsxs("div",{className:"border rounded-lg p-3 bg-muted/30 max-h-[50vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(In,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>X(!1),className:"h-7 px-2 text-xs",children:[e.jsx(Ur,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx(c1s,{onSelect:Rt})]}):e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>X(!0),children:[e.jsx(In,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(Zl,{}),!y&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{htmlFor:"gmail-to",children:"To"}),e.jsx(Fe,{id:"gmail-to",value:S,onChange:Xe=>T(Xe.target.value),placeholder:"recipient@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{htmlFor:"gmail-subject",children:"Subject"}),e.jsx(Fe,{id:"gmail-subject",value:I,onChange:Xe=>{L(Xe.target.value),de(Xe.target.value)},placeholder:"Enter subject..."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{htmlFor:"gmail-body",children:"Message"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(nt,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{$(Xe=>Xe+"{{first_name}}"),ne(Xe=>Xe+"{{first_name}}")},children:"{{first_name}}"}),e.jsx(nt,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{$(Xe=>Xe+"{{last_name}}"),ne(Xe=>Xe+"{{last_name}}")},children:"{{last_name}}"})]})]}),e.jsx(Ar,{id:"gmail-body",value:R,onChange:Xe=>{$(Xe.target.value),ne(Xe.target.value)},placeholder:"Write your message...",rows:10,className:"resize-y"}),y&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}"," to personalize. You'll preview each recipient's email in the next step."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>{var Xe;return(Xe=document.getElementById("gmail-attachments"))==null?void 0:Xe.click()},disabled:q,children:[e.jsx(W4,{className:"h-4 w-4"}),"Attach Files"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"PDF, images, Word, Excel (max 5MB total)"}),e.jsx("input",{id:"gmail-attachments",type:"file",multiple:!0,accept:".pdf,.jpg,.jpeg,.png,.gif,.webp,.doc,.docx,.xls,.xlsx,.csv",className:"hidden",onChange:ct})]}),se.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:se.map((Xe,He)=>e.jsxs(nt,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(W4,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-[140px] truncate text-xs",children:Xe.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",h1s(Xe.size),")"]}),e.jsx("button",{type:"button",onClick:()=>De(He),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Ur,{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"}),y?e.jsxs(K,{onClick:()=>{qe(b[0]||null),he("reviewing")},disabled:!I||!R,className:"gap-2",children:["Review Emails",e.jsx(Ki,{className:"h-4 w-4"})]}):e.jsxs(K,{onClick:Se,disabled:q||!I||!R,className:"gap-2",children:[q?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(oa,{className:"h-4 w-4"}),q?"Sending...":"Send Email"]})]})]}),le==="reviewing"&&y&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-xs text-primary bg-primary/10 rounded-md px-2.5 py-1.5",children:["✉️ Click any recipient below to preview the ",e.jsx("span",{className:"font-semibold",children:"exact personalized email"})," they will receive."]}),N&&e.jsxs("p",{className:"text-xs text-amber-600 bg-amber-500/10 rounded-md px-2.5 py-1.5",children:["📦 ",b.length," contacts will be sent in ",j," batches of up to ",vv,". You'll confirm before each batch."]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(_e,{children:["Recipients (",b.length,")"]}),e.jsx("div",{className:"bg-muted p-1.5 rounded-md space-y-0.5 max-h-32 overflow-y-auto",children:b.map(Xe=>e.jsxs("div",{className:`text-sm px-2 py-1 rounded cursor-pointer transition-colors ${(Te==null?void 0:Te.id)===Xe.id?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>qe(Xe),children:[Xe.first_name," ",Xe.last_name," — ",Xe.email]},Xe.id))})]}),Te&&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(br,{className:"h-3.5 w-3.5"}),"Preview for ",Te.first_name," ",Te.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:"})," ",Te.email]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Subject:"})," ",S_(Q,Te)]})]}),e.jsx(Zl,{}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-background rounded p-2.5 max-h-40 overflow-y-auto border",children:S_(re,Te)})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>{he("composing"),qe(null)},children:[e.jsx(di,{className:"h-4 w-4 mr-1"}),"Back to Edit"]}),e.jsxs(K,{onClick:Se,disabled:q,className:"gap-2",children:[q?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(oa,{className:"h-4 w-4"}),N?`Send First ${vv}`:`Send to ${b.length}`]})]})]})]})})}function p1s(){const t=Pr(),{data:s}=Fm(),{data:r}=bO(),n=dke(),{isGmailConnected:a,gmailEmail:o}=D0(),[l,i]=C.useState(null),[c,u]=C.useState(!1),[p,f]=C.useState(new Set),y=Pm(new Date),_=kl(y,30),b=I=>{if(!I)return null;const L=I.split(/[-/T]/);if(L.length<3)return null;const R=parseInt(L[1],10)-1,$=parseInt(L[2],10);return isNaN(R)||isNaN($)?null:new Date(y.getFullYear(),R,$)},w=C.useMemo(()=>{if(!s)return[];const I=[];for(const L of s){if(L.birthday){const R=b(L.birthday);R&&(_l(R,y)||bS(R,y)&&wS(R,_))&&I.push({contact:L,type:"birthday",date:R,daysUntil:af(R,y),dateStr:L.birthday})}if(L.home_anniversary){const R=b(L.home_anniversary);R&&(_l(R,y)||bS(R,y)&&wS(R,_))&&I.push({contact:L,type:"anniversary",date:R,daysUntil:af(R,y),dateStr:L.home_anniversary})}}return I.sort((L,R)=>L.daysUntil-R.daysUntil),I},[s]),j=async I=>{const L=(r==null?void 0:r.find(R=>R.name==="Call"))||(r==null?void 0:r[0]);if(L)try{await n.mutateAsync({contactId:I.contact.id,actionTypeId:L.id,notes:`${I.type==="birthday"?"Birthday":"Home Anniversary"} outreach`}),f(R=>new Set(R).add(`${I.contact.id}-${I.type}`)),fn({title:"Touch logged!",description:`Logged outreach for ${I.contact.first_name}`})}catch{fn({title:"Error",description:"Failed to log touch",variant:"destructive"})}},N=I=>{const L=`${I.contact.first_name}${I.contact.last_name?" "+I.contact.last_name:""}`,R=I.type==="birthday"?"birthday":"home_anniversary",$=new URLSearchParams({cardType:R,contactId:I.contact.id,name:L,...I.contact.address?{address:I.contact.address}:{},...I.type==="anniversary"&&I.dateStr?{date:I.dateStr}:{}});t(`/mission-control/card-studio?${$.toString()}`)},S=I=>I===0?"Today!":I===1?"Tomorrow":`${I} days`,T=I=>I===0?"bg-red-500/15 text-red-600 dark:text-red-400 border-red-500/30":I<=3?"bg-amber-500/15 text-amber-600 dark:text-amber-400 border-amber-500/30":I<=7?"bg-blue-500/15 text-blue-600 dark:text-blue-400 border-blue-500/30":"bg-muted text-muted-foreground border-border";return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(Md,{className:"h-5 w-5 text-primary"}),"Upcoming Milestones",e.jsx(nt,{variant:"secondary",className:"text-xs font-normal",children:"Next 30 days"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[w.length," event",w.length!==1?"s":""]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[w.length===0&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(xh,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No birthdays or anniversaries in the next 30 days."}),e.jsx("p",{className:"text-xs mt-1",children:"Add dates to your contacts to see upcoming milestones here."})]}),w.map((I,L)=>{var U,V;const R=`${I.contact.id}-${I.type}`,$=p.has(R),q=`${((U=I.contact.first_name)==null?void 0:U[0])||""}${((V=I.contact.last_name)==null?void 0:V[0])||""}`.toUpperCase();return e.jsxs("div",{className:At("p-3 rounded-lg border transition-colors",I.daysUntil===0&&I.type==="birthday"?"bg-pink-500/10 border-pink-500/30 dark:bg-pink-900/20 dark:border-pink-800/40":I.daysUntil===0&&I.type==="anniversary"?"bg-blue-500/10 border-blue-500/30 dark:bg-blue-900/20 dark:border-blue-800/40":I.type==="birthday"?"bg-pink-50/60 border-pink-200/60 hover:bg-pink-100/60 dark:bg-pink-950/20 dark:border-pink-900/30 dark:hover:bg-pink-950/30":"bg-blue-50/60 border-blue-200/60 hover:bg-blue-100/60 dark:bg-blue-950/20 dark:border-blue-900/30 dark:hover:bg-blue-950/30"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx(yn,{className:At("h-10 w-10",I.type==="birthday"?"ring-2 ring-pink-300/50 dark:ring-pink-700/50":"ring-2 ring-blue-300/50 dark:ring-blue-700/50"),children:e.jsx(vn,{className:At("text-xs font-medium",I.type==="birthday"?"bg-pink-100 text-pink-700 dark:bg-pink-900/40 dark:text-pink-300":"bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300"),children:q})}),e.jsx("span",{className:"absolute -bottom-1.5 -right-1.5 text-base leading-none drop-shadow-sm",children:I.type==="birthday"?"🎂":"🏠"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[I.contact.first_name," ",I.contact.last_name||""]}),e.jsx(nt,{variant:"outline",className:At("text-[10px] shrink-0 whitespace-nowrap",T(I.daysUntil)),children:S(I.daysUntil)})]}),e.jsxs("div",{className:At("text-xs flex items-center gap-1.5 mt-0.5",I.type==="birthday"?"text-pink-600/80 dark:text-pink-400/80":"text-blue-600/80 dark:text-blue-400/80"),children:[I.type==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(xh,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Rn,{className:"h-3 w-3"})," Home Anniversary"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:ys(I.date,"MMM d")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 pl-[52px]",children:[I.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Call",asChild:!0,children:e.jsx("a",{href:`tel:${I.contact.phone}`,children:e.jsx(ea,{className:"h-3.5 w-3.5"})})}),I.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Text",asChild:!0,children:e.jsx("a",{href:`sms:${I.contact.phone}`,children:e.jsx(po,{className:"h-3.5 w-3.5"})})}),I.contact.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Email",onClick:()=>{a?(i({id:I.contact.id,first_name:I.contact.first_name,last_name:I.contact.last_name,email:I.contact.email}),u(!0)):window.location.href=`mailto:${I.contact.email}`},children:e.jsx(br,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Record video",onClick:()=>t(`/mission-control/video/record?contactId=${I.contact.id}`),children:e.jsx(Nn,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"ghost",size:"sm",className:At("h-7 px-2 gap-1 text-xs",I.type==="birthday"?"text-pink-600 hover:text-pink-700 dark:text-pink-400":"text-blue-600 hover:text-blue-700 dark:text-blue-400"),title:`Send ${I.type==="birthday"?"birthday":"anniversary"} card`,onClick:()=>N(I),children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Card"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:At("h-7 w-7",$&&"text-green-600"),title:"Log a touch",disabled:$||n.isPending,onClick:()=>j(I),children:e.jsx(ha,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"View contact",onClick:()=>t(`/mission-control/contacts/${I.contact.id}`),children:e.jsx(va,{className:"h-3.5 w-3.5"})})]})]},`${R}-${L}`)})]})]}),a&&l&&e.jsx(iE,{open:c,onOpenChange:u,contact:l,gmailEmail:o})]})}const yFe={Crown:Sm,FileText:In,Users:mr,Globe:yp,Star:Kn,Phone:ea,MessageSquare:po,PenTool:Db,Video:Nn,Gift:bo},f1s={"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 g1s(){var $e,ot,Ue,Ke,Xe,He;const t=Pr(),{user:s}=Ws(),{data:r}=Rg(),{data:n}=hYe(),{data:a}=Fm(),{data:o}=bO(),{data:l}=xYe(),i=bIt(),c=uke(),u=vIt(90),p=dke(),[f,y]=C.useState(null),[_,b]=C.useState(null),[w,j]=C.useState(!1),[N,S]=C.useState(""),[T,I]=C.useState(!1),[L,R]=C.useState(""),[$,q]=C.useState($oe()),[U,V]=C.useState("cards"),[X,se]=C.useState(!1),[ee,Q]=C.useState(null),[de,re]=C.useState(null),[ne,le]=C.useState(""),{isGmailConnected:he,gmailEmail:we}=D0(),ye=()=>{const Ye=parseInt(L,10);if(isNaN(Ye)||Ye<1){fn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}q(Ye),gYe(Ye),I(!1),fn({title:"Goal updated",description:`Weekly touch goal set to ${Ye}`})},je=()=>{R($.toString()),I(!0)};C.useEffect(()=>{(async()=>{if(!(s!=null&&s.id))return;const{data:tt}=await G.from("profiles").select("name").eq("id",s.id).single();tt!=null&&tt.name&&S(tt.name.split(" ")[0])})()},[s==null?void 0:s.id]),C.useEffect(()=>{i.mutate()},[]);const ke=Pm(new Date),We=kl(ke,7),be=Ye=>{if(!Ye)return null;const tt=Ye.split(/[-/T]/);if(tt.length<3)return null;const Et=parseInt(tt[1],10)-1,qt=parseInt(tt[2],10);return isNaN(Et)||isNaN(qt)?null:new Date(ke.getFullYear(),Et,qt)},Me=(a==null?void 0:a.filter(Ye=>{const tt=be(Ye.birthday),Et=be(Ye.home_anniversary);return tt&&_l(tt,ke)||Et&&_l(Et,ke)}))||[];a!=null&&a.filter(Ye=>{if(!Ye.birthday&&!Ye.home_anniversary)return!1;const tt=Et=>{if(!Et)return!1;const qt=be(Et);return qt?bS(qt,ke)&&wS(qt,We):!1};return tt(Ye.birthday)||tt(Ye.home_anniversary)}).slice(0,5);const Ae=[],Re=(o==null?void 0:o.find(Ye=>Ye.name==="Call"))||(o==null?void 0:o[0]);for(const Ye of Me){const tt=be(Ye.birthday),Et=be(Ye.home_anniversary),qt=tt&&_l(tt,ke),ms=Et&&_l(Et,ke);qt&&Ae.push({contact:Ye,actionType:Re||{id:"special-date-birthday",name:"Birthday Call",icon:"Cake",color:"#EC4899",description:"Wish them happy birthday!",active:!0,sort_order:0,created_at:"",updated_at:""},planName:"🎂 Birthday Today!",relationshipTypeName:((Ue=(ot=($e=Ye.tags)==null?void 0:$e[0])==null?void 0:ot.relationship_type)==null?void 0:Ue.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),ms&&Ae.push({contact:Ye,actionType:Re||{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=(Xe=(Ke=Ye.tags)==null?void 0:Ke[0])==null?void 0:Xe.relationship_type)==null?void 0:He.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const qe=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((Ye,tt)=>{var qt,ms,Xt;const Et=o==null?void 0:o[tt%((o==null?void 0:o.length)||1)];return Et?{contact:Ye,actionType:Et,planName:"Quick Touch",relationshipTypeName:((Xt=(ms=(qt=Ye.tags)==null?void 0:qt[0])==null?void 0:ms.relationship_type)==null?void 0:Xt.name)||"",monthNumber:0}:null}).filter(Boolean))||[],ct=[...Ae,...qe],De=async(Ye,tt,Et)=>{await p.mutateAsync({contactId:Ye,actionTypeId:tt,scriptUsedId:Et}),j(!1),b(null)},Rt=Ye=>{Ye.script?(b(Ye),j(!0)):De(Ye.contact.id,Ye.actionType.id)},pe=Ye=>yFe[Ye||"Phone"]||ea,Je=Ye=>yFe[Ye||"Users"]||mr,lt=(Ye,tt)=>Ye.replace(/\{\{FirstName\}\}/g,tt.first_name).replace(/\{\{LastName\}\}/g,tt.last_name||"").replace(/\{\{AgentName\}\}/g,N||"there"),rt=(Ye,tt)=>({Call:`Thinking of you, ${tt}!`,Text:`Quick hello, ${tt}`,Email:`Checking in, ${tt}`,"Handwritten Note":`A note for ${tt}`,Video:`Video message for ${tt}`,Gift:`Something special for you, ${tt}`})[Ye]||`Hello ${tt}!`,Se=(Ye,tt,Et)=>{const qt=`sms:${Ye}`;if(tt&&Et){const ms=lt(tt,Et);return`${qt}?body=${encodeURIComponent(ms)}`}return qt},it=(Ye,tt,Et,qt,ms)=>{const Xt=`mailto:${Ye}`,rs=[];if(ms){const ps=Et||rt(qt||"Email",ms.first_name);if(rs.push(`subject=${encodeURIComponent(ps)}`),tt){const Ms=lt(tt,ms);rs.push(`body=${encodeURIComponent(Ms)}`)}}return rs.length>0?`${Xt}?${rs.join("&")}`:Xt};return e.jsxs(e.Fragment,{children:[e.jsxs(Es,{title:"Mission Control",description:"Your relationship-first contact system",children:[e.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Mission Control"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Your Sphere"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:r==null?void 0:r.filter(Ye=>Ye.active).map(Ye=>{const tt=Je(Ye.icon),Et=(n==null?void 0:n[Ye.id])||0,qt=f===Ye.id,ms=f1s[Ye.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{qt?(y(null),t("/mission-control/contacts")):(y(Ye.id),t(`/mission-control/contacts?type=${Ye.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${qt?ms:"bg-card hover:bg-accent"} `,children:[e.jsx(tt,{className:"h-5 w-5"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:Ye.name}),e.jsxs("div",{className:`text-sm ${qt?"opacity-90":"text-muted-foreground"}`,children:[Et," Contacts"]})]})]},Ye.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(Fu,{className:"h-4 w-4 mr-1"}),"Quick Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/contacts"),className:"w-full",variant:"outline",children:["View Contacts",e.jsx(Xa,{className:"h-4 w-4 ml-1"})]}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),className:"w-full",children:"Video Library"}),e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/plans"),className:"w-full",children:"Manage Plans"})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Today in Your InnerCircle"}),l!==void 0&&e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(hn,{className:"h-3 w-3"}),"Plan-based"]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 border rounded-lg p-0.5",children:[e.jsx(K,{variant:U==="cards"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("cards"),title:"Card view",children:e.jsx(lf,{className:"h-4 w-4"})}),e.jsx(K,{variant:U==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>V("table"),title:"Table view",children:e.jsx(Mm,{className:"h-4 w-4"})})]})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:ct.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No actions scheduled for today."}),e.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."}),e.jsx(K,{variant:"outline",className:"mt-4",onClick:()=>t("/mission-control/plans"),children:"Manage Plans"})]}):U==="table"?e.jsx(l1s,{actions:ct,onMarkComplete:De,onViewScript:Rt,isLoading:p.isPending,buildSmsLink:Se,buildEmailLink:it,onGmailCompose:he?Ye=>{Q(Ye),se(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[ct.map((Ye,tt)=>{var jt,As,Ps,ar,Dn,Va,pa;const Et=Ye.isSpecialDate,qt=Ye.specialDateType,ms=Et?qt==="birthday"?xh:Rn:pe(((jt=Ye.actionType)==null?void 0:jt.icon)||null),Xt=Ye.contact.phone,rs=Ye.contact.email,ps=Et?qt==="birthday"?"#EC4899":"#8B5CF6":((As=Ye.actionType)==null?void 0:As.color)||"#3B82F6",Ms=Et?qt==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(Ps=Ye.actionType)==null?void 0:Ps.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${Et?"ring-2 ring-offset-2":""}`,style:Et?{"--tw-ring-color":ps}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:ps},children:[e.jsx(ms,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:Ms})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>t(`/mission-control/contacts/${Ye.contact.id}`),className:"font-medium text-sm hover:text-primary hover:underline transition-colors text-left",children:[Ye.contact.first_name," ",Ye.contact.last_name]}),e.jsxs("div",{className:"flex gap-1.5",children:[Xt&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${Ye.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(ea,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:Se(Ye.contact.phone,(ar=Ye.script)==null?void 0:ar.script_body,Ye.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(po,{className:"h-3 w-3"}),"Text"]})]}),rs&&(he?e.jsxs("button",{onClick:()=>{Q({id:Ye.contact.id,first_name:Ye.contact.first_name,last_name:Ye.contact.last_name,email:Ye.contact.email}),se(!0)},className:"flex-1 flex items-center justify-center gap-1 px-2 py-1.5 bg-sky-500/10 hover:bg-sky-500/20 text-sky-600 dark:text-sky-400 rounded text-xs font-medium transition-colors",title:"Compose Email",children:[e.jsx(br,{className:"h-3 w-3"}),"Email"]}):e.jsxs("a",{href:it(Ye.contact.email,(Dn=Ye.script)==null?void 0:Dn.script_body,(Va=Ye.script)==null?void 0:Va.email_subject,(pa=Ye.actionType)==null?void 0:pa.name,Ye.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(br,{className:"h-3 w-3"}),"Email"]}))]}),Et&&e.jsxs("button",{onClick:()=>{const qa=`${Ye.contact.first_name}${Ye.contact.last_name?" "+Ye.contact.last_name:""}`,Kr=qt==="birthday"?"birthday":"home_anniversary",Yn=new URLSearchParams({cardType:Kr,contactId:Ye.contact.id,name:qa,...Ye.contact.address?{address:Ye.contact.address}:{},...qt==="anniversary"&&Ye.contact.home_anniversary?{date:Ye.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${Yn.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(br,{className:"h-3 w-3"}),"Send ",qt==="birthday"?"Birthday":"Anniversary"," Card"]}),!Xt&&!rs&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No contact info"}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[Ye.relationshipTypeName&&e.jsx(nt,{variant:"secondary",className:"text-xs",children:Ye.relationshipTypeName}),Ye.monthNumber>0&&e.jsxs(nt,{variant:"outline",className:"text-xs",children:["Month ",Ye.monthNumber]})]}),Ye.script&&e.jsx(K,{size:"sm",variant:"outline",className:"w-full",onClick:()=>Rt(Ye),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(Ye.contact.id),le(`${Ye.contact.first_name} ${Ye.contact.last_name||""}`.trim())},children:[e.jsx(cf,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(K,{size:"sm",className:"flex-1",onClick:()=>{var qa;return De(Ye.contact.id,Ye.actionType.id,(qa=Ye.script)==null?void 0:qa.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]},Ye.contact.id+tt)}),e.jsx("div",{className:"flex-shrink-0 w-[100px] border rounded-lg flex items-center justify-center",children:e.jsxs(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"h-full w-full",children:[e.jsx(ig,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(Jd,{children:e.jsx(Ta,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ot,{className:"text-lg",children:"Momentum"}),e.jsxs(_s,{open:T,onOpenChange:I,children:[e.jsx(Fi,{asChild:!0,children:e.jsx("button",{onClick:je,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Jl,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),e.jsxs(vs,{className:"sm:max-w-[360px]",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Set Weekly Goal"}),e.jsx(Zr,{children:"How many touches do you want to complete each week?"})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"weekly-goal-ic",children:"Weekly touch goal"}),e.jsx(Fe,{id:"weekly-goal-ic",type:"number",min:"1",value:L,onChange:Ye=>R(Ye.target.value),placeholder:"20",onKeyDown:Ye=>{Ye.key==="Enter"&&ye()}})]}),e.jsx(K,{onClick:ye,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Oi,{value:Math.min(c.actionsThisWeek/$*100,100),className:"h-3 w-full max-w-full"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Fh,{className:"h-5 w-5 text-orange-500"}),e.jsxs("span",{className:"font-medium",children:[c.actionsThisWeek," / ",$]}),e.jsx("span",{className:"text-muted-foreground",children:"Actions Completed This Week"})]}),c.streak>0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-lg",children:"🔥"}),e.jsx("span",{className:"font-medium",children:"Great Job!"}),e.jsxs("span",{className:"text-muted-foreground",children:["Keep Your Streak Going! (",c.streak," days)"]})]}),u.count>0&&e.jsxs("button",{onClick:()=>t("/mission-control/contacts?filter=not-touched-90"),className:"flex items-start gap-2 text-sm pt-2 border-t w-full text-left hover:bg-accent/50 -mx-4 px-4 py-2 rounded-md transition-colors",children:[e.jsx(Tn,{className:"h-4 w-4 text-orange-500 mt-0.5"}),e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-orange-600 dark:text-orange-400",children:[u.count," Contact",u.count!==1?"s":""]}),e.jsx("span",{className:"text-muted-foreground",children:" Not Reached in 90+ Days"})]}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground ml-auto mt-0.5"})]})]})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsx(PYe,{}),e.jsx(p1s,{})]})]}),e.jsx(_s,{open:w,onOpenChange:j,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ns,{className:"flex items-center gap-2",children:_&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:_.actionType.color||"#3B82F6"}}),_.actionType.name," Script"]})})}),_&&_.script&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["For: ",e.jsxs("span",{className:"font-medium text-foreground",children:[_.contact.first_name," ",_.contact.last_name]})]}),e.jsx("div",{className:"bg-muted p-4 rounded-lg",children:e.jsx("p",{className:"whitespace-pre-wrap",children:lt(_.script.script_body,_.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>j(!1),children:"Close"}),e.jsx(K,{className:"flex-1",onClick:()=>{var Ye;return De(_.contact.id,_.actionType.id,(Ye=_.script)==null?void 0:Ye.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(s1s,{})]}),he&&ee&&e.jsx(iE,{open:X,onOpenChange:se,contact:ee,gmailEmail:we}),e.jsx(Lhe,{open:!!de,onOpenChange:Ye=>!Ye&&re(null),contactId:de||"",contactName:ne})]})}var eat="Toggle",L4e=C.forwardRef((t,s)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...o}=t,[l,i]=Yu({prop:r,onChange:a,defaultProp:n??!1,caller:eat});return e.jsx(Jr.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":t.disabled?"":void 0,...o,ref:s,onClick:Mr(t.onClick,()=>{t.disabled||i(!l)})})});L4e.displayName=eat;var tat=L4e,D2="ToggleGroup",[sat]=Yc(D2,[w2]),rat=w2(),D4e=ht.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(x1s,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(y1s,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${D2}\``)});D4e.displayName=D2;var[nat,aat]=sat(D2),x1s=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=Yu({prop:r,defaultProp:n??"",onChange:a,caller:D2});return e.jsx(nat,{scope:t.__scopeToggleGroup,type:"single",value:ht.useMemo(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:ht.useCallback(()=>i(""),[i]),children:e.jsx(iat,{...o,ref:s})})}),y1s=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=Yu({prop:r,defaultProp:n??[],onChange:a,caller:D2}),c=ht.useCallback(p=>i((f=[])=>[...f,p]),[i]),u=ht.useCallback(p=>i((f=[])=>f.filter(y=>y!==p)),[i]);return e.jsx(nat,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:c,onItemDeactivate:u,children:e.jsx(iat,{...o,ref:s})})});D4e.displayName=D2;var[v1s,_1s]=sat(D2),iat=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:o,dir:l,loop:i=!0,...c}=t,u=rat(r),p=b2(l),f={role:"group",dir:p,...c};return e.jsx(v1s,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(kde,{asChild:!0,...u,orientation:o,dir:p,loop:i,children:e.jsx(Jr.div,{...f,ref:s})}):e.jsx(Jr.div,{...f,ref:s})})}),Fce="ToggleGroupItem",oat=ht.forwardRef((t,s)=>{const r=aat(Fce,t.__scopeToggleGroup),n=_1s(Fce,t.__scopeToggleGroup),a=rat(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(Nde,{asChild:!0,...a,focusable:!l,active:o,ref:c,children:e.jsx(vFe,{...i,ref:s})}):e.jsx(vFe,{...i,ref:s})});oat.displayName=Fce;var vFe=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=aat(Fce,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(L4e,{...i,...a,ref:s,onPressedChange:c=>{c?o.onItemActivate(n):o.onItemDeactivate(n)}})}),lat=D4e,cat=oat;const dat=HS("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"}}),b1s=C.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(tat,{ref:a,className:At(dat({variant:s,size:r,className:t})),...n}));b1s.displayName=tat.displayName;const uat=C.createContext({size:"default",variant:"default"}),hat=C.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(lat,{ref:o,className:At("flex items-center justify-center gap-1",t),...a,children:e.jsx(uat.Provider,{value:{variant:s,size:r},children:n})}));hat.displayName=lat.displayName;const mat=C.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=C.useContext(uat);return e.jsx(cat,{ref:o,className:At(dat({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});mat.displayName=cat.displayName;const w1s=[{value:"bidirectional",label:"Two-Way",icon:ud,tooltip:"Sync contacts in both directions"},{value:"push_only",label:"Push Only",icon:gu,tooltip:"Only push Agent OS → BoldTrail"},{value:"pull_only",label:"Pull Only",icon:Oh,tooltip:"Only pull BoldTrail → Agent OS"}];function Cbe({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(hat,{type:"single",value:t,onValueChange:a=>{a&&s(a)},className:"justify-start",children:w1s.map(a=>e.jsxs(hd,{children:[e.jsx(md,{asChild:!0,children:e.jsxs(mat,{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(Uc,{children:a.tooltip})]},a.value))})]})}function j1s(){const t=ss(),[s,r]=C.useState(!1),[n,a]=C.useState(null),[o,l]=C.useState(!1),[i,c]=C.useState(!1),[u,p]=C.useState(null),[f,y]=C.useState(null),[_,b]=C.useState(0),w=C.useRef(!1),{data:j}=wt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:$,error:q}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(q)throw q;return $}}),N=(j==null?void 0:j.sync_direction)||"bidirectional",S=u??N,T=Dt({mutationFn:async()=>{const{data:$,error:q}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(q)throw q;if($!=null&&$.error)throw new Error($.error);return $},onSuccess:$=>{p(null),a($),r(!0)},onError:$=>{me.error($.message||"Failed to generate sync preview")}}),I=Dt({mutationFn:async()=>{w.current=!1,y("Initializing sync..."),b(5);const{data:$,error:q}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:S}});if(q)throw q;if($!=null&&$.error)throw new Error($.error);const U=$;let V=U.sync_log_id,X=U.next_phase,se=U.next_offset;const ee=U.push_total||0,Q=U.pull_total||0,de=ee+Q;let re=0,ne=0;for(;X!=="finalize"&&!w.current;){X==="push"?(y(`Pushing contacts to BoldTrail... (${re}/${ee})`),b(de>0?re/de*100:0)):X==="pull"&&(y(`Pulling contacts from BoldTrail... (${ne}/${Q})`),b(de>0?(ee+ne)/de*100:0));const{data:we,error:ye}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:X,offset:se,sync_log_id:V,sync_direction:S}});if(ye)throw ye;if(we!=null&&we.error)throw new Error(we.error);const je=we;re+=je.chunk_pushed||0,ne+=je.chunk_pulled||0,je.progress&&y(je.progress),X==="pull"&&Q>0?b(Math.min(95,ne/Q*100)):X==="push"&&ee>0&&b(Math.min(95,re/ee*100)),X=je.next_phase,se=je.next_offset}y("Finalizing sync..."),b(95);const{data:le,error:he}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:V,sync_direction:S}});if(he)throw he;return b(100),le},onSuccess:$=>{y(null),b(0),r(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),me.success(`Sync complete! Pushed ${$.contacts_pushed||0}, pulled ${$.contacts_pulled||0}, skipped ${$.contacts_skipped||0} duplicates.`)},onError:$=>{y(null),b(0),me.error($.message||"Sync failed")}});if(!(j!=null&&j.connected))return null;const L=S==="pull_only"?0:(n==null?void 0:n.to_push)??0,R=S==="push_only"?0:(n==null?void 0:n.to_pull)??0;return e.jsxs(e.Fragment,{children:[e.jsxs(hd,{children:[e.jsx(md,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"icon",onClick:()=>T.mutate(),disabled:T.isPending,className:"shrink-0",children:T.isPending?e.jsx(Bo,{className:"h-4 w-4 animate-spin"}):e.jsx(ud,{className:"h-4 w-4 text-emerald-600"})})}),e.jsx(Uc,{children:"Sync with BoldTrail"})]}),e.jsx(_s,{open:s,onOpenChange:$=>{I.isPending||r($)},children:e.jsxs(vs,{className:"sm:max-w-lg",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(ud,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Zr,{children:"Review what will happen when you sync your contacts."})]}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(Cbe,{value:S,onChange:p,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${S==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:L}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(gu,{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:R}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Oh,{className:"h-3 w-3"})," Pull to Agent OS"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-muted-foreground",children:n.already_synced}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(mr,{className:"h-3 w-3"})," Already synced"]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["Agent OS: ",n.agent_os_total," contacts · BoldTrail: ",n.boldtrail_total," contacts"]}),L>0&&e.jsxs(bg,{open:o,onOpenChange:l,children:[e.jsx(wg,{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(gu,{className:"h-3 w-3 text-emerald-600"}),L," contacts to push to BoldTrail"]}),e.jsx(tl,{className:`h-3 w-3 transition-transform ${o?"rotate-180":""}`})]})}),e.jsx(jg,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.push_preview.map(($,q)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:$.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:$.email})]},q)),n.to_push>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",n.to_push-20," more"]})]})})]}),R>0&&e.jsxs(bg,{open:i,onOpenChange:c,children:[e.jsx(wg,{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(Oh,{className:"h-3 w-3 text-blue-600"}),R," contacts to pull from BoldTrail"]}),e.jsx(tl,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})}),e.jsx(jg,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[n.pull_preview.map(($,q)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:$.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:$.email})]},q)),n.to_pull>20&&e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground text-center",children:["...and ",n.to_pull-20," more"]})]})})]}),L===0&&R===0&&!I.isPending&&e.jsx("div",{className:"text-center py-4 text-sm text-muted-foreground",children:"✅ Everything is already in sync! No contacts to transfer."}),I.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(Oi,{value:_||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:f||"Sync in progress..."})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>r(!1),disabled:I.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>I.mutate(),disabled:I.isPending||L===0&&R===0,className:"gap-2",children:[I.isPending?e.jsx(Bo,{className:"h-4 w-4 animate-spin"}):e.jsx(ud,{className:"h-4 w-4"}),I.isPending?"Syncing...":"Sync Now"]})]})]})]})})]})}const k1s=()=>{const{user:t}=Ws();return wt({queryKey:["popby-items",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("popby_items").select("*").or(`owner_user_id.is.null,owner_user_id.eq.${t==null?void 0:t.id}`).eq("is_active",!0).order("name");if(r)throw r;return s},enabled:!!t})},Dhe=t=>{const{user:s}=Ws();return wt({queryKey:["popby-logs",s==null?void 0:s.id,t],queryFn:async()=>{let r=G.from("popby_logs").select("*").order("completed_at",{ascending:!1});if(t){const o=new Date;o.setDate(o.getDate()-t),r=r.gte("completed_at",o.toISOString())}const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!s})},O4e=()=>{const{user:t}=Ws();return wt({queryKey:["relationship-type-popby-defaults",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("relationship_type_popby_defaults").select("*");if(r)throw r;return s},enabled:!!t})},pat=()=>{const{user:t}=Ws();return wt({queryKey:["contact-popby-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_popby_settings").select("*");if(r)throw r;return s},enabled:!!t})},N1s=()=>{const{data:t}=Fm(),{data:s}=Rg(),{data:r}=Dhe(),{data:n}=pat(),{data:a}=O4e(),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=Pm(new Date);return(t||[]).map(p=>{let f=90;if(i.has(p.id))f=i.get(p.id);else if(p.tags&&p.tags.length>0){const j=p.tags.map(N=>l.get(N.relationship_type_id)).filter(N=>N!==void 0);j.length>0&&(f=Math.min(...j))}const y=o.get(p.id)||null,_=y?ty(c,Pm(new Date(y))):null,b=_===null||_>=f,w=b&&_!==null?_-f:0;return{...p,lastPopby:y,daysSinceLastPopby:_,frequencyDays:f,isDue:b,daysOverdue:w}}).sort((p,f)=>f.daysOverdue-p.daysOverdue)},fat=()=>N1s().filter(s=>s.isDue),S1s=()=>{const t=ss(),{user:s}=Ws();return Dt({mutationFn:async r=>{const{error:n}=await G.from("popby_items").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-items"]}),fn({title:"Popby item created!"})},onError:r=>{fn({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},C1s=()=>{const t=ss(),{user:s}=Ws();return Dt({mutationFn:async r=>{const{error:n}=await G.from("popby_logs").insert({...r,owner_user_id:s==null?void 0:s.id});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["popby-logs"]}),fn({title:"Popby logged!"})},onError:r=>{fn({title:"Error logging popby",description:r.message,variant:"destructive"})}})},M1s=()=>{const t=ss(),{user:s}=Ws();return Dt({mutationFn:async r=>{const{error:n}=await G.from("relationship_type_popby_defaults").upsert({...r,owner_user_id:s==null?void 0:s.id},{onConflict:"relationship_type_id,owner_user_id"});if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["relationship-type-popby-defaults"]}),fn({title:"Frequency updated!"})},onError:r=>{fn({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},T1s=()=>{const{data:t}=Dhe(30),s=fat(),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 A1s(){const{user:t}=Ws();return wt({queryKey:["contact-touch-logs",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_touch_logs").select("*").order("completed_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function gat(t){const{data:s}=A1s(),{data:r}=pat(),{data:n}=O4e(),{data:a}=r1s();return C.useMemo(()=>{const o=a==null?void 0:a.find(j=>j.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=Pm(new Date);if(l&&!wS(l,i))return{nextTouchDate:l,daysUntil:ty(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const u=((s==null?void 0:s.filter(j=>j.contact_id===t.id))||[]).sort((j,N)=>new Date(N.completed_at).getTime()-new Date(j.completed_at).getTime())[0],p=u?new Date(u.completed_at):null;let f=90;const y=r==null?void 0:r.find(j=>j.contact_id===t.id&&j.is_active);if(y)f=y.frequency_days;else if(t.tags&&t.tags.length>0){const j=t.tags.map(N=>{const S=n==null?void 0:n.find(T=>T.relationship_type_id===N.relationship_type_id);return S==null?void 0:S.frequency_days}).filter(N=>N!==void 0);j.length>0&&(f=Math.min(...j))}if(!p)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:f,lastTouchDate:null,snoozedUntil:null};const _=kl(Pm(p),f),b=ty(_,i);let w;return b<0?w="overdue":b<=7?w="due-soon":w="on-track",{nextTouchDate:_,daysUntil:b,status:w,frequencyDays:f,lastTouchDate:p,snoozedUntil:null}},[t,s,r,n,a])}function Mbe({contact:t}){const s=gat(t),n=(()=>{switch(s.status){case"overdue":return{variant:"destructive",icon:yl,text:`${Math.abs(s.daysUntil)} days overdue`,className:""};case"due-soon":return{variant:"secondary",icon:Tn,text:s.daysUntil===0?"Due today":`Due in ${s.daysUntil} days`,className:"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400"};case"on-track":return{variant:"secondary",icon:ha,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:cf,text:`Snoozed until ${ys(s.snoozedUntil,"MMM d")}`,className:"bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300"};case"never-touched":return{variant:"outline",icon:on,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(nt,{variant:n.variant,className:At("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function E1s({contact:t,onLogTouch:s,onSnooze:r}){const n=gat(t),a=a1s(),[o,l]=C.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(yl,{className:"h-5 w-5 text-destructive"});case"due-soon":return e.jsx(Tn,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return e.jsx(ha,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"});case"snoozed":return e.jsx(cf,{className:"h-5 w-5 text-slate-600 dark:text-slate-400"});case"never-touched":return e.jsx(on,{className:"h-5 w-5 text-muted-foreground"})}},u=()=>{switch(n.status){case"overdue":return`${Math.abs(n.daysUntil)} days overdue`;case"due-soon":return n.daysUntil===0?"Due today!":`Due in ${n.daysUntil} days`;case"on-track":return`On track - ${n.daysUntil} days remaining`;case"snoozed":return`Snoozed for ${n.daysUntil} more days`;case"never-touched":return"No touches logged yet"}},p=async()=>{await a.mutateAsync(t.id)};return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Next Touch"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c(),e.jsx("span",{className:At("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:"})," ",ys(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:"})," ",ys(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:"})," ",ys(n.lastTouchDate,"MMM d, yyyy")]}),n.status!=="snoozed"&&e.jsxs("div",{className:"text-xs text-muted-foreground border-t pt-2",children:["Touch frequency: Every ",n.frequencyDays," days"]}),n.status==="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:p,disabled:a.isPending,children:[e.jsx(Ur,{className:"h-4 w-4 mr-1"}),"Cancel Snooze"]}),s&&e.jsx(K,{size:"sm",className:"flex-1",onClick:s,children:"Log Touch"})]}),n.status!=="snoozed"&&e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(K,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>l(!0),children:[e.jsx(cf,{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(Lhe,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const nye=768;function oE(){const[t,s]=C.useState(void 0);return C.useEffect(()=>{const r=window.matchMedia(`(max-width: ${nye-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}const P1s={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"}},I1s={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 e8({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=P1s[t.status],l=I1s[n],i=e.jsxs("div",{className:At("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:At("rounded-full",o.bgClass,l.dot)}),s?e.jsx("span",{children:t.score}):e.jsx("span",{children:o.label})]});return r?e.jsx(x2,{children:e.jsxs(hd,{children:[e.jsx(md,{asChild:!0,children:i}),e.jsx(Uc,{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:At("font-bold",o.textClass),children:[t.score,"/100"]})]}),e.jsx(Oi,{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 L1s=[{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}],jz=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]},D1s=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=Ws(),{toast:o}=Ra(),l=C.useRef(null),[i,c]=C.useState("upload"),[u,p]=C.useState([]),[f,y]=C.useState([]),[_,b]=C.useState({}),[w,j]=C.useState([]),[N,S]=C.useState([]),[T,I]=C.useState(!1),[L,R]=C.useState(null),$=()=>{c("upload"),p([]),y([]),b({}),j([]),S([]),R(null),l.current&&(l.current.value="")},q=()=>{$(),s(!1)},U=we=>{const ye=we.split(` `).map(be=>be.trim()).filter(be=>be);if(ye.length===0)return{headers:[],data:[]};const je=be=>{const Me=[];let Ae="",Re=!1;for(let Te=0;Te{var ke;const ye=(ke=we.target.files)==null?void 0:ke[0];if(!ye)return;const je=new FileReader;je.onload=We=>{var Te;const be=(Te=We.target)==null?void 0:Te.result,{headers:Me,data:Ae}=U(be);if(Me.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}p(Me),y(Ae);const Re={};Me.forEach(qe=>{const ct=qe.toLowerCase().replace(/[_\s-]/g,"");ct.includes("firstname")||ct==="first"?Re.first_name=qe:ct.includes("lastname")||ct==="last"?Re.last_name=qe:ct.includes("spouse")&&ct.includes("email")?Re.spouse_email=qe:ct.includes("spouse")||ct.includes("partner")?Re.spouse_name=qe:ct.includes("email")?Re.email=qe:ct.includes("phone")||ct.includes("mobile")||ct.includes("cell")?Re.phone=qe:ct.includes("address")||ct.includes("street")?Re.address=qe:ct==="city"?Re.city=qe:ct==="state"||ct==="province"?Re.state=qe:ct==="zip"||ct==="zipcode"||ct==="postalcode"?Re.zip=qe:ct.includes("company")||ct.includes("organization")||ct.includes("business")?Re.company_name=qe:ct.includes("jobtitle")||ct.includes("title")&&!ct.includes("spouse")?Re.job_title=qe:ct.includes("birthday")||ct.includes("dob")||ct.includes("birthdate")?Re.birthday=qe:ct.includes("anniversary")||ct.includes("homeanniversary")?Re.home_anniversary=qe:(ct.includes("notes")||ct.includes("comment"))&&(Re.notes=qe)}),b(Re),c("mapping")},je.readAsText(ye)},X=(we,ye)=>{b(je=>{if(ye==="none"){const{[we]:ke,...We}=je;return We}return{...je,[we]:ye}})},se=we=>{j(ye=>ye.includes(we)?ye.filter(je=>je!==we):[...ye,we])},ee=async()=>{if(!(a!=null&&a.id))return;const{data:we}=await G.from("innercircle_contacts").select("id, email, phone").eq("owner_user_id",a.id),ye=new Set((we||[]).filter(We=>We.email).map(We=>We.email.toLowerCase())),je=new Set((we||[]).filter(We=>We.phone).map(We=>We.phone.replace(/[^0-9]/g,""))),ke=f.map(We=>{const be=ct=>{const De=_[ct];if(!De)return"";const Rt=u.indexOf(De);return Rt>=0?(We[Rt]||"").trim():""},Me=be("first_name"),Ae=be("email"),Re=be("phone"),Te=Me.length>0,qe=!!(Ae&&ye.has(Ae.toLowerCase())||Re&&je.has(Re.replace(/[^0-9]/g,"")));return{first_name:Me,last_name:be("last_name"),email:Ae,phone:Re,address:be("address"),city:be("city"),state:be("state"),zip:be("zip"),spouse_name:be("spouse_name"),spouse_email:be("spouse_email"),company_name:be("company_name"),job_title:be("job_title"),birthday:be("birthday"),home_anniversary:be("home_anniversary"),notes:be("notes"),isValid:Te,isDuplicate:qe,error:Te?void 0:"First name is required"}});S(ke),c("preview")},Q=we=>{const ye=we.trim().split(/\s+/);return{first_name:ye[0],last_name:ye.length>1?ye.slice(1).join(" "):null}},de=async()=>{if(!(a!=null&&a.id))return;const we=N.filter(We=>We.isValid);if(we.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}I(!0);let ye=0,je=0,ke=0;try{for(const We of we)try{let be=null;if(We.email){const{data:Re}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",We.email).maybeSingle();be=Re}if(!be&&We.phone){const Re=We.phone.replace(/[^0-9]/g,""),{data:Te}=await G.from("innercircle_contacts").select("id, phone").eq("owner_user_id",a.id).not("phone","is",null);if(Te){const qe=Te.find(ct=>ct.phone&&ct.phone.replace(/[^0-9]/g,"")===Re);qe&&(be={id:qe.id})}}const Me={owner_user_id:a.id,first_name:We.first_name,last_name:We.last_name||null,email:We.email||null,phone:We.phone||null,address:We.address||null,city:We.city||null,state:We.state||null,zip:We.zip||null,spouse_name:We.spouse_name||null,spouse_email:We.spouse_email||null,company_name:We.company_name||null,job_title:We.job_title||null,birthday:jz(We.birthday),home_anniversary:jz(We.home_anniversary),notes:We.notes||null};let Ae=null;if(be){const{data:Re}=await G.from("innercircle_contacts").select("*").eq("id",be.id).single();if(Re){const Te={},qe=["last_name","email","phone","address","city","state","zip","spouse_name","spouse_email","company_name","job_title","birthday","home_anniversary","notes"];for(const ct of qe){const De=Re[ct],Rt=Me[ct];(!De||De==="")&&Rt&&(Te[ct]=Rt)}Object.keys(Te).length>0&&await G.from("innercircle_contacts").update(Te).eq("id",be.id)}Ae=be.id,je++}else{const{data:Re,error:Te}=await G.from("innercircle_contacts").insert(Me).select("id").single();Te?(console.error("Insert error for contact:",We.first_name,Te),ke++):Re?(Ae=Re.id,w.length>0&&await G.from("innercircle_contact_tags").insert(w.map(qe=>({contact_id:Re.id,relationship_type_id:qe}))),ye++):ke++}if(Ae&&We.spouse_name){const Re=Q(We.spouse_name);let Te=null;if(We.spouse_email){const{data:ct}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",We.spouse_email).maybeSingle();Te=ct}if(!Te){const{data:ct}=await G.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("first_name",Re.first_name).eq("last_name",Re.last_name||We.last_name||"").maybeSingle();Te=ct}let qe=null;if(Te){qe=Te.id;const ct=jz(We.home_anniversary);ct&&await G.from("innercircle_contacts").update({home_anniversary:ct}).eq("id",Te.id).is("home_anniversary",null)}else{const{data:ct}=await G.from("innercircle_contacts").insert({owner_user_id:a.id,first_name:Re.first_name,last_name:Re.last_name||We.last_name||null,email:We.spouse_email||null,address:We.address||null,city:We.city||null,state:We.state||null,zip:We.zip||null,home_anniversary:jz(We.home_anniversary),spouse_name:`${We.first_name}${We.last_name?" "+We.last_name:""}`,spouse_email:We.email||null,notes:`Spouse of ${We.first_name} ${We.last_name||""} (imported via CSV)`.trim()}).select("id").single();ct&&(qe=ct.id,ye++)}qe&&(await G.from("innercircle_contacts").update({spouse_contact_id:qe}).eq("id",Ae),await G.from("innercircle_contacts").update({spouse_contact_id:Ae}).eq("id",qe))}}catch(be){console.error("Error importing contact:",be),ke++}R({created:ye,updated:je,failed:ke}),c("result"),(ye>0||je>0)&&n(),o({title:"Import Complete",description:`${ye} created, ${je} updated${ke>0?`, ${ke} failed`:""}.`})}catch(We){console.error("Import error:",We),o({title:"Import Failed",description:We.message||"Failed to import contacts",variant:"destructive"})}finally{I(!1)}},re=N.filter(we=>we.isValid).length,ne=N.filter(we=>!we.isValid).length,le=N.filter(we=>we.isValid&&we.isDuplicate).length,he=re-le;return e.jsx(_s,{open:t,onOpenChange:q,children:e.jsxs(vs,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Yv,{className:"h-5 w-5"}),"Import Contacts from CSV"]}),e.jsx(Zr,{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(ni,{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 we;return(we=l.current)==null?void 0:we.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 we=`First Name,Last Name,Email,Phone,Street Address,City,State,Zip,Spouse Name,Spouse Email,Company,Job Title,Birthday,Home Anniversary,Notes John,Doe,john@example.com,555-123-4567,123 Main St,Austin,TX,78701,Jane Doe,jane@example.com,ABC Realty,Real Estate Agent,1985-06-15,2020-03-22,Met at open house`,ye=new Blob([we],{type:"text/csv"}),je=URL.createObjectURL(ye),ke=document.createElement("a");ke.href=je,ke.download="contact_import_template.csv",ke.click(),URL.revokeObjectURL(je)},children:[e.jsx(ki,{className:"h-4 w-4 mr-2"}),"Download Template"]})]})]}),i==="mapping"&&e.jsxs("div",{className:"flex-1 overflow-auto space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{className:"text-base font-medium",children:"Map CSV Columns to Contact Fields"}),e.jsx("div",{className:"grid gap-3",children:L1s.map(we=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(_e,{className:"w-40 text-sm",children:[we.label,we.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(rr,{value:_[we.key]||"none",onValueChange:ye=>X(we.key,ye),children:[e.jsx(tr,{className:"w-48",children:e.jsx(nr,{placeholder:"Select column..."})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"-- Not mapped --"}),u.map(ye=>e.jsx(Tt,{value:ye,children:ye},ye))]})]})]},we.key))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{className:"text-base font-medium",children:"Apply Relationship Types (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(we=>e.jsx(nt,{variant:w.includes(we.id)?"default":"outline",className:"cursor-pointer",onClick:()=>se(we.id),children:we.name},we.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(ha,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{children:[he," new"]})]}),le>0&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(yl,{className:"h-4 w-4"}),e.jsxs("span",{children:[le," existing (will merge gaps)"]})]}),ne>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(yl,{className:"h-4 w-4"}),e.jsxs("span",{children:[ne," invalid"]})]})]}),le>0&&e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-xs text-muted-foreground",children:"Duplicates matched by email or phone will only fill in missing fields — your existing data won't be overwritten."}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{className:"bg-muted/30",children:[e.jsx(bt,{children:"First Name"}),e.jsx(bt,{children:"Last Name"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Phone"}),e.jsx(bt,{children:"Status"})]})}),e.jsx(Pn,{children:N.slice(0,100).map((we,ye)=>e.jsxs(ks,{children:[e.jsx(dt,{children:we.first_name}),e.jsx(dt,{children:we.last_name}),e.jsx(dt,{children:we.email}),e.jsx(dt,{children:we.phone}),e.jsx(dt,{children:we.isValid?we.isDuplicate?e.jsx(nt,{variant:"outline",className:"bg-accent text-accent-foreground",children:"Merge"}):e.jsx(nt,{variant:"secondary",className:"bg-primary/10 text-primary",children:"New"}):e.jsx(nt,{variant:"destructive",children:we.error||"Invalid"})})]},ye))})]}),N.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",N.length," contacts"]})]})]}),i==="result"&&L&&e.jsxs("div",{className:"space-y-4 py-4 text-center",children:[e.jsx(ha,{className:"h-12 w-12 mx-auto text-primary"}),e.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),e.jsxs("p",{className:"text-muted-foreground",children:[L.created," created, ",L.updated," merged"]}),L.failed>0&&e.jsxs("p",{className:"text-destructive",children:[L.failed," failed to import"]})]}),e.jsxs(Vn,{children:[i==="upload"&&e.jsx(K,{variant:"outline",onClick:q,children:"Cancel"}),i==="mapping"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:$,children:"Back"}),e.jsx(K,{onClick:ee,disabled:!_.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:de,disabled:T||re===0,children:T?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${re} Contact${re!==1?"s":""}`})]}),i==="result"&&e.jsx(K,{onClick:q,children:"Done"})]})]})})};function O1s(){return"contacts"in navigator&&"ContactsManager"in window}function R1s(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 _=f.substring(f.indexOf(":")+1).split(";");l=(_[0]||"").trim(),o=(_[1]||"").trim()}if((f.startsWith("FN:")||f.startsWith("FN;"))&&!o){const _=f.substring(f.indexOf(":")+1).trim().split(" ");o=_[0]||"",l=_.slice(1).join(" ")}(f.startsWith("EMAIL")||f.match(/^item\d+\.EMAIL/i))&&!i&&(i=f.substring(f.indexOf(":")+1).trim()),(f.startsWith("TEL")||f.match(/^item\d+\.TEL/i))&&!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(b=>b.trim()).filter(Boolean).join(", "))}(o||l)&&s.push({first_name:o,last_name:l,email:i,phone:c,address:u})}return s}function F1s({open:t,onOpenChange:s,onComplete:r}){const{user:n}=Ws(),{data:a}=Fm(),o=uue(),l=C.useRef(null),[i,c]=C.useState("choose"),[u,p]=C.useState([]),[f,y]=C.useState(new Set),[_,b]=C.useState(0),[w,j]=C.useState(0),N=O1s(),S=C.useCallback(X=>{if(!a)return X;const se=new Set(a.filter(Q=>Q.email).map(Q=>Q.email.toLowerCase())),ee=new Set(a.filter(Q=>Q.phone).map(Q=>Q.phone.replace(/\D/g,"")));return X.map(Q=>{var ne,le;const de=(ne=Q.email)==null?void 0:ne.toLowerCase(),re=(le=Q.phone)==null?void 0:le.replace(/\D/g,"");return de&&se.has(de)?{...Q,isDuplicate:!0,duplicateField:"email"}:re&&re.length>=7&&ee.has(re)?{...Q,isDuplicate:!0,duplicateField:"phone"}:Q})},[a]),T=async()=>{try{const X=["name","email","tel","address"],se=await navigator.contacts.select(X,{multiple:!0});if(!se||se.length===0)return;const ee=se.map(re=>{var he,we,ye,je;const le=(((he=re.name)==null?void 0:he[0])||"").split(" ");return{first_name:le[0]||"",last_name:le.slice(1).join(" "),email:((we=re.email)==null?void 0:we[0])||"",phone:((ye=re.tel)==null?void 0:ye[0])||"",address:(je=re.address)!=null&&je[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 de=new Set;Q.forEach((re,ne)=>{re.isDuplicate||de.add(ne)}),y(de),c("preview")}catch(X){console.error("Contact Picker error:",X),fn({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},I=X=>{var Q;const se=(Q=X.target.files)==null?void 0:Q[0];if(!se)return;const ee=new FileReader;ee.onload=de=>{var we;const re=(we=de.target)==null?void 0:we.result,ne=R1s(re);if(ne.length===0){fn({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const le=S(ne);p(le);const he=new Set;le.forEach((ye,je)=>{ye.isDuplicate||he.add(je)}),y(he),c("preview")},ee.readAsText(se),l.current&&(l.current.value="")},L=async()=>{const X=u.filter((ee,Q)=>f.has(Q));if(X.length===0)return;c("importing");let se=0;for(const ee of X)try{await o.mutateAsync({first_name:ee.first_name,last_name:ee.last_name||void 0,email:ee.email||void 0,phone:ee.phone||void 0,address:ee.address||void 0}),se++,j(Math.round(se/X.length*100))}catch(Q){console.error(`Failed to import ${ee.first_name} ${ee.last_name}:`,Q)}b(se),c("done")},R=X=>{y(se=>{const ee=new Set(se);return ee.has(X)?ee.delete(X):ee.add(X),ee})},$=()=>{f.size===u.length?y(new Set):y(new Set(u.map((X,se)=>se)))},q=X=>{X||(c("choose"),p([]),y(new Set),b(0),j(0),i==="done"&&r()),s(X)},U=u.filter(X=>X.isDuplicate).length,V=f.size;return e.jsx(_s,{open:t,onOpenChange:q,children:e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh]",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(i1,{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(Zr,{children:"Add contacts from your phone directly into Agent OS."})]}),i==="choose"&&e.jsxs("div",{className:"space-y-4 pt-2",children:[N&&e.jsxs(K,{onClick:T,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(i1,{className:"h-6 w-6"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-semibold",children:"Select from Phone"}),e.jsx("div",{className:"text-xs opacity-80",children:"Pick contacts directly from your device"})]})]}),e.jsxs("div",{className:"relative",children:[N&&e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),N&&e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"or"})})]}),e.jsxs(K,{variant:N?"outline":"default",onClick:()=>{var X;return(X=l.current)==null?void 0:X.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(ni,{className:"h-6 w-6"}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"font-semibold",children:"Upload Contact File"}),e.jsx("div",{className:"text-xs opacity-80",children:N?"Import a .vcf file exported from your Contacts app":"Export contacts from your phone as a .vcf file, then upload here"})]})]}),e.jsx("input",{ref:l,type:"file",accept:".vcf,.vcard",onChange:I,className:"hidden"}),!N&&e.jsxs("div",{className:"rounded-lg bg-muted p-3 text-sm text-muted-foreground space-y-2",children:[e.jsx("p",{className:"font-medium",children:"How to export contacts:"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-xs",children:"iPhone:"}),e.jsx("p",{className:"text-xs",children:'Open Contacts → select contacts → Share → choose "Export vCard"'})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-xs",children:"Android:"}),e.jsx("p",{className:"text-xs",children:"Open Contacts → Menu → Export → save as .vcf file"})]})]})]}),i==="preview"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{children:[u.length," contact",u.length!==1?"s":""," found",U>0&&e.jsxs("span",{className:"text-amber-600 ml-1",children:["(",U," already exist)"]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:$,children:f.size===u.length?"Deselect All":"Select All"})]}),e.jsx(Vi,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:u.map((X,se)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${X.isDuplicate?"opacity-60":""}`,onClick:()=>R(se),children:[e.jsx(Yo,{checked:f.has(se),onCheckedChange:()=>R(se),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[X.first_name," ",X.last_name]}),X.isDuplicate&&e.jsxs(nt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",X.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[X.phone&&e.jsx("div",{children:X.phone}),X.email&&e.jsx("div",{className:"truncate",children:X.email})]})]})]},se))})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c("choose"),children:"Back"}),e.jsxs(K,{onClick:L,disabled:V===0,children:["Import ",V," Contact",V!==1?"s":""]})]})]}),i==="importing"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx(Ss,{className:"h-8 w-8 animate-spin text-primary"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:"Importing contacts..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[w,"% complete"]})]}),e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${w}%`}})})]}),i==="done"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx(ma,{className:"h-6 w-6 text-emerald-600"})}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"font-semibold text-lg",children:[_," contact",_!==1?"s":""," imported!"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Your contacts are now in Agent OS and ready for touchpoint plans."})]}),e.jsx(K,{onClick:()=>q(!1),className:"mt-2",children:"Done"})]})]})})}function Ohe(){const t=ai();return wt({queryKey:["custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_custom_tags").select("*").eq("owner_user_id",t).order("name");if(r)throw r;return s},enabled:!!t})}function z1s(t){return wt({queryKey:["contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_custom_tag_assignments").select("*, tag:contact_custom_tags(*)").eq("contact_id",t);if(r)throw r;return s},enabled:!!t})}function R4e(){const t=ss(),s=ai();return Dt({mutationFn:async({name:r,color:n})=>{const{data:a,error:o}=await G.from("contact_custom_tags").insert({owner_user_id:s,name:r.trim(),color:n||"#6366F1"}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]})}})}function B1s(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("contact_custom_tags").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]}),t.invalidateQueries({queryKey:["contact-custom-tags"]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function $1s(){const t=ss();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 G.from("contact_custom_tags").update(a).eq("id",s);if(o)throw o},onSuccess:()=>{t.invalidateQueries({queryKey:["custom-tags"]}),t.invalidateQueries({queryKey:["contact-custom-tags"]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function xat(){const t=ss();return Dt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await G.from("contact_custom_tag_assignments").insert({contact_id:s,tag_id:r});if(n)throw n},onSuccess:(s,{contactId:r})=>{t.invalidateQueries({queryKey:["contact-custom-tags",r]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function q1s(){const t=ss();return Dt({mutationFn:async({contactId:s,tagId:r})=>{const{error:n}=await G.from("contact_custom_tag_assignments").delete().eq("contact_id",s).eq("tag_id",r);if(n)throw n},onSuccess:(s,{contactId:r})=>{t.invalidateQueries({queryKey:["contact-custom-tags",r]}),t.invalidateQueries({queryKey:["all-contact-custom-tags"]})}})}function U1s(){const t=ai();return wt({queryKey:["all-contact-custom-tags",t],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_custom_tag_assignments").select("contact_id, tag_id, tag:contact_custom_tags(id, name, color)");if(r)throw r;return s},enabled:!!t})}function V1s({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const i=Pr(),{data:c}=Rg(),u=cke(),p=ss(),{isGmailConnected:f}=D0(),{isReady:y}=I4e(),{data:_}=Ohe(),b=R4e(),w=xat(),[j,N]=C.useState(!1),[S,T]=C.useState(!1),[I,L]=C.useState(!1),[R,$]=C.useState(""),q=t.size;if(q===0)return null;const U=async re=>{N(!0);try{const le=Array.from(t).map(we=>({contact_id:we,relationship_type_id:re})),{error:he}=await G.from("innercircle_contact_tags").upsert(le,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(he)throw he;p.invalidateQueries({queryKey:["innercircle-contacts"]}),p.invalidateQueries({queryKey:["innercircle-contact-counts"]}),fn({title:`Assigned type to ${q} contacts`}),r()}catch(ne){fn({title:"Error assigning type",description:ne.message,variant:"destructive"})}finally{N(!1)}},V=async re=>{N(!0);try{const ne=Array.from(t);for(const le of ne)try{await w.mutateAsync({contactId:le,tagId:re})}catch{}p.invalidateQueries({queryKey:["all-contact-custom-tags"]}),fn({title:`Tagged ${q} contacts`}),L(!1),$("")}catch(ne){fn({title:"Error adding tags",description:ne.message,variant:"destructive"})}finally{N(!1)}},X=async()=>{if(R.trim()){N(!0);try{const re=await b.mutateAsync({name:R.trim()});await V(re.id)}catch(re){fn({title:"Error creating tag",description:re.message,variant:"destructive"}),N(!1)}}},se=(_==null?void 0:_.filter(re=>re.name.toLowerCase().includes(R.toLowerCase())))||[],ee=_==null?void 0:_.find(re=>re.name.toLowerCase()===R.trim().toLowerCase()),Q=()=>{const re=s.filter(ke=>t.has(ke.id)),ne=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],le=re.map(ke=>{var We;return[ke.first_name,ke.last_name||"",ke.email||"",ke.phone||"",ke.address||"",ke.birthday||"",ke.home_anniversary||"",ke.notes||"",((We=ke.tags)==null?void 0:We.map(be=>{var Me;return(Me=be.relationship_type)==null?void 0:Me.name}).join("; "))||""]}),he=[ne.join(","),...le.map(ke=>ke.map(We=>`"${(We||"").replace(/"/g,'""')}"`).join(","))].join(` `),we=new Blob([he],{type:"text/csv"}),ye=URL.createObjectURL(we),je=document.createElement("a");je.href=ye,je.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,je.click(),URL.revokeObjectURL(ye),fn({title:`Exported ${q} contacts`})},de=async()=>{if(confirm(`Are you sure you want to delete ${q} contacts? This cannot be undone.`)){N(!0);try{const re=Array.from(t);for(const ne of re)await u.mutateAsync(ne);r()}catch(re){fn({title:"Error deleting contacts",description:re.message,variant:"destructive"})}finally{N(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 border border-primary/20 rounded-lg",children:[e.jsxs(nt,{variant:"secondary",className:"font-semibold",children:[q," selected"]}),e.jsxs(rr,{onValueChange:U,disabled:j,children:[e.jsx(tr,{className:"w-[180px] h-8",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Tm,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:"Assign Type"})]})}),e.jsx(sr,{children:c==null?void 0:c.filter(re=>re.active).map(re=>e.jsx(Tt,{value:re.id,children:re.name},re.id))})]}),e.jsxs(Lo,{open:I,onOpenChange:L,children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",disabled:j,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(Eo,{className:"w-56 p-2",align:"start",children:[e.jsx(Fe,{placeholder:"Search or create tag...",value:R,onChange:re=>$(re.target.value),onKeyDown:re=>{re.key==="Enter"&&R.trim()&&!ee?(re.preventDefault(),X()):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:[se.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)),R.trim()&&!ee&&e.jsxs("button",{onClick:X,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx(Zs,{className:"h-3.5 w-3.5"}),'Create "',R.trim(),'"']}),se.length===0&&!R.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create a tag"})]})]})]}),f&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>T(!0),disabled:j,children:[e.jsx(br,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),y&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{const re=Array.from(t).join(",");i(`/admin/email-campaigns/new?contactIds=${re}`)},disabled:j,children:[e.jsx(bp,{className:"h-3.5 w-3.5 mr-1"}),"Mass Email"]}),a&&n&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>n(Array.from(t)),disabled:j,children:[e.jsx(Wx,{className:"h-3.5 w-3.5 mr-1"}),"Send to Lead Pond"]}),l&&o&&e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>o(Array.from(t)),disabled:j,children:[e.jsx(Gv,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:Q,disabled:j,children:[e.jsx(ki,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:de,disabled:j,className:"text-destructive hover:text-destructive",children:[e.jsx(jr,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:r,className:"ml-auto",children:[e.jsx(Ur,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),e.jsx(iE,{open:S,onOpenChange:T,bulkContacts:Array.from(t).map(re=>{const ne=s.find(le=>le.id===re);return ne?{id:ne.id,first_name:ne.first_name,last_name:ne.last_name,email:ne.email||""}:null}).filter(re=>re!==null&&re.email!==""),onSendComplete:()=>{T(!1),r()}})]})}function _Fe({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const c=Pr(),{isReady:u}=I4e(),p=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:f=>f.stopPropagation(),children:e.jsx(ig,{className:"h-4 w-4"})})}),e.jsxs(Jd,{align:"end",onClick:f=>f.stopPropagation(),children:[e.jsxs(Ta,{onClick:()=>c(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(ea,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(Ta,{onClick:()=>c(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(Ta,{onClick:()=>c(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(Ui,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),u&&t.email&&e.jsxs(Ta,{onClick:()=>c(`/admin/email-campaigns/new?contactIds=${t.id}`),children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Mass Email"]}),e.jsxs(Ta,{onClick:()=>n(t.id,p),children:[e.jsx(cf,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(Ta,{onClick:()=>a(t.id),children:[e.jsx(Wx,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(Ta,{onClick:()=>l(t.id),children:[e.jsx(Gv,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(Ta,{onClick:()=>s(t),children:[e.jsx($a,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ta,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function H1s(){const{user:t}=Ws();return wt({queryKey:["contact-smart-lists",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("contact_smart_lists").select("*").order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function W1s(){const t=ss(),{user:s}=Ws();return Dt({mutationFn:async({name:r,filters:n,sort_by:a})=>{const{data:o,error:l}=await G.from("contact_smart_lists").insert({owner_user_id:s.id,name:r,filters:n,sort_by:a}).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),fn({title:"Smart filter saved"})},onError:r=>{fn({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function G1s(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("contact_smart_lists").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-smart-lists"]}),fn({title:"Smart filter deleted"})}})}function K1s({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=H1s(),a=W1s(),o=G1s(),[l,i]=C.useState(!1),[c,u]=C.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(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(a0,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(nt,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(tl,{className:"h-3.5 w-3.5"})]})}),e.jsxs(Jd,{align:"start",className:"w-56",children:[n&&n.length>0?e.jsxs(e.Fragment,{children:[n.map(y=>e.jsxs(Ta,{className:"flex items-center justify-between group",children:[e.jsx("span",{className:"flex-1 cursor-pointer",onClick:()=>r(y.filters,y.sort_by),children:y.name}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",onClick:_=>{_.stopPropagation(),o.mutate(y.id)},children:e.jsx(jr,{className:"h-3 w-3 text-destructive"})})]},y.id)),e.jsx(r2,{})]}):e.jsx(Ta,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),p&&e.jsxs(Ta,{onClick:()=>i(!0),children:[e.jsx(EI,{className:"h-4 w-4 mr-2"}),"Save Current Filter"]})]})]}),e.jsx(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{className:"max-w-sm",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Save Smart Filter"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Fe,{placeholder:"e.g. Buyers in 40205",value:c,onChange:y=>u(y.target.value),onKeyDown:y=>y.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 dI(t){if(!t)return null;try{const s=t.split(/[-/T]/);if(s.length<3)return null;const r=parseInt(s[1],10)-1,n=parseInt(s[2],10);if(isNaN(r)||isNaN(n))return null;const a=new Date;a.setHours(0,0,0,0);let o=new Date(a.getFullYear(),r,n);return o.setHours(0,0,0,0),or)return null;const a=s==="birthday"?"🎂":"🏡",o=n===0?s==="birthday"?"Birthday today!":"Anniversary today!":n===1?s==="birthday"?"Birthday tomorrow":"Anniversary tomorrow":`${a} in ${n}d`;return{emoji:a,label:o,daysUntil:n}}function wFe({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=Pr(),i=bFe(t,"birthday",7),c=bFe(s,"anniversary",7);if(!i&&!c)return null;const u=(p,f)=>{f.stopPropagation();const y=new URLSearchParams;n&&y.set("contactId",n),a&&y.set("name",a),o&&y.set("address",o),p==="home_anniversary"&&s&&y.set("date",s),y.set("cardType",p),l(`/mission-control/card-studio?${y.toString()}`)};return e.jsxs("div",{className:At("flex flex-wrap gap-1",r),children:[i&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(nt,{variant:"secondary",className:At("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(br,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),c&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(nt,{variant:"secondary",className:At("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(br,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function jFe({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(nt,{variant:"outline",className:"text-[10px] gap-1 font-medium whitespace-nowrap",style:{borderColor:s.color,color:s.color,backgroundColor:`${s.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:s.color}}),s.name]})}function Z1s(){const t=ai();return wt({queryKey:["contact-deals-map",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_pipeline").select(` id, deal_name, contact_id, stage:deal_pipeline_stages(id, name, color, icon, is_won_stage, is_lost_stage) `).not("contact_id","is",null);if(r)throw r;const n={};return(s||[]).forEach(a=>{a.contact_id&&!n[a.contact_id]&&(n[a.contact_id]=a)}),n},enabled:!!t})}function Y1s({contactId:t,compact:s=!1}){const{data:r}=Ohe(),{data:n}=z1s(t),a=R4e(),o=xat(),l=q1s(),[i,c]=C.useState(!1),[u,p]=C.useState(""),f=C.useRef(null),y=new Set((n==null?void 0:n.map(N=>N.tag_id))||[]),_=(r==null?void 0:r.filter(N=>N.name.toLowerCase().includes(u.toLowerCase())))||[],b=r==null?void 0:r.find(N=>N.name.toLowerCase()===u.trim().toLowerCase()),w=async N=>{y.has(N.id)?await l.mutateAsync({contactId:t,tagId:N.id}):await o.mutateAsync({contactId:t,tagId:N.id})},j=async()=>{if(!(!u.trim()||b))try{const N=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:N.id}),p("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(N=>{var S,T,I;return e.jsxs(nt,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((S=N.tag)==null?void 0:S.color)||"#6366F1",color:((T=N.tag)==null?void 0:T.color)||"#6366F1"},children:[e.jsx(Tm,{className:"h-2.5 w-2.5"}),(I=N.tag)==null?void 0:I.name,e.jsx("button",{onClick:L=>{L.stopPropagation(),l.mutate({contactId:t,tagId:N.tag_id})},className:"ml-0.5 rounded-full hover:bg-accent p-0.5",children:e.jsx(Ur,{className:"h-2.5 w-2.5"})})]},N.id)}),e.jsxs(Lo,{open:i,onOpenChange:c,children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:s?"h-6 w-6 p-0":"h-6 px-2 text-xs",onClick:N=>N.stopPropagation(),children:[e.jsx(Zs,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(Eo,{className:"w-56 p-2",align:"start",onClick:N=>N.stopPropagation(),children:[e.jsx(Fe,{ref:f,placeholder:"Search or create tag...",value:u,onChange:N=>p(N.target.value),onKeyDown:N=>{N.key==="Enter"&&u.trim()&&!b?(N.preventDefault(),j()):N.key==="Enter"&&b&&!y.has(b.id)&&(N.preventDefault(),w(b))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[_.map(N=>e.jsxs("button",{onClick:()=>w(N),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors",children:[e.jsx("div",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:N.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:N.name}),y.has(N.id)&&e.jsx(ma,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},N.id)),u.trim()&&!b&&e.jsxs("button",{onClick:j,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-sm hover:bg-accent transition-colors text-primary",children:[e.jsx(Zs,{className:"h-3.5 w-3.5"}),'Create "',u.trim(),'"']}),_.length===0&&!u.trim()&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-2",children:"Type to create your first tag"})]})]})]})]})}function kFe({contactId:t,tags:s}){return!s||s.length===0?null:e.jsx(e.Fragment,{children:s.map(r=>{var n,a,o;return e.jsx(nt,{variant:"outline",className:"text-[10px] gap-0.5",style:{borderColor:((n=r.tag)==null?void 0:n.color)||"#6366F1",color:((a=r.tag)==null?void 0:a.color)||"#6366F1"},children:(o=r.tag)==null?void 0:o.name},r.tag_id)})})}const kz=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function X1s({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Ohe(),a=R4e(),o=$1s(),l=B1s(),[i,c]=C.useState(""),[u,p]=C.useState(kz[0]),[f,y]=C.useState(null),[_,b]=C.useState(""),[w,j]=C.useState(""),N=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),c(""),p(kz[0]),fn({title:"Tag created"})}catch(L){fn({title:"Error",description:L.message,variant:"destructive"})}},S=async L=>{if(_.trim())try{await o.mutateAsync({id:L,name:_.trim(),color:w}),y(null),fn({title:"Tag updated"})}catch(R){fn({title:"Error",description:R.message,variant:"destructive"})}},T=async(L,R)=>{if(confirm(`Delete tag "${R}"? It will be removed from all contacts.`))try{await l.mutateAsync(L),fn({title:"Tag deleted"})}catch($){fn({title:"Error",description:$.message,variant:"destructive"})}},I=L=>{y(L.id),b(L.name),j(L.color)};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Manage Tags"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{placeholder:"New tag name...",value:i,onChange:L=>c(L.target.value),onKeyDown:L=>L.key==="Enter"&&N(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:N,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:kz.map(L=>e.jsx("button",{onClick:()=>p(L),className:`h-6 w-6 rounded-full border-2 transition-transform ${u===L?"border-foreground scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:L}},L))})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[320px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No tags yet. Create one above!"}),r==null?void 0:r.map(L=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:f===L.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:kz.map(R=>e.jsx("button",{onClick:()=>j(R),className:`h-5 w-5 rounded-full border-2 ${w===R?"border-foreground":"border-transparent"}`,style:{backgroundColor:R}},R))}),e.jsx(Fe,{value:_,onChange:R=>b(R.target.value),onKeyDown:R=>R.key==="Enter"&&S(L.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>S(L.id),children:e.jsx(ma,{className:"h-4 w-4 text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>y(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-3.5 w-3.5 rounded-full shrink-0",style:{backgroundColor:L.color}}),e.jsx("span",{className:"flex-1 text-sm",children:L.name}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>I(L),children:e.jsx($a,{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:()=>T(L.id,L.name),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})},L.id))]})]})})}function Q1s({open:t,onOpenChange:s}){const{data:r,isLoading:n}=FA(),a=hke(),o=rLt(),l=nLt(),[i,c]=C.useState(""),[u,p]=C.useState(null),[f,y]=C.useState(""),_=async()=>{if(i.trim())try{await a.mutateAsync(i.trim()),c("")}catch(N){me.error(N.message||"Failed to add lead source")}},b=async N=>{if(f.trim())try{await o.mutateAsync({id:N,name:f.trim()}),p(null)}catch(S){me.error(S.message||"Failed to update")}},w=async(N,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(N)}catch(T){me.error(T.message||"Failed to remove")}},j=N=>{p(N.id),y(N.name)};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Manage Lead Sources"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{placeholder:"New lead source name...",value:i,onChange:N=>c(N.target.value),onKeyDown:N=>N.key==="Enter"&&_(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:_,disabled:!i.trim()||a.isPending,className:"h-9",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add"]})]}),e.jsxs("div",{className:"mt-2 space-y-1 max-h-[360px] overflow-y-auto",children:[n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading..."}),(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No lead sources yet. Create one above!"}),r==null?void 0:r.map(N=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:u===N.id?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{value:f,onChange:S=>y(S.target.value),onKeyDown:S=>S.key==="Enter"&&b(N.id),className:"flex-1 h-8 text-sm",autoFocus:!0}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>b(N.id),children:e.jsx(ma,{className:"h-4 w-4 text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>p(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-sm",children:N.name}),N.owner_user_id&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>j(N),children:e.jsx($a,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity text-destructive hover:text-destructive",onClick:()=>w(N.id,N.name),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]}),!N.owner_user_id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default"})]})},N.id))]})]})})}function yat({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=FA(),a=hke(),[o,l]=C.useState(!1),[i,c]=C.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(_e,{children:r}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(rr,{value:t||"_none",onValueChange:p=>s(p==="_none"?"":p),children:[e.jsx(tr,{className:"flex-1",children:e.jsx(nr,{placeholder:"Select lead source"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"_none",children:"No source"}),n==null?void 0:n.map(p=>e.jsx(Tt,{value:p.id,children:p.name},p.id))]})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",className:"shrink-0",onClick:()=>l(!o),children:o?e.jsx(Ur,{className:"h-4 w-4"}):e.jsx(Zs,{className:"h-4 w-4"})})]}),o&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{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 Tbe({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=Pr(),[c,u]=C.useState(!1),[p,f]=C.useState(""),{data:y}=wt({queryKey:["innercircle-contact-spouse",s],queryFn:async()=>{const{data:b,error:w}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone, birthday").eq("id",s).maybeSingle();if(w)throw w;return b},enabled:!!s}),{data:_}=wt({queryKey:["spouse-search",p],queryFn:async()=>{let b=G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").neq("id",t).order("first_name").limit(20);p.trim()&&(b=b.or(`first_name.ilike.%${p}%,last_name.ilike.%${p}%,email.ilike.%${p}%,phone.ilike.%${p}%`));const{data:w,error:j}=await b;if(j)throw j;return w},enabled:c});if(s&&y){const b=`${y.first_name} ${y.last_name||""}`.trim();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-3 py-2",children:[e.jsx(ro,{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/${y.id}`),className:"text-sm font-medium text-primary hover:underline truncate block",children:b}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:[y.phone,y.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(Z4,{className:"h-3.5 w-3.5 mr-1"}),"Unlink"]}),!l&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>i(`/mission-control/contacts/${y.id}`),className:"shrink-0 h-7 px-2",children:e.jsx(Ki,{className:"h-3.5 w-3.5"})})]})]})}return!s&&(r||n)?e.jsxs("div",{className:"space-y-1",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-3 py-2",children:[e.jsx(ro,{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(Lo,{open:c,onOpenChange:u,children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"shrink-0 h-7 px-2",children:[e.jsx(sl,{className:"h-3.5 w-3.5 mr-1"}),"Link Contact"]})}),e.jsx(Eo,{className:"w-72 p-2",align:"end",children:e.jsx(NFe,{search:p,setSearch:f,results:_,onSelect:b=>{a(b),u(!1),f("")}})})]})]})]}):l?e.jsxs("div",{className:"space-y-1",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs(Lo,{open:c,onOpenChange:u,children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full justify-start text-muted-foreground font-normal h-10",children:[e.jsx(sl,{className:"h-4 w-4 mr-2"}),"Link an existing contact as spouse..."]})}),e.jsx(Eo,{className:"w-72 p-2",align:"start",children:e.jsx(NFe,{search:p,setSearch:f,results:_,onSelect:b=>{a(b),u(!1),f("")}})})]})]}):null}function NFe({search:t,setSearch:s,results:r,onSelect:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Fe,{value:t,onChange:a=>s(a.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Vi,{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 J1s(){var Gn;const t=Pr(),[s]=Xc(),{user:r}=Ws(),n=oE(),a=ss(),o=s.get("type"),l=s.get("filter")??s.get("status"),i=s.get("new")==="true",{contactsWithScores:c,isLoading:u}=pue(),{data:p}=Rg(),{data:f}=Z1s(),{data:y}=Ohe(),{data:_}=U1s(),[b,w]=C.useState(new Set),[j,N]=C.useState("any"),S=uue(),T=lke(),I=cke(),L=mYe(),[R,$]=C.useState(""),[q,U]=C.useState(o||"all"),[V,X]=C.useState(l||"all"),[se,ee]=C.useState("date-added"),[Q,de]=C.useState(i),[re,ne]=C.useState(null),[le,he]=C.useState(!1),[we,ye]=C.useState(!1),[je,ke]=C.useState(null),[We,be]=C.useState(""),[Me,Ae]=C.useState(new Set),[Re,Te]=C.useState(!1),[qe,ct]=C.useState(1),[De,Rt]=C.useState(50),[pe,Je]=C.useState("my"),[lt,rt]=C.useState(!1),[Se,it]=C.useState(!1),{data:$e}=Lg(),{addToLeadPond:ot}=Aet($e==null?void 0:$e.teamId),Ue=!!((Gn=$e==null?void 0:$e.team)!=null&&Gn.lead_pond_enabled&&($e!=null&&$e.teamId)),Ke=!!($e!=null&&$e.teamId),[Xe,He]=C.useState([]),[Ye,tt]=C.useState(!1),Et=Zt=>{He([Zt]),tt(!0)},qt=Zt=>{He(Zt),tt(!0)},ms=Zt=>{$e!=null&&$e.teamId&&ot.mutate({contact_id:Zt,team_id:$e.teamId})},Xt=Zt=>{$e!=null&&$e.teamId&&Zt.forEach($r=>{ot.mutate({contact_id:$r,team_id:$e.teamId})})},rs=C.useCallback(Zt=>{Te(!1),Ae($r=>{const es=new Set($r);return es.has(Zt)?es.delete(Zt):es.add(Zt),es})},[]);C.useEffect(()=>{if(!(r!=null&&r.id))return;const Zt=G.channel(`innercircle_contacts_inserts_${r.id}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"innercircle_contacts",filter:`owner_user_id=eq.${r.id}`},()=>{a.invalidateQueries({queryKey:["innercircle-contacts"]}),a.invalidateQueries({queryKey:["innercircle-contact-counts"]})}).subscribe();return()=>{G.removeChannel(Zt)}},[a,r==null?void 0:r.id]),C.useEffect(()=>{l&&X(l)},[l]);const[ps,Ms]=C.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]});C.useEffect(()=>{i&&de(!0)},[i]),C.useEffect(()=>{var Zt;re&&Ms({first_name:re.first_name||"",last_name:re.last_name||"",email:re.email||"",phone:re.phone||"",address:re.address||"",city:re.city||"",state:re.state||"",zip_code:re.zip_code||"",birthday:re.birthday||"",home_anniversary:re.home_anniversary||"",spouse_name:re.spouse_name||"",spouse_email:re.spouse_email||"",lead_source_id:re.lead_source_id||"",notes:re.notes||"",tagIds:((Zt=re.tags)==null?void 0:Zt.map($r=>$r.relationship_type_id))||[]})},[re]);const jt=C.useMemo(()=>{if(!c)return[];let Zt=c.filter($r=>{var Xn,Ir,_i;const es=R===""||`${$r.first_name} ${$r.last_name}`.toLowerCase().includes(R.toLowerCase())||((Xn=$r.email)==null?void 0:Xn.toLowerCase().includes(R.toLowerCase()))||((Ir=$r.phone)==null?void 0:Ir.includes(R)),an=q==="all"||((_i=$r.tags)==null?void 0:_i.some(rl=>rl.relationship_type_id===q)),Ha=b.size===0||(()=>{const rl=(_==null?void 0:_.filter(Ni=>Ni.contact_id===$r.id).map(Ni=>Ni.tag_id))||[];return j==="any"?rl.some(Ni=>b.has(Ni)):Array.from(b).every(Ni=>rl.includes(Ni))})();return es&&an&&Ha});return V==="not-touched-90"?Zt=Zt.filter($r=>{const es=$r.relationshipScore.daysSinceTouch;return es===null||es>90}):V==="at-risk"?Zt=Zt.filter($r=>$r.relationshipScore.status==="at-risk"):V==="cooling"?Zt=Zt.filter($r=>$r.relationshipScore.status==="cooling"):V==="warm"?Zt=Zt.filter($r=>$r.relationshipScore.status==="warm"):V==="has-deal"?Zt=Zt.filter($r=>f&&f[$r.id]):V==="no-deal"?Zt=Zt.filter($r=>!f||!f[$r.id]):V==="open-house"&&(Zt=Zt.filter($r=>{var an;return(((an=$r.lead_source_ref)==null?void 0:an.name)||$r.lead_source)==="Open House"})),Zt=[...Zt].sort(($r,es)=>{switch(se){case"important-dates":{const an=dI($r.birthday),Ha=dI(es.birthday),Xn=dI($r.home_anniversary),Ir=dI(es.home_anniversary),_i=[an,Xn].filter(Ni=>Ni!==null).sort((Ni,sc)=>(Ni??1/0)-(sc??1/0))[0]??1/0,rl=[Ha,Ir].filter(Ni=>Ni!==null).sort((Ni,sc)=>(Ni??1/0)-(sc??1/0))[0]??1/0;return _i-rl}case"last-touched":{const an=$r.relationshipScore.lastTouchDate,Ha=es.relationshipScore.lastTouchDate;return!an&&!Ha?0:an?Ha?new Date(an).getTime()-new Date(Ha).getTime():1:-1}case"next-touch":{const an=$r.relationshipScore.daysSinceTouch,Ha=es.relationshipScore.daysSinceTouch;return an===null&&Ha===null?0:an===null?-1:Ha===null?1:Ha-an}case"score":return $r.relationshipScore.score-es.relationshipScore.score;case"date-added":{const an=$r.created_at,Ha=es.created_at;return!an&&!Ha?0:an?Ha?new Date(Ha).getTime()-new Date(an).getTime():-1:1}case"name":default:{const an=`${$r.first_name||""} ${$r.last_name||""}`.toLowerCase(),Ha=`${es.first_name||""} ${es.last_name||""}`.toLowerCase();return an.localeCompare(Ha)}}}),Zt},[c,R,q,b,j,V,se,f,_]),As=jt.length,Ps=Math.max(1,Math.ceil(As/De)),ar=Math.min(qe,Ps),Dn=C.useMemo(()=>{const Zt=(ar-1)*De;return jt.slice(Zt,Zt+De)},[jt,ar,De]);C.useEffect(()=>{ct(1)},[R,q,b,j,V,se]);const Va=C.useCallback(()=>{Te(!1),Ae(Zt=>Zt.size>0?new Set:new Set(Dn.map($r=>$r.id)))},[Dn]),pa=C.useCallback(()=>{Te(!0),Ae(new Set(jt.map(Zt=>Zt.id)))},[jt]),qa=C.useCallback((Zt,$r)=>{$(Zt.search||""),U(Zt.type||"all"),X(Zt.status||"all"),ee($r||"name")},[]),Kr=()=>{Ms({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},Yn=async Zt=>{Zt.preventDefault();const $r={...ps,lead_source_id:ps.lead_source_id||null};re?(await T.mutateAsync({id:re.id,...$r}),ne(null)):(await S.mutateAsync($r),de(!1)),Kr()},mn=async Zt=>{confirm("Are you sure you want to delete this contact?")&&await I.mutateAsync(Zt)};return e.jsx(Es,{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"})]}),$e&&e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsx("button",{onClick:()=>Je("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${pe==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),($e.team.contact_visibility==="full_team"||$e.team.contact_visibility==="leader_only"&&$e.role==="team_leader")&&e.jsxs("button",{onClick:()=>Je("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${pe==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(mr,{className:"h-3.5 w-3.5"}),"Team"]}),$e.team.lead_pond_enabled&&e.jsxs("button",{onClick:()=>Je("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${pe==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Wx,{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(Xl,{className:"h-4 w-4 mr-1"}),"Back"]})}),pe==="team"?e.jsx(gNe,{}):pe==="lead-pond"&&$e?e.jsx(xNe,{teamId:$e.teamId}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name, email, or phone...",value:R,onChange:Zt=>$(Zt.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto pb-1",children:[e.jsxs(K,{onClick:()=>de(!0),className:"shrink-0",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),e.jsxs(K,{variant:"outline",onClick:()=>he(!0),className:"shrink-0",children:[e.jsx(ni,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(K,{variant:"outline",onClick:()=>ye(!0),className:"shrink-0",children:[e.jsx(i1,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx(j1s,{})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(rr,{value:q,onValueChange:U,children:[e.jsx(tr,{className:"w-[145px] h-9 text-sm",children:e.jsx(nr,{placeholder:"Filter by type"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Types"}),p==null?void 0:p.filter(Zt=>Zt.active).map(Zt=>e.jsx(Tt,{value:Zt.id,children:Zt.name},Zt.id))]})]}),y&&y.length>0&&e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"h-9 justify-start text-sm",children:[e.jsx(Tm,{className:"h-3.5 w-3.5 mr-1.5 shrink-0 text-muted-foreground"}),b.size===0?"Filter by Tags":`${b.size} tag${b.size>1?"s":""}`]})}),e.jsx(Eo,{className:"w-60 p-3",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Tags"}),e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-md p-0.5",children:[e.jsx("button",{onClick:()=>N("any"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${j==="any"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"Any"}),e.jsx("button",{onClick:()=>N("all"),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${j==="all"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:"All"})]})]}),e.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:y.map(Zt=>{const $r=b.has(Zt.id);return e.jsxs("button",{onClick:()=>{w(es=>{const an=new Set(es);return an.has(Zt.id)?an.delete(Zt.id):an.add(Zt.id),an})},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(Yo,{checked:$r,className:"pointer-events-none"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:Zt.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:Zt.name})]},Zt.id)})}),b.size>0&&e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>w(new Set),children:"Clear tags"})]})})]}),e.jsxs(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",title:"Settings",children:e.jsx(Jl,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs(Jd,{align:"end",children:[e.jsxs(Ta,{onClick:()=>rt(!0),children:[e.jsx(Tm,{className:"h-4 w-4 mr-2"}),"Manage Tags"]}),e.jsxs(Ta,{onClick:()=>it(!0),children:[e.jsx(Wx,{className:"h-4 w-4 mr-2"}),"Manage Lead Sources"]})]})]}),e.jsxs(rr,{value:V,onValueChange:X,children:[e.jsx(tr,{className:"w-[145px] h-9 text-sm",children:e.jsx(nr,{placeholder:"Filter by status"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Status"}),e.jsx(Tt,{value:"warm",children:"🟢 Warm"}),e.jsx(Tt,{value:"cooling",children:"🟡 Cooling Off"}),e.jsx(Tt,{value:"at-risk",children:"🔴 At Risk"}),e.jsx(Tt,{value:"has-deal",children:"📋 Has Deal"}),e.jsx(Tt,{value:"no-deal",children:"📭 No Deal"}),e.jsx(Tt,{value:"open-house",children:"🏠 Open House"})]})]}),e.jsxs(rr,{value:se,onValueChange:ee,children:[e.jsx(tr,{className:"w-[165px] h-9 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ud,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(nr,{placeholder:"Sort by"})]})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"name",children:"Name (A-Z)"}),e.jsx(Tt,{value:"important-dates",children:"Important Dates"}),e.jsx(Tt,{value:"last-touched",children:"Last Touched"}),e.jsx(Tt,{value:"next-touch",children:"Next Touch Due"}),e.jsx(Tt,{value:"score",children:"Relationship Score"}),e.jsx(Tt,{value:"date-added",children:"Date Added"})]})]}),e.jsx(K1s,{currentFilters:{search:R,type:q,status:V},currentSortBy:se,onApplySmartList:qa})]})]})})}),e.jsx(V1s,{selectedIds:Me,contacts:jt,onClearSelection:()=>{Ae(new Set),Te(!1)},showLeadPondAction:Ue,onSendToLeadPond:Xt,showTransferAction:Ke,onTransfer:qt}),Me.size>0&&Me.size===Dn.length&&!Re&&As>De&&e.jsxs("div",{className:"flex items-center justify-center gap-2 p-2 bg-primary/5 border border-primary/20 rounded-lg text-sm",children:[e.jsxs("span",{children:["All ",Dn.length," contacts on this page are selected."]}),e.jsxs(K,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:pa,children:["Select all ",As.toLocaleString()," matching contacts"]})]}),Re&&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 ",As.toLocaleString()," matching contacts are selected.",e.jsx(K,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{Ae(new Set),Te(!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..."}):jt.length===0?e.jsx(Ee,{className:"p-6 text-center text-muted-foreground",children:R||q!=="all"||V!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):Dn.map(Zt=>{var es,an,Ha;const{relationshipScore:$r}=Zt;return e.jsx(Ee,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const Xn=new URLSearchParams;R&&Xn.set("search",R),q!=="all"&&Xn.set("type",q),V!=="all"&&Xn.set("filter",V);const Ir=Xn.toString();t(`/mission-control/contacts/${Zt.id}${Ir?`?${Ir}`:""}`)},children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("h3",{className:"font-semibold text-base truncate",children:[Zt.first_name," ",Zt.last_name]}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground shrink-0"})]}),e.jsxs("div",{className:"space-y-1 text-sm mb-3",children:[Zt.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(br,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:Zt.email})]}),Zt.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ea,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:Zt.phone})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[e.jsx(e8,{score:$r,size:"sm"}),e.jsx(Mbe,{contact:Zt}),(((es=Zt.lead_source_ref)==null?void 0:es.name)||Zt.lead_source)&&e.jsx(nt,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((an=Zt.lead_source_ref)==null?void 0:an.name)||Zt.lead_source}),(Ha=Zt.tags)==null?void 0:Ha.map(Xn=>{var Ir;return e.jsx(nt,{variant:"secondary",className:"text-xs",children:(Ir=Xn.relationship_type)==null?void 0:Ir.name},Xn.id)}),e.jsx(kFe,{contactId:Zt.id,tags:_==null?void 0:_.filter(Xn=>Xn.contact_id===Zt.id)}),e.jsx(jFe,{deal:f==null?void 0:f[Zt.id]})]}),e.jsx(wFe,{birthday:Zt.birthday,homeAnniversary:Zt.home_anniversary,className:"mb-2",contactId:Zt.id,contactName:`${Zt.first_name}${Zt.last_name?" "+Zt.last_name:""}`,contactAddress:[Zt.address,Zt.city,Zt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[$r.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),ys(new Date($r.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),Zt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ys(Ml(Zt.birthday),"MMM d")]}),Zt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Rn,{className:"h-3 w-3"}),ys(Ml(Zt.home_anniversary),"MMM d")]}),Zt.created_at&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Zs,{className:"h-3 w-3"}),"Added ",ys(new Date(Zt.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:Xn=>Xn.stopPropagation(),children:e.jsx(_Fe,{contact:Zt,onEdit:ne,onDelete:mn,onSnooze:(Xn,Ir)=>{ke(Xn),be(Ir)},showLeadPondAction:Ue,onSendToLeadPond:ms,showTransferAction:Ke,onTransfer:Et})})]})})},Zt.id)})}):e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0 overflow-x-auto",children:e.jsxs(An,{className:"min-w-[800px]",children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"w-[40px]",children:e.jsx(Yo,{checked:Dn.length>0&&Dn.every(Zt=>Me.has(Zt.id)),onCheckedChange:()=>Va()})}),e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Score"}),e.jsx(bt,{children:"Contact Info"}),e.jsx(bt,{children:"Types / Pipeline"}),e.jsx(bt,{children:"Last Contact"}),e.jsx(bt,{className:"cursor-pointer select-none",onClick:()=>ee(se==="date-added"?"name":"date-added"),children:e.jsxs("div",{className:"flex items-center gap-1",children:["Date Added",se==="date-added"&&e.jsx(ud,{className:"h-3 w-3"})]})}),e.jsx(bt,{children:"Important Dates"}),e.jsx(bt,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(Pn,{children:u?e.jsx(ks,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):jt.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:R||q!=="all"||V!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):Dn.map(Zt=>{var an,Ha,Xn;const{relationshipScore:$r}=Zt,es=f==null?void 0:f[Zt.id];return e.jsxs(ks,{className:`cursor-pointer hover:bg-accent/50 ${Me.has(Zt.id)?"bg-accent/30":""}`,onClick:()=>{const Ir=new URLSearchParams;R&&Ir.set("search",R),q!=="all"&&Ir.set("type",q),V!=="all"&&Ir.set("status",V);const _i=Ir.toString();t(`/mission-control/contacts/${Zt.id}${_i?`?${_i}`:""}`)},children:[e.jsx(dt,{onClick:Ir=>Ir.stopPropagation(),children:e.jsx(Yo,{checked:Me.has(Zt.id),onCheckedChange:()=>rs(Zt.id)})}),e.jsxs(dt,{className:"font-medium",children:[Zt.first_name," ",Zt.last_name]}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(e8,{score:$r,size:"sm"}),e.jsx(Mbe,{contact:Zt})]})}),e.jsx(dt,{children:e.jsx(e8,{score:$r,size:"sm",showScore:!0})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[Zt.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(br,{className:"h-3 w-3"}),Zt.email]}),Zt.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(ea,{className:"h-3 w-3"}),Zt.phone]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((an=Zt.lead_source_ref)==null?void 0:an.name)||Zt.lead_source)&&e.jsx(nt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((Ha=Zt.lead_source_ref)==null?void 0:Ha.name)||Zt.lead_source}),(Xn=Zt.tags)==null?void 0:Xn.map(Ir=>{var _i;return e.jsx(nt,{variant:"secondary",className:"text-xs",children:(_i=Ir.relationship_type)==null?void 0:_i.name},Ir.id)}),e.jsx(kFe,{contactId:Zt.id,tags:_==null?void 0:_.filter(Ir=>Ir.contact_id===Zt.id)}),e.jsx(jFe,{deal:es})]})}),e.jsx(dt,{children:e.jsx("div",{className:"text-sm",children:$r.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3"}),ys(new Date($r.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:Zt.created_at?ys(new Date(Zt.created_at),"MMM d, yyyy"):"—"})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(wFe,{birthday:Zt.birthday,homeAnniversary:Zt.home_anniversary,contactId:Zt.id,contactName:`${Zt.first_name}${Zt.last_name?" "+Zt.last_name:""}`,contactAddress:[Zt.address,Zt.city,Zt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Zt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ys(Ml(Zt.birthday),"MMM d")]}),Zt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Rn,{className:"h-3 w-3"}),ys(Ml(Zt.home_anniversary),"MMM d")]})]})]})}),e.jsx(dt,{children:e.jsx(_Fe,{contact:Zt,onEdit:ne,onDelete:mn,onSnooze:(Ir,_i)=>{ke(Ir),be(_i)},showLeadPondAction:Ue,onSendToLeadPond:ms,showTransferAction:Ke,onTransfer:Et})})]},Zt.id)})})]})})}),As>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsxs("span",{children:["Showing ",(ar-1)*De+1,"–",Math.min(ar*De,As)," of ",As.toLocaleString()," contacts"]}),e.jsxs(rr,{value:String(De),onValueChange:Zt=>{Rt(Number(Zt)),ct(1)},children:[e.jsx(tr,{className:"w-[80px] h-8",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"50",children:"50"}),e.jsx(Tt,{value:"100",children:"100"}),e.jsx(Tt,{value:"250",children:"250"})]})]}),e.jsx("span",{className:"text-xs",children:"per page"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",disabled:ar<=1,onClick:()=>ct(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:ar<=1,onClick:()=>ct(Zt=>Zt-1),children:e.jsx(Xl,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",ar," of ",Ps]}),e.jsx(K,{variant:"outline",size:"sm",disabled:ar>=Ps,onClick:()=>ct(Zt=>Zt+1),children:e.jsx(Xa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:ar>=Ps,onClick:()=>ct(Ps),children:"Last"})]})]}),e.jsx(_s,{open:Q||!!re,onOpenChange:Zt=>{Zt||(de(!1),ne(null),Kr())},children:e.jsxs(vs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:re?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:Yn,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"first_name",children:"First Name *"}),e.jsx(Fe,{id:"first_name",value:ps.first_name,onChange:Zt=>Ms({...ps,first_name:Zt.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Fe,{id:"last_name",value:ps.last_name,onChange:Zt=>Ms({...ps,last_name:Zt.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"email",children:"Email"}),e.jsx(Fe,{id:"email",type:"email",value:ps.email,onChange:Zt=>Ms({...ps,email:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"phone",children:"Phone"}),e.jsx(Fe,{id:"phone",value:ps.phone,onChange:Zt=>Ms({...ps,phone:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"address",children:"Address"}),e.jsx(Fe,{id:"address",value:ps.address,onChange:Zt=>Ms({...ps,address:Zt.target.value}),placeholder:"Street address"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"city",children:"City"}),e.jsx(Fe,{id:"city",value:ps.city,onChange:Zt=>Ms({...ps,city:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"state",children:"State"}),e.jsx(Fe,{id:"state",value:ps.state,onChange:Zt=>Ms({...ps,state:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"zip_code",children:"Zip"}),e.jsx(Fe,{id:"zip_code",value:ps.zip_code,onChange:Zt=>Ms({...ps,zip_code:Zt.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"birthday",children:"Birthday"}),e.jsx(Fe,{id:"birthday",type:"date",value:ps.birthday,onChange:Zt=>Ms({...ps,birthday:Zt.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Fe,{id:"home_anniversary",type:"date",value:ps.home_anniversary,onChange:Zt=>Ms({...ps,home_anniversary:Zt.target.value})})]})]}),re&&e.jsx(Tbe,{contactId:re.id,currentSpouseContactId:(re==null?void 0:re.spouse_contact_id)||null,currentSpouseName:(re==null?void 0:re.spouse_name)||null,currentSpouseEmail:(re==null?void 0:re.spouse_email)||null,onLink:Zt=>L.mutate({contactId:re.id,spouseContactId:Zt}),onUnlink:()=>L.mutate({contactId:re.id,spouseContactId:null}),isEditing:!0}),e.jsx(yat,{value:ps.lead_source_id,onChange:Zt=>Ms({...ps,lead_source_id:Zt})}),e.jsxs("div",{children:[e.jsx(_e,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:p==null?void 0:p.filter(Zt=>Zt.active).map(Zt=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Yo,{checked:ps.tagIds.includes(Zt.id),onCheckedChange:$r=>{Ms($r?{...ps,tagIds:[...ps.tagIds,Zt.id]}:{...ps,tagIds:ps.tagIds.filter(es=>es!==Zt.id)})}}),e.jsx("span",{className:"text-sm",children:Zt.name})]},Zt.id))})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"notes",children:"Notes"}),e.jsx(Ar,{id:"notes",value:ps.notes,onChange:Zt=>Ms({...ps,notes:Zt.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{de(!1),ne(null),Kr()},children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:S.isPending||T.isPending,children:[re?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(D1s,{open:le,onOpenChange:he,relationshipTypes:(p==null?void 0:p.filter(Zt=>Zt.active))||[],onSuccess:()=>{he(!1)}}),e.jsx(F1s,{open:we,onOpenChange:ye,onComplete:()=>ye(!1)}),e.jsx(Lhe,{open:!!je,onOpenChange:Zt=>{Zt||ke(null)},contactId:je||"",contactName:We}),e.jsx(X1s,{open:lt,onOpenChange:rt}),e.jsx(Q1s,{open:Se,onOpenChange:it}),e.jsx(Eet,{open:Ye,onOpenChange:tt,contactIds:Xe,contactNames:Xe.map(Zt=>{const $r=jt.find(es=>es.id===Zt);return $r?`${$r.first_name} ${$r.last_name||""}`.trim():""}),onComplete:()=>{He([]),Ae(new Set),Te(!1)}})]})]})})}function e_s(){return wt({queryKey:["video-script-categories"],queryFn:async()=>{const{data:t,error:s}=await G.from("video_script_categories").select("*").order("sort_order");if(s)throw s;return t}})}function t_s(t){return wt({queryKey:["video-scripts",t],queryFn:async()=>{let s=G.from("video_scripts").select("*, category:video_script_categories(*)").eq("is_active",!0).order("title");const{data:r,error:n}=await s;if(n)throw n;return r}})}function s_s(){const{user:t}=Ws();return wt({queryKey:["user-video-scripts",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await G.from("user_video_scripts").select("*, category:video_script_categories(*)").eq("owner_user_id",t.id).order("title");if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function r_s(){const{user:t}=Ws(),s=ss();return Dt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await G.from("user_video_scripts").insert([{owner_user_id:t.id,source_script_id:r.id,category_id:r.category_id,title:r.title,script_text:r.script_text,tags:r.tags,is_custom:!1}]).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["user-video-scripts"]})}})}function n_s(t){const{user:s}=Ws();return wt({queryKey:["agent-videos",s==null?void 0:s.id,t],queryFn:async()=>{if(!(s!=null&&s.id))return[];let r=G.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("owner_user_id",s.id).order("created_at",{ascending:!1});r=r.eq("is_deleted",!1);const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!(s!=null&&s.id)})}function a_s(t){return wt({queryKey:["agent-video",t],queryFn:async()=>{const{data:s,error:r}=await G.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function nC(){const{user:t}=Ws(),s=ss();return Dt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await G.from("agent_videos").insert([{owner_user_id:t.id,contact_id:r.contact_id,bunny_video_id:r.bunny_video_id,playback_url:r.playback_url,thumbnail_url:r.thumbnail_url,preview_url:r.preview_url,duration_seconds:r.duration_seconds,file_size_mb:r.file_size_mb||0,title:r.title,notes:r.notes,task_id:r.task_id,status:r.status||"processing",touch_type:r.touch_type||"video",page_template:"default"}]).select("*, share_token").single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["agent-videos"]}),s.invalidateQueries({queryKey:["storage-usage"]})}})}function i_s(){const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("agent_videos").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["agent-videos"]}),t.invalidateQueries({queryKey:["agent-video",s.id]})}})}function o_s(){const t=ss();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 G.functions.invoke("bunny-upload",{body:{action:"delete",videoId:r,isAgentVideo:!0}});o?console.error("Failed to delete from Bunny:",o):console.log("Bunny delete response:",a)}else console.warn("No bunnyVideoId provided, skipping Bunny.net deletion");if(n){console.log("Hard deleting from database:",s);const{error:a}=await G.from("agent_videos").delete().eq("id",s);if(a)throw a}else{console.log("Soft deleting from database:",s);const{error:a}=await G.from("agent_videos").update({is_deleted:!0}).eq("id",s);if(a)throw a}console.log("Video deletion complete")},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-videos"]}),t.invalidateQueries({queryKey:["storage-usage"]})}})}function Rhe(){const{user:t}=Ws();return wt({queryKey:["storage-usage",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await G.from("agent_storage_usage").select("*").eq("user_id",t.id).maybeSingle();if(r)throw r;return s||{user_id:t.id,total_storage_mb:0,storage_tier:"basic",max_storage_mb:1024}},enabled:!!(t!=null&&t.id)})}function vat(){const{data:t,isLoading:s}=Rhe(),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 GO(t){const{data:s,error:r}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:t,isAgentVideo:!0}});if(r)throw r;return s}async function KO(t){const{data:s,error:r}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}async function rA(t){const{data:s,error:r}=await G.functions.invoke("bunny-upload",{body:{action:"status",videoId:t,isAgentVideo:!0}});if(r)throw r;return s}function l_s(){const{user:t}=Ws(),s=ss();return Dt({mutationFn:async({contactId:r,videoId:n,notes:a})=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:o}=await G.from("action_types").select("id").eq("name","Video").single();if(!o)throw new Error("Video action type not found");const{data:l,error:i}=await G.from("contact_touch_logs").insert([{owner_user_id:t.id,contact_id:r,action_type_id:o.id,notes:a||`Quick Video Touch - Video ID: ${n}`}]).select().single();if(i)throw i;return l},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-touch-logs"]}),s.invalidateQueries({queryKey:["contacts"]})}})}function c_s(t){return wt({queryKey:["contact-video-replies",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("video_replies").select(` *, video:agent_videos(id, title, thumbnail_url, playback_url) `).eq("contact_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function d_s(t){return wt({queryKey:["client-portal",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("client_portals").select("*").eq("deal_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function F4e(){const t=ai(),s=ss();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("client_portals").insert({deal_id:r.deal_id,owner_user_id:t,slug:"",is_enabled:r.is_enabled??!0,visibility:r.visibility||"private",require_onboarding:r.require_onboarding??!0,allow_spouse:r.allow_spouse??!1,client_name:r.client_name||null,client_email:r.client_email||null,client_phone:r.client_phone||null,invite_method:r.invite_method||"email"}).select().single();if(a)throw a;return n},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["client-portal",n.deal_id]})}})}function ZO(){const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("client_portals").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function u_s(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("client_portals").update({archived_at:new Date().toISOString(),is_enabled:!1}).eq("id",s).select().single();if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function h_s(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("client_portals").update({archived_at:null}).eq("id",s).select().single();if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s.deal_id]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function m_s(){const t=ss();return Dt({mutationFn:async({id:s,dealId:r})=>{await G.from("portal_updates").delete().eq("portal_id",s);const{error:n}=await G.from("client_portals").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["client-portal",s]}),t.invalidateQueries({queryKey:["all-client-portals"]})}})}function _at(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("portal_updates").insert({portal_id:s.portal_id,title:s.title,content:s.content||null,video_url:s.video_url||null,is_stage_change:s.is_stage_change||!1}).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["portal-updates",r.portal_id]})}})}function p_s(){const t=ai();return wt({queryKey:["portal-custom-questions",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("portal_custom_questions").select("*").eq("owner_user_id",t).eq("is_active",!0).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function f_s(){const t=ai(),s=ss();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("portal_custom_questions").insert({owner_user_id:t,question_text:r.question_text,field_type:r.field_type,options:r.options||[],is_required:r.is_required||!1,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function g_s(){const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("portal_custom_questions").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function x_s(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("portal_custom_questions").update({is_active:!1}).eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function h1(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function y_s({contactId:t}){const s=Pr(),r=ss(),[n,a]=C.useState(null),[o,l]=C.useState(!1),[i,c]=C.useState(!1),[u,p]=C.useState(""),[f,y]=C.useState(""),[_,b]=C.useState(null),w=ZO(),j=_at(),{data:N,isLoading:S}=wt({queryKey:["contact-portals",t],queryFn:async()=>{const{data:q,error:U}=await G.from("deal_pipeline").select("id, deal_name, deal_type").eq("contact_id",t);if(U)throw U;if(!q||q.length===0)return[];const V=q.map(ee=>ee.id),{data:X,error:se}=await G.from("client_portals").select("*").in("deal_id",V).is("archived_at",null);if(se)throw se;return(X||[]).map(ee=>({...ee,deal:q.find(Q=>Q.id===ee.deal_id)}))},enabled:!!t}),T=(N==null?void 0:N.map(q=>q.id))||[],{data:I}=wt({queryKey:["contact-portal-updates",T],queryFn:async()=>{if(T.length===0)return{};const{data:q,error:U}=await G.from("portal_updates").select("*").in("portal_id",T).order("created_at",{ascending:!1});if(U)throw U;const V={};return(q||[]).forEach(X=>{V[X.portal_id]||(V[X.portal_id]=X)}),V},enabled:T.length>0}),L=q=>{navigator.clipboard.writeText(h1(q)),a(q),me.success("Portal link copied!"),setTimeout(()=>a(null),2e3)},R=async q=>{u.trim()&&(await j.mutateAsync({portal_id:q,title:u,content:f||void 0}),c(!1),p(""),y(""),r.invalidateQueries({queryKey:["contact-portal-updates"]}),me.success("Portal update posted!"))},$=async()=>{_&&(await w.mutateAsync({id:_.id,welcome_message:_.welcome_message,next_step_text:_.next_step_text,is_enabled:_.is_enabled,show_post_close_tips:_.show_post_close_tips,review_url:_.review_url}),l(!1),b(null),r.invalidateQueries({queryKey:["contact-portals",t]}),me.success("Portal settings updated!"))};return S||!N||N.length===0?null:e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(yp,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(Oe,{className:"space-y-3",children:N.map(q=>{var se,ee,Q;const U=((se=q.stage_mapping)==null?void 0:se.length)>0?q.stage_mapping:qje(((ee=q.deal)==null?void 0:ee.deal_type)||"buyer"),V=U==null?void 0:U[q.current_stage_index??0],X=I==null?void 0:I[q.id];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:((Q=q.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(nt,{variant:q.is_enabled?"default":"secondary",className:"text-[10px] flex-shrink-0",children:q.is_enabled?"Active":"Disabled"})]}),X&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-2",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:X.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ys(new Date(X.created_at),"MMM d, yyyy")})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>L(q.slug),children:[n===q.slug?e.jsx(ma,{className:"h-3 w-3 mr-1"}):e.jsx(mi,{className:"h-3 w-3 mr-1"}),"Copy Link"]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open(h1(q.slug),"_blank"),children:[e.jsx(rn,{className:"h-3 w-3 mr-1"}),"View"]}),e.jsxs(_s,{open:i,onOpenChange:c,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>c(!0),children:[e.jsx(po,{className:"h-3 w-3 mr-1"}),"Post Update"]})}),e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title"}),e.jsx(Fe,{value:u,onChange:de=>p(de.target.value),placeholder:"e.g. Inspection completed!"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Details (optional)"}),e.jsx(Ar,{value:f,onChange:de=>y(de.target.value),placeholder:"Add more details...",rows:3})]}),e.jsxs(K,{onClick:()=>R(q.id),disabled:!u.trim()||j.isPending,className:"w-full",children:[e.jsx(oa,{className:"h-4 w-4 mr-1"}),"Post Update"]})]})]})]}),e.jsxs(_s,{open:o,onOpenChange:l,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>{b({...q}),l(!0)},children:[e.jsx(Jl,{className:"h-3 w-3 mr-1"}),"Settings"]})}),e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Portal Settings"})}),_&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Portal Enabled"}),e.jsx(Br,{checked:_.is_enabled,onCheckedChange:de=>b({..._,is_enabled:de})})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Welcome Message"}),e.jsx(Ar,{value:_.welcome_message||"",onChange:de=>b({..._,welcome_message:de.target.value}),placeholder:"Welcome to your home journey!",rows:2})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Next Step"}),e.jsx(Fe,{value:_.next_step_text||"",onChange:de=>b({..._,next_step_text:de.target.value}),placeholder:"What your client should do next..."})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Review URL"}),e.jsx(Fe,{value:_.review_url||"",onChange:de=>b({..._,review_url:de.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Show Post-Close Tips"}),e.jsx(Br,{checked:_.show_post_close_tips,onCheckedChange:de=>b({..._,show_post_close_tips:de})})]}),e.jsx(Zl,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:$,disabled:w.isPending,className:"flex-1",children:"Save Settings"}),e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/pipeline?deal=${q.deal_id}`),children:[e.jsx(Ki,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),N.length>1&&e.jsx(Zl,{})]},q.id)})})]})}function v_s({videoId:t}){var l;const{data:s,isLoading:r,error:n}=a_s(t);if(r)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(xs,{className:"w-full aspect-video rounded-lg"}),e.jsx(xs,{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(uh,{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 __s({contactId:t}){const s=Pr(),[r,n]=C.useState(!1),{data:a,isLoading:o}=wt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:y}=await G.from("deal_tasks").select(` id, title, priority, status, due_date, completed_at, deal:deal_pipeline(id, deal_name) `).eq("contact_id",t).order("status").order("due_date",{ascending:!0,nullsFirst:!1});if(y)throw y;return f},enabled:!!t}),l=async(f,y)=>{const _=y==="done"?"todo":"done";await G.from("deal_tasks").update({status:_,completed_at:_==="done"?new Date().toISOString():null}).eq("id",f),window.dispatchEvent(new CustomEvent("refetch-contact-tasks"))},{refetch:i}=wt({queryKey:["deal-tasks","contact",t],queryFn:async()=>{const{data:f,error:y}=await G.from("deal_tasks").select(` id, title, priority, status, due_date, completed_at, deal:deal_pipeline(id, deal_name) `).eq("contact_id",t).order("status").order("due_date",{ascending:!0,nullsFirst:!1});if(y)throw y;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(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(ma,{className:"h-4 w-4"}),"Tasks",u.length>0&&e.jsx(nt,{variant:"secondary",className:"text-xs",children:u.length})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/tasks"),children:"View All"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>n(!0),children:e.jsx(Zs,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(Oe,{className:"space-y-1",children:o?e.jsx(xs,{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:ys(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(b_s,{contactId:t,open:r,onOpenChange:f=>{n(f),f||i()}})]})}function b_s({contactId:t,open:s,onOpenChange:r}){const[n,a]=C.useState(""),[o,l]=C.useState("medium"),[i,c]=C.useState(),{data:u}=wt({queryKey:["session"],queryFn:async()=>{const{data:f}=await G.auth.getSession();return f.session}}),p=async()=>{var y;if(!n.trim()||!((y=u==null?void 0:u.user)!=null&&y.id))return;const{error:f}=await G.from("deal_tasks").insert([{owner_user_id:u.user.id,contact_id:t,title:n.trim(),priority:o,status:"todo",due_date:i?ys(i,"yyyy-MM-dd"):null}]);if(f){console.error("Task create error:",f);return}r(!1)};return e.jsx(_s,{open:s,onOpenChange:r,children:e.jsxs(vs,{className:"sm:max-w-[400px]",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Add Task"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title"}),e.jsx(Fe,{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(_e,{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(_e,{children:"Due Date"}),e.jsx(Fe,{type:"date",value:i?ys(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 w_s({contactId:t}){const s=Pr(),{data:r,isLoading:n}=wt({queryKey:["contact-linked-deals",t],queryFn:async()=>{const{data:a,error:o}=await G.from("deal_pipeline").select(` id, deal_name, deal_type, expected_price, property_address, stage:deal_pipeline_stages(id, name, color, icon, is_won_stage, is_lost_stage) `).eq("contact_id",t).order("updated_at",{ascending:!1});if(o)throw o;return a},enabled:!!t});return n||!r||r.length===0?null:e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Rh,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx(Oe,{className:"space-y-2",children:r.map(a=>{const o=a.stage;return e.jsx("button",{onClick:()=>s(`/mission-control/pipeline?deal=${a.id}`),className:"w-full text-left p-3 rounded-lg border hover:bg-accent transition-colors group",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:a.deal_name}),a.property_address&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.property_address}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(nt,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(nt,{variant:"outline",className:"text-[10px] gap-1",style:{borderColor:o.color,color:o.color,backgroundColor:`${o.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:o.color}}),o.name]})]})]}),e.jsx(Ki,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function j_s(){var $e,ot,Ue,Ke,Xe;const{contactId:t}=Po(),s=Pr(),[r]=Xc(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=lIt(t||""),{data:c}=Rg(),{data:u}=bO(),{data:p}=wO(3650),{data:f}=Dhe(365),{data:y}=c_s(t),{contactsWithScores:_}=pue(),b=lke(),w=cke(),j=dke(),N=mYe(),[S,T]=C.useState(!1),[I,L]=C.useState({}),[R,$]=C.useState(!1),[q,U]=C.useState(null),[V,X]=C.useState(""),[se,ee]=C.useState(void 0),[Q,de]=C.useState(""),[re,ne]=C.useState(null),[le,he]=C.useState(!1),[we,ye]=C.useState(null),{isGmailConnected:je,gmailEmail:ke}=D0(),{data:We}=wt({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:He,error:Ye}=await G.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(Ye)throw Ye;return He},enabled:!!t}),be=He=>{if(!He)return null;const Ye=He.match(/Video ID:\s*([a-f0-9-]+)/i);return Ye?Ye[1]:null},Me=C.useMemo(()=>{if(!_)return[];let He=_.filter(Ye=>{var qt,ms,Xt;const tt=n===""||`${Ye.first_name} ${Ye.last_name}`.toLowerCase().includes(n.toLowerCase())||((qt=Ye.email)==null?void 0:qt.toLowerCase().includes(n.toLowerCase()))||((ms=Ye.phone)==null?void 0:ms.includes(n)),Et=a==="all"||((Xt=Ye.tags)==null?void 0:Xt.some(rs=>rs.relationship_type_id===a));return tt&&Et});return o==="not-touched-90"?He=He.filter(Ye=>{const tt=Ye.relationshipScore.daysSinceTouch;return tt===null||tt>90}):o==="at-risk"?He=He.filter(Ye=>Ye.relationshipScore.status==="at-risk"):o==="cooling"?He=He.filter(Ye=>Ye.relationshipScore.status==="cooling"):o==="warm"&&(He=He.filter(Ye=>Ye.relationshipScore.status==="warm")),He.map(Ye=>Ye.id)},[_,n,a,o]),Ae=Me.indexOf(t||""),Re=Ae>0?Me[Ae-1]:null,Te=Ae1&&Ae!==-1,ct=He=>{const Ye=new URLSearchParams;n&&Ye.set("search",n),a!=="all"&&Ye.set("type",a),o!=="all"&&Ye.set("status",o);const tt=Ye.toString();return`/mission-control/contacts/${He}${tt?`?${tt}`:""}`},De=C.useMemo(()=>{const He=((p==null?void 0:p.filter(tt=>tt.contact_id===t))||[]).map(tt=>{var Xt,rs,ps;const Et=be(tt.notes);let qt=((Xt=tt.action_type)==null?void 0:Xt.name)||"Touch",ms=tt.notes;if(qt==="Other"&&((rs=tt.notes)!=null&&rs.startsWith("["))){const Ms=tt.notes.indexOf("]");Ms>0&&(qt=tt.notes.substring(1,Ms),ms=tt.notes.substring(Ms+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:tt.id,type:"touch",completed_at:tt.completed_at,name:qt,color:((ps=tt.action_type)==null?void 0:ps.color)||"#3B82F6",notes:ms,videoId:Et}}),Ye=((f==null?void 0:f.filter(tt=>tt.contact_id===t))||[]).map(tt=>({id:tt.id,type:"popby",completed_at:tt.completed_at,name:"Pop-by",color:"#F97316",notes:tt.notes,videoId:null}));return[...He,...Ye].sort((tt,Et)=>new Date(Et.completed_at).getTime()-new Date(tt.completed_at).getTime())},[p,f,t]),Rt=()=>{var He;l&&(L({first_name:l.first_name||"",last_name:l.last_name||"",email:l.email||"",phone:l.phone||"",address:l.address||"",city:l.city||"",state:l.state||"",zip_code:l.zip_code||"",birthday:l.birthday||"",home_anniversary:l.home_anniversary||"",spouse_name:l.spouse_name||"",spouse_email:l.spouse_email||"",company_name:l.company_name||"",job_title:l.job_title||"",lead_source_id:l.lead_source_id||"",notes:l.notes||"",tagIds:((He=l.tags)==null?void 0:He.map(Ye=>Ye.relationship_type_id))||[]}),T(!0))},pe=async()=>{await b.mutateAsync({id:t,...I,lead_source_id:I.lead_source_id||null}),T(!1)},Je=async()=>{confirm("Are you sure you want to delete this contact?")&&(await w.mutateAsync(t),s("/mission-control/contacts"))},rt=(($e=u==null?void 0:u.find(He=>He.id===q))==null?void 0:$e.name)==="Other",Se=async()=>{if(!q||rt&&!Q.trim())return;const He=se?new Date(se.getFullYear(),se.getMonth(),se.getDate(),12,0,0).toISOString():void 0,Ye=rt?`[${Q.trim()}]${V?" — "+V:""}`:V;await j.mutateAsync({contactId:t,actionTypeId:q,notes:Ye,completedAt:He}),$(!1),U(null),X(""),ee(void 0),de("")},it=(He,Ye)=>{je&&l?(ye({email:He,name:Ye||`${l.first_name} ${l.last_name||""}`.trim()}),he(!0)):window.location.href=`mailto:${He}`};return i?e.jsx(Es,{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(Es,{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(Xl,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),qe&&e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Re&&s(ct(Re)),disabled:!Re,className:"px-2",children:[e.jsx(Xl,{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:[Ae+1," of ",Me.length]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Te&&s(ct(Te)),disabled:!Te,className:"px-2",children:[e.jsx("span",{className:"sr-only sm:not-sr-only sm:mr-1",children:"Next"}),e.jsx(Xa,{className:"h-4 w-4"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end flex-wrap",children:[l.email&&e.jsxs(K,{variant:"outline",onClick:()=>it(l.email,`${l.first_name} ${l.last_name||""}`.trim()),children:[e.jsx(br,{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(Nn,{className:"h-4 w-4 mr-1"}),"Quick Video Touch"]}),e.jsxs(_s,{open:R,onOpenChange:$,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Log Action"]})}),e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Log an Action"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Action Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:u==null?void 0:u.filter(He=>He.active).map(He=>e.jsxs("button",{onClick:()=>U(He.id),className:` p-3 rounded-lg border text-left transition-all ${q===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))}),rt&&e.jsxs("div",{className:"mt-3",children:[e.jsx(_e,{htmlFor:"custom-action-name",children:"What did you do?"}),e.jsx(Fe,{id:"custom-action-name",value:Q,onChange:He=>de(He.target.value),placeholder:"e.g. Met a client for lunch, Dropped off a gift...",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Date (optional — backdate if needed)"}),e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:At("w-full justify-start text-left font-normal mt-2",!se&&"text-muted-foreground"),children:[e.jsx(on,{className:"h-4 w-4 mr-2"}),se?ys(se,"PPP"):"Today (default)"]})}),e.jsx(Eo,{className:"w-auto p-0",align:"start",children:e.jsx(mf,{mode:"single",selected:se,onSelect:ee,disabled:He=>He>new Date,initialFocus:!0,className:At("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(Ar,{id:"action-notes",value:V,onChange:He=>X(He.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(K,{onClick:Se,disabled:!q||rt&&!Q.trim()||j.isPending,className:"w-full",children:[e.jsx(ma,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(K,{variant:"outline",onClick:Rt,children:[e.jsx(rd,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:Je,children:e.jsx(jr,{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||""]}),(((ot=l.lead_source_ref)==null?void 0:ot.name)||l.lead_source)&&e.jsx(nt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((Ue=l.lead_source_ref)==null?void 0:Ue.name)||l.lead_source})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-2 text-muted-foreground",children:[l.email&&e.jsxs("button",{onClick:()=>it(l.email),className:"flex items-center gap-1 hover:text-primary transition-colors",children:[e.jsx(br,{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(ea,{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(Mbe,{contact:l}),(Ke=l.tags)==null?void 0:Ke.map(He=>{const Ye=c==null?void 0:c.find(tt=>tt.id===He.relationship_type_id);return Ye?e.jsx(nt,{variant:"secondary",className:"text-xs",children:Ye.name},He.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(Y1s,{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(It,{children:e.jsx(Ot,{children:"Contact Information"})}),e.jsx(Oe,{children:S?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"first_name",children:"First Name"}),e.jsx(Fe,{id:"first_name",value:I.first_name,onChange:He=>L({...I,first_name:He.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"last_name",children:"Last Name"}),e.jsx(Fe,{id:"last_name",value:I.last_name,onChange:He=>L({...I,last_name:He.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"email",children:"Email"}),e.jsx(Fe,{id:"email",type:"email",value:I.email,onChange:He=>L({...I,email:He.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"phone",children:"Phone"}),e.jsx(Fe,{id:"phone",value:I.phone,onChange:He=>L({...I,phone:He.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"address",children:"Street Address"}),e.jsx(Fe,{id:"address",value:I.address,onChange:He=>L({...I,address:He.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(_e,{htmlFor:"city",children:"City"}),e.jsx(Fe,{id:"city",value:I.city,onChange:He=>L({...I,city:He.target.value}),placeholder:"City"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"state",children:"State"}),e.jsx(Fe,{id:"state",value:I.state,onChange:He=>L({...I,state:He.target.value}),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"zip_code",children:"Zip Code"}),e.jsx(Fe,{id:"zip_code",value:I.zip_code,onChange:He=>L({...I,zip_code:He.target.value}),placeholder:"12345"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"birthday",children:"Birthday"}),e.jsx(Fe,{id:"birthday",type:"date",value:I.birthday,onChange:He=>L({...I,birthday:He.target.value})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(Fe,{id:"home_anniversary",type:"date",value:I.home_anniversary,onChange:He=>L({...I,home_anniversary:He.target.value})})]})]}),e.jsx(Zl,{}),e.jsx(Tbe,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:(l==null?void 0:l.spouse_name)||null,currentSpouseEmail:(l==null?void 0:l.spouse_email)||null,onLink:He=>N.mutate({contactId:t,spouseContactId:He}),onUnlink:()=>N.mutate({contactId:t,spouseContactId:null}),isEditing:!0}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"company_name",children:"Company"}),e.jsx(Fe,{id:"company_name",value:I.company_name,onChange:He=>L({...I,company_name:He.target.value}),placeholder:"Enter company name"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"job_title",children:"Job Title"}),e.jsx(Fe,{id:"job_title",value:I.job_title,onChange:He=>L({...I,job_title:He.target.value}),placeholder:"Enter job title"})]})]}),e.jsx(yat,{value:I.lead_source_id||"",onChange:He=>L({...I,lead_source_id:He})}),e.jsxs("div",{children:[e.jsx(_e,{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 Ye;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Yo,{checked:(Ye=I.tagIds)==null?void 0:Ye.includes(He.id),onCheckedChange:tt=>{var Et;L(tt?{...I,tagIds:[...I.tagIds||[],He.id]}:{...I,tagIds:(Et=I.tagIds)==null?void 0:Et.filter(qt=>qt!==He.id)})}}),e.jsx("span",{className:"text-sm",children:He.name})]},He.id)})})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"notes",children:"Notes"}),e.jsx(Ar,{id:"notes",value:I.notes,onChange:He=>L({...I,notes:He.target.value}),rows:4})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:pe,disabled:b.isPending,children:"Save Changes"}),e.jsx(K,{variant:"outline",onClick:()=>T(!1),children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[De.length>0&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",ys(new Date(De[0].completed_at),"MMM d, yyyy")," ","(",De[0].name,")"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:gap-6 gap-2",children:[l.email&&e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(br,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("button",{onClick:()=>it(l.email),className:"text-primary hover:underline truncate text-left",children:l.email})]}),l.phone&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ea,{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(Ui,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{className:"flex flex-col",children:[l.address&&e.jsx("span",{children:l.address}),(l.city||l.state||l.zip_code)&&e.jsxs("span",{className:"text-muted-foreground",children:[[l.city,l.state].filter(Boolean).join(", "),l.zip_code&&` ${l.zip_code}`]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[l.birthday&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",ys(Ml(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",ys(Ml(l.home_anniversary),"MMMM d")]})]}),l.created_at&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Zs,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Date Added: ",ys(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(Zl,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(Tbe,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:l.spouse_name||null,currentSpouseEmail:l.spouse_email||null,onLink:He=>N.mutate({contactId:t,spouseContactId:He}),onUnlink:()=>N.mutate({contactId:t,spouseContactId:null}),isEditing:!1}),(l.company_name||l.job_title)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(La,{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(Zl,{}),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:(Xe=l.tags)!=null&&Xe.length?l.tags.map(He=>{var Ye;return e.jsx(nt,{variant:"secondary",children:(Ye=He.relationship_type)==null?void 0:Ye.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(Zl,{}),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(E1s,{contact:l,onLogTouch:()=>$(!0)}),e.jsx(w_s,{contactId:t}),e.jsx(y_s,{contactId:t}),e.jsx(__s,{contactId:t}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Activity Log"})}),e.jsx(Oe,{children:De.length>0?e.jsx("div",{className:"space-y-4",children:De.map(He=>{var Ye;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(bo,{className:"h-4 w-4"}):(Ye=He.name)==null?void 0:Ye.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:()=>ne(He.videoId),children:[e.jsx(wl,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ys(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"})})]}),y&&y.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(po,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:y.map(He=>{var Ye,tt;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(Ye=He.video)!=null&&Ye.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:()=>ne(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:()=>ne(He.video_id),children:e.jsx(Nn,{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: ",((tt=He.video)==null?void 0:tt.title)||"Untitled Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>ne(He.video_id),children:[e.jsx(wl,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ys(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)})})})]}),We&&We.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(oa,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:We.map(He=>e.jsxs(_s,{children:[e.jsx(Fi,{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(br,{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," · ",ys(new Date(He.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground mt-1 flex-shrink-0"})]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5 text-sky-500"}),He.subject]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",He.to_email," · ",ys(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(_s,{open:!!re,onOpenChange:He=>!He&&ne(null),children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Video Preview"})}),re&&e.jsx(v_s,{videoId:re})]})})]})]})}),je&&l&&we&&e.jsx(iE,{open:le,onOpenChange:he,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:we.email},gmailEmail:ke})]}):e.jsx(Es,{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 SFe={Crown:Sm,FileText:In,Users:mr,Globe:yp,Star:Kn,Phone:ea,MessageSquare:po,PenTool:Db,Video:Nn,Gift:bo},aye=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function k_s(){var Xe,He;const t=Pr(),{user:s}=Ws(),{data:r}=Rg(),{data:n}=dIt(),{data:a}=xIt(),{data:o}=hYe(),{data:l}=bO(),{data:i}=cIt(),c=yIt(),u=uIt(),p=mIt(),f=pIt(),y=fIt(),_=gIt(),b=hIt(),[w,j]=C.useState(null),[N,S]=C.useState(!1),[T,I]=C.useState(null),[L,R]=C.useState(""),[$,q]=C.useState(""),[U,V]=C.useState([]),[X,se]=C.useState(null),[ee,Q]=C.useState(null),[de,re]=C.useState(!1),[ne,le]=C.useState(""),[he,we]=C.useState(""),[ye,je]=C.useState(""),[ke,We]=C.useState(""),be=(Ye,tt)=>a==null?void 0:a.some(Et=>Et.plan_id===Ye&&Et.relationship_type_id===tt&&Et.active),Me=Ye=>a==null?void 0:a.find(tt=>tt.relationship_type_id===Ye&&tt.active),Ae=async(Ye,tt)=>{const Et=be(Ye,tt);await c.mutateAsync({planId:Ye,relationshipTypeId:tt,active:!Et})},Re=(n==null?void 0:n.filter(Ye=>Ye.active&&!Ye.owner_user_id))||[],Te=(n==null?void 0:n.filter(Ye=>Ye.owner_user_id===(s==null?void 0:s.id)))||[],qe=r==null?void 0:r.find(Ye=>Ye.id===w),ct=w?Me(w):null,De=n==null?void 0:n.find(Ye=>Ye.id===(ct==null?void 0:ct.plan_id)),Rt=async()=>{if(!L.trim())return;const Ye=await u.mutateAsync({name:L,description:$});Ye&&U.length>0&&await y.mutateAsync({planId:Ye.id,items:U}),lt()},pe=async()=>{!L.trim()||!T||(await p.mutateAsync({id:T,name:L,description:$}),await y.mutateAsync({planId:T,items:U}),lt())},Je=Ye=>{var tt;I(Ye.id),R(Ye.name),q(Ye.description||""),V(((tt=Ye.items)==null?void 0:tt.map(Et=>({month_number:Et.month_number,action_type_id:Et.action_type_id,default_script_id:Et.default_script_id||void 0,notes:Et.notes||void 0})))||[]),S(!0)},lt=()=>{S(!1),I(null),R(""),q(""),V([])},rt=(Ye,tt)=>{Q(tt)},Se=(Ye,tt,Et)=>{V(qt=>[...qt.filter(Xt=>Xt.month_number!==Ye),{month_number:Ye,action_type_id:tt,default_script_id:Et}]),se(null),Q(null)},it=Ye=>{V(tt=>tt.filter(Et=>Et.month_number!==Ye))},$e=async()=>{if(!ne.trim()||!he.trim()||!ee)return;const Ye=await _.mutateAsync({actionTypeId:ee,title:ne,scriptBody:he,emailSubject:ye||void 0,tone:ke||void 0});Ye&&X!==null&&Se(X,ee,Ye.id),re(!1),le(""),we(""),je(""),We("")},ot=ee?i==null?void 0:i.filter(Ye=>Ye.action_type_id===ee&&Ye.active):[],Ue=Ye=>SFe[Ye||"Phone"]||ea,Ke=Ye=>SFe[Ye||"Users"]||mr;return e.jsxs(Es,{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(Xl,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(K,{onClick:()=>S(!0),className:"w-full sm:w-auto",children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Custom Plan"]})]}),e.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Your Contact Groups"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a group to assign a touchpoint plan"}),r==null?void 0:r.filter(Ye=>Ye.active).map(Ye=>{const tt=Ke(Ye.icon),Et=(o==null?void 0:o[Ye.id])||0,qt=Me(Ye.id),ms=n==null?void 0:n.find(rs=>rs.id===(qt==null?void 0:qt.plan_id)),Xt=w===Ye.id;return e.jsxs("button",{onClick:()=>j(Ye.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${Xt?"border-primary bg-primary/5 ring-2 ring-primary":"hover:bg-accent"} `,children:[e.jsx(tt,{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:Ye.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Et," contacts"]})]}),ms?e.jsxs(nt,{variant:"secondary",className:"text-xs",children:[e.jsx(vi,{className:"h-3 w-3 mr-1"}),ms.name.split(" ")[0]]}):e.jsx(nt,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},Ye.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:w&&qe?e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[(()=>{const Ye=Ke(qe.icon);return e.jsx(Ye,{className:"h-5 w-5"})})(),qe.name," Touchpoint Plan"]}),e.jsxs(fr,{children:["Choose a plan for your ",qe.name," contacts"]})]}),e.jsxs(Oe,{className:"space-y-6",children:[De&&e.jsxs("div",{className:"p-4 bg-primary/5 rounded-lg border border-primary/20",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(vi,{className:"h-4 w-4 text-green-500"}),"Currently using: ",De.name]}),De.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:De.description})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Ae(De.id,w),children:"Disable"})]}),De.items&&De.items.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:aye.map((Ye,tt)=>{var Xt,rs;const Et=((Xt=De.items)==null?void 0:Xt.filter(ps=>ps.month_number===tt+1))||[],qt=(rs=Et[0])==null?void 0:rs.action_type,ms=qt?Ue(qt.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${Et.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:Ye}),ms&&e.jsx(ms,{className:"h-4 w-4 mx-auto mt-1",style:{color:(qt==null?void 0:qt.color)||"#3B82F6"}})]},tt)})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:De?"Switch to a Different Plan":"Choose a Plan"}),Re.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"}),Re.map(Ye=>{var Et;const tt=(De==null?void 0:De.id)===Ye.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${tt?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ye.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Et=Ye.items)==null?void 0:Et.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Duplicate as my own plan",disabled:b.isPending,onClick:()=>{const qt=`${Ye.name} (Copy)`;b.mutate({sourcePlanId:Ye.id,newName:qt})},children:e.jsx(mi,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:tt?"outline":"default",disabled:tt||c.isPending,onClick:()=>Ae(Ye.id,w),children:tt?"Active":"Use This"})]})]},Ye.id)})]}),Te.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),Te.map(Ye=>{var Et;const tt=(De==null?void 0:De.id)===Ye.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${tt?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ye.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Et=Ye.items)==null?void 0:Et.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>Je(Ye),children:e.jsx(Wy,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>f.mutate(Ye.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})}),e.jsx(K,{size:"sm",variant:tt?"outline":"default",disabled:tt||c.isPending,onClick:()=>Ae(Ye.id,w),children:tt?"Active":"Use This"})]})]},Ye.id)})]}),Re.length===0&&Te.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No plans available. Create a custom plan to get started."})]})]})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(on,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"Select a contact group to view and assign plans"})]})})})]}),e.jsx(Ee,{className:"bg-muted/50",children:e.jsx(Oe,{className:"py-4",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("strong",{children:"How it works:"})," When you assign a plan to a contact group, those contacts will appear in your daily suggested actions based on the plan's schedule."]})})})]}),e.jsx(_s,{open:N,onOpenChange:Ye=>{Ye?S(!0):lt()},children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:T?"Edit Touchpoint Plan":"Create Custom Touchpoint Plan"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"plan-name",children:"Plan Name"}),e.jsx(Fe,{id:"plan-name",value:L,onChange:Ye=>R(Ye.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(Ar,{id:"plan-description",value:$,onChange:Ye=>q(Ye.target.value),placeholder:"Describe your plan...",rows:2})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"12-Month Schedule"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Click on a month to add a touchpoint"}),e.jsx("div",{className:"grid grid-cols-6 gap-2",children:aye.map((Ye,tt)=>{const Et=tt+1,qt=U.find(rs=>rs.month_number===Et),ms=qt?l==null?void 0:l.find(rs=>rs.id===qt.action_type_id):null,Xt=ms?Ue(ms.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>se(X===Et?null:Et),className:` w-full p-3 rounded-lg border text-center transition-all ${qt?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${X===Et?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:Ye}),Xt?e.jsx(Xt,{className:"h-5 w-5 mx-auto mt-1",style:{color:(ms==null?void 0:ms.color)||"#3B82F6"}}):e.jsx(Zs,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),qt&&e.jsx("button",{type:"button",onClick:rs=>{rs.stopPropagation(),it(Et)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(Ur,{className:"h-3 w-3"})})]},tt)})}),X!==null&&!ee&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[e.jsxs("div",{className:"text-sm font-medium mb-2",children:["Step 1: Select action for ",aye[X-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(Ye=>Ye.active).map(Ye=>{const tt=Ue(Ye.icon);return e.jsxs("button",{type:"button",onClick:()=>rt(X,Ye.id),className:"flex items-center gap-2 px-3 py-2 rounded-lg border bg-background hover:bg-accent transition-colors",children:[e.jsx(tt,{className:"h-4 w-4",style:{color:Ye.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:Ye.name})]},Ye.id)})})]}),X!==null&&ee&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm font-medium",children:"Step 2: Select a script (optional)"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Q(null),children:[e.jsx(Xl,{className:"h-4 w-4 mr-1"})," Back"]})]}),e.jsxs("div",{className:"space-y-2 max-h-[300px] overflow-y-auto pr-1",children:[e.jsx("button",{type:"button",onClick:()=>Se(X,ee),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-background hover:bg-accent transition-colors text-left",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:"No Script"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Use without a predefined script"})]})}),ot==null?void 0:ot.map(Ye=>e.jsx("button",{type:"button",onClick:()=>Se(X,ee,Ye.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:Ye.title}),Ye.tone&&e.jsx(nt,{variant:"secondary",className:"text-xs mt-1",children:Ye.tone}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:[Ye.script_body.substring(0,100),"..."]})]})},Ye.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(Zs,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:"Create Custom Script"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Write your own script for this action"})]})]})]})]})]}),U.length>0&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[U.length," touchpoint",U.length!==1?"s":""," per year"]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:lt,children:"Cancel"}),e.jsxs(K,{onClick:T?pe:Rt,disabled:!L.trim()||u.isPending||p.isPending,children:[e.jsx(Wu,{className:"h-4 w-4 mr-2"}),T?"Save Changes":"Create Plan"]})]})]})}),e.jsx(_s,{open:de,onOpenChange:re,children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Create Custom Script"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script-title",children:"Script Title"}),e.jsx(Fe,{id:"script-title",value:ne,onChange:Ye=>le(Ye.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs(rr,{value:ke,onValueChange:We,children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select tone..."})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"friendly",children:"Friendly"}),e.jsx(Tt,{value:"professional",children:"Professional"}),e.jsx(Tt,{value:"casual",children:"Casual"}),e.jsx(Tt,{value:"formal",children:"Formal"})]})]})]}),((He=(Xe=l==null?void 0:l.find(Ye=>Ye.id===ee))==null?void 0:Xe.name)==null?void 0:He.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(Fe,{id:"script-email-subject",value:ye,onChange:Ye=>je(Ye.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"script-body",children:"Script Content"}),e.jsx(Ar,{id:"script-body",value:he,onChange:Ye=>we(Ye.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(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>re(!1),children:"Cancel"}),e.jsxs(K,{onClick:$e,disabled:!ne.trim()||!he.trim()||_.isPending,children:[e.jsx(Wu,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}const N_s="0dde5abb-0005-4c8c-a471-30d0cbc9e280",S_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 C_s(){const t=Pr(),s=fat(),{data:r}=k1s(),{data:n}=Rg(),{data:a}=O4e(),{data:o}=Dhe(90),{data:l}=Fm(),i=T1s(),c=C1s(),u=S1s(),p=M1s(),{data:f=[],isLoading:y}=wt({queryKey:["popby-templates"],queryFn:async()=>{const{data:de,error:re}=await G.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",N_s).order("publish_date",{ascending:!1});if(re)throw re;const{data:ne}=await G.from("template_likes").select("template_id"),{data:le}=await G.from("template_comments").select("template_id"),he=new Map;ne==null||ne.forEach(ye=>{he.set(ye.template_id,(he.get(ye.template_id)||0)+1)});const we=new Map;return le==null||le.forEach(ye=>{we.set(ye.template_id,(we.get(ye.template_id)||0)+1)}),(de||[]).map(ye=>({...ye,likesCount:he.get(ye.id)||0,commentsCount:we.get(ye.id)||0}))}}),_=de=>{const re=l==null?void 0:l.find(ne=>ne.id===de);return re?`${re.first_name} ${re.last_name||""}`.trim():"Unknown"},b=de=>{if(!de)return null;const re=r==null?void 0:r.find(ne=>ne.id===de);return(re==null?void 0:re.name)||null},[w,j]=C.useState(null),[N,S]=C.useState(!1),[T,I]=C.useState(!1),[L,R]=C.useState(!1),[$,q]=C.useState({popby_item_id:"",notes:""}),[U,V]=C.useState({name:"",description:""}),X=async()=>{w&&(await c.mutateAsync({contact_id:w.id,popby_item_id:$.popby_item_id||void 0,notes:$.notes||void 0}),S(!1),j(null),q({popby_item_id:"",notes:""}))},se=async()=>{U.name.trim()&&(await u.mutateAsync({name:U.name.trim(),description:U.description.trim()||void 0}),R(!1),V({name:"",description:""}))},ee=async(de,re)=>{await p.mutateAsync({relationship_type_id:de,frequency_days:parseInt(re)})},Q=de=>{var ne;const re=a==null?void 0:a.find(le=>le.relationship_type_id===de);return((ne=re==null?void 0:re.frequency_days)==null?void 0:ne.toString())||"90"};return e.jsx(Es,{title:"Popbys",description:"Drop off gifts to stay top of mind",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Popbys"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-primary",children:i.thisWeekCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Week"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-emerald-500",children:i.thisMonthCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This Month"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-amber-500",children:i.dueCount}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Due Now"})]})})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{onClick:()=>t("/mission-control/popbys/map"),children:[e.jsx(Ui,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(K,{variant:"outline",onClick:()=>I(!0),children:[e.jsx(Jl,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(K,{variant:"outline",onClick:()=>R(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(Aa,{defaultValue:"due",children:[e.jsxs(ja,{children:[e.jsx(js,{value:"due",children:"Due for Popby"}),e.jsx(js,{value:"activity",children:"Recent Activity"}),e.jsx(js,{value:"library",children:"Popby Library"}),e.jsx(js,{value:"templates",children:"Popby Templates"})]}),e.jsx($s,{value:"due",className:"space-y-4 mt-4",children:!s||s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(bo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No contacts due for a popby right now!"}),e.jsx("p",{className:"text-sm mt-1",children:"Great job staying connected."})]})}):e.jsx("div",{className:"space-y-3",children:s.map(de=>e.jsx(Ee,{className:"hover:shadow-md transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium",children:[de.first_name," ",de.last_name]}),de.daysOverdue>0&&e.jsxs(nt,{variant:"destructive",className:"text-xs",children:[de.daysOverdue,"+ days overdue"]}),de.daysSinceLastPopby===null&&e.jsx(nt,{variant:"outline",className:"text-xs",children:"Never visited"})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-1 text-sm text-muted-foreground",children:[de.address&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ui,{className:"h-3 w-3"}),de.city||de.address]}),de.tags&&de.tags.length>0&&e.jsx("span",{children:de.tags.map(re=>{var ne;return(ne=re.relationship_type)==null?void 0:ne.name}).join(", ")})]}),de.lastPopby&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",ys(new Date(de.lastPopby),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[de.phone&&e.jsx(K,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx("a",{href:`tel:${de.phone}`,children:e.jsx(ea,{className:"h-4 w-4"})})}),e.jsxs(K,{size:"sm",onClick:()=>{j(de),S(!0)},children:[e.jsx(vi,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})},de.id))})}),e.jsx($s,{value:"activity",className:"space-y-4 mt-4",children:!o||o.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(Tn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No popby activity yet!"}),e.jsx("p",{className:"text-sm mt-1",children:"Start logging popbys to see your history here."})]})}):e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx(Oe,{className:"space-y-3",children:o.map(de=>e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0 last:pb-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/10 flex items-center justify-center",children:e.jsx(bo,{className:"h-5 w-5 text-orange-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium",children:_(de.contact_id)}),b(de.popby_item_id)&&e.jsx(nt,{variant:"secondary",className:"text-xs",children:b(de.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ys(new Date(de.completed_at),"MMM d, yyyy h:mm a")}),de.notes&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:de.notes})]})]},de.id))})]})}),e.jsx($s,{value:"library",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[r==null?void 0:r.map(de=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(bo,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-medium",children:de.name}),de.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:de.description}),!de.owner_user_id&&e.jsx(nt,{variant:"secondary",className:"mt-2 text-xs",children:"Shared"})]})]})})},de.id)),e.jsx(Ee,{className:"border-dashed cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>R(!0),children:e.jsx(Oe,{className:"p-4 flex items-center justify-center h-full min-h-[100px]",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(Zs,{className:"h-8 w-8 mx-auto mb-2"}),e.jsx("p",{children:"Add New Popby Idea"})]})})})]})}),e.jsxs($s,{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"]}),y&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[...Array(4)].map((de,re)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx(xs,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),e.jsx(xs,{className:"h-5 w-3/4 mb-2"}),e.jsx(xs,{className:"h-4 w-full mb-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(xs,{className:"h-5 w-16"}),e.jsx(xs,{className:"h-5 w-20"})]})]})},re))}),!y&&f.length===0&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(bl,{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."})]})}),!y&&f.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:f.map(de=>e.jsxs(Ee,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer",onClick:()=>t(`/templates/${de.id}`),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:de.preview_image_url?e.jsx("img",{src:de.preview_image_url,alt:de.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"})}),e.jsxs(Oe,{className:"p-4 flex flex-col",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:de.name}),de.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:mde(de.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(nt,{variant:"secondary",className:"text-xs",children:"PopBys"})}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Gu,{className:"h-3.5 w-3.5"}),de.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ec,{className:"h-3.5 w-3.5"}),de.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:re=>{re.stopPropagation(),t(`/templates/${de.id}`)},children:[e.jsx(rn,{className:"h-4 w-4"}),"View Template"]})]})]},de.id))})]})]}),e.jsx(_s,{open:N,onOpenChange:S,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:["Log Popby for ",w==null?void 0:w.first_name," ",w==null?void 0:w.last_name]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Popby Item (optional)"}),e.jsxs(rr,{value:$.popby_item_id,onValueChange:de=>q(re=>({...re,popby_item_id:de})),children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select a popby item..."})}),e.jsx(sr,{children:r==null?void 0:r.map(de=>e.jsx(Tt,{value:de.id,children:de.name},de.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Notes (optional)"}),e.jsx(Ar,{placeholder:"Any notes about this popby...",value:$.notes,onChange:de=>q(re=>({...re,notes:de.target.value}))})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(K,{onClick:X,disabled:c.isPending,children:"Log Popby"})]})]})}),e.jsx(_s,{open:T,onOpenChange:I,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Popby Frequency Settings"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set default popby frequency for each relationship type. You can override these per-contact."}),n==null?void 0:n.map(de=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx(_e,{className:"font-medium",children:de.name}),e.jsxs(rr,{value:Q(de.id),onValueChange:re=>ee(de.id,re),children:[e.jsx(tr,{className:"w-[180px]",children:e.jsx(nr,{})}),e.jsx(sr,{children:S_s.map(re=>e.jsx(Tt,{value:re.value,children:re.label},re.value))})]})]},de.id))]}),e.jsx(Vn,{children:e.jsx(K,{onClick:()=>I(!1),children:"Done"})})]})}),e.jsx(_s,{open:L,onOpenChange:R,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Add Popby Idea"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Name *"}),e.jsx(Fe,{placeholder:"e.g., Homemade cookies",value:U.name,onChange:de=>V(re=>({...re,name:de.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Ar,{placeholder:"Optional description...",value:U.description,onChange:de=>V(re=>({...re,description:de.target.value}))})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),e.jsx(K,{onClick:se,disabled:!U.name.trim()||u.isPending,children:"Add Item"})]})]})})]})})}const M_s=ZS({property_address:uc().min(1,"Property address is required"),city:uc().optional(),state:uc().optional(),zip:uc().optional(),transaction_type:JWe(["buyer","seller"]),close_date:uc().min(1,"Close date is required"),sale_price:SL().min(0,"Sale price must be positive"),commission_amount:SL().optional(),lead_source_id:uc().optional(),client_type_id:uc().optional(),contact_id:uc().optional(),notes:uc().optional(),is_win:hCt()});function bat({open:t,onOpenChange:s,transaction:r}){const[n,a]=C.useState(!1),[o,l]=C.useState(""),[i,c]=C.useState(!1),[u,p]=C.useState(""),f=hue(),y=aLt(),{data:_}=FA(),{data:b}=Rg(),{data:w}=Fm(),j=uue(),N=hke(),{data:S}=mue(),T=(S==null?void 0:S.show_commission)??!0,I=rue({resolver:nue(M_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}});C.useEffect(()=>{r?I.reset({property_address:r.property_address,city:r.city||"",state:r.state||"",zip:r.zip||"",transaction_type:r.transaction_type,close_date:r.close_date,sale_price:Number(r.sale_price),commission_amount:r.commission_amount?Number(r.commission_amount):void 0,lead_source_id:r.lead_source_id||void 0,client_type_id:r.client_type_id||void 0,contact_id:r.contact_id||void 0,notes:r.notes||"",is_win:r.is_win}):I.reset({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:new Date().toISOString().split("T")[0],sale_price:0,commission_amount:void 0,lead_source_id:void 0,client_type_id:void 0,contact_id:void 0,notes:"",is_win:!1})},[r,I]);const L=async U=>{const V={property_address:U.property_address,transaction_type:U.transaction_type,close_date:U.close_date,sale_price:U.sale_price,is_win:U.is_win,commission_amount:U.commission_amount||null,lead_source_id:U.lead_source_id||null,client_type_id:U.client_type_id||null,contact_id:U.contact_id||null,city:U.city||null,state:U.state||null,zip:U.zip||null,notes:U.notes||null};r?await y.mutateAsync({id:r.id,...V}):await f.mutateAsync(V),s(!1)},R=async()=>{if(!o.trim())return;const[U,...V]=o.trim().split(" "),X=V.join(" ")||null,se=await j.mutateAsync({first_name:U,last_name:X,tagIds:[]});se&&(I.setValue("contact_id",se.id),l(""),c(!1),a(!1))},$=async()=>{if(!u.trim())return;const U=await N.mutateAsync(u.trim());U&&(I.setValue("lead_source_id",U.id),p(""))},q=w==null?void 0:w.find(U=>U.id===I.watch("contact_id"));return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-lg max-h-[90vh]",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(Vi,{className:"max-h-[70vh] pr-4",children:e.jsx(aue,{...I,children:e.jsxs("form",{onSubmit:I.handleSubmit(L),className:"space-y-4",children:[e.jsx(Rc,{control:I.control,name:"property_address",render:({field:U})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Property Address *"}),e.jsx(Sc,{children:e.jsx(Fe,{placeholder:"123 Main St",...U})}),e.jsx(vm,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Rc,{control:I.control,name:"city",render:({field:U})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"City"}),e.jsx(Sc,{children:e.jsx(Fe,{placeholder:"City",...U})})]})}),e.jsx(Rc,{control:I.control,name:"state",render:({field:U})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"State"}),e.jsx(Sc,{children:e.jsx(Fe,{placeholder:"TX",...U})})]})}),e.jsx(Rc,{control:I.control,name:"zip",render:({field:U})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Zip"}),e.jsx(Sc,{children:e.jsx(Fe,{placeholder:"75001",...U})})]})})]}),e.jsx(Rc,{control:I.control,name:"transaction_type",render:({field:U})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Transaction Type *"}),e.jsxs(rr,{onValueChange:U.onChange,value:U.value,children:[e.jsx(Sc,{children:e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select type"})})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"buyer",children:"Buyer"}),e.jsx(Tt,{value:"seller",children:"Seller"})]})]}),e.jsx(vm,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Rc,{control:I.control,name:"close_date",render:({field:U})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Close Date *"}),e.jsx(Sc,{children:e.jsx(Fe,{type:"date",...U})}),e.jsx(vm,{})]})}),e.jsx(Rc,{control:I.control,name:"sale_price",render:({field:U})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Sale Price *"}),e.jsx(Sc,{children:e.jsx(Fe,{type:"number",placeholder:"0",...U,onChange:V=>U.onChange(Number(V.target.value))})}),e.jsx(vm,{})]})})]}),T&&e.jsx(Rc,{control:I.control,name:"commission_amount",render:({field:U})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Commission"}),e.jsx(Sc,{children:e.jsx(Fe,{type:"number",placeholder:"0",...U,value:U.value??"",onChange:V=>U.onChange(V.target.value?Number(V.target.value):void 0)})})]})}),e.jsx(Rc,{control:I.control,name:"lead_source_id",render:({field:U})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Lead Source"}),e.jsxs(rr,{onValueChange:U.onChange,value:U.value||"",children:[e.jsx(Sc,{children:e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select source"})})}),e.jsx(sr,{children:_==null?void 0:_.map(V=>e.jsx(Tt,{value:V.id,children:V.name},V.id))})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{placeholder:"Add custom source...",value:u,onChange:U=>p(U.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:$,disabled:!u.trim(),children:e.jsx(Zs,{className:"h-4 w-4"})})]}),e.jsx(Rc,{control:I.control,name:"client_type_id",render:({field:U})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Client Type"}),e.jsxs(rr,{onValueChange:U.onChange,value:U.value||"",children:[e.jsx(Sc,{children:e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select client type"})})}),e.jsx(sr,{children:b==null?void 0:b.map(V=>e.jsx(Tt,{value:V.id,children:V.name},V.id))})]})]})}),e.jsx(Rc,{control:I.control,name:"contact_id",render:({field:U})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Client Contact"}),e.jsxs(Lo,{open:n,onOpenChange:a,children:[e.jsx(Do,{asChild:!0,children:e.jsx(Sc,{children:e.jsxs(K,{variant:"outline",role:"combobox",className:At("w-full justify-between",!U.value&&"text-muted-foreground"),children:[q?`${q.first_name} ${q.last_name||""}`.trim():"Select contact",e.jsx(xg,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs(Eo,{className:"w-full p-0",align:"start",children:[e.jsxs(Mg,{children:[e.jsx(Tg,{placeholder:"Search contacts..."}),e.jsxs(Ag,{children:[e.jsx(Eg,{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(Zs,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),e.jsx(Pg,{children:w==null?void 0:w.map(V=>e.jsxs(up,{value:`${V.first_name} ${V.last_name||""}`,onSelect:()=>{U.onChange(V.id),a(!1)},children:[e.jsx(ma,{className:At("mr-2 h-4 w-4",V.id===U.value?"opacity-100":"opacity-0")}),V.first_name," ",V.last_name||""]},V.id))})]})]}),i&&e.jsxs("div",{className:"p-2 border-t space-y-2",children:[e.jsx(Fe,{placeholder:"Enter contact name...",value:o,onChange:V=>l(V.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",onClick:R,disabled:!o.trim()||j.isPending,children:"Add Contact"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{c(!1),l("")},children:"Cancel"})]})]})]})]})]})}),e.jsx(Rc,{control:I.control,name:"notes",render:({field:U})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Notes"}),e.jsx(Sc,{children:e.jsx(Ar,{placeholder:"Any notes about this transaction...",...U})})]})}),e.jsx(Rc,{control:I.control,name:"is_win",render:({field:U})=>e.jsxs(kc,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Nc,{children:"Mark as Win 🏆"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),e.jsx(Sc,{children:e.jsx(Br,{checked:U.value,onCheckedChange:U.onChange})})]})}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:f.isPending||y.isPending,children:[r?"Update":"Add"," Transaction"]})]})]})})})]})})}function z4e({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=C.useState(null),[i,c]=C.useState(null),[u,p]=C.useState(""),[f,y]=C.useState("all"),[_,b]=C.useState("all"),[w,j]=C.useState("all"),[N,S]=C.useState(!1),T=iLt(),I=hue(),{data:L}=FA(),{data:R}=Rg(),$=oE(),q=X=>{const{id:se,created_at:ee,updated_at:Q,lead_source:de,client_type:re,contact:ne,...le}=X;I.mutate(le)},U=()=>{i&&(T.mutate(i),c(null))},V=t.filter(X=>{var ne,le,he,we;const se=u===""||X.property_address.toLowerCase().includes(u.toLowerCase())||((le=(ne=X.contact)==null?void 0:ne.first_name)==null?void 0:le.toLowerCase().includes(u.toLowerCase()))||((we=(he=X.contact)==null?void 0:he.last_name)==null?void 0:we.toLowerCase().includes(u.toLowerCase())),ee=f==="all"||X.transaction_type===f,Q=_==="all"||X.lead_source_id===_,de=w==="all"||X.client_type_id===w,re=!N||X.is_win;return se&&ee&&Q&&de&&re});return r?e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6 space-y-4",children:[1,2,3].map(X=>e.jsx(xs,{className:"h-16 w-full"},X))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{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(Ot,{children:["Transactions (",V.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search...",value:u,onChange:X=>p(X.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(rr,{value:f,onValueChange:y,children:[e.jsx(tr,{className:"w-[100px]",children:e.jsx(nr,{placeholder:"Type"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Types"}),e.jsx(Tt,{value:"buyer",children:"Buyer"}),e.jsx(Tt,{value:"seller",children:"Seller"})]})]}),e.jsxs(rr,{value:_,onValueChange:b,children:[e.jsx(tr,{className:"w-[130px]",children:e.jsx(nr,{placeholder:"Lead Source"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Sources"}),L==null?void 0:L.map(X=>e.jsx(Tt,{value:X.id,children:X.name},X.id))]})]}),e.jsxs(K,{variant:N?"default":"outline",size:"sm",onClick:()=>S(!N),children:[e.jsx(fc,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(Oe,{children:V.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No transactions found"}):$?e.jsx("div",{className:"space-y-3",children:V.map(X=>e.jsxs(Ee,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium truncate",children:X.property_address}),X.is_win&&e.jsx(fc,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[X.city,X.state?`, ${X.state}`:""]})]}),e.jsx(nt,{variant:X.transaction_type==="buyer"?"default":"secondary",children:X.transaction_type})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Close Date: "}),iAe(X.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),$l(X.sale_price)]}),s&&X.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),$l(X.commission_amount)]}),X.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),X.lead_source.name]}),X.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),X.contact.first_name," ",X.contact.last_name]}),n&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent: "}),n[X.owner_user_id]||"Unknown"]})]}),!a&&e.jsxs("div",{className:"flex justify-end gap-2 mt-3 pt-3 border-t",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>l(X),children:e.jsx(rd,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>q(X),children:e.jsx(mi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(X.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})]},X.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[n&&e.jsx(bt,{children:"Agent"}),e.jsx(bt,{children:"Property"}),e.jsx(bt,{children:"Type"}),e.jsx(bt,{children:"Close Date"}),e.jsx(bt,{children:"Sale Price"}),s&&e.jsx(bt,{children:"Commission"}),e.jsx(bt,{children:"Lead Source"}),e.jsx(bt,{children:"Client"}),!a&&e.jsx(bt,{className:"w-[50px]"})]})}),e.jsx(Pn,{children:V.map(X=>{var se;return e.jsxs(ks,{children:[n&&e.jsx(dt,{className:"font-medium text-sm",children:n[X.owner_user_id]||"Unknown"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[X.is_win&&e.jsx(fc,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:X.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[X.city,X.state?`, ${X.state}`:""]})]})]})}),e.jsx(dt,{children:e.jsx(nt,{variant:X.transaction_type==="buyer"?"default":"secondary",children:X.transaction_type})}),e.jsx(dt,{children:iAe(X.close_date)}),e.jsx(dt,{children:$l(X.sale_price)}),s&&e.jsx(dt,{children:X.commission_amount?$l(X.commission_amount):"-"}),e.jsx(dt,{children:((se=X.lead_source)==null?void 0:se.name)||"-"}),e.jsx(dt,{children:X.contact?`${X.contact.first_name} ${X.contact.last_name||""}`.trim():"-"}),!a&&e.jsx(dt,{children:e.jsxs(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(ag,{className:"h-4 w-4"})})}),e.jsxs(Jd,{align:"end",children:[e.jsxs(Ta,{onClick:()=>l(X),children:[e.jsx(rd,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ta,{onClick:()=>q(X),children:[e.jsx(mi,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(Ta,{onClick:()=>c(X.id),className:"text-destructive",children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},X.id)})})]})})})]}),e.jsx(bat,{open:!!o,onOpenChange:X=>!X&&l(null),transaction:o||void 0}),e.jsx(gc,{open:!!i,onOpenChange:X=>!X&&c(null),children:e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Delete Transaction?"}),e.jsx(Gl,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:U,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=(y,_)=>{if(!_||_===0)return null;const b=Math.min(y/_*100,100),w=Math.max(_-y,0),j=l>0?w/l:0,N=o/12*100,S=b>=N?"ahead":b>=N*.8?"on-track":"behind";return{percent:b,remaining:w,pace:j,status:S}},c=i(s.totalTransactions,t.transactions_goal),u=i(s.totalVolume,t.volume_goal),p=n?i(s.totalCommission,t.gci_goal):null,f=y=>{switch(y){case"ahead":return e.jsxs(nt,{className:"bg-green-500 text-white",children:[e.jsx(xc,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(nt,{variant:"secondary",children:[e.jsx(t1,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(nt,{variant:"destructive",children:[e.jsx(K4,{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(It,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Am,{className:"h-5 w-5 text-primary"}),e.jsxs(Ot,{children:[r," Goals Progress"]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[t.transactions_goal&&c&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:"Transactions"}),f(c.status)]}),e.jsx(Oi,{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(Oi,{value:u.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[$l(s.totalVolume,!0)," of ",$l(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 ",$l(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(Oi,{value:p.percent,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[$l(s.totalCommission,!0)," of ",$l(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 ",$l(p.pace,!0),"/month"]})]})]})})]})}const T_s={light:"",dark:".dark"},jat=C.createContext(null);function kat(){const t=C.useContext(jat);if(!t)throw new Error("useChart must be used within a ");return t}const Nat=C.forwardRef(({id:t,className:s,children:r,config:n,...a},o)=>{const l=C.useId(),i=`chart-${t||l.replace(/:/g,"")}`;return e.jsx(jat.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:At("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(A_s,{id:i,config:n}),e.jsx(BM,{children:r})]})})});Nat.displayName="Chart";const A_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(T_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},Sat=C.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:y},_)=>{const{config:b}=kat(),w=C.useMemo(()=>{var L;if(a||!(s!=null&&s.length))return null;const[N]=s,S=`${y||N.dataKey||N.name||"value"}`,T=Abe(b,N,S),I=!y&&typeof l=="string"?((L=b[l])==null?void 0:L.label)||l:T==null?void 0:T.label;return i?e.jsx("div",{className:At("font-medium",c),children:i(I,s)}):I?e.jsx("div",{className:At("font-medium",c),children:I}):null},[l,i,s,a,c,b,y]);if(!t||!(s!=null&&s.length))return null;const j=s.length===1&&n!=="dot";return e.jsxs("div",{ref:_,className:At("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",r),children:[j?null:w,e.jsx("div",{className:"grid gap-1.5",children:s.map((N,S)=>{const T=`${f||N.name||N.dataKey||"value"}`,I=Abe(b,N,T),L=p||N.payload.fill||N.color;return e.jsx("div",{className:At("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",n==="dot"&&"items-center"),children:u&&(N==null?void 0:N.value)!==void 0&&N.name?u(N.value,N.name,N,S,N.payload):e.jsxs(e.Fragment,{children:[I!=null&&I.icon?e.jsx(I.icon,{}):!o&&e.jsx("div",{className:At("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]",{"h-2.5 w-2.5":n==="dot","w-1":n==="line","w-0 border-[1.5px] border-dashed bg-transparent":n==="dashed","my-0.5":j&&n==="dashed"}),style:{"--color-bg":L,"--color-border":L}}),e.jsxs("div",{className:At("flex flex-1 justify-between leading-none",j?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[j?w:null,e.jsx("span",{className:"text-muted-foreground",children:(I==null?void 0:I.label)||N.name})]}),N.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:N.value.toLocaleString()})]})]})},N.dataKey)})})]})});Sat.displayName="ChartTooltip";const E_s=C.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:At("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=Abe(l,i,c);return e.jsxs("div",{className:At("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});E_s.displayName="ChartLegend";function Abe(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 Nz=["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 B4e({stats:t,year:s}){const r=t.transactionsByMonth.some(a=>a.count>0),n=t.leadSourceBreakdown.length>0;return!r&&!n?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12 text-center text-muted-foreground",children:"Add transactions to see your performance charts"})}):e.jsxs("div",{className:"grid gap-6",children:[r&&e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Transactions by Month"})}),e.jsx(Oe,{className:"overflow-hidden",children:e.jsx(Nat,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(BM,{width:"100%",height:"100%",children:e.jsxs(Xnt,{data:t.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsx(Lnt,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(RS,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(FS,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(rp,{content:e.jsx(Sat,{})}),e.jsx(N1,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(BM,{width:"100%",height:"100%",children:e.jsxs(Qnt,{children:[e.jsx(L0,{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(zO,{fill:Nz[o%Nz.length]},`cell-${o}`))}),e.jsx(rp,{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:Nz[o%Nz.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function P_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=oje(s,n,new Date);if(vve(a))return ys(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(vve(n))return ys(n,"yyyy-MM-dd")}catch{}return null}const I_s=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function L_s({open:t,onOpenChange:s}){const[r,n]=C.useState([]),[a,o]=C.useState(!1),[l,i]=C.useState(0),{data:c}=FA(),{data:u}=Rg(),p=hue(),f=()=>{const N=I_s.join(","),S=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),T=`${N} ${S}`,I=new Blob([T],{type:"text/csv"}),L=URL.createObjectURL(I),R=document.createElement("a");R.href=L,R.download="transaction-import-template.csv",R.click(),URL.revokeObjectURL(L)},y=N=>{const S=N.split(` `).filter(I=>I.trim());if(S.length<2)return[];const T=S[0].split(",").map(I=>I.trim().toLowerCase().replace(/['"]/g,""));return S.slice(1).map((I,L)=>{var ne,le,he,we;const R=[];let $="",q=!1;for(const ye of I)ye==='"'?q=!q:ye===","&&!q?(R.push($.trim()),$=""):$+=ye;R.push($.trim());const U=ye=>{var ke;const je=T.indexOf(ye);return je>=0?(ke=R[je])==null?void 0:ke.replace(/^["']|["']$/g,"").trim():""},V=(ne=U("transaction_type"))==null?void 0:ne.toLowerCase(),X=(le=U("sale_price"))==null?void 0:le.replace(/[$,]/g,""),se=(he=U("commission_amount"))==null?void 0:he.replace(/[$,]/g,""),ee=(we=U("is_win"))==null?void 0:we.toLowerCase(),Q=U("close_date"),de=P_s(Q);let re;return U("property_address")?["buyer","seller"].includes(V)?de?(!X||isNaN(Number(X)))&&(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:U("property_address"),city:U("city"),state:U("state"),zip:U("zip"),transaction_type:V==="seller"?"seller":"buyer",close_date:de||"",sale_price:Number(X)||0,commission_amount:se?Number(se):null,lead_source_name:U("lead_source"),client_type_name:U("client_type"),is_win:["yes","true","1"].includes(ee),notes:U("notes"),error:re}})},_=N=>{var I;const S=(I=N.target.files)==null?void 0:I[0];if(!S)return;const T=new FileReader;T.onload=L=>{var q;const R=(q=L.target)==null?void 0:q.result,$=y(R);n($)},T.readAsText(S)},b=async()=>{const N=r.filter(I=>!I.error);if(N.length===0){me.error("No valid transactions to import");return}o(!0),i(0);let S=0,T=0;for(let I=0;Iq.name.toLowerCase()===L.lead_source_name.toLowerCase()),$=u==null?void 0:u.find(q=>q.name.toLowerCase()===L.client_type_name.toLowerCase());await p.mutateAsync({property_address:L.property_address,city:L.city||null,state:L.state||null,zip:L.zip||null,transaction_type:L.transaction_type,close_date:L.close_date,sale_price:L.sale_price,commission_amount:L.commission_amount,lead_source_id:(R==null?void 0:R.id)||null,client_type_id:($==null?void 0:$.id)||null,contact_id:null,notes:L.notes||null,is_win:L.is_win}),S++}catch(R){T++,console.error("Failed to import transaction:",R)}i(Math.round((I+1)/N.length*100))}o(!1),S>0&&me.success(`Imported ${S} transaction${S>1?"s":""}`),T>0&&me.error(`Failed to import ${T} transaction${T>1?"s":""}`),n([]),s(!1)},w=r.filter(N=>!N.error).length,j=r.filter(N=>N.error).length;return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Import Transactions"}),e.jsx(Zr,{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(ki,{className:"h-4 w-4 mr-2"}),"Template"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"csv-file",children:"Upload CSV File"}),e.jsx(Fe,{id:"csv-file",type:"file",accept:".csv",onChange:_})]}),r.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(nt,{variant:"outline",children:[r.length," rows found"]}),w>0&&e.jsxs(nt,{className:"bg-green-500 text-white",children:[e.jsx(ma,{className:"h-3 w-3 mr-1"}),w," valid"]}),j>0&&e.jsxs(nt,{variant:"destructive",children:[e.jsx(yl,{className:"h-3 w-3 mr-1"}),j," errors"]})]}),e.jsx(Vi,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((N,S)=>e.jsxs("div",{className:`p-2 rounded text-sm ${N.error?"bg-destructive/10":"bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:N.property_address||"(no address)"}),e.jsx(nt,{variant:N.transaction_type==="buyer"?"default":"secondary",children:N.transaction_type})]}),e.jsxs("div",{className:"text-muted-foreground",children:[N.close_date," • $",N.sale_price.toLocaleString()]}),N.error&&e.jsx(hNe,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(mNe,{className:"text-xs",children:N.error})})]},S)),r.length>10&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["...and ",r.length-10," more"]})]})}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:e.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${l}%`}})}),e.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:["Importing... ",l,"%"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:b,disabled:w===0||a,children:[e.jsx(ni,{className:"h-4 w-4 mr-2"}),"Import ",w," Transaction",w!==1?"s":""]})]})]})]})})}const D_s=ZS({transactions_goal:SL().min(0).optional(),volume_goal:SL().min(0).optional(),gci_goal:SL().min(0).optional()});function O_s({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=oLt(),{data:o}=mue(),l=(o==null?void 0:o.show_commission)??!0,i=rue({resolver:nue(D_s),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});C.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(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{children:[r," Goals"]}),e.jsx(Zr,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(aue,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),className:"space-y-4",children:[e.jsx(Rc,{control:i.control,name:"transactions_goal",render:({field:u})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Transactions Goal"}),e.jsx(Sc,{children:e.jsx(Fe,{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(fie,{children:"Total number of deals you want to close"}),e.jsx(vm,{})]})}),e.jsx(Rc,{control:i.control,name:"volume_goal",render:({field:u})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"Volume Goal ($)"}),e.jsx(Sc,{children:e.jsx(Fe,{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(fie,{children:"Total sales volume you want to achieve"}),e.jsx(vm,{})]})}),l&&e.jsx(Rc,{control:i.control,name:"gci_goal",render:({field:u})=>e.jsxs(kc,{children:[e.jsx(Nc,{children:"GCI Goal ($)"}),e.jsx(Sc,{children:e.jsx(Fe,{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(fie,{children:"Gross commission income target"}),e.jsx(vm,{})]})}),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 $4e({transactions:t,isLoading:s}){const r=C.useRef(null),n=C.useRef(null),a=C.useRef([]),o=C.useRef(null),{isAdmin:l}=Ws(),[i,c]=C.useState(""),[u,p]=C.useState(!0),[f,y]=C.useState(0),[_,b]=C.useState(!1),w=t.filter(N=>N.latitude!=null&&N.longitude!=null),j=t.filter(N=>N.latitude==null||N.longitude==null);return C.useEffect(()=>{(async()=>{p(!0);try{const{data:S}=await G.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)})()},[]),C.useEffect(()=>{if(!i||j.length===0||_)return;(async()=>{var T;b(!0);let S=0;for(const I of j){const L=[I.property_address,I.city,I.state,I.zip].filter(Boolean).join(", ");if(L)try{const $=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(L)}.json?access_token=${i}&limit=1`)).json();if((T=$.features)!=null&&T[0]){const[q,U]=$.features[0].center;await G.from("scorecard_transactions").update({latitude:U,longitude:q}).eq("id",I.id),I.latitude=U,I.longitude=q,S++}}catch(R){console.error("Geocode error:",R)}}y(S),b(!1)})()},[i,t]),C.useEffect(()=>{if(!r.current||!i||n.current)return;$u.accessToken=i;const N=t.filter(I=>I.latitude!=null&&I.longitude!=null);let S=[-98.5795,39.8283],T=4;if(N.length>0){const I=N.reduce((R,$)=>R+$.longitude,0)/N.length,L=N.reduce((R,$)=>R+$.latitude,0)/N.length;S=[I,L],T=N.length===1?12:10}return n.current=new $u.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:T,center:S}),n.current.addControl(new $u.NavigationControl,"top-right"),()=>{var I;(I=n.current)==null||I.remove(),n.current=null}},[i]),C.useEffect(()=>{var S;if(!n.current||!i)return;a.current.forEach(T=>T.remove()),a.current=[],(S=o.current)==null||S.remove();const N=t.filter(T=>T.latitude!=null&&T.longitude!=null);if(N.forEach(T=>{var U;const I=T.transaction_type==="buyer",L=I?"#3B82F6":"#10B981",R=document.createElement("div");R.className="cursor-pointer",R.innerHTML=`
${I?'':''}
`;const $=new $u.Popup({offset:25,closeButton:!0}).setHTML(`
${T.property_address}
${T.city?`
${T.city}${T.state?", "+T.state:""} ${T.zip||""}
`:""}
${I?"Buyer":"Seller"} $${Number(T.sale_price).toLocaleString()}
Closed: ${Ml(T.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${(U=T.lead_source)!=null&&U.name?" · "+T.lead_source.name:""}
${T.contact?`
Client: ${T.contact.first_name} ${T.contact.last_name||""}
`:""}
`),q=new $u.Marker(R).setLngLat([T.longitude,T.latitude]).setPopup($).addTo(n.current);a.current.push(q)}),N.length>1){const T=new $u.LngLatBounds;N.forEach(I=>T.extend([I.longitude,I.latitude])),n.current.fitBounds(T,{padding:60,maxZoom:13})}else N.length===1&&n.current.flyTo({center:[N[0].longitude,N[0].latitude],zoom:12})},[t,i,_]),u||s?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[50vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(Ui,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"No Transactions Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add transactions to see them plotted on the map."})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#3B82F6"}}),e.jsx("span",{children:"Buyer"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#10B981"}}),e.jsx("span",{children:"Seller"})]}),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[w.length," of ",t.length," mapped",_&&" · Geocoding..."]})]}),e.jsx("div",{ref:r,className:"w-full h-[55vh] rounded-lg shadow-lg border"})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(yl,{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 Cat=()=>{const{data:t}=Lg();return wt({queryKey:["team-scorecard-members",t==null?void 0:t.teamId],queryFn:async()=>{const{data:s,error:r}=await G.from("team_members").select("user_id").eq("team_id",t.teamId);if(r)throw r;const n=s.map(l=>l.user_id),{data:a,error:o}=await G.from("profiles").select("id, name, email, avatar_url").in("id",n);if(o)throw o;return a||[]},enabled:!!(t!=null&&t.teamId)&&(t==null?void 0:t.role)==="team_leader"})},R_s=t=>{const{data:s}=Lg(),{data:r}=Cat();return wt({queryKey:["team-scorecard-transactions",s==null?void 0:s.teamId,t],queryFn:async()=>{const n=r.map(l=>l.id),{data:a,error:o}=await G.from("scorecard_transactions").select(` *, lead_source:lead_sources(id, name), client_type:relationship_types(id, name), contact:innercircle_contacts(id, first_name, last_name) `).in("owner_user_id",n).gte("close_date",`${t}-01-01`).lte("close_date",`${t}-12-31`).order("close_date",{ascending:!1});if(o)throw o;return a},enabled:!!r&&r.length>0})};function F_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 z_s(t,s){return t?t.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2):s[0].toUpperCase()}function B_s({year:t}){var y;const{data:s,isLoading:r}=Cat(),{data:n,isLoading:a}=R_s(t),o=Pr(),l=r||a,{aggregate:i,memberStats:c,topPerformer:u,agentNameMap:p,teamChartStats:f}=C.useMemo(()=>{if(!s||!n)return{aggregate:null,memberStats:[],topPerformer:null,agentNameMap:{},teamChartStats:null};const _=s.map(V=>F_s(V,n));_.sort((V,X)=>X.totalVolume-V.totalVolume);const b={};s.forEach(V=>{b[V.id]=V.name||V.email});const w=n.length,j=n.reduce((V,X)=>V+Number(X.sale_price),0),N=n.reduce((V,X)=>V+(Number(X.commission_amount)||0),0),S=n.filter(V=>V.transaction_type==="buyer").length,T=n.filter(V=>V.transaction_type==="seller").length,I={};n.forEach(V=>{var se;const X=((se=V.lead_source)==null?void 0:se.name)||"Unknown";I[X]=(I[X]||0)+1});const L=Object.entries(I).sort((V,X)=>X[1]-V[1])[0],R={};n.forEach(V=>{const X=Ml(V.close_date).toLocaleString("default",{month:"short"});R[X]=(R[X]||0)+1});const q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(V=>({month:V,count:R[V]||0})),U=Object.entries(I).map(([V,X])=>({name:V,count:X})).sort((V,X)=>X.count-V.count);return{aggregate:{totalTxns:w,buyerCount:S,sellerCount:T,totalVolume:j,avgPrice:w>0?j/w:0,totalGCI:N,topSource:L?{name:L[0],count:L[1]}:null,memberCount:s.length},memberStats:_,topPerformer:_[0]||null,agentNameMap:b,teamChartStats:{transactionsByMonth:q,leadSourceBreakdown:U}}},[s,n]);return l?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[1,2,3,4].map(_=>e.jsx(xs,{className:"h-24"},_))}),e.jsx(xs,{className:"h-64"})]}):!i||c.length===0?e.jsx(Ee,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-2",children:[e.jsx(mr,{className:"h-10 w-10 mx-auto text-muted-foreground"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No Team Data"}),e.jsxs("p",{className:"text-muted-foreground",children:["No scorecard transactions found for your team members in ",t,"."]})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(mr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Members"})]}),e.jsx("p",{className:"text-2xl font-bold",children:i.memberCount})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Rn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Team Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:i.totalTxns}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.buyerCount,"B / ",i.sellerCount,"S"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Td,{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:$l(i.totalVolume,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xc,{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:$l(i.avgPrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Td,{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:$l(i.totalGCI,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(fc,{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:((y=i.topSource)==null?void 0:y.name)||"-"}),i.topSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.topSource.count," deals"]})]})})]}),u&&u.totalTransactions>0&&e.jsx(Ee,{className:"border-primary/30 bg-primary/5",children:e.jsxs(Oe,{className:"pt-4 flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center justify-center h-10 w-10 rounded-full bg-primary/10",children:e.jsx(mo,{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:$l(u.totalVolume,!0)})]})]})}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Member Performance"})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Agent"}),e.jsx(bt,{className:"text-center",children:"Transactions"}),e.jsx(bt,{className:"text-center",children:"B / S"}),e.jsx(bt,{className:"text-right",children:"Volume"}),e.jsx(bt,{className:"text-right",children:"Avg Price"}),e.jsx(bt,{className:"text-right",children:"GCI"}),e.jsx(bt,{className:"text-right"})]})}),e.jsx(Pn,{children:c.map((_,b)=>e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[b===0&&_.totalTransactions>0&&e.jsx(mo,{className:"absolute -top-2 -right-2 h-3.5 w-3.5 text-amber-500"}),e.jsxs(yn,{className:"h-8 w-8",children:[e.jsx(Da,{src:_.member.avatar_url||void 0}),e.jsx(vn,{className:"text-xs",children:z_s(_.member.name,_.member.email)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:_.member.name||_.member.email}),_.member.name&&e.jsx("p",{className:"text-xs text-muted-foreground",children:_.member.email})]})]})}),e.jsx(dt,{className:"text-center font-semibold",children:_.totalTransactions}),e.jsxs(dt,{className:"text-center text-sm",children:[_.buyerCount," / ",_.sellerCount]}),e.jsx(dt,{className:"text-right font-medium",children:$l(_.totalVolume,!0)}),e.jsx(dt,{className:"text-right text-sm",children:$l(_.averagePrice,!0)}),e.jsx(dt,{className:"text-right font-medium",children:$l(_.totalGCI,!0)}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>o(`/mission-control/scorecard/${_.member.id}`),children:e.jsx(va,{className:"h-4 w-4"})})})]},_.member.id))})]})})})]}),e.jsxs(Aa,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(ja,{children:[e.jsxs(js,{value:"transactions",children:[e.jsx(Mm,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(js,{value:"charts",children:[e.jsx(xl,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(js,{value:"map",children:[e.jsx(Ui,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx($s,{value:"transactions",children:e.jsx(z4e,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:p,readOnly:!0})}),e.jsx($s,{value:"charts",children:f&&e.jsx(B4e,{stats:f,year:t})}),e.jsx($s,{value:"map",children:e.jsx($4e,{transactions:n||[],isLoading:a})})]})]})}const Mat=new Date().getFullYear(),CFe=Array.from({length:10},(t,s)=>Mat-s);function $_s(){var U;const[t,s]=C.useState(Mat),[r,n]=C.useState(!1),[a,o]=C.useState(!1),[l,i]=C.useState(!1),[c,u]=C.useState(!1),[p,f]=C.useState("my"),{data:y}=Lg(),_=(y==null?void 0:y.role)==="team_leader",{data:b,isLoading:w}=mke(t),{yearStats:j,lifetimeStats:N,showCommission:S}=EYe(t),{data:T,isLoading:I}=AYe(t),{data:L}=mue(),R=lLt(),$=()=>{if(!b||b.length===0)return;const V=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...S?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],X=b.map(re=>{var ne,le;return[re.property_address,re.city||"",re.state||"",re.zip||"",re.transaction_type,re.close_date,re.sale_price,...S?[re.commission_amount||""]:[],((ne=re.lead_source)==null?void 0:ne.name)||"",((le=re.client_type)==null?void 0:le.name)||"",re.contact?`${re.contact.first_name} ${re.contact.last_name||""}`.trim():"",re.is_win?"Yes":"No",re.notes||""]}),se=[V,...X].map(re=>re.map(ne=>`"${String(ne).replace(/"/g,'""')}"`).join(",")).join(` `),ee=new Blob([se],{type:"text/csv"}),Q=URL.createObjectURL(ee),de=document.createElement("a");de.href=Q,de.download=`transactions-${t}.csv`,de.click(),URL.revokeObjectURL(Q)},q=!b||b.length===0;return e.jsxs(Es,{title:"Scorecard",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Scorecard"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500/50 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),_&&e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-1 w-fit",children:[e.jsx(K,{variant:p==="my"?"default":"ghost",size:"sm",onClick:()=>f("my"),className:"h-8",children:"My Scorecard"}),e.jsxs(K,{variant:p==="team"?"default":"ghost",size:"sm",onClick:()=>f("team"),className:"h-8",children:[e.jsx(mr,{className:"h-4 w-4 mr-1.5"}),"Team"]})]}),p==="team"&&_?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Team Performance"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Aggregate stats and member comparison"})]}),e.jsxs(rr,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(tr,{className:"w-[120px]",children:e.jsx(nr,{})}),e.jsx(sr,{children:CFe.map(V=>e.jsx(Tt,{value:String(V),children:V},V))})]})]}),e.jsx(B_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(rr,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(tr,{className:"w-[120px]",children:e.jsx(nr,{})}),e.jsx(sr,{children:CFe.map(V=>e.jsx(Tt,{value:String(V),children:V},V))})]}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(!c),children:e.jsx(Jl,{className:"h-4 w-4"})})]})]}),c&&e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsx(Ot,{className:"text-lg",children:"Settings"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(_e,{children:"Show Commission"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display commission fields and include in stats"})]}),e.jsx(Br,{checked:(L==null?void 0:L.show_commission)??!0,onCheckedChange:V=>R.mutate({show_commission:V})})]})})]}),q&&!w?e.jsx(Ee,{className:"py-12",children:e.jsxs(Oe,{className:"text-center space-y-4",children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(xl,{className:"h-8 w-8 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Start Tracking Your Success"}),e.jsx("p",{className:"text-muted-foreground max-w-md mx-auto mt-1",children:"Add your past transactions to see your performance metrics, track your goals, and celebrate your wins."})]}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(ni,{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(ki,{className:"h-4 w-4 mr-2"}),"Download CSV Template"]})})]})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{onClick:()=>n(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!0),children:[e.jsx(Am,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(ni,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(K,{variant:"outline",onClick:$,disabled:q,children:[e.jsx(ki,{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(ki,{className:"h-4 w-4 mr-2"}),"CSV Template"]})})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Rn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:j.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[N.totalTransactions," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(mr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[j.buyerCount,"/",j.sellerCount]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"B/S split"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Td,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:$l(j.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[$l(N.totalVolume,!0)," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xc,{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:$l(j.averagePrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(fc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((U=j.topLeadSource)==null?void 0:U.name)||"-"}),j.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.topLeadSource.count," deals"]})]})}),S&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Td,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:$l(j.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[$l(N.totalCommission,!0)," lifetime"]})]})}),S&&j.totalNetToAgent>0&&j.totalNetToAgent!==j.totalCommission&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-teal-600 dark:text-teal-400 mb-1",children:[e.jsx(Td,{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:$l(j.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[$l(N.totalNetToAgent,!0)," lifetime"]})]})})]}),T&&e.jsx(wat,{goals:T,stats:j,year:t,showCommission:S}),e.jsxs(Aa,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(ja,{children:[e.jsx(js,{value:"transactions",children:"Transactions"}),e.jsx(js,{value:"charts",children:"Charts"}),e.jsxs(js,{value:"map",children:[e.jsx(Ui,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx($s,{value:"transactions",children:e.jsx(z4e,{transactions:b||[],showCommission:S,isLoading:w})}),e.jsx($s,{value:"charts",children:e.jsx(B4e,{stats:j,year:t})}),e.jsx($s,{value:"map",children:e.jsx($4e,{transactions:b||[],isLoading:w})})]})]})]})]}),e.jsx(bat,{open:r,onOpenChange:n}),e.jsx(L_s,{open:a,onOpenChange:o}),e.jsx(O_s,{open:l,onOpenChange:i,year:t,existingGoals:T})]})}function Tat({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=Ws(),[l,i]=C.useState(null),[c,u]=C.useState(!1),[p,f]=C.useState(!1);C.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:j,error:N}=await G.from("listing_shares").select("id, share_token, click_count, lead_count").eq("listing_id",r).eq("sharing_agent_id",o.id).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(N)throw N;if(j&&j.share_token)i(j);else if(j&&!j.share_token){const{data:S,error:T}=await G.from("listing_shares").update({share_type:"referral_link"}).eq("id",j.id).select("id, share_token, click_count, lead_count").single();if(T)throw T;i(S)}else{const{data:S,error:T}=await G.from("listing_shares").insert({listing_id:r,sharing_agent_id:o.id,share_type:"referral_link"}).select("id, share_token, click_count, lead_count").single();if(T)throw T;i(S)}}catch(j){console.error("Error creating share link:",j),me.error("Failed to generate share link")}finally{u(!1)}}})()},[t,o,r]);const y=l!=null&&l.share_token?`https://listings.relevelup.com/${n||r}?ref=${l.share_token}`:"",_=async()=>{try{await navigator.clipboard.writeText(y),f(!0),me.success("Link copied to clipboard!"),setTimeout(()=>f(!1),2e3)}catch{me.error("Failed to copy link")}},b=w=>{const j=encodeURIComponent(y),N=encodeURIComponent(`Check out this listing: ${a}`);switch(w){case"email":window.open(`mailto:?subject=${N}&body=${j}`);break;case"text":window.open(`sms:?body=${N}%20${j}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${j}`,"_blank");break}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-amber-500"}),"Share & Earn Leads"]}),e.jsx(Zr,{children:"Share this listing with your network. When someone submits a lead through your link, they'll become your contact!"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-3",children:e.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:[e.jsx("strong",{children:"How it works:"})," The listing still shows the original agent's info, but any leads from your unique link go directly to you!"]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Your Referral Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:c?"Generating...":y,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:_,disabled:c||!y,variant:p?"default":"outline",children:p?e.jsx(ma,{className:"h-4 w-4"}):e.jsx(mi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Share via"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("email"),disabled:c,children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("text"),disabled:c,children:[e.jsx(po,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>b("facebook"),disabled:c,children:[e.jsx(xu,{className:"h-4 w-4 mr-2"}),"Facebook"]})]})]}),l&&(l.click_count>0||l.lead_count>0)&&e.jsxs("div",{className:"pt-4 border-t",children:[e.jsx(_e,{className:"mb-2 block",children:"Your Share Performance"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-muted rounded-lg p-3 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 text-muted-foreground mb-1",children:[e.jsx(va,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Clicks"})]}),e.jsx("p",{className:"text-2xl font-bold",children:l.click_count})]}),e.jsxs("div",{className:"bg-primary/10 rounded-lg p-3 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 text-primary mb-1",children:[e.jsx(mr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs",children:"Leads"})]}),e.jsx("p",{className:"text-2xl font-bold text-primary",children:l.lead_count})]})]})]})]})]})})}const q_s={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},U_s={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},V_s={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Sz({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var w,j;const{user:o}=Ws(),{data:l}=kYe(t.id),i=jYe(),[c,u]=C.useState(!1),p=N=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(N),f=((w=t.photos)==null?void 0:w.find(N=>N.is_primary))||((j=t.photos)==null?void 0:j[0]),y=(o==null?void 0:o.id)===t.agent_id,_=async N=>{N.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")}},b=N=>{if(N.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(c0,{className:"h-12 w-12"})}),e.jsx(nt,{className:`absolute top-2 left-2 ${q_s[t.status]} text-white border-0`,children:U_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(Kn,{className:"h-4 w-4 text-white fill-white"})}),e.jsxs("div",{className:"absolute bottom-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:_,children:e.jsx(Ii,{className:`h-4 w-4 ${l?"fill-pink-500 text-pink-500":""}`})}),e.jsx(K,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:b,title:y?"Copy link":"Share & earn leads",children:y?e.jsx(Ad,{className:"h-4 w-4"}):e.jsx(hn,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(Tat,{open:c,onOpenChange:u,listingId:t.id,listingSlug:t.slug||null,listingTitle:t.property_address||`${t.city}, ${t.state}`}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xl font-bold text-primary",children:p(t.price)}),t.open_to_referrals&&e.jsxs(nt,{variant:"outline",className:"text-xs",children:[e.jsx(mr,{className:"h-3 w-3 mr-1"}),"Referrals"]})]}),e.jsxs("div",{children:[t.property_address&&e.jsx("p",{className:"font-medium truncate",children:t.property_address}),e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Ui,{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(Kv,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(n0,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(c0,{className:"h-4 w-4"}),t.square_footage.toLocaleString()," sqft"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsx(nt,{variant:"secondary",className:"text-xs",children:V_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(va,{className:"h-3 w-3"}),t.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ad,{className:"h-3 w-3"}),t.share_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ii,{className:"h-3 w-3"}),t.save_count]})]}),a&&(r||n)&&e.jsxs("div",{className:"flex gap-2",children:[r&&e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1",onClick:N=>{N.stopPropagation(),r()},children:[e.jsx(rd,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(K,{variant:"destructive",size:"sm",onClick:N=>{N.stopPropagation(),n()},children:e.jsx(jr,{className:"h-4 w-4"})})]})]})]})}const H_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"}],W_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 G_s({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(Ot,{className:"text-lg",children:"Filters"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:n,children:"Clear All"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:r,children:e.jsx(Ur,{className:"h-4 w-4"})})]})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Status"}),e.jsxs(rr,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"All statuses"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Statuses"}),H_s.map(a=>e.jsx(Tt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Property Type"}),e.jsxs(rr,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"All types"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Types"}),W_s.map(a=>e.jsx(Tt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Min Price"}),e.jsx(Fe,{type:"number",placeholder:"No minimum",value:t.minPrice||"",onChange:a=>s({...t,minPrice:a.target.value?Number(a.target.value):void 0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Max Price"}),e.jsx(Fe,{type:"number",placeholder:"No maximum",value:t.maxPrice||"",onChange:a=>s({...t,maxPrice:a.target.value?Number(a.target.value):void 0})})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Open to Referrals Only"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),e.jsx(Br,{checked:t.openToReferrals||!1,onCheckedChange:a=>s({...t,openToReferrals:a||void 0})})]})]})]})}function K_s({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(mo,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(e1,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(fc,{className:"h-5 w-5 text-amber-700"});default:return e.jsx("span",{className:"text-sm font-medium text-muted-foreground w-5 text-center",children:n+1})}},r=(n,a)=>!n||n.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"No data yet. Start sharing to climb the leaderboard!"}):e.jsx("div",{className:"space-y-2",children:n.map((o,l)=>e.jsxs("div",{className:`flex items-center gap-4 p-3 rounded-lg ${l===0?"bg-gradient-to-r from-amber-500/10 to-amber-500/5 border border-amber-500/20":"bg-muted/50"}`,children:[e.jsx("div",{className:"flex items-center justify-center w-8",children:s(l)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-medium truncate",children:o.name})}),e.jsxs(nt,{variant:l===0?"default":"secondary",children:[o.count," ",a]})]},o.agentId))});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(mo,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"text-center p-4 rounded-lg bg-gradient-to-br from-emerald-500/10 to-emerald-500/5 border border-emerald-500/20",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-emerald-500/20 flex items-center justify-center",children:e.jsx(Ad,{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(Rn,{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(e1,{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(mo,{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(It,{children:e.jsx(Ot,{children:"Community Leaderboard"})}),e.jsx(Oe,{children:e.jsxs(Aa,{defaultValue:"sharers",children:[e.jsxs(ja,{className:"w-full",children:[e.jsxs(js,{value:"sharers",className:"flex-1",children:[e.jsx(Ad,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(js,{value:"listers",className:"flex-1",children:[e.jsx(Rn,{className:"h-4 w-4 mr-2"}),"Top Contributors"]})]}),e.jsx($s,{value:"sharers",className:"mt-4",children:r(t==null?void 0:t.topSharers,"shares")}),e.jsx($s,{value:"listers",className:"mt-4",children:r(t==null?void 0:t.topListers,"listings")})]})})]})]})}const MFe={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},TFe={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function Z_s(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function Y_s({listings:t,isLoading:s}){const r=Pr(),n=C.useRef(null),a=C.useRef(null),o=C.useRef([]),{isAdmin:l}=Ws(),[i,c]=C.useState(""),[u,p]=C.useState(!0),[f,y]=C.useState(!1),_=t.filter(w=>w.latitude!=null&&w.longitude!=null),b=t.filter(w=>(w.latitude==null||w.longitude==null)&&(w.property_address||w.city));return C.useEffect(()=>{(async()=>{p(!0);try{const{data:j}=await G.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();j!=null&&j.value&&c(j.value)}catch(j){console.error("Error fetching mapbox token:",j)}p(!1)})()},[]),C.useEffect(()=>{if(!i||b.length===0||f)return;(async()=>{var j;y(!0);for(const N of b){const S=[N.property_address,N.city,N.state].filter(Boolean).join(", ");if(S)try{const I=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(S)}.json?access_token=${i}&limit=1`)).json();if((j=I.features)!=null&&j[0]){const[L,R]=I.features[0].center;await G.from("listings").update({latitude:R,longitude:L}).eq("id",N.id),N.latitude=R,N.longitude=L}}catch(T){console.error("Geocode error:",T)}}y(!1)})()},[i,t]),C.useEffect(()=>{if(!n.current||!i||a.current)return;$u.accessToken=i;const w=t.filter(S=>S.latitude!=null&&S.longitude!=null);let j=[-98.5795,39.8283],N=4;if(w.length>0){const S=w.reduce((I,L)=>I+L.longitude,0)/w.length,T=w.reduce((I,L)=>I+L.latitude,0)/w.length;j=[S,T],N=w.length===1?12:10}return a.current=new $u.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:N,center:j}),a.current.addControl(new $u.NavigationControl,"top-right"),()=>{var S;(S=a.current)==null||S.remove(),a.current=null}},[i]),C.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(j=>j.remove()),o.current=[];const w=t.filter(j=>j.latitude!=null&&j.longitude!=null);if(w.forEach(j=>{var R,$,q;const N=MFe[j.status]||"#10B981",S=((R=j.photos)==null?void 0:R.find(U=>U.is_primary))||(($=j.photos)==null?void 0:$[0]),T=document.createElement("div");T.className="cursor-pointer",T.innerHTML=`
`;const I=new $u.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${S!=null&&S.photo_url?``:""}
${Z_s(j.price)}
${j.property_address||""}
${j.city}, ${j.state}
${TFe[j.status]||j.status} ${j.bedrooms?`${j.bedrooms} bed`:""} ${j.bathrooms?`${j.bathrooms} bath`:""}
${(q=j.agent)!=null&&q.name?`
Listed by ${j.agent.name}
`:""}
Click to view details →
`),L=new $u.Marker(T).setLngLat([j.longitude,j.latitude]).setPopup(I).addTo(a.current);o.current.push(L)}),w.length>1){const j=new $u.LngLatBounds;w.forEach(N=>j.extend([N.longitude,N.latitude])),a.current.fitBounds(j,{padding:60,maxZoom:13})}else w.length===1&&a.current.flyTo({center:[w[0].longitude,w[0].latitude],zoom:12})},[t,i,f]),C.useEffect(()=>(window.__navigateToListing__=w=>{r(`/mission-control/listings/${w}`)},()=>{delete window.__navigateToListing__}),[r]),u||s?e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center h-[60vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?t.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(Ui,{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(MFe).map(([w,j])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:j}}),e.jsx("span",{className:"text-xs",children:TFe[w]})]},w)),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[_.length," of ",t.length," mapped",f&&" · Geocoding..."]})]}),e.jsx("div",{ref:n,className:"w-full h-[60vh] rounded-lg shadow-lg border"})]}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(yl,{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 X_s(){var U,V,X,se,ee,Q,de,re;const t=Pr(),{brokerageId:s}=Ws(),{data:r,isLoading:n}=yYe(),[a,o]=C.useState("feed"),[l,i]=C.useState(!1),[c,u]=C.useState(""),[p,f]=C.useState({sortBy:"newest"}),{data:y,isLoading:_}=vYe({...p,city:c||p.city}),{data:b,isLoading:w}=VIt(),{data:j,isLoading:N}=_Ye(),{data:S,isLoading:T}=KIt(),{data:I,isLoading:L}=XIt(),{data:R}=YIt(),$=wYe(),q=async ne=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await $.mutateAsync(ne),me.success("Listing deleted successfully")}catch{me.error("Failed to delete listing")}};return n?e.jsx(Es,{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(Es,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Listing Exchange"}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0.5 rounded border border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10",children:"Beta"})]}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Rn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(y==null?void 0:y.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Listings"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-pink-500/10 rounded-lg",children:e.jsx(Ii,{className:"h-5 w-5 text-pink-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(b==null?void 0:b.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-emerald-500/10 rounded-lg",children:e.jsx(R4,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(j==null?void 0:j.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"My Listings"})]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(mr,{className:"h-5 w-5 text-sky-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(((U=S==null?void 0:S.sent)==null?void 0:U.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(Aa,{value:a,onValueChange:o,children:[e.jsxs(ja,{className:"w-full justify-start overflow-x-auto",children:[e.jsx(js,{value:"feed",children:"Community Feed"}),s&&e.jsx(js,{value:"brokerage",children:"Brokerage"}),e.jsx(js,{value:"my-listings",children:"My Listings"}),e.jsx(js,{value:"saved",children:"Saved"}),e.jsx(js,{value:"referrals",children:"Referrals"}),e.jsx(js,{value:"map",children:"Map"}),e.jsx(js,{value:"leaderboard",children:"Leaderboard"})]}),e.jsxs($s,{value:"feed",className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by city or neighborhood...",value:c,onChange:ne=>u(ne.target.value),className:"pl-9"})]}),e.jsxs(rr,{value:p.sortBy,onValueChange:ne=>f({...p,sortBy:ne}),children:[e.jsx(tr,{className:"w-[180px]",children:e.jsx(nr,{placeholder:"Sort by"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"newest",children:"Newest First"}),e.jsx(Tt,{value:"updated",children:"Recently Updated"}),e.jsx(Tt,{value:"price_asc",children:"Price: Low to High"}),e.jsx(Tt,{value:"price_desc",children:"Price: High to Low"})]})]}),e.jsxs(K,{variant:"outline",onClick:()=>i(!l),children:[e.jsx(a0,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(G_s,{filters:p,onFiltersChange:f,onClose:()=>i(!1)}),_?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((ne,le)=>e.jsxs(Ee,{children:[e.jsx(xs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(xs,{className:"h-5 w-3/4"}),e.jsx(xs,{className:"h-4 w-1/2"}),e.jsx(xs,{className:"h-4 w-1/4"})]})]},le))}):(y==null?void 0:y.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Rn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No listings found"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Be the first to share a listing with the community!"}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:y==null?void 0:y.map(ne=>e.jsx(Sz,{listing:ne,onClick:()=>t(`/mission-control/listings/${ne.id}`)},ne.id))})]}),e.jsx($s,{value:"my-listings",className:"space-y-4",children:N?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ne,le)=>e.jsxs(Ee,{children:[e.jsx(xs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(xs,{className:"h-5 w-3/4"}),e.jsx(xs,{className:"h-4 w-1/2"})]})]},le))}):(j==null?void 0:j.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(R4,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No listings yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Share your listings with the LevelUp community!"}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Your First Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:j==null?void 0:j.map(ne=>e.jsx(Sz,{listing:ne,showActions:!0,onClick:()=>t(`/mission-control/listings/${ne.id}`),onEdit:()=>t(`/mission-control/listings/${ne.id}/edit`),onDelete:()=>q(ne.id)},ne.id))})}),e.jsx($s,{value:"saved",className:"space-y-4",children:w?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ne,le)=>e.jsxs(Ee,{children:[e.jsx(xs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(xs,{className:"h-5 w-3/4"}),e.jsx(xs,{className:"h-4 w-1/2"})]})]},le))}):(b==null?void 0:b.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Ii,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No saved listings"}),e.jsx("p",{className:"text-muted-foreground",children:"Save listings to quickly access them later"})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:b==null?void 0:b.map(ne=>e.jsx(Sz,{listing:ne.listing,onClick:()=>t(`/mission-control/listings/${ne.listing.id}`)},ne.id))})}),e.jsx($s,{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(Ad,{className:"h-4 w-4"}),"Referrals Sent (",((X=S==null?void 0:S.sent)==null?void 0:X.length)||0,")"]}),((se=S==null?void 0:S.sent)==null?void 0:se.length)===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals sent yet"})}):e.jsx("div",{className:"space-y-3",children:(ee=S==null?void 0:S.sent)==null?void 0:ee.map(ne=>{var le,he;return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:ne.buyer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((le=ne.listing)==null?void 0:le.property_address)||((he=ne.listing)==null?void 0:he.city)})]}),e.jsx(nt,{variant:ne.status==="closed"?"default":"secondary",children:ne.status.replace("_"," ")})]})})},ne.id)})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),"Referrals Received (",((Q=S==null?void 0:S.received)==null?void 0:Q.length)||0,")"]}),((de=S==null?void 0:S.received)==null?void 0:de.length)===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(re=S==null?void 0:S.received)==null?void 0:re.map(ne=>{var le;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:ne.buyer_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(le=ne.sender)==null?void 0:le.name]})]}),e.jsx(nt,{variant:ne.status==="closed"?"default":"secondary",children:ne.status.replace("_"," ")})]}),e.jsx(K,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>t(`/mission-control/listings/${ne.listing_id}`),children:"View Listing"})]})},ne.id)})})]})]})}),s&&e.jsx($s,{value:"brokerage",className:"space-y-4",children:L?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((ne,le)=>e.jsxs(Ee,{children:[e.jsx(xs,{className:"h-48 w-full"}),e.jsxs(Oe,{className:"p-4 space-y-2",children:[e.jsx(xs,{className:"h-5 w-3/4"}),e.jsx(xs,{className:"h-4 w-1/2"})]})]},le))}):(I==null?void 0:I.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(R4,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No brokerage listings yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No agents in your brokerage have added listings yet."}),e.jsxs(K,{onClick:()=>t("/mission-control/listings/new"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add a Listing"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:I==null?void 0:I.map(ne=>e.jsx(Sz,{listing:ne,onClick:()=>t(`/mission-control/listings/${ne.id}`)},ne.id))})}),e.jsx($s,{value:"map",children:e.jsx(Y_s,{listings:y||[],isLoading:_})}),e.jsx($s,{value:"leaderboard",children:e.jsx(K_s,{leaderboard:R})})]})]})}):e.jsx(Es,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Rn,{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 dg(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 Fhe(){const t=ai();return wt({queryKey:["deal-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function Aat(){const t=ai(),s=ss();return Dt({mutationFn:async()=>{if(!t)throw new Error("Not authenticated");const{error:r}=await G.rpc("initialize_deal_pipeline_stages",{p_user_id:t});if(r)throw r},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-stages"]})}})}function zhe(){const t=ai();return wt({queryKey:["deal-pipeline-deals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_pipeline").select(` *, contact:innercircle_contacts(id, first_name, last_name, email, phone), listing:listings(id, property_address, city, state, price, status, created_at) `).eq("owner_user_id",t).order("updated_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Eat(){const t=ai(),s=ss();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("deal_pipeline").insert({deal_name:r.deal_name,deal_type:r.deal_type,stage_id:r.stage_id||null,contact_id:r.contact_id||null,listing_id:r.listing_id||null,property_address:r.property_address||null,city:r.city||null,state:r.state||null,zip_code:r.zip_code||null,expected_price:r.expected_price||null,expected_commission:r.expected_commission||null,commission_percentage:r.commission_percentage||3,target_close_date:r.target_close_date||null,contract_date:r.contract_date||null,listing_date:r.listing_date||null,priority:r.priority||"medium",probability:r.probability||50,notes:r.notes||null,owner_user_id:t}).select().single();if(a)throw a;return await G.from("deal_activities").insert([{deal_id:n.id,activity_type:"system",title:"Deal created",description:`Deal "${r.deal_name}" was created`}]),n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-pipeline-deals"]}),s.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function Pat(){const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("deal_pipeline").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function Q_s(){const t=ss();return Dt({mutationFn:async({dealId:s,stageId:r,stageName:n})=>{const{data:a,error:o}=await G.from("deal_pipeline").update({stage_id:r}).eq("id",s).select().single();if(o)throw o;return await G.from("deal_activities").insert({deal_id:s,activity_type:"stage_change",title:`Moved to ${n}`,metadata:{new_stage_id:r,new_stage_name:n}}),a},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-activities"]})}})}function J_s(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("deal_pipeline").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function ebs(t){return wt({queryKey:["deal-activities",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_activities").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function tbs(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("deal_activities").insert([{deal_id:s.deal_id,activity_type:s.activity_type,title:s.title,description:s.description||null}]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-activities",r.deal_id]})}})}function sbs(t){return wt({queryKey:["deal-checklist",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_checklist_items").select("*").eq("deal_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function rbs(){const t=ss();return Dt({mutationFn:async({id:s,is_completed:r,deal_id:n})=>{const{data:a,error:o}=await G.from("deal_checklist_items").update({is_completed:r,completed_at:r?new Date().toISOString():null}).eq("id",s).select().single();if(o)throw o;return a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-checklist",r.deal_id]})}})}function nbs(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("deal_checklist_items").insert([{deal_id:s.deal_id,title:s.title,description:s.description||null,due_date:s.due_date||null,sort_order:s.sort_order||0}]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-checklist",r.deal_id]})}})}function abs(){const t=ai();return wt({queryKey:["deal-pipeline-stats",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.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+(dg(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+(dg(c)||0)*u},0),ytdWonDeals:l.length,ytdWonGCI:l.reduce((i,c)=>i+(c.expected_commission||0),0),ytdWonNet:l.reduce((i,c)=>i+(dg(c)||0),0),projectedAnnualNet:l.reduce((i,c)=>i+(dg(c)||0),0)+n.reduce((i,c)=>{const u=(c.probability??50)/100;return i+(dg(c)||0)*u},0)}},enabled:!!t})}function ibs(t){const s=ai();return wt({queryKey:["deal-by-listing",t,s],queryFn:async()=>{if(!s||!t)return null;const{data:r,error:n}=await G.from("deal_pipeline").select(` *, deal_pipeline_stages(id, name, color) `).eq("owner_user_id",s).eq("listing_id",t).maybeSingle();if(n)throw n;return r},enabled:!!s&&!!t})}function obs(){const t=ss();return Dt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await G.from("deal_pipeline").update({listing_id:r}).eq("id",s).select().single();if(a)throw a;return await G.from("deal_activities").insert({deal_id:s,activity_type:"system",title:"Linked to Listing Exchange",description:"This deal is now synced with Listing Exchange",metadata:{listing_id:r}}),n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-by-listing",r.listingId]})}})}function lbs(){const t=ss();return Dt({mutationFn:async({dealId:s,listingId:r})=>{const{data:n,error:a}=await G.from("deal_pipeline").update({listing_id:null}).eq("id",s).select().single();if(a)throw a;return{data:n,listingId:r}},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-by-listing",s.listingId]})}})}function cbs({listing:t}){const s=Pr(),[r,n]=C.useState(""),[a,o]=C.useState(!1),{data:l,isLoading:i}=ibs(t.id),{data:c,isLoading:u}=Fhe(),{data:p,isLoading:f}=zhe(),y=Aat(),_=obs(),b=lbs(),w=Eat(),j=(p==null?void 0:p.filter(L=>!L.listing_id))||[],N=L=>{if(!(c!=null&&c.length))return null;switch(L){case"coming_soon":case"active":case"price_improvement":return c.find(R=>R.name==="Active");case"under_contract":return c.find(R=>R.name==="Under Contract");case"sold":return c.find(R=>R.is_won_stage);default:return c.find(R=>R.name==="Active")}},S=async()=>{o(!0);try{c!=null&&c.length||await y.mutateAsync();const L=N(t.status);await w.mutateAsync({deal_name:t.property_address?`${t.property_address}, ${t.city}`:`${t.city}, ${t.state}`,deal_type:"seller",stage_id:(L==null?void 0:L.id)||null,listing_id:t.id,property_address:t.property_address,city:t.city,state:t.state,expected_price:t.price,expected_commission:t.price*.03,commission_percentage:3,priority:"medium",probability:50}),me.success("Deal created and linked to listing!")}catch(L){console.error("Failed to create deal:",L),me.error("Failed to create deal")}finally{o(!1)}},T=async()=>{if(!r){me.error("Please select a deal");return}try{await _.mutateAsync({dealId:r,listingId:t.id}),me.success("Listing linked to deal!"),n("")}catch{me.error("Failed to link listing")}},I=async()=>{if(l)try{await b.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(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2 text-base",children:[e.jsx(i0,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ss,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(Ee,{className:"border-primary/20 bg-primary/5",children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"flex items-center gap-2 text-base",children:[e.jsx(sl,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:l.deal_name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:l.deal_pipeline_stages&&e.jsx(nt,{variant:"secondary",className:"text-xs",style:{backgroundColor:`${l.deal_pipeline_stages.color}20`,color:l.deal_pipeline_stages.color},children:l.deal_pipeline_stages.name})})]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Status changes sync automatically between the listing and pipeline."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>s("/mission-control/pipeline"),children:["View Pipeline",e.jsx(Ki,{className:"h-3 w-3 ml-1"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:I,disabled:b.isPending,children:b.isPending?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(Z4,{className:"h-4 w-4"})})]})]})]}):e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"flex items-center gap-2 text-base",children:[e.jsx(i0,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link this listing to your pipeline to track the deal and sync status changes."}),e.jsxs(K,{onClick:S,disabled:a||w.isPending,className:"w-full",size:"sm",children:[a||w.isPending?e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create New Deal"]}),j.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(rr,{value:r,onValueChange:n,children:[e.jsx(tr,{className:"flex-1 text-sm",children:e.jsx(nr,{placeholder:"Link to existing deal..."})}),e.jsx(sr,{children:j.map(L=>e.jsx(Tt,{value:L.id,children:L.deal_name},L.id))})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:T,disabled:!r||_.isPending,children:_.isPending?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(sl,{className:"h-4 w-4"})})]})]})]})]})}const dbs={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},ubs={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},AFe={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function hbs(){var ee,Q,de,re,ne,le,he,we,ye;const{listingId:t}=Po(),s=Pr(),{user:r}=Ws(),{data:n,isLoading:a}=bYe(t||""),{data:o}=kYe(t||""),{data:l}=WIt(t||""),i=jYe(),c=HIt(),u=GIt(),p=wYe(),f=ZIt(),[y,_]=C.useState(!1),[b,w]=C.useState(!1),[j,N]=C.useState(!1),[S,T]=C.useState(null),[I,L]=C.useState({buyerName:"",buyerType:"",notes:""}),R=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),$=je=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(je),q=async je=>{const ke=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,We=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:je});try{switch(je){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(ke)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(ke),me.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${We} ${ke}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(We)}&body=${encodeURIComponent(`Check out this listing: ${ke}`)}`);break}}catch(be){console.error("Share error:",be),me.error("Failed to share")}},U=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(!I.buyerName.trim()){me.error("Please enter buyer name");return}try{await f.mutateAsync({listingId:n.id,listingAgentId:n.agent_id,buyerName:I.buyerName,buyerType:I.buyerType||void 0,notes:I.notes||void 0}),me.success("Referral sent successfully!"),w(!1),L({buyerName:"",buyerType:"",notes:""})}catch{me.error("Failed to send referral")}},X=je=>{var Te,qe;const ke=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,We=$((n==null?void 0:n.price)||0),be=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Me=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",Ae=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",Re=[be,Me,Ae].filter(Boolean).join(" | ");switch(je){case"just_listed":return`🏡 JUST LISTED! ${ke} ${We} ${Re} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(Te=n==null?void 0:n.city)==null?void 0:Te.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${ke} Now ${We}! ${Re} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${AFe[(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! ${Re} DM me for details! 📩 #ComingSoon #RealEstate #${(qe=n==null?void 0:n.city)==null?void 0:qe.replace(/\s/g,"")}`;default:return""}};if(a)return e.jsx(Es,{title:"Listing",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-10 w-32"}),e.jsx(xs,{className:"h-[400px] w-full"}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsx(xs,{className:"h-48"}),e.jsx(xs,{className:"h-48"}),e.jsx(xs,{className:"h-48"})]})]})});if(!n)return e.jsx(Es,{title:"Listing Not Found",description:"",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing could not be found."}),e.jsx(K,{onClick:()=>s("/mission-control/listings"),children:"Back to Listings"})]})})});const se=((ee=n.photos)==null?void 0:ee.find(je=>je.is_primary))||((Q=n.photos)==null?void 0:Q[0]);return e.jsxs(Es,{title:"",description:"",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs(K,{variant:"ghost",onClick:()=>s("/mission-control/listings"),children:[e.jsx(di,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>se&&T(se.photo_url),children:se?e.jsx("img",{src:se.photo_url,alt:"Primary",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No photos"})})}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:(de=n.photos)==null?void 0:de.slice(1,5).map((je,ke)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>T(je.photo_url),children:e.jsx("img",{src:je.photo_url,alt:`Photo ${ke+2}`,className:"w-full h-full object-cover"})},je.id))})]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(nt,{className:`${dbs[n.status]} text-white border-0`,children:ubs[n.status]}),n.is_featured&&e.jsxs(nt,{variant:"outline",className:"border-amber-500 text-amber-500",children:[e.jsx(Kn,{className:"h-3 w-3 mr-1 fill-amber-500"}),"Featured"]}),n.open_to_referrals&&e.jsxs(nt,{variant:"outline",children:[e.jsx(mr,{className:"h-3 w-3 mr-1"}),"Open to Referrals"]})]}),e.jsx("h1",{className:"text-3xl font-bold text-primary mb-2",children:$(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(Ui,{className:"h-4 w-4"}),n.city,", ",n.state,n.neighborhood&&` • ${n.neighborhood}`]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>i.mutate(n.id),children:e.jsx(Ii,{className:`h-4 w-4 ${o?"fill-pink-500 text-pink-500":""}`})}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>c.mutate(n.id),children:l?e.jsx(Mb,{className:"h-4 w-4"}):e.jsx(gg,{className:"h-4 w-4"})}),!R&&e.jsxs(K,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>N(!0),children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),e.jsxs(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Ad,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(Jd,{children:[e.jsxs(Ta,{onClick:()=>q("copy"),children:[e.jsx(mi,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(Ta,{onClick:()=>q("facebook"),children:[e.jsx(xu,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(Ta,{onClick:()=>q("text"),children:[e.jsx(po,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(Ta,{onClick:()=>q("email"),children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),R&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/listings/${n.id}/edit`),children:[e.jsx(rd,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>_(!0),children:e.jsx(jr,{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(Kv,{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(n0,{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(c0,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.square_footage.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sq Ft"})]}),n.year_built&&e.jsxs("div",{className:"text-center",children:[e.jsx(on,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),e.jsx("p",{className:"font-semibold",children:n.year_built}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Built"})]})]}),e.jsxs("div",{className:"pt-4 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(nt,{variant:"secondary",children:[e.jsx(La,{className:"h-3 w-3 mr-1"}),AFe[n.property_type]]}),n.lot_size&&e.jsxs(nt,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(nt,{variant:"secondary",children:"HOA"})]}),n.description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium mb-2",children:"Description"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.description})]}),n.agent_notes&&n.agent_notes_public&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium mb-2",children:"Agent Notes"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.agent_notes})]}),n.mls_link&&e.jsx(K,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:n.mls_link,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{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(va,{className:"h-4 w-4"}),n.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ad,{className:"h-4 w-4"}),n.share_count," shares"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ii,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Share Content"})}),e.jsx(Oe,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(je=>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:[je.replace("_"," ")," Caption"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(X(je)),me.success("Caption copied!")},children:e.jsx(mi,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:X(je)})]},je))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Listing Agent"})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("span",{className:"text-lg font-semibold text-primary",children:((ne=(re=n.agent)==null?void 0:re.name)==null?void 0:ne.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((le=n.agent)==null?void 0:le.name)||"Unknown"}),((we=(he=n.agent)==null?void 0:he.brokerage)==null?void 0:we.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:n.agent.brokerage.name})]})]}),!R&&e.jsx("div",{className:"space-y-2",children:((ye=n.agent)==null?void 0:ye.email)&&e.jsx(K,{variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`mailto:${n.agent.email}`,children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),R&&e.jsx(cbs,{listing:n}),!R&&n.open_to_referrals&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Have a buyer interested in this property? Send a referral to the listing agent."}),e.jsx(K,{className:"w-full",onClick:()=>w(!0),children:"Send Referral"})]})]})]})]})]}),e.jsx(_s,{open:!!S,onOpenChange:()=>T(null),children:e.jsx(vs,{className:"max-w-4xl",children:e.jsx("img",{src:S||"",alt:"Full size",className:"w-full h-auto"})})}),e.jsx(_s,{open:y,onOpenChange:_,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Delete Listing"}),e.jsx(Zr,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:U,disabled:p.isPending,children:p.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(_s,{open:b,onOpenChange:w,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Send Buyer Referral"}),e.jsx(Zr,{children:"Submit buyer information to the listing agent"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Buyer Name *"}),e.jsx(Fe,{value:I.buyerName,onChange:je=>L({...I,buyerName:je.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Buyer Type"}),e.jsxs(rr,{value:I.buyerType,onValueChange:je=>L({...I,buyerType:je}),children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select type"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"first_time",children:"First-Time Buyer"}),e.jsx(Tt,{value:"investor",children:"Investor"}),e.jsx(Tt,{value:"relocating",children:"Relocating"}),e.jsx(Tt,{value:"upgrade",children:"Upgrading"}),e.jsx(Tt,{value:"downsize",children:"Downsizing"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Notes"}),e.jsx(Ar,{value:I.notes,onChange:je=>L({...I,notes:je.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(K,{onClick:V,disabled:f.isPending,children:f.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(Tat,{open:j,onOpenChange:N,listingId:(n==null?void 0:n.id)||"",listingSlug:(n==null?void 0:n.slug)||null,listingTitle:(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`})]})}function mbs({photo:t,onRemove:s,onSetPrimary:r}){const{attributes:n,listeners:a,setNodeRef:o,transform:l,transition:i,isDragging:c}=ott({id:t.id}),u={transform:ET.Transform.toString(l),transition:i};return e.jsxs("div",{ref:o,style:u,className:At("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(yh,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>s(t.id),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Ur,{className:"h-3 w-3"})}),t.is_primary?e.jsxs("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded flex items-center gap-0.5",children:[e.jsx(Kn,{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 pbs({photos:t,uploading:s,onUpload:r,onRemove:n,onReorder:a,onSetPrimary:o}){const l=zet(Z1e(Fue,{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 y=i.findIndex(N=>N.id===p.id),_=i.findIndex(N=>N.id===f.id),b=[...i],[w]=b.splice(y,1);b.splice(_,0,w);const j=b.map((N,S)=>({...N,sort_order:S}));a(j)};return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Drag photos to reorder. Hover to set primary."}),e.jsx(stt,{sensors:l,collisionDetection:Uet,onDragEnd:c,children:e.jsx(att,{items:i.map(u=>u.id),strategy:$ue,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[i.map(u=>e.jsx(mbs,{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(Ss,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(ni,{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 fbs({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=Pr(),{user:a}=Ws(),[o,l]=C.useState(!1),[i,c]=C.useState([]),[u,p]=C.useState(!1),[f,y]=C.useState(null),[_,b]=C.useState({});C.useEffect(()=>{t&&a?w():y(null)},[t,a]);const w=async()=>{if(!t)return;const{data:U,error:V}=await G.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("id",t).eq("is_deleted",!1).single();!V&&U&&(y(U),j(U))},j=async U=>{try{const{data:V,error:X}=await G.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:U.bunny_video_id,isAgentVideo:!0}});!X&&(V!=null&&V.thumbnailUrl)&&b(se=>({...se,[U.id]:{thumbnailUrl:V.thumbnailUrl}}))}catch(V){console.warn("Failed to get signed URL",V)}},N=async()=>{if(a){p(!0);try{const{data:U,error:V}=await G.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("owner_user_id",a.id).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(V)throw V;c(U||[]),U!=null&&U.length&&S(U)}catch(U){console.error("Error fetching videos:",U),me.error("Failed to load videos")}finally{p(!1)}}},S=async U=>{var V;try{const X=U.map(re=>re.bunny_video_id),{data:se,error:ee}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:X,isAgentVideo:!0}});if(ee)throw ee;const Q=(se==null?void 0:se.assets)||{},de={};for(const re of U)(V=Q[re.bunny_video_id])!=null&&V.thumbnailUrl&&(de[re.id]={thumbnailUrl:Q[re.bunny_video_id].thumbnailUrl});b(re=>({...re,...de}))}catch(X){console.warn("Failed to bulk-fetch signed URLs",X)}},T=()=>{l(!0),N()},I=U=>{s(U.id),y(U),l(!1),me.success("Video selected")},L=()=>{s(null),y(null)},R=()=>{const U=r?`/mission-control/listings/${r}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent(U)}`)},$=U=>{if(!U)return"0:00";const V=Math.floor(U/60),X=U%60;return`${V}:${X.toString().padStart(2,"0")}`},q=U=>{var V;return((V=_[U.id])==null?void 0:V.thumbnailUrl)||U.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[f?e.jsx(Ee,{className:"overflow-hidden",children:e.jsx(Oe,{className:"p-0",children:e.jsxs("div",{className:"flex items-start gap-4 p-4",children:[e.jsxs("div",{className:"relative w-32 h-20 bg-muted rounded-lg overflow-hidden flex-shrink-0",children:[q(f)?e.jsx("img",{src:q(f),alt:f.title||"Video thumbnail",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Nn,{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(wl,{className:"h-6 w-6 text-white fill-white"})}),f.duration_seconds&&e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded",children:$(f.duration_seconds)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:f.title||"Untitled Video"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Property Video Tour"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{type:"button",variant:"outline",size:"sm",onClick:T,children:"Change"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:L,className:"text-destructive hover:text-destructive",children:e.jsx(Ur,{className:"h-4 w-4"})})]})]})})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"p-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Nn,{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:T,className:"gap-2",children:[e.jsx(pM,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(K,{type:"button",variant:"outline",onClick:R,className:"gap-2",children:[e.jsx(Vx,{className:"h-4 w-4"}),"Record New Video"]})]})]})})}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsx(Cs,{children:e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(pM,{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(Ss,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Nn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No videos in your library yet"}),e.jsxs(K,{onClick:R,className:"gap-2",children:[e.jsx(Vx,{className:"h-4 w-4"}),"Record Your First Video"]})]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 p-1",children:i.map(U=>e.jsxs("button",{type:"button",onClick:()=>I(U),className:`group relative rounded-lg overflow-hidden border-2 transition-all text-left ${t===U.id?"border-primary ring-2 ring-primary/20":"border-transparent hover:border-muted-foreground/30"}`,children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[q(U)?e.jsx("img",{src:q(U),alt:U.title||"Video",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Nn,{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(wl,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity"})}),U.duration_seconds&&e.jsx("div",{className:"absolute bottom-1 right-1 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded",children:$(U.duration_seconds)})]}),e.jsx("div",{className:"p-2 bg-card",children:e.jsx("p",{className:"text-xs font-medium truncate",children:U.title||"Untitled Video"})})]},U.id))})}),e.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:R,className:"gap-2",children:[e.jsx(Vx,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const gbs=[{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"}],xbs=[{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 EFe(){const{listingId:t}=Po(),[s]=Xc(),r=s.get("brokerage"),n=Pr(),{user:a}=Ws(),o=!!t&&t!=="new",l=!!r&&!o,{data:i,isLoading:c}=bYe(o?t:""),u=RIt(),p=FIt(),f=zIt(),y=BIt(),_=$It(),b=qIt(),w=UIt(),{data:j=[]}=wt({queryKey:["brokerage-agents",r],queryFn:async()=>{if(!r)return[];const{data:ne,error:le}=await G.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name");if(le)throw le;return ne||[]},enabled:l}),[N,S]=C.useState(""),[T,I]=C.useState(!1),[L,R]=C.useState([]),[$,q]=C.useState([]),[U,V]=C.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});C.useEffect(()=>{var ne,le,he,we,ye;i&&o&&V({property_address:i.property_address||"",city:i.city||"",state:i.state||"",neighborhood:i.neighborhood||"",price:((ne=i.price)==null?void 0:ne.toString())||"",property_type:i.property_type,status:i.status,bedrooms:((le=i.bedrooms)==null?void 0:le.toString())||"",bathrooms:((he=i.bathrooms)==null?void 0:he.toString())||"",square_footage:((we=i.square_footage)==null?void 0:we.toString())||"",lot_size:i.lot_size||"",year_built:((ye=i.year_built)==null?void 0:ye.toString())||"",has_hoa:i.has_hoa,description:i.description||"",agent_notes:i.agent_notes||"",agent_notes_public:i.agent_notes_public,mls_link:i.mls_link||"",video_link:i.video_link||"",video_id:i.video_id||null,allow_sharing:i.allow_sharing,open_to_referrals:i.open_to_referrals,open_to_social_promotion:i.open_to_social_promotion,share_with_brokerage:i.share_with_brokerage??!1,is_public:i.is_public})},[i,o]);const X=ne=>{if(!ne)return;const le=Array.from(ne);R(we=>[...we,...le]);const he=le.map(we=>URL.createObjectURL(we));q(we=>[...we,...he])},se=ne=>{URL.revokeObjectURL($[ne]),R(le=>le.filter((he,we)=>we!==ne)),q(le=>le.filter((he,we)=>we!==ne))},ee=async ne=>{var le;if(!(!ne||!i)){I(!0);try{for(const he of Array.from(ne)){const we=he.name.split(".").pop(),ye=`${a==null?void 0:a.id}/${i.id}/${Date.now()}.${we}`,{error:je}=await G.storage.from("listing-photos").upload(ye,he);if(je)throw je;const{data:{publicUrl:ke}}=G.storage.from("listing-photos").getPublicUrl(ye);await y.mutateAsync({listingId:i.id,photoUrl:ke,isPrimary:!((le=i.photos)!=null&&le.length)})}me.success("Photos uploaded!")}catch(he){console.error("Upload error:",he),me.error("Failed to upload photos")}finally{I(!1)}}},Q=async ne=>{for(let le=0;le{if(i)try{await _.mutateAsync({photoId:ne,listingId:i.id}),me.success("Photo removed")}catch{me.error("Failed to remove photo")}},re=async ne=>{if(ne.preventDefault(),!U.city.trim()||!U.state.trim()||!U.price){me.error("Please fill in required fields (City, State, Price)");return}if(l&&!N){me.error("Please select an agent to assign this listing to");return}try{const le={property_address:U.property_address||null,city:U.city,state:U.state,neighborhood:U.neighborhood||null,price:Number(U.price),property_type:U.property_type,status:U.status,bedrooms:U.bedrooms?Number(U.bedrooms):null,bathrooms:U.bathrooms?Number(U.bathrooms):null,square_footage:U.square_footage?Number(U.square_footage):null,lot_size:U.lot_size||null,year_built:U.year_built?Number(U.year_built):null,has_hoa:U.has_hoa,description:U.description||null,agent_notes:U.agent_notes||null,agent_notes_public:U.agent_notes_public,mls_link:U.mls_link||null,video_link:U.video_link||null,video_id:U.video_id||null,allow_sharing:U.allow_sharing,open_to_referrals:U.open_to_referrals,open_to_social_promotion:U.open_to_social_promotion,share_with_brokerage:U.share_with_brokerage,is_public:U.is_public};if(o)await f.mutateAsync({id:t,...le}),me.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{I(!0);let he;if(l&&N?he=await p.mutateAsync({agentId:N,...le}):he=await u.mutateAsync(le),L.length>0)try{await Q(he.id),$.forEach(we=>URL.revokeObjectURL(we)),R([]),q([])}catch(we){console.error("Photo upload error:",we),me.error("Listing created but some photos failed to upload")}I(!1),me.success("Listing created!"),n(l?"/my-brokerage":`/mission-control/listings/${he.id}`)}}catch(le){console.error("Save error:",le),me.error("Failed to save listing"),I(!1)}};return o&&c?e.jsx(Es,{title:"Loading...",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-10 w-32"}),e.jsx(xs,{className:"h-[600px] w-full"})]})}):e.jsx(Es,{title:o?"Edit Listing":l?"Add Listing for Agent":"Add Listing",description:"",children:e.jsxs("form",{onSubmit:re,className:"space-y-6",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:()=>n(l?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(di,{className:"h-4 w-4 mr-2"}),l?"Back to Brokerage":"Back to Listings"]}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[l&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Assign to Agent *"})}),e.jsxs(Oe,{children:[e.jsxs(rr,{value:N,onValueChange:S,children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select an agent..."})}),e.jsx(sr,{children:j.map(ne=>e.jsx(Tt,{value:ne.id,children:ne.name||ne.email},ne.id))})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"This listing will appear on the selected agent's Listing Exchange."})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Property Details"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"sm:col-span-2 space-y-2",children:[e.jsx(_e,{children:"Property Address"}),e.jsx(Fe,{value:U.property_address,onChange:ne=>V({...U,property_address:ne.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"City *"}),e.jsx(Fe,{value:U.city,onChange:ne=>V({...U,city:ne.target.value}),placeholder:"City",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"State *"}),e.jsx(Fe,{value:U.state,onChange:ne=>V({...U,state:ne.target.value}),placeholder:"State",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Neighborhood"}),e.jsx(Fe,{value:U.neighborhood,onChange:ne=>V({...U,neighborhood:ne.target.value}),placeholder:"Neighborhood"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Price *"}),e.jsx(Fe,{type:"number",value:U.price,onChange:ne=>V({...U,price:ne.target.value}),placeholder:"500000",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Property Type"}),e.jsxs(rr,{value:U.property_type,onValueChange:ne=>V({...U,property_type:ne}),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:xbs.map(ne=>e.jsx(Tt,{value:ne.value,children:ne.label},ne.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Status"}),e.jsxs(rr,{value:U.status,onValueChange:ne=>V({...U,status:ne}),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:gbs.map(ne=>e.jsx(Tt,{value:ne.value,children:ne.label},ne.value))})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Property Specs (Optional)"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Bedrooms"}),e.jsx(Fe,{type:"number",value:U.bedrooms,onChange:ne=>V({...U,bedrooms:ne.target.value}),placeholder:"3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Bathrooms"}),e.jsx(Fe,{type:"number",step:"0.5",value:U.bathrooms,onChange:ne=>V({...U,bathrooms:ne.target.value}),placeholder:"2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Sq Ft"}),e.jsx(Fe,{type:"number",value:U.square_footage,onChange:ne=>V({...U,square_footage:ne.target.value}),placeholder:"2000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Lot Size"}),e.jsx(Fe,{value:U.lot_size,onChange:ne=>V({...U,lot_size:ne.target.value}),placeholder:"0.25 acres"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Year Built"}),e.jsx(Fe,{type:"number",value:U.year_built,onChange:ne=>V({...U,year_built:ne.target.value}),placeholder:"2005"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx(Br,{checked:U.has_hoa,onCheckedChange:ne=>V({...U,has_hoa:ne})}),e.jsx(_e,{children:"Has HOA"})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Description & Links"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Description"}),e.jsx(Ar,{value:U.description,onChange:ne=>V({...U,description:ne.target.value}),placeholder:"Tell the story of this property...",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Agent Notes"}),e.jsx(Ar,{value:U.agent_notes,onChange:ne=>V({...U,agent_notes:ne.target.value}),placeholder:"Notes for other agents...",rows:2}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:U.agent_notes_public,onCheckedChange:ne=>V({...U,agent_notes_public:ne})}),e.jsx(_e,{className:"text-sm text-muted-foreground",children:"Make notes visible to other agents"})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"MLS Link"}),e.jsx(Fe,{value:U.mls_link,onChange:ne=>V({...U,mls_link:ne.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Video Link"}),e.jsx(Fe,{value:U.video_link,onChange:ne=>V({...U,video_link:ne.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Nn,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(Oe,{children:e.jsx(fbs,{selectedVideoId:U.video_id,onVideoSelect:ne=>V({...U,video_id:ne}),listingId:o?t:void 0})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Photos"})}),e.jsx(Oe,{children:o&&(i!=null&&i.photos)?e.jsx(pbs,{photos:i.photos,uploading:T,onUpload:ne=>ee(ne),onRemove:ne=>de(ne),onReorder:ne=>{b.mutate({photos:ne.map(le=>({id:le.id,sort_order:le.sort_order,is_primary:le.is_primary}))})},onSetPrimary:ne=>{i&&w.mutate({photoId:ne,listingId:i.id})}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[$.map((ne,le)=>e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:ne,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:()=>se(le),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90",children:e.jsx(Ur,{className:"h-3 w-3"})}),le===0&&e.jsx("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded",children:"Primary"})]},le)),e.jsxs("label",{className:"aspect-square rounded-lg border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 cursor-pointer flex flex-col items-center justify-center gap-2 text-muted-foreground",children:[T?e.jsx(Ss,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(ni,{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:ne=>X(ne.target.files),disabled:T})]})]}),L.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-4",children:[L.length," photo",L.length!==1?"s":""," will be uploaded when you save."]})]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Sharing & Collaboration"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Allow Sharing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Other agents can share this listing"})]}),e.jsx(Br,{checked:U.allow_sharing,onCheckedChange:ne=>V({...U,allow_sharing:ne})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Open to Referrals"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept buyer referrals"})]}),e.jsx(Br,{checked:U.open_to_referrals,onCheckedChange:ne=>V({...U,open_to_referrals:ne})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Social Promotion"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be promoted on social media"})]}),e.jsx(Br,{checked:U.open_to_social_promotion,onCheckedChange:ne=>V({...U,open_to_social_promotion:ne})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Share with Brokerage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),e.jsx(Br,{checked:U.share_with_brokerage,onCheckedChange:ne=>V({...U,share_with_brokerage:ne})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Make Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Publish on listings.relevelup.com to get leads"})]}),e.jsx(Br,{checked:U.is_public,onCheckedChange:ne=>V({...U,is_public:ne})})]})]})]}),e.jsx(K,{type:"submit",className:"w-full",size:"lg",disabled:u.isPending||f.isPending,children:u.isPending||f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):o?"Update Listing":"Create Listing"})]})]})]})})}let Qm=null;function ybs(){if(Qm)return Qm;try{const t=document.createElement("canvas"),s=t.getContext("webgl2")||t.getContext("webgl");if(!s)return Qm={canRunVirtualBg:!1,reason:"WebGL is not supported on this device"},Qm;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 Qm={canRunVirtualBg:!1,reason:"Your device uses a software renderer which may cause lag",renderer:n},Qm;const i=performance;return i.memory&&i.memory.jsHeapSizeLimit<256*1024*1024?(Qm={canRunVirtualBg:!1,reason:"Limited device memory detected",renderer:n},Qm):navigator.hardwareConcurrency&&navigator.hardwareConcurrency<2?(Qm={canRunVirtualBg:!1,reason:"Single-core device detected — virtual backgrounds may cause lag",renderer:n},Qm):(Qm={canRunVirtualBg:!0,renderer:n},Qm)}catch{return Qm={canRunVirtualBg:!0},Qm}}const vbs=[{type:"none",label:"Off"},{type:"blur",label:"Blur"}];function _bs({value:t,onChange:s,isLoading:r=!1,disabled:n=!1,className:a}){const o=C.useRef(null),[l,i]=C.useState(!1),[c]=C.useState(()=>ybs()),u=!c.canRunVirtualBg,{data:p=[],refetch:f}=wt({queryKey:["video-backgrounds"],queryFn:async()=>{const{data:{user:j}}=await G.auth.getUser();if(!j)return[];const{data:N,error:S}=await G.from("video_backgrounds").select("*").eq("is_active",!0).order("sort_order",{ascending:!0});return S?(console.error("Failed to load backgrounds:",S),[]):N||[]}}),y=p.map(j=>({type:"image",label:j.name,imageUrl:j.image_url,thumbnail:j.thumbnail_url||j.image_url})),_=[...vbs,...y],b=j=>j.type!==t.type?!1:j.type==="image"?j.imageUrl===t.imageUrl:!0,w=async j=>{var S;const N=(S=j.target.files)==null?void 0:S[0];if(N){if(!N.type.startsWith("image/")){me.error("Please select an image file");return}if(N.size>5*1024*1024){me.error("Image must be under 5MB");return}i(!0);try{const{data:{user:T}}=await G.auth.getUser();if(!T)throw new Error("Not authenticated");const I=N.name.split(".").pop()||"jpg",L=`${T.id}/${crypto.randomUUID()}.${I}`,{error:R}=await G.storage.from("video-backgrounds").upload(L,N,{contentType:N.type});if(R)throw R;const{data:$}=G.storage.from("video-backgrounds").getPublicUrl(L),q=$.publicUrl,{error:U}=await G.from("video_backgrounds").insert({name:N.name.replace(/\.[^.]+$/,""),image_url:q,thumbnail_url:q,category:"custom",is_stock:!1,user_id:T.id});if(U)throw U;await f(),s({type:"image",imageUrl:q,blurRadius:15}),me.success("Background uploaded!")}catch(T){console.error("Upload error:",T),me.error("Failed to upload background")}finally{i(!1),o.current&&(o.current.value="")}}};return e.jsxs("div",{className:At("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(uh,{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(Ss,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"Loading…"})]}),_.map((j,N)=>{const S=b(j);return e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({type:j.type,imageUrl:j.imageUrl,blurRadius:15}),className:At("flex-shrink-0 flex flex-col items-center gap-0.5 rounded-lg border-2 p-1 transition-all","hover:border-primary/50 focus:outline-none focus:ring-2 focus:ring-primary/30",S?"border-primary bg-primary/10":"border-transparent bg-muted/50",n&&"opacity-50 cursor-not-allowed"),children:[e.jsxs("div",{className:"w-12 h-8 rounded flex items-center justify-center overflow-hidden bg-muted",children:[j.type==="none"&&e.jsx(TI,{className:"h-4 w-4 text-muted-foreground"}),j.type==="blur"&&e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-primary/20 to-primary/40 flex items-center justify-center",children:e.jsx("span",{className:"text-[10px] font-medium text-primary",children:"Blur"})}),j.type==="image"&&j.thumbnail&&e.jsx("img",{src:j.thumbnail,alt:j.label,className:"w-full h-full object-cover"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-14",children:j.label})]},`${j.type}-${j.imageUrl||N}`)}),e.jsxs("button",{type:"button",disabled:n||l,onClick:()=>{var j;return(j=o.current)==null?void 0:j.click()},className:At("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(Ss,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(Zs,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:l?"Uploading":"Custom"})]}),e.jsx("input",{ref:o,type:"file",accept:"image/*",className:"hidden",onChange:w}),e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({...t,mirror:!t.mirror}),className:At("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(FI,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Mirror"})]})]})]})}var nA=typeof self<"u"?self:{};function Iat(t,s){e:{for(var r=["CLOSURE_FLAGS"],n=nA,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 Dat(t){nA.setTimeout(()=>{throw t},0)}var Ebe,kbs=Iat(610401301,!1),IFe=Iat(748402147,!0);function LFe(){var t=nA.navigator;return t&&(t=t.userAgent)?t:""}const DFe=nA.navigator;function Bhe(t){return Bhe[" "](t),t}Ebe=DFe&&DFe.userAgentData||null,Bhe[" "]=function(){};const Oat={};let uI=null;function Nbs(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),y!=64&&l(f<<6&192|y))}}(t,function(o){n[a++]=o}),a!==r?n.subarray(0,a):n}function Rat(){if(!uI){uI={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),s=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const n=t.concat(s[r].split(""));Oat[r]=n;for(let a=0;a0)&&(LFe().indexOf("Trident")!=-1||LFe().indexOf("MSIE")!=-1))&&typeof btoa=="function";const OFe=/[-_.]/g,Cbs={"-":"+",_:"/",".":"="};function Mbs(t){return Cbs[t]||""}function zat(t){if(!Fat)return Nbs(t);t=OFe.test(t)?t.replace(OFe,Mbs):t,t=atob(t);const s=new Uint8Array(t.length);for(let r=0;r=s||(r[t]=n+1,$at(t=Error(),"incident"),Dat(t))}}function lE(){return typeof BigInt=="function"}var cE=typeof Symbol=="function"&&typeof Symbol()=="symbol";function O0(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 Ebs=O0("jas",void 0,!0),RFe=O0(void 0,"0di"),H6=O0(void 0,"1oa"),gf=O0(void 0,Symbol()),Pbs=O0(void 0,"0ub"),Ibs=O0(void 0,"0ubs"),Ibe=O0(void 0,"0ubsb"),Lbs=O0(void 0,"0actk"),oA=O0("m_m","Pa",!0),FFe=O0();const qat={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},Uat=Object.defineProperties,wa=cE?Ebs:"Ga";var aC;const zFe=[];function YO(t,s){cE||wa in t||Uat(t,qat),t[wa]|=s}function wu(t,s){cE||wa in t||Uat(t,qat),t[wa]=s}function XO(t){return YO(t,34),t}function FD(t){return YO(t,8192),t}wu(zFe,7),aC=Object.freeze(zFe);var lA={};function _f(t,s){return s===void 0?t.h!==BS&&!!(2&(0|t.v[wa])):!!(2&s)&&t.h!==BS}const BS={};function V4e(t,s){if(t!=null){if(typeof t=="string")t=t?new g0(t,aA):zS();else if(t.constructor!==g0)if(q4e(t))t=t.length?new g0(new Uint8Array(t),aA):zS();else{if(!s)throw Error();t=void 0}}return t}class BFe{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 Dbs=Object.freeze({});function Vat(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"),$Fe=$he(t=>typeof t=="string"),Rbs=$he(t=>typeof t=="boolean"),qhe=typeof nA.BigInt=="function"&&typeof nA.BigInt(0)=="bigint";function xf(t){var s=t;if($Fe(s)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(s))throw Error(String(s))}else if(Obs(s)&&!Number.isSafeInteger(s))throw Error(String(s));return qhe?BigInt(t):t=Rbs(t)?t?"1":"0":$Fe(t)?t.trim()||"0":String(t)}var Lbe=$he(t=>qhe?t>=zbs&&t<=$bs:t[0]==="-"?qFe(t,Fbs):qFe(t,Bbs));const Fbs=Number.MIN_SAFE_INTEGER.toString(),zbs=qhe?BigInt(Number.MIN_SAFE_INTEGER):void 0,Bbs=Number.MAX_SAFE_INTEGER.toString(),$bs=qhe?BigInt(Number.MAX_SAFE_INTEGER):void 0;function qFe(t,s){if(t.length>s.length)return!1;if(t.lengtha)return!1;if(n>>0;zc=s,Hd=(t-s)/4294967296>>>0}function cA(t){if(t<0){UFe(-t);const[s,r]=G4e(zc,Hd);zc=s>>>0,Hd=r>>>0}else UFe(t)}function H4e(t){const s=Ubs||(Ubs=new DataView(new ArrayBuffer(8)));s.setFloat32(0,+t,!0),Hd=0,zc=s.getUint32(0,!0)}function Wat(t,s){const r=4294967296*s+(t>>>0);return Number.isSafeInteger(r)?r:zD(t,s)}function Vbs(t,s){return xf(lE()?BigInt.asUintN(64,(BigInt(s>>>0)<>>0)):zD(t,s))}function Gat(t,s){return lE()?xf(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(s))<>>=0,(s>>>=0)<=2097151)var r=""+(4294967296*s+t);else lE()?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+VFe(r)+VFe(t));return r}function VFe(t){return t=String(t),"0000000".slice(t.length)+t}function W4e(t,s){if(2147483648&s)if(lE())t=""+(BigInt(0|s)<>>0));else{const[r,n]=G4e(t,s);t="-"+zD(r,n)}else t=zD(t,s);return t}function Uhe(t){if(t.length<16)cA(Number(t));else if(lE())t=BigInt(t),zc=Number(t&BigInt(4294967295))>>>0,Hd=Number(t>>BigInt(32)&BigInt(4294967295));else{const s=+(t[0]==="-");Hd=zc=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));Hd*=1e6,zc=1e6*zc+o,zc>=4294967296&&(Hd+=Math.trunc(zc/4294967296),Hd>>>=0,zc>>>=0)}if(s){const[n,a]=G4e(zc,Hd);zc=n,Hd=a}}}function G4e(t,s){return s=~s,t?t=1+~t:s+=1,[t,s]}function Xx(t){return Array.prototype.slice.call(t)}const QO=typeof BigInt=="function"?BigInt.asIntN:void 0,Hbs=typeof BigInt=="function"?BigInt.asUintN:void 0,$S=Number.isSafeInteger,Vhe=Number.isFinite,dA=Math.trunc,Wbs=xf(0);function hI(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 t0(t){return t==null||typeof t=="number"?t:t==="NaN"||t==="Infinity"||t==="-Infinity"?Number(t):void 0}function BD(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 Kat(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0}const Gbs=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function JO(t){switch(typeof t){case"bigint":return!0;case"number":return Vhe(t);case"string":return Gbs.test(t);default:return!1}}function uE(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Vhe(t)?0|t:void 0}function Zat(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Vhe(t)?t>>>0:void 0}function Yat(t){const s=t.length;return(t[0]==="-"?s<20||s===20&&t<="-9223372036854775808":s<19||s===19&&t<="9223372036854775807")?t:(Uhe(t),W4e(zc,Hd))}function K4e(t){if(t=dA(t),!$S(t)){cA(t);var s=zc,r=Hd;(t=2147483648&r)&&(r=~r>>>0,(s=1+~s>>>0)==0&&(r=r+1>>>0)),t=typeof(s=Wat(s,r))=="number"?t?-s:s:t?"-"+s:s}return t}function Xat(t){var s=dA(Number(t));return $S(s)?String(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),Yat(t))}function Qat(t){var s=dA(Number(t));return $S(s)?xf(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),lE()?xf(QO(64,BigInt(t))):xf(Yat(t)))}function Jat(t){return $S(t)?t=xf(K4e(t)):(t=dA(t),$S(t)?t=String(t):(cA(t),t=W4e(zc,Hd)),t=xf(t)),t}function zce(t){const s=typeof t;return t==null?t:s==="bigint"?xf(QO(64,t)):JO(t)?s==="string"?Qat(t):Jat(t):void 0}function eit(t){if(typeof t!="string")throw Error();return t}function eR(t){if(t!=null&&typeof t!="string")throw Error();return t}function _h(t){return t==null||typeof t=="string"?t:void 0}function Z4e(t,s,r,n){return t!=null&&t[oA]===lA?t:Array.isArray(t)?((n=(r=0|t[wa])|32&n|2&n)!==r&&wu(t,n),new s(t)):(r?2&n?((t=s[RFe])||(XO((t=new s).v),t=s[RFe]=t),s=t):s=new s:s=void 0,s)}function Kbs(t,s,r){if(s)e:{if(!JO(s=t))throw Pbe("int64");switch(typeof s){case"string":s=Qat(s);break e;case"bigint":s=xf(QO(64,s));break e;default:s=Jat(s)}}else s=zce(t);return(t=s)==null?r?Wbs:void 0:t}const Zbs={};let Ybs=function(){try{return Bhe(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class oye{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 Xbs=Ybs?(Object.setPrototypeOf(oye.prototype,Map.prototype),Object.defineProperties(oye.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),oye):class extends Map{constructor(){super()}};function HFe(t){return t}function lye(t){if(2&t.J)throw Error("Cannot mutate an immutable Map")}var S1=class extends Xbs{constructor(t,s,r=HFe,n=HFe){super(),this.J=0|t[wa],this.K=s,this.S=r,this.fa=this.K?Qbs:n;for(let a=0;a{t.call(s,a.get(n),n,a)}):super.forEach(t,s)}set(t,s){return lye(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 Qbs(t,s,r,n,a,o){return t=Z4e(t,n,r,o),a&&(t=X4e(t)),t}function Jbs(t){return[t,this.get(t)]}let e2s;function WFe(){return e2s||(e2s=new S1(XO([]),void 0,void 0,void 0,Zbs))}function Hhe(t){return gf?t[gf]:void 0}function Bce(t,s){for(const r in t)!isNaN(r)&&s(t,+r,t[r])}S1.prototype.toJSON=void 0;var Dbe=class{};const t2s={Ka:!0};function s2s(t,s){s<100||iA(Ibs,1)}function Whe(t,s,r,n){const a=n!==void 0;n=!!n;var o,l=gf;!a&&cE&&l&&(o=t[l])&&Bce(o,s2s),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 y=0;y=o){const b=y-f;(s??(s={}))[b]=_}else l[y]=_}if(c)for(let _ in c){if((i=c[_])==null||(i=r(i,n))==null)continue;let b;y=+_,p&&!Number.isNaN(y)&&(b=y+f){b[j]=Xx(N)}),b.da=_.da,b}(t)),l}function r2s(t){return t[0]=$D(t[0]),t[1]=$D(t[1]),t}function $D(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return Lbe(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var s=0|t[wa];return t.length===0&&1&s?void 0:Whe(t,s,$D)}if(t!=null&&t[oA]===lA)return tit(t);if(t instanceof g0){if((s=t.g)==null)t="";else if(typeof s=="string")t=s;else{if(Fat){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 S1?t=t.size!==0?t.V(r2s):void 0:void 0}return t}let n2s,a2s;function tit(t){return Whe(t=t.v,0|t[wa],$D)}function aS(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[wa],IFe&&1&a)throw Error("rfarr");if(2048&a&&!(2&a)&&function(){if(IFe)throw Error("carr");iA(Lbs,5)}(),256&a)throw Error("farr");if(64&a)return(a|n)!==a&&wu(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 wu(t,64|a|n),t}function i2s(t,s){if(typeof t!="object")return t;if(Array.isArray(t)){var r=0|t[wa];return t.length===0&&1&r?void 0:GFe(t,r,s)}if(t!=null&&t[oA]===lA)return KFe(t);if(t instanceof S1){if(2&(s=t.J))return t;if(!t.size)return;if(r=XO(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 vl(t,s,r,n){pE(t),_u(t=t.v,0|t[wa],s,r,n)}function _u(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[wa]))>>14&1023||536870912)?n!=null&&(t[l+(a?0:-1)]={[r]:n}):t[o]=n),s)}function w4(){return Dbs===void 0?2:4}function j4(t,s,r,n,a){let o=t.v,l=0|o[wa];n=_f(t,l)?1:n,a=!!a||n===3,n===2&&mE(t)&&(o=t.v,l=0|o[wa]);let i=(t=J4e(o,s))===aC?7:0|t[wa],c=eSe(i,l);var u=!(4&c);if(u){4&c&&(t=Xx(t),i=0,c=oS(c,l),l=_u(o,l,s,t));let p=0,f=0;for(;p{const i=Z4e(l,r,!1,s);return o=i!==l&&i!=null,i}))!=null)return o&&!_f(n)&&iC(t,s),n}function Uo(t,s,r,n){let a=t.v,o=0|a[wa];if((s=lit(a,o,s,r,n))==null)return s;if(o=0|a[wa],!_f(t,o)){const l=X4e(s);l!==s&&(mE(t)&&(a=t.v,o=0|a[wa]),o=_u(a,o,r,s=l,n),iC(a,o))}return s}function cit(t,s,r,n,a,o,l,i){var c=_f(t,r);o=c?1:o,l=!!l||o===3,c=i&&!c,(o===2||c)&&mE(t)&&(r=0|(s=t.v)[wa]);var u=(t=J4e(s,a))===aC?7:0|t[wa],p=eSe(u,r);if(i=!(4&p)){var f=t,y=r;const _=!!(2&p);_&&(y|=2);let b=!_,w=!0,j=0,N=0;for(;j32)for(a|=(127&r)>>4,o=3;o<32&&128&r;o+=7)r=l[i++],a|=(127&r)<>>0,a>>>0);throw Error()}function oSe(t){let s=0,r=t.g;const n=r+10,a=t.h;for(;r>>0}function qce(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],lS(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 o2s(t){return u2(t)}function lS(t,s){if(t.g=s,s>t.l)throw Error()}function uit(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 hit(t,s){if(s==0)return zS();var r=uit(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):qbs?t.slice(r,s):new Uint8Array(t.subarray(r,s))),r.length==0?zS():new g0(r,aA)}var ZFe=[];function mit(t,s,r,n){if(Uce.length){const a=Uce.pop();return a.o(n),a.g.init(t,s,r,n),a}return new l2s(t,s,r,n)}function pit(t){t.g.clear(),t.l=-1,t.h=-1,Uce.length<100&&Uce.push(t)}function fit(t){var s=t.g;if(s.g==s.l)return!1;t.m=t.g.g;var r=S0(t.g);if(s=r>>>3,!((r&=7)>=0&&r<=5)||s<1)throw Error();return t.l=s,t.h=r,!0}function Sie(t){switch(t.h){case 0:t.h!=0?Sie(t):oSe(t.g);break;case 1:lS(t=t.g,t.g+8);break;case 2:if(t.h!=2)Sie(t);else{var s=S0(t.g);lS(t=t.g,t.g+s)}break;case 5:lS(t=t.g,t.g+4);break;case 3:for(s=t.l;;){if(!fit(t))throw Error();if(t.h==4){if(t.l!=s)throw Error();break}Sie(t)}break;default:throw Error()}}function tR(t,s,r){const n=t.g.l;var a=S0(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 lSe(t){var s=S0(t.g),r=uit(t=t.g,s);if(t=t.h,bbs){var n,a=t;(n=iye)||(n=iye=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(Cz===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),Cz=!0}catch{Cz=!1}}throw!Cz&&(iye=void 0),i}}else{s=(o=r)+s,r=[];let i,c=null;for(;o=s?Dw():(i=t[o++],l<194||(192&i)!=128?(o--,Dw()):r.push((31&l)<<6|63&i)):l<240?o>=s-1?Dw():(i=t[o++],(192&i)!=128||l===224&&i<160||l===237&&i>=160||(192&(n=t[o++]))!=128?(o--,Dw()):r.push((15&l)<<12|(63&i)<<6|63&n)):l<=244?o>=s-2?Dw():(i=t[o++],(192&i)!=128||i-144+(l<<28)>>30||(192&(n=t[o++]))!=128||(192&(a=t[o++]))!=128?(o--,Dw()):(l=(7&l)<<18|(63&i)<<12|(63&n)<<6|63&a,l-=65536,r.push(55296+(l>>10&1023),56320+(1023&l)))):Dw(),r.length>=8192&&(c=PFe(c,r),r.length=0)}o=PFe(c,r)}return o}function git(t){const s=S0(t.g);return hit(t.g,s)}function Khe(t,s,r){var n=S0(t.g);for(n=t.g.g+n;t.g.g>>0,this.g=s>>>0}};let c2s;function XFe(t){return t?/^-?\d+$/.test(t)?(Uhe(t),new Rbe(zc,Hd)):null:d2s||(d2s=new Rbe(0,0))}var Rbe=class{constructor(t,s){this.h=t>>>0,this.g=s>>>0}};let d2s;function UM(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 gE(t,s){for(;s>127;)t.g.push(127&s|128),s>>>=7;t.g.push(s)}function Zhe(t,s){if(s>=0)gE(t,s);else{for(let r=0;r<9;r++)t.g.push(127&s|128),s>>=7;t.g.push(1)}}function cSe(t){var s=zc;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 uA(t,s){s.length!==0&&(t.l.push(s),t.h+=s.length)}function Bg(t,s,r){gE(t.g,8*s+r)}function dSe(t,s){return Bg(t,s,2),s=t.g.end(),uA(t,s),s.push(t.h),s}function uSe(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 Yhe(t,s,r){Bg(t,s,2),gE(t.g,r.length),uA(t,t.g.end()),uA(t,r)}function Vce(t,s,r,n){r!=null&&(s=dSe(t,s),n(r,t),uSe(t,s))}function R0(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var hSe=R0(),xit=R0(),mSe=R0(),pSe=R0(),fSe=R0(),yit=R0(),u2s=R0(),Xhe=R0(),vit=R0(),_it=R0();function F0(t,s,r){var n=t.v;gf&&gf in n&&(n=n[gf])&&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 ka=class{constructor(t,s){this.v=sit(t,s,void 0,2048)}toJSON(){return tit(this)}j(){var a;var t=W2s,s=this.v,r=t.g,n=gf;if(cE&&n&&((a=s[n])==null?void 0:a[r])!=null&&iA(Pbs,3),s=t.g,FFe&&gf&&FFe===void 0&&(n=(r=this.v)[gf])&&(n=n.da))try{n(r,s,t2s)}catch(o){Dat(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[wa];return Q4e(this,t,s)?Y4e(this,t,!0):new this.constructor(hE(t,s,!1))}};ka.prototype[oA]=lA,ka.prototype.toString=function(){return this.v.toString()};var xE=class{constructor(t,s,r){this.g=t,this.h=s,t=hSe,this.l=!!t&&r===t||!1}};function Qhe(t,s){return new xE(t,s,hSe)}function bit(t,s,r,n,a){Vce(t,r,Nit(s,n),a)}const h2s=Qhe(function(t,s,r,n,a){return t.h===2&&(tR(t,rSe(s,n,r),a),!0)},bit),m2s=Qhe(function(t,s,r,n,a){return t.h===2&&(tR(t,rSe(s,n,r),a),!0)},bit);var Jhe=Symbol(),eme=Symbol(),Fbe=Symbol(),QFe=Symbol(),JFe=Symbol();let wit,jit;function oC(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 n2s||(n2s=[0,void 0,!0]);case"number":return f>0?void 0:f===0?a2s||(a2s=[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),jit??(jit=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 xSe(t,s,r,n,a){const o=r.g;let l,i;t[s]=(c,u,p)=>o(c,u,p,i||(i=oC(eme,gSe,xSe,n).T),l||(l=ySe(n)),a)}function ySe(t){let s=t[Fbe];if(s!=null)return s;const r=oC(eme,gSe,xSe,t);return s=r.ma?(n,a)=>wit(n,a,r):(n,a)=>{for(;fit(a)&&a.h!=4;){var o=a.l,l=r[o];if(l==null){var i=r.ba;i&&(i=i[o])&&(i=f2s(i))!=null&&(l=r[o]=i)}if(l==null||!l(a,n,o)){if(l=(i=a).m,Sie(i),i.ha)var c=void 0;else c=i.g.g-l,i.g.g=l,c=hit(i.g,c);l=void 0,i=n,c&&((l=i[gf]??(i[gf]=new Dbe))[o]??(l[o]=[])).push(c)}}return(n=Hhe(n))&&(n.da=r.qa[JFe]),!0},t[Fbe]=s,t[JFe]=p2s.bind(t),s}function p2s(t,s,r,n){var a=this[eme];const o=this[Fbe],l=aS(void 0,a.T),i=Hhe(t);if(i){var c=!1,u=a.ba;if(u){if(a=(p,f,y)=>{if(y.length!==0)if(u[f])for(const _ of y){p=mit(_);try{c=!0,o(l,p)}finally{pit(p)}}else n==null||n(t,f,y)},s==null)Bce(i,a);else if(i!=null){const p=i[s];p&&a(i,s,p)}if(c){let p=0|t[wa];if(2&p&&2048&p&&!(r!=null&&r.Ka))throw Error();const f=dE(p),y=(_,b)=>{if(C1(t,_,f)!=null){if((r==null?void 0:r.Qa)===1)return;throw Error()}b!=null&&(p=_u(t,p,_,b,f)),delete i[_]};s==null?Vat(l,0|l[wa],(_,b)=>{y(_,b)}):y(s,C1(l,s,f))}}}}function f2s(t){const s=(t=kit(t))[0].g;if(t=t[1]){const r=ySe(t),n=oC(eme,gSe,xSe,t).T;return(a,o,l)=>s(a,o,l,n,r)}return s}function tme(t,s,r){t[s]=r.h}function sme(t,s,r,n){let a,o;const l=r.h;t[s]=(i,c,u)=>l(i,c,u,o||(o=oC(Jhe,tme,sme,n).T),a||(a=Sit(n)))}function Sit(t){let s=t[QFe];if(!s){const r=oC(Jhe,tme,sme,t);s=(n,a)=>Cit(n,a,r),t[QFe]=s}return s}function Cit(t,s,r){Vat(t,0|t[wa],(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=Sit(c),f=oC(Jhe,tme,sme,c).T;c=l.ma?jit(f,p):(y,_,b)=>u(y,_,b,f,p)}else c=u;return l[i]=c}}(r,n);o?o(s,a,n):n<500||iA(Ibe,3)}}),(t=Hhe(t))&&Bce(t,(n,a,o)=>{for(uA(s,s.g.end()),n=0;n{Vce(t,r,aS([l,o],n),a)});else if(Array.isArray(s)){for(let o=0;o>BigInt(32))),UM(t.g,r.h,r.g);break;default:r=XFe(s),UM(t.g,r.h,r.g)}}function Ait(t,s,r){(s=uE(s))!=null&&s!=null&&(Bg(t,r,0),Zhe(t.g,s))}function Eit(t,s,r){(s=Kat(s))!=null&&(Bg(t,r,0),t.g.g.push(s?1:0))}function Pit(t,s,r){(s=_h(s))!=null&&Yhe(t,r,Lat(s))}function Iit(t,s,r,n,a){Vce(t,r,Nit(s,n),a)}function Lit(t,s,r){(s=s==null||typeof s=="string"||s instanceof g0?s:void 0)!=null&&Yhe(t,r,aSe(s,!0).buffer)}function Dit(t,s,r){(s=Zat(s))!=null&&s!=null&&(Bg(t,r,0),gE(t.g,s))}function Oit(t,s,r){return(t.h===5||t.h===2)&&(s=fE(s,0|s[wa],r),t.h==2?Khe(t,qce,s):s.push(qce(t.g)),!0)}var Kd=Yh(function(t,s,r){return t.h===5&&(Xh(s,r,qce(t.g)),!0)},Mit,Xhe),y2s=vE(Oit,function(t,s,r){if((s=yE(t0,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"))||(Uhe(n),n=zD(zc,Hd))),n;if(a==="number")return(n=dA(n))>=0&&$S(n)||(cA(n),n=Wat(zc,Hd)),n}}(s),s!=null&&(typeof s=="string"&&YFe(s),s!=null))switch(Bg(t,r,0),typeof s){case"number":t=t.g,cA(s),UM(t,zc,Hd);break;case"bigint":r=BigInt.asUintN(64,s),r=new Obe(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),UM(t.g,r.h,r.g);break;default:r=YFe(s),UM(t.g,r.h,r.g)}},u2s),fu=Yh(function(t,s,r){return t.h===0&&(Xh(s,r,u2(t.g)),!0)},Ait,pSe),sR=vE(function(t,s,r){return(t.h===0||t.h===2)&&(s=fE(s,0|s[wa],r),t.h==2?Khe(t,u2,s):s.push(u2(t.g)),!0)},function(t,s,r){if((s=yE(uE,s))!=null&&s.length){r=dSe(t,r);for(let n=0;n{{const o={ea:!0};n&&Object.assign(o,n),r=mit(r,void 0,void 0,o);try{const l=new t,i=l.v;ySe(s)(i,r);var a=l}finally{pit(r)}}return a}}function rme(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}}}};Cit(this.v,s,oC(Jhe,tme,sme,t)),uA(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=s7e.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r}()),t=(s=uye)?s.createScriptURL(t):t,new class{constructor(r){this.g=r}toString(){return this.g+""}}(t)}function Mz(t,...s){if(s.length===0)return r7e(t[0]);let r=t[0];for(let n=0;n({index:pg(n,1)??0??-1,score:kd(n,2)??0,categoryName:_h(Vc(n,3))??""??"",displayName:_h(Vc(n,4))??""??""})),headIndex:s,headName:r}}function Y2s(t){const s={classifications:M1(t,E2s,1).map(r=>{var n;return CSe(((n=Uo(r,Hit,4))==null?void 0:n.g())??[],pg(r,2)??0,_h(Vc(r,3))??"")})};return function(r){return r==null?r:typeof r=="bigint"?(Lbe(r)?r=Number(r):(r=QO(64,r),r=Lbe(r)?Number(r):String(r)),r):JO(r)?typeof r=="number"?K4e(r):Xat(r):void 0}(Vc(t,2,void 0,void 0,zce))!=null&&(s.timestampMs=yot(Vc(t,2,void 0,void 0,zce)??rit)),s}function vot(t){var l,i;var s=j4(t,3,t0,w4()),r=j4(t,2,uE,w4()),n=j4(t,1,_h,w4()),a=j4(t,9,_h,w4());const o={categories:[],keypoints:[]};for(let c=0;cs>127?s-256:s)}function f7e(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 g7e(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 Ma(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 x7e(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 y7e(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 Ly(t,s,r){t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[s]=r}function M_(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)}}j5.forVisionTasks=function(t,s=!1){return Az("vision",t??Mz``,s)},j5.forTextTasks=function(t,s=!1){return Az("text",t??Mz``,s)},j5.forGenAiTasks=function(t,s=!1){return Az("genai",t??Mz``,s)},j5.forAudioTasks=function(t,s=!1){return Az("audio",t??Mz``,s)},j5.isSimdSupported=function(t=!1){return _ot(t)};async function Q2s(t,s,r,n){return t=await(async(a,o,l,i,c)=>{if(o&&await g7e(o),!self.ModuleFactory||l&&(await g7e(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 pye(t,s){const r=Uo(t.baseOptions,Hce,1)||new Hce;typeof s=="string"?(vl(r,2,eR(s)),vl(r,1)):s instanceof Uint8Array&&(vl(r,1,V4e(s,!1)),vl(r,2)),ri(t.baseOptions,0,1,r)}function v7e(t){try{const s=t.H.length;if(s===1)throw Error(t.H[0].message);if(s>1)throw Error("Encountered multiple errors: "+t.H.map(r=>r.message).join(", "))}finally{t.H=[]}}function ra(t,s){t.C=Math.max(t.C,s)}function ome(t,s){t.B=new Mp,bf(t.B,2,"PassThroughCalculator"),Ic(t.B,"free_memory"),Ao(t.B,"free_memory_unused_out"),Gc(s,"free_memory"),$g(s,t.B)}function hA(t,s){Ic(t.B,s),Ao(t.B,s+"_unused_out")}function lme(t){t.g.addBoolToStream(!0,"free_memory",t.C)}var Ube=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=Uo(this.baseOptions,Hce,1))!=null&&a.g()||(o=Uo(this.baseOptions,Hce,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=Uo(u.baseOptions,d7e,3);if(!f){var y=f=new d7e,_=new n7e;t8(y,4,Cie,_)}"delegate"in p&&(p.delegate==="GPU"?(p=f,y=new k2s,t8(p,2,Cie,y)):(p=f,y=new n7e,t8(p,4,Cie,y))),ri(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),pye(this,"/model.dat"),this.m(),this.L()});if(c.modelAssetBuffer instanceof Uint8Array)pye(this,c.modelAssetBuffer);else if(c.modelAssetBuffer)return async function(u){const p=[];for(var f=0;;){const{done:y,value:_}=await u.read();if(y)break;p.push(_),f+=_.length}if(p.length===0)return new Uint8Array(0);if(p.length===1)return p[0];u=new Uint8Array(f),f=0;for(const y of p)u.set(y,f),f+=y.length;return u}(c.modelAssetBuffer).then(u=>{pye(this,u),this.m(),this.L()})}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let t;if(this.g.ca(s=>{t=N2s(s)}),!t)throw Error("Failed to retrieve CalculatorGraphConfig");return t}setGraph(t,s){this.g.attachErrorListener((r,n)=>{this.H.push(Error(n))}),this.g.Ja(),this.g.setGraph(t,s),this.B=void 0,v7e(this)}finishProcessing(){this.g.finishProcessing(),v7e(this)}close(){this.B=void 0,this.g.closeGraph()}};function Yb(t,s){if(!t)throw Error(`Unable to obtain required WebGL resource: ${s}`);return t}Ube.prototype.close=Ube.prototype.close;class J2s{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 _7e(t,s,r){const n=t.g;if(r=Yb(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 b7e(t,s){const r=t.g,n=Yb(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(n);const a=Yb(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=Yb(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 J2s(r,n,a,o)}function MSe(t,s){if(t.g){if(s!==t.g)throw Error("Cannot change GL context once initialized")}else t.g=s}function ews(t,s,r,n){return MSe(t,s),t.h||(t.m(),t.D()),r?(t.u||(t.u=b7e(t,!0)),r=t.u):(t.A||(t.A=b7e(t,!1)),r=t.A),s.useProgram(t.h),r.bind(),t.l(),t=n(),r.g.bindVertexArray(null),t}function jot(t,s,r){return MSe(t,s),t=Yb(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){MSe(t,s),t.B||(t.B=Yb(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 tws(t){var s;(s=t.g)==null||s.bindFramebuffer(t.g.FRAMEBUFFER,null)}var Not=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=Yb(t.createProgram(),"Failed to create WebGL program"),this.X=_7e(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=_7e(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 Rv(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 Vbe(t){var s=Rv(t,1);if(!s){if(s=Rv(t,0))s=new Float32Array(s).map(n=>n/255);else{s=new Float32Array(t.width*t.height);const n=mA(t);var r=TSe(t);if(kot(r,n,Sot(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 Vbe(this)}N(){return Sot(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=mA(this),a=TSe(this);n.activeTexture(n.TEXTURE1),r=jot(a,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);const o=Cot(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),ews(a,n,!1,()=>{Mot(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),Hbe(this)}),tws(a),Hbe(this)}}t.push(r)}return new Du(t,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&mA(this).deleteTexture(Rv(this,2)),w7e=-1}};Du.prototype.close=Du.prototype.close,Du.prototype.clone=Du.prototype.clone,Du.prototype.getAsWebGLTexture=Du.prototype.N,Du.prototype.getAsFloat32Array=Du.prototype.ia,Du.prototype.getAsUint8Array=Du.prototype.ja,Du.prototype.hasWebGLTexture=Du.prototype.R,Du.prototype.hasFloat32Array=Du.prototype.ka,Du.prototype.hasUint8Array=Du.prototype.Fa;var w7e=250;function ly(...t){return t.map(([s,r])=>({start:s,end:r}))}const sws=function(t){return class extends t{Ja(){this.i._registerModelResourcesGraphService()}}}((j7e=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:bot()?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?'),Ma(this,n||"input_audio",o=>{Ma(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){Ly(this,"__graph_config__",s=>{t(s)}),Ma(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),Ma(this,n,l=>{this.i._addAudioToInputStream(this.g,s,r,l,a)})}addGpuBufferToStream(t,s,r){Ma(this,s,n=>{const[a,o]=x7e(this,t,n);this.i._addBoundTextureToStream(n,a,o,r)})}addBoolToStream(t,s,r){Ma(this,s,n=>{this.i._addBoolToInputStream(t,n,r)})}addDoubleToStream(t,s,r){Ma(this,s,n=>{this.i._addDoubleToInputStream(t,n,r)})}addFloatToStream(t,s,r){Ma(this,s,n=>{this.i._addFloatToInputStream(t,n,r)})}addIntToStream(t,s,r){Ma(this,s,n=>{this.i._addIntToInputStream(t,n,r)})}addUintToStream(t,s,r){Ma(this,s,n=>{this.i._addUintToInputStream(t,n,r)})}addStringToStream(t,s,r){Ma(this,s,n=>{Ma(this,t,a=>{this.i._addStringToInputStream(a,n,r)})})}addStringRecordToStream(t,s,r){Ma(this,s,n=>{y7e(this,Object.keys(t),a=>{y7e(this,Object.values(t),o=>{this.i._addFlatHashMapToInputStream(a,o,Object.keys(t).length,n,r)})})})}addProtoToStream(t,s,r,n){Ma(this,r,a=>{Ma(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){Ma(this,t,r=>{this.i._addEmptyPacketToInputStream(r,s)})}addBoolVectorToStream(t,s,r){Ma(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){Ma(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){Ma(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){Ma(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){Ma(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){Ma(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)Ma(this,o,l=>{this.i._addStringVectorEntry(a,l)});this.i._addStringVectorToInputStream(a,n,r)})}addBoolToInputSidePacket(t,s){Ma(this,s,r=>{this.i._addBoolToInputSidePacket(t,r)})}addDoubleToInputSidePacket(t,s){Ma(this,s,r=>{this.i._addDoubleToInputSidePacket(t,r)})}addFloatToInputSidePacket(t,s){Ma(this,s,r=>{this.i._addFloatToInputSidePacket(t,r)})}addIntToInputSidePacket(t,s){Ma(this,s,r=>{this.i._addIntToInputSidePacket(t,r)})}addUintToInputSidePacket(t,s){Ma(this,s,r=>{this.i._addUintToInputSidePacket(t,r)})}addStringToInputSidePacket(t,s){Ma(this,s,r=>{Ma(this,t,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(t,s,r){Ma(this,r,n=>{Ma(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){Ma(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){Ma(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){Ma(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){Ma(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){Ma(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){Ma(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)Ma(this,a,o=>{this.i._addStringVectorEntry(n,o)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(t,s){Ly(this,t,s),Ma(this,t,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(t,s){M_(this,t,s),Ma(this,t,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(t,s){Ly(this,t,s),Ma(this,t,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(t,s){M_(this,t,s),Ma(this,t,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(t,s){Ly(this,t,s),Ma(this,t,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(t,s){M_(this,t,s),Ma(this,t,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(t,s){Ly(this,t,s),Ma(this,t,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(t,s){M_(this,t,s),Ma(this,t,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(t,s){Ly(this,t,s),Ma(this,t,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(t,s){M_(this,t,s),Ma(this,t,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(t,s){Ly(this,t,s),Ma(this,t,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(t,s){M_(this,t,s),Ma(this,t,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(t,s,r){Ly(this,t,s),Ma(this,t,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(t,s,r){M_(this,t,s),Ma(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?'),Ly(this,t,(n,a)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),s(n,a)}),Ma(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 j7e{get ga(){return this.i}pa(t,s,r){Ma(this,s,n=>{const[a,o]=x7e(this,t,n);this.ga._addBoundTextureAsImageToStream(n,a,o,r)})}Z(t,s){Ly(this,t,s),Ma(this,t,r=>{this.ga._attachImageListener(r)})}aa(t,s){M_(this,t,s),Ma(this,t,r=>{this.ga._attachImageVectorListener(r)})}}));var j7e,cy=class extends sws{};async function Oo(t,s,r){return async function(n,a,o,l){return Q2s(n,a,o,l)}(t,r.canvas??(bot()?void 0:document.createElement("canvas")),s,r)}function Tot(t,s,r,n){if(t.U){const o=new Yit;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].");za(o,1,(a.left+a.right)/2),za(o,2,(a.top+a.bottom)/2),za(o,4,a.right-a.left),za(o,3,a.bottom-a.top)}else za(o,1,.5),za(o,2,.5),za(o,4,1),za(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(za(o,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[l,i]=wot(s);r=kd(o,3)*i/l,a=kd(o,4)*l/i,za(o,4,r),za(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 dy(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'.");Tot(t,s,r,t.C+1)}function B0(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'.");Tot(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 Du([a],r,!1,t.g.i.canvas,t.P,o,s),n?t.clone():t}var wf=class extends Ube{constructor(t,s,r,n){super(t),this.g=t,this.X=s,this.U=r,this.oa=n,this.P=new Not}l(t,s=!0){if("runningMode"in t&&vl(this.baseOptions,2,BD(!!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()}};wf.prototype.close=wf.prototype.close;var Wf=class extends wf{constructor(t,s){super(new cy(t,s),"image_in","norm_rect_in",!1),this.j={detections:[]},ri(t=this.h=new ame,0,1,s=new xd),za(this.h,2,.5),za(this.h,3,.3)}get baseOptions(){return Uo(this.h,xd,1)}set baseOptions(t){ri(this.h,0,1,t)}o(t){return"minDetectionConfidence"in t&&za(this.h,2,t.minDetectionConfidence??.5),"minSuppressionThreshold"in t&&za(this.h,3,t.minSuppressionThreshold??.3),this.l(t)}F(t,s){return this.j={detections:[]},dy(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},B0(this,t,r,s),this.j}m(){var t=new Sf;Gc(t,"image_in"),Gc(t,"norm_rect_in"),Zo(t,"detections");const s=new Nf;F0(s,R2s,this.h);const r=new Mp;bf(r,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),Ic(r,"IMAGE:image_in"),Ic(r,"NORM_RECT:norm_rect_in"),Ao(r,"DETECTIONS:detections"),r.o(s),$g(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Git(o),this.j.detections.push(vot(n));ra(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{ra(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Wf.prototype.detectForVideo=Wf.prototype.G,Wf.prototype.detect=Wf.prototype.F,Wf.prototype.setOptions=Wf.prototype.o,Wf.createFromModelPath=async function(t,s){return Oo(Wf,t,{baseOptions:{modelAssetPath:s}})},Wf.createFromModelBuffer=function(t,s){return Oo(Wf,t,{baseOptions:{modelAssetBuffer:s}})},Wf.createFromOptions=function(t,s){return Oo(Wf,t,s)};var ASe=ly([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]),ESe=ly([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]),PSe=ly([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Aot=ly([474,475],[475,476],[476,477],[477,474]),ISe=ly([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]),LSe=ly([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Eot=ly([469,470],[470,471],[471,472],[472,469]),DSe=ly([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]),Pot=[...ASe,...ESe,...PSe,...ISe,...LSe,...DSe],Iot=ly([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 k7e(t){t.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var ed=class extends wf{constructor(t,s){super(new cy(t,s),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,ri(t=this.h=new tot,0,1,s=new xd),this.A=new eot,ri(this.h,0,3,this.A),this.u=new ame,ri(this.h,0,2,this.u),T1(this.u,4,1),za(this.u,2,.5),za(this.A,2,.5),za(this.h,4,.5)}get baseOptions(){return Uo(this.h,xd,1)}set baseOptions(t){ri(this.h,0,1,t)}o(t){return"numFaces"in t&&T1(this.u,4,t.numFaces??1),"minFaceDetectionConfidence"in t&&za(this.u,2,t.minFaceDetectionConfidence??.5),"minTrackingConfidence"in t&&za(this.h,4,t.minTrackingConfidence??.5),"minFacePresenceConfidence"in t&&za(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 k7e(this),dy(this,t,s),this.j}G(t,s,r){return k7e(this),B0(this,t,r,s),this.j}m(){var t=new Sf;Gc(t,"image_in"),Gc(t,"norm_rect"),Zo(t,"face_landmarks");const s=new Nf;F0(s,z2s,this.h);const r=new Mp;bf(r,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),Ic(r,"IMAGE:image_in"),Ic(r,"NORM_RECT:norm_rect"),Ao(r,"NORM_LANDMARKS:face_landmarks"),r.o(s),$g(t,r),this.g.attachProtoVectorListener("face_landmarks",(n,a)=>{for(const o of n)n=rR(o),this.j.faceLandmarks.push(ime(n));ra(this,a)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{ra(this,n)}),this.outputFaceBlendshapes&&(Zo(t,"blendshapes"),Ao(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,a)=>{if(this.outputFaceBlendshapes)for(const o of n)n=nme(o),this.j.faceBlendshapes.push(CSe(n.g()??[]));ra(this,a)}),this.g.attachEmptyPacketListener("blendshapes",n=>{ra(this,n)})),this.outputFacialTransformationMatrixes&&(Zo(t,"face_geometry"),Ao(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,a)=>{if(this.outputFacialTransformationMatrixes)for(const o of n)(n=Uo(n=F2s(o),T2s,2))&&this.j.facialTransformationMatrixes.push({rows:pg(n,1)??0??0,columns:pg(n,2)??0??0,data:j4(n,3,t0,w4()).slice()??[]});ra(this,a)}),this.g.attachEmptyPacketListener("face_geometry",n=>{ra(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ed.prototype.detectForVideo=ed.prototype.G,ed.prototype.detect=ed.prototype.F,ed.prototype.setOptions=ed.prototype.o,ed.createFromModelPath=function(t,s){return Oo(ed,t,{baseOptions:{modelAssetPath:s}})},ed.createFromModelBuffer=function(t,s){return Oo(ed,t,{baseOptions:{modelAssetBuffer:s}})},ed.createFromOptions=function(t,s){return Oo(ed,t,s)},ed.FACE_LANDMARKS_LIPS=ASe,ed.FACE_LANDMARKS_LEFT_EYE=ESe,ed.FACE_LANDMARKS_LEFT_EYEBROW=PSe,ed.FACE_LANDMARKS_LEFT_IRIS=Aot,ed.FACE_LANDMARKS_RIGHT_EYE=ISe,ed.FACE_LANDMARKS_RIGHT_EYEBROW=LSe,ed.FACE_LANDMARKS_RIGHT_IRIS=Eot,ed.FACE_LANDMARKS_FACE_OVAL=DSe,ed.FACE_LANDMARKS_CONTOURS=Pot,ed.FACE_LANDMARKS_TESSELATION=Iot;var OSe=ly([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 N7e(t){t.gestures=[],t.landmarks=[],t.worldLandmarks=[],t.handedness=[]}function S7e(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 C7e(t,s=!0){const r=[];for(const a of t){var n=nme(a);t=[];for(const o of n.g())n=s&&pg(o,1)!=null?pg(o,1)??0:-1,t.push({score:kd(o,2)??0,index:n,categoryName:_h(Vc(o,3))??""??"",displayName:_h(Vc(o,4))??""??""});r.push(t)}return r}var Bp=class extends wf{constructor(t,s){super(new cy(t,s),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ri(t=this.j=new not,0,1,s=new xd),this.u=new jSe,ri(this.j,0,2,this.u),this.D=new wSe,ri(this.u,0,3,this.D),this.A=new rot,ri(this.u,0,2,this.A),this.h=new B2s,ri(this.j,0,3,this.h),za(this.A,2,.5),za(this.u,4,.5),za(this.D,2,.5)}get baseOptions(){return Uo(this.j,xd,1)}set baseOptions(t){ri(this.j,0,1,t)}o(t){var a,o,l,i;if(T1(this.A,3,t.numHands??1),"minHandDetectionConfidence"in t&&za(this.A,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&za(this.u,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&za(this.D,2,t.minHandPresenceConfidence??.5),t.cannedGesturesClassifierOptions){var s=new u5,r=s,n=qbe(t.cannedGesturesClassifierOptions,(a=Uo(this.h,u5,3))==null?void 0:a.l());ri(r,0,2,n),ri(this.h,0,3,s)}else t.cannedGesturesClassifierOptions===void 0&&((o=Uo(this.h,u5,3))==null||o.g());return t.customGesturesClassifierOptions?(ri(r=s=new u5,0,2,n=qbe(t.customGesturesClassifierOptions,(l=Uo(this.h,u5,4))==null?void 0:l.l())),ri(this.h,0,4,s)):t.customGesturesClassifierOptions===void 0&&((i=Uo(this.h,u5,4))==null||i.g()),this.l(t)}Ha(t,s){return N7e(this),dy(this,t,s),S7e(this)}Ia(t,s,r){return N7e(this),B0(this,t,r,s),S7e(this)}m(){var t=new Sf;Gc(t,"image_in"),Gc(t,"norm_rect"),Zo(t,"hand_gestures"),Zo(t,"hand_landmarks"),Zo(t,"world_hand_landmarks"),Zo(t,"handedness");const s=new Nf;F0(s,$2s,this.j);const r=new Mp;bf(r,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),Ic(r,"IMAGE:image_in"),Ic(r,"NORM_RECT:norm_rect"),Ao(r,"HAND_GESTURES:hand_gestures"),Ao(r,"LANDMARKS:hand_landmarks"),Ao(r,"WORLD_LANDMARKS:world_hand_landmarks"),Ao(r,"HANDEDNESS:handedness"),r.o(s),$g(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n){n=rR(o);const l=[];for(const i of M1(n,Zit,1))l.push({x:kd(i,1)??0,y:kd(i,2)??0,z:kd(i,3)??0,visibility:kd(i,4)??0});this.landmarks.push(l)}ra(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{ra(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n){n=VM(o);const l=[];for(const i of M1(n,Kit,1))l.push({x:kd(i,1)??0,y:kd(i,2)??0,z:kd(i,3)??0,visibility:kd(i,4)??0});this.worldLandmarks.push(l)}ra(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{ra(this,n)}),this.g.attachProtoVectorListener("hand_gestures",(n,a)=>{this.gestures.push(...C7e(n,!1)),ra(this,a)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{ra(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{this.handedness.push(...C7e(n)),ra(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{ra(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function M7e(t){return{landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handednesses:t.handedness,handedness:t.handedness}}Bp.prototype.recognizeForVideo=Bp.prototype.Ia,Bp.prototype.recognize=Bp.prototype.Ha,Bp.prototype.setOptions=Bp.prototype.o,Bp.createFromModelPath=function(t,s){return Oo(Bp,t,{baseOptions:{modelAssetPath:s}})},Bp.createFromModelBuffer=function(t,s){return Oo(Bp,t,{baseOptions:{modelAssetBuffer:s}})},Bp.createFromOptions=function(t,s){return Oo(Bp,t,s)},Bp.HAND_CONNECTIONS=OSe;var $p=class extends wf{constructor(t,s){super(new cy(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ri(t=this.h=new jSe,0,1,s=new xd),this.u=new wSe,ri(this.h,0,3,this.u),this.j=new rot,ri(this.h,0,2,this.j),T1(this.j,3,1),za(this.j,2,.5),za(this.u,2,.5),za(this.h,4,.5)}get baseOptions(){return Uo(this.h,xd,1)}set baseOptions(t){ri(this.h,0,1,t)}o(t){return"numHands"in t&&T1(this.j,3,t.numHands??1),"minHandDetectionConfidence"in t&&za(this.j,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&za(this.h,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&za(this.u,2,t.minHandPresenceConfidence??.5),this.l(t)}F(t,s){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],dy(this,t,s),M7e(this)}G(t,s,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],B0(this,t,r,s),M7e(this)}m(){var t=new Sf;Gc(t,"image_in"),Gc(t,"norm_rect"),Zo(t,"hand_landmarks"),Zo(t,"world_hand_landmarks"),Zo(t,"handedness");const s=new Nf;F0(s,q2s,this.h);const r=new Mp;bf(r,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),Ic(r,"IMAGE:image_in"),Ic(r,"NORM_RECT:norm_rect"),Ao(r,"LANDMARKS:hand_landmarks"),Ao(r,"WORLD_LANDMARKS:world_hand_landmarks"),Ao(r,"HANDEDNESS:handedness"),r.o(s),$g(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n)n=rR(o),this.landmarks.push(ime(n));ra(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{ra(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n)n=VM(o),this.worldLandmarks.push(r8(n));ra(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{ra(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{var o=this.handedness,l=o.push;const i=[];for(const c of n){n=nme(c);const u=[];for(const p of n.g())u.push({score:kd(p,2)??0,index:pg(p,1)??0??-1,categoryName:_h(Vc(p,3))??""??"",displayName:_h(Vc(p,4))??""??""});i.push(u)}l.call(o,...i),ra(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{ra(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};$p.prototype.detectForVideo=$p.prototype.G,$p.prototype.detect=$p.prototype.F,$p.prototype.setOptions=$p.prototype.o,$p.createFromModelPath=function(t,s){return Oo($p,t,{baseOptions:{modelAssetPath:s}})},$p.createFromModelBuffer=function(t,s){return Oo($p,t,{baseOptions:{modelAssetBuffer:s}})},$p.createFromOptions=function(t,s){return Oo($p,t,s)},$p.HAND_CONNECTIONS=OSe;var Lot=ly([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 T7e(t){t.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function A7e(t){try{if(!t.D)return t.h;t.D(t.h)}finally{lme(t)}}function Pz(t,s){t=rR(t),s.push(ime(t))}var wc=class extends wf{constructor(t,s){super(new cy(t,s),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,ri(t=this.j=new cot,0,1,s=new xd),this.I=new wSe,ri(this.j,0,2,this.I),this.W=new U2s,ri(this.j,0,3,this.W),this.u=new ame,ri(this.j,0,4,this.u),this.O=new eot,ri(this.j,0,5,this.O),this.A=new oot,ri(this.j,0,6,this.A),this.M=new lot,ri(this.j,0,7,this.M),za(this.u,2,.5),za(this.u,3,.3),za(this.O,2,.5),za(this.A,2,.5),za(this.A,3,.3),za(this.M,2,.5),za(this.I,2,.5)}get baseOptions(){return Uo(this.j,xd,1)}set baseOptions(t){ri(this.j,0,1,t)}o(t){return"minFaceDetectionConfidence"in t&&za(this.u,2,t.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in t&&za(this.u,3,t.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in t&&za(this.O,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"minPoseDetectionConfidence"in t&&za(this.A,2,t.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in t&&za(this.A,3,t.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in t&&za(this.M,2,t.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in t&&(this.outputPoseSegmentationMasks=!!t.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in t&&za(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,T7e(this),dy(this,t,n),A7e(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:n,T7e(this),B0(this,t,a,s),A7e(this)}m(){var t=new Sf;Gc(t,"input_frames_image"),Zo(t,"pose_landmarks"),Zo(t,"pose_world_landmarks"),Zo(t,"face_landmarks"),Zo(t,"left_hand_landmarks"),Zo(t,"left_hand_world_landmarks"),Zo(t,"right_hand_landmarks"),Zo(t,"right_hand_world_landmarks");const s=new Nf,r=new e7e;bf(r,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),function(a,o){if(o!=null)if(Array.isArray(o))vl(a,2,Whe(o,0,$D));else{if(!(typeof o=="string"||o instanceof g0||q4e(o)))throw Error("invalid value in Any.value field: "+o+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");H_(a,2,V4e(o,!1),zS())}}(r,this.j.g());const n=new Mp;bf(n,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),nSe(n,8,e7e,r),Ic(n,"IMAGE:input_frames_image"),Ao(n,"POSE_LANDMARKS:pose_landmarks"),Ao(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),Ao(n,"FACE_LANDMARKS:face_landmarks"),Ao(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),Ao(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),Ao(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),Ao(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(s),$g(t,n),ome(this,t),this.g.attachProtoListener("pose_landmarks",(a,o)=>{Pz(a,this.h.poseLandmarks),ra(this,o)}),this.g.attachEmptyPacketListener("pose_landmarks",a=>{ra(this,a)}),this.g.attachProtoListener("pose_world_landmarks",(a,o)=>{var l=this.h.poseWorldLandmarks;a=VM(a),l.push(r8(a)),ra(this,o)}),this.g.attachEmptyPacketListener("pose_world_landmarks",a=>{ra(this,a)}),this.outputPoseSegmentationMasks&&(Ao(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),hA(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",(a,o)=>{this.h.poseSegmentationMasks=[pA(this,a,!0,!this.D)],ra(this,o)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",a=>{this.h.poseSegmentationMasks=[],ra(this,a)})),this.g.attachProtoListener("face_landmarks",(a,o)=>{Pz(a,this.h.faceLandmarks),ra(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",a=>{ra(this,a)}),this.outputFaceBlendshapes&&(Zo(t,"extra_blendshapes"),Ao(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(a,o)=>{var l=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(a=nme(a),l.push(CSe(a.g()??[]))),ra(this,o)}),this.g.attachEmptyPacketListener("extra_blendshapes",a=>{ra(this,a)})),this.g.attachProtoListener("left_hand_landmarks",(a,o)=>{Pz(a,this.h.leftHandLandmarks),ra(this,o)}),this.g.attachEmptyPacketListener("left_hand_landmarks",a=>{ra(this,a)}),this.g.attachProtoListener("left_hand_world_landmarks",(a,o)=>{var l=this.h.leftHandWorldLandmarks;a=VM(a),l.push(r8(a)),ra(this,o)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",a=>{ra(this,a)}),this.g.attachProtoListener("right_hand_landmarks",(a,o)=>{Pz(a,this.h.rightHandLandmarks),ra(this,o)}),this.g.attachEmptyPacketListener("right_hand_landmarks",a=>{ra(this,a)}),this.g.attachProtoListener("right_hand_world_landmarks",(a,o)=>{var l=this.h.rightHandWorldLandmarks;a=VM(a),l.push(r8(a)),ra(this,o)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",a=>{ra(this,a)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};wc.prototype.detectForVideo=wc.prototype.G,wc.prototype.detect=wc.prototype.F,wc.prototype.setOptions=wc.prototype.o,wc.createFromModelPath=function(t,s){return Oo(wc,t,{baseOptions:{modelAssetPath:s}})},wc.createFromModelBuffer=function(t,s){return Oo(wc,t,{baseOptions:{modelAssetBuffer:s}})},wc.createFromOptions=function(t,s){return Oo(wc,t,s)},wc.HAND_CONNECTIONS=OSe,wc.POSE_CONNECTIONS=Lot,wc.FACE_LANDMARKS_LIPS=ASe,wc.FACE_LANDMARKS_LEFT_EYE=ESe,wc.FACE_LANDMARKS_LEFT_EYEBROW=PSe,wc.FACE_LANDMARKS_LEFT_IRIS=Aot,wc.FACE_LANDMARKS_RIGHT_EYE=ISe,wc.FACE_LANDMARKS_RIGHT_EYEBROW=LSe,wc.FACE_LANDMARKS_RIGHT_IRIS=Eot,wc.FACE_LANDMARKS_FACE_OVAL=DSe,wc.FACE_LANDMARKS_CONTOURS=Pot,wc.FACE_LANDMARKS_TESSELATION=Iot;var Gf=class extends wf{constructor(t,s){super(new cy(t,s),"input_image","norm_rect",!0),this.j={classifications:[]},ri(t=this.h=new dot,0,1,s=new xd)}get baseOptions(){return Uo(this.h,xd,1)}set baseOptions(t){ri(this.h,0,1,t)}o(t){return ri(this.h,0,2,qbe(t,Uo(this.h,_Se,2))),this.l(t)}sa(t,s){return this.j={classifications:[]},dy(this,t,s),this.j}ta(t,s,r){return this.j={classifications:[]},B0(this,t,r,s),this.j}m(){var t=new Sf;Gc(t,"input_image"),Gc(t,"norm_rect"),Zo(t,"classifications");const s=new Nf;F0(s,V2s,this.h);const r=new Mp;bf(r,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),Ic(r,"IMAGE:input_image"),Ic(r,"NORM_RECT:norm_rect"),Ao(r,"CLASSIFICATIONS:classifications"),r.o(s),$g(t,r),this.g.attachProtoListener("classifications",(n,a)=>{this.j=Y2s(P2s(n)),ra(this,a)}),this.g.attachEmptyPacketListener("classifications",n=>{ra(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Gf.prototype.classifyForVideo=Gf.prototype.ta,Gf.prototype.classify=Gf.prototype.sa,Gf.prototype.setOptions=Gf.prototype.o,Gf.createFromModelPath=function(t,s){return Oo(Gf,t,{baseOptions:{modelAssetPath:s}})},Gf.createFromModelBuffer=function(t,s){return Oo(Gf,t,{baseOptions:{modelAssetBuffer:s}})},Gf.createFromOptions=function(t,s){return Oo(Gf,t,s)};var qp=class extends wf{constructor(t,s){super(new cy(t,s),"image_in","norm_rect",!0),this.h=new uot,this.embeddings={embeddings:[]},ri(t=this.h,0,1,s=new xd)}get baseOptions(){return Uo(this.h,xd,1)}set baseOptions(t){ri(this.h,0,1,t)}o(t){var s=this.h,r=Uo(this.h,c7e,2);return r=r?r.clone():new c7e,t.l2Normalize!==void 0?vl(r,1,BD(t.l2Normalize)):"l2Normalize"in t&&vl(r,1),t.quantize!==void 0?vl(r,2,BD(t.quantize)):"quantize"in t&&vl(r,2),ri(s,0,2,r),this.l(t)}za(t,s){return dy(this,t,s),this.embeddings}Aa(t,s,r){return B0(this,t,r,s),this.embeddings}m(){var t=new Sf;Gc(t,"image_in"),Gc(t,"norm_rect"),Zo(t,"embeddings_out");const s=new Nf;F0(s,H2s,this.h);const r=new Mp;bf(r,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),Ic(r,"IMAGE:image_in"),Ic(r,"NORM_RECT:norm_rect"),Ao(r,"EMBEDDINGS:embeddings_out"),r.o(s),$g(t,r),this.g.attachProtoListener("embeddings_out",(n,a)=>{n=D2s(n),this.embeddings=function(o){return{embeddings:M1(o,L2s,1).map(l=>{var u,p;const i={headIndex:pg(l,3)??0??-1,headName:_h(Vc(l,4))??""??""};var c=l.v;return lit(c,0|c[wa],l7e,cye(l,1))!==void 0?(l=j4(l=Uo(l,l7e,cye(l,1),void 0),1,t0,w4()),i.floatEmbedding=l.slice()):(c=new Uint8Array(0),i.quantizedEmbedding=((p=(u=Uo(l,I2s,cye(l,2),void 0))==null?void 0:u.na())==null?void 0:p.h())??c),i}),timestampMs:yot(Vc(o,2,void 0,void 0,zce)??rit)}}(n),ra(this,a)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{ra(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};qp.cosineSimilarity=function(t,s){if(t.floatEmbedding&&s.floatEmbedding)t=f7e(t.floatEmbedding,s.floatEmbedding);else{if(!t.quantizedEmbedding||!s.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=f7e(p7e(t.quantizedEmbedding),p7e(s.quantizedEmbedding))}return t},qp.prototype.embedForVideo=qp.prototype.Aa,qp.prototype.embed=qp.prototype.za,qp.prototype.setOptions=qp.prototype.o,qp.createFromModelPath=function(t,s){return Oo(qp,t,{baseOptions:{modelAssetPath:s}})},qp.createFromModelBuffer=function(t,s){return Oo(qp,t,{baseOptions:{modelAssetBuffer:s}})},qp.createFromOptions=function(t,s){return Oo(qp,t,s)};var Wbe=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 rws(t){var r,n;const s=function(a){return M1(a,Mp,1)}(t.ca()).filter(a=>(_h(Vc(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=Uo(s[0],Nf,7))==null?void 0:r.j())==null?void 0:n.g())??new Map).forEach((a,o)=>{t.u[Number(o)]=_h(Vc(a,1))??""})}function E7e(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function P7e(t){try{const s=new Wbe(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return s;t.j(s)}finally{lme(t)}}Wbe.prototype.close=Wbe.prototype.close;var cm=class extends wf{constructor(t,s){super(new cy(t,s),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new SSe,this.A=new hot,ri(this.h,0,3,this.A),ri(t=this.h,0,1,s=new xd)}get baseOptions(){return Uo(this.h,xd,1)}set baseOptions(t){ri(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?vl(this.h,2,eR(t.displayNamesLocale)):"displayNamesLocale"in t&&vl(this.h,2),"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}L(){rws(this)}segment(t,s,r){const n=typeof s!="function"?s:{};return this.j=typeof s=="function"?s:r,E7e(this),dy(this,t,n),P7e(this)}La(t,s,r,n){const a=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,E7e(this),B0(this,t,a,s),P7e(this)}Da(){return this.u}m(){var t=new Sf;Gc(t,"image_in"),Gc(t,"norm_rect");const s=new Nf;F0(s,pot,this.h);const r=new Mp;bf(r,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),Ic(r,"IMAGE:image_in"),Ic(r,"NORM_RECT:norm_rect"),r.o(s),$g(t,r),ome(this,t),this.outputConfidenceMasks&&(Zo(t,"confidence_masks"),Ao(r,"CONFIDENCE_MASKS:confidence_masks"),hA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>pA(this,o,!0,!this.j)),ra(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],ra(this,n)})),this.outputCategoryMask&&(Zo(t,"category_mask"),Ao(r,"CATEGORY_MASK:category_mask"),hA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=pA(this,n,!1,!this.j),ra(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,ra(this,n)})),Zo(t,"quality_scores"),Ao(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,ra(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,ra(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};cm.prototype.getLabels=cm.prototype.Da,cm.prototype.segmentForVideo=cm.prototype.La,cm.prototype.segment=cm.prototype.segment,cm.prototype.setOptions=cm.prototype.o,cm.createFromModelPath=function(t,s){return Oo(cm,t,{baseOptions:{modelAssetPath:s}})},cm.createFromModelBuffer=function(t,s){return Oo(cm,t,{baseOptions:{modelAssetBuffer:s}})},cm.createFromOptions=function(t,s){return Oo(cm,t,s)};var Gbe=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()}};Gbe.prototype.close=Gbe.prototype.close;var Dy=class extends wf{constructor(t,s){super(new cy(t,s),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new SSe,this.u=new hot,ri(this.h,0,3,this.u),ri(t=this.h,0,1,s=new xd)}get baseOptions(){return Uo(this.h,xd,1)}set baseOptions(t){ri(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 fot,s.keypoint&&s.scribble)throw Error("Cannot provide both keypoint and scribble.");if(s.keypoint){var o=new mye;H_(o,3,BD(!0),!1),H_(o,1,hI(s.keypoint.x),0),H_(o,2,hI(s.keypoint.y),0),t8(n,1,$be,o)}else{if(!s.scribble)throw Error("Must provide either a keypoint or a scribble.");{const i=new G2s;for(o of s.scribble)H_(s=new mye,3,BD(!0),!1),H_(s,1,hI(o.x),0),H_(s,2,hI(o.y),0),nSe(i,1,mye,s);t8(n,2,$be,i)}}this.g.addProtoToStream(n.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",r),dy(this,t,a);e:{try{const i=new Gbe(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=i;break e}this.j(i)}finally{lme(this)}l=void 0}return l}m(){var t=new Sf;Gc(t,"image_in"),Gc(t,"roi_in"),Gc(t,"norm_rect_in");const s=new Nf;F0(s,pot,this.h);const r=new Mp;bf(r,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),Ic(r,"IMAGE:image_in"),Ic(r,"ROI:roi_in"),Ic(r,"NORM_RECT:norm_rect_in"),r.o(s),$g(t,r),ome(this,t),this.outputConfidenceMasks&&(Zo(t,"confidence_masks"),Ao(r,"CONFIDENCE_MASKS:confidence_masks"),hA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>pA(this,o,!0,!this.j)),ra(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],ra(this,n)})),this.outputCategoryMask&&(Zo(t,"category_mask"),Ao(r,"CATEGORY_MASK:category_mask"),hA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=pA(this,n,!1,!this.j),ra(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,ra(this,n)})),Zo(t,"quality_scores"),Ao(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,ra(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,ra(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Dy.prototype.segment=Dy.prototype.segment,Dy.prototype.setOptions=Dy.prototype.o,Dy.createFromModelPath=function(t,s){return Oo(Dy,t,{baseOptions:{modelAssetPath:s}})},Dy.createFromModelBuffer=function(t,s){return Oo(Dy,t,{baseOptions:{modelAssetBuffer:s}})},Dy.createFromOptions=function(t,s){return Oo(Dy,t,s)};var Kf=class extends wf{constructor(t,s){super(new cy(t,s),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},ri(t=this.h=new got,0,1,s=new xd)}get baseOptions(){return Uo(this.h,xd,1)}set baseOptions(t){ri(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?vl(this.h,2,eR(t.displayNamesLocale)):"displayNamesLocale"in t&&vl(this.h,2),t.maxResults!==void 0?T1(this.h,3,t.maxResults):"maxResults"in t&&vl(this.h,3),t.scoreThreshold!==void 0?za(this.h,4,t.scoreThreshold):"scoreThreshold"in t&&vl(this.h,4),t.categoryAllowlist!==void 0?$ce(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&vl(this.h,5),t.categoryDenylist!==void 0?$ce(this.h,6,t.categoryDenylist):"categoryDenylist"in t&&vl(this.h,6),this.l(t)}F(t,s){return this.j={detections:[]},dy(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},B0(this,t,r,s),this.j}m(){var t=new Sf;Gc(t,"input_frame_gpu"),Gc(t,"norm_rect"),Zo(t,"detections");const s=new Nf;F0(s,K2s,this.h);const r=new Mp;bf(r,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),Ic(r,"IMAGE:input_frame_gpu"),Ic(r,"NORM_RECT:norm_rect"),Ao(r,"DETECTIONS:detections"),r.o(s),$g(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=Git(o),this.j.detections.push(vot(n));ra(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{ra(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Kf.prototype.detectForVideo=Kf.prototype.G,Kf.prototype.detect=Kf.prototype.F,Kf.prototype.setOptions=Kf.prototype.o,Kf.createFromModelPath=async function(t,s){return Oo(Kf,t,{baseOptions:{modelAssetPath:s}})},Kf.createFromModelBuffer=function(t,s){return Oo(Kf,t,{baseOptions:{modelAssetBuffer:s}})},Kf.createFromOptions=function(t,s){return Oo(Kf,t,s)};var Kbe=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 I7e(t){t.landmarks=[],t.worldLandmarks=[],t.segmentationMasks=void 0}function L7e(t){try{const s=new Kbe(t.landmarks,t.worldLandmarks,t.segmentationMasks);if(!t.u)return s;t.u(s)}finally{lme(t)}}Kbe.prototype.close=Kbe.prototype.close;var Up=class extends wf{constructor(t,s){super(new cy(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,ri(t=this.h=new xot,0,1,s=new xd),this.A=new lot,ri(this.h,0,3,this.A),this.j=new oot,ri(this.h,0,2,this.j),T1(this.j,4,1),za(this.j,2,.5),za(this.A,2,.5),za(this.h,4,.5)}get baseOptions(){return Uo(this.h,xd,1)}set baseOptions(t){ri(this.h,0,1,t)}o(t){return"numPoses"in t&&T1(this.j,4,t.numPoses??1),"minPoseDetectionConfidence"in t&&za(this.j,2,t.minPoseDetectionConfidence??.5),"minTrackingConfidence"in t&&za(this.h,4,t.minTrackingConfidence??.5),"minPosePresenceConfidence"in t&&za(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,I7e(this),dy(this,t,n),L7e(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:n,I7e(this),B0(this,t,a,s),L7e(this)}m(){var t=new Sf;Gc(t,"image_in"),Gc(t,"norm_rect"),Zo(t,"normalized_landmarks"),Zo(t,"world_landmarks"),Zo(t,"segmentation_masks");const s=new Nf;F0(s,Z2s,this.h);const r=new Mp;bf(r,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),Ic(r,"IMAGE:image_in"),Ic(r,"NORM_RECT:norm_rect"),Ao(r,"NORM_LANDMARKS:normalized_landmarks"),Ao(r,"WORLD_LANDMARKS:world_landmarks"),r.o(s),$g(t,r),ome(this,t),this.g.attachProtoVectorListener("normalized_landmarks",(n,a)=>{this.landmarks=[];for(const o of n)n=rR(o),this.landmarks.push(ime(n));ra(this,a)}),this.g.attachEmptyPacketListener("normalized_landmarks",n=>{this.landmarks=[],ra(this,n)}),this.g.attachProtoVectorListener("world_landmarks",(n,a)=>{this.worldLandmarks=[];for(const o of n)n=VM(o),this.worldLandmarks.push(r8(n));ra(this,a)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],ra(this,n)}),this.outputSegmentationMasks&&(Ao(r,"SEGMENTATION_MASK:segmentation_masks"),hA(this,"segmentation_masks"),this.g.aa("segmentation_masks",(n,a)=>{this.segmentationMasks=n.map(o=>pA(this,o,!0,!this.u)),ra(this,a)}),this.g.attachEmptyPacketListener("segmentation_masks",n=>{this.segmentationMasks=[],ra(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Up.prototype.detectForVideo=Up.prototype.G,Up.prototype.detect=Up.prototype.F,Up.prototype.setOptions=Up.prototype.o,Up.createFromModelPath=function(t,s){return Oo(Up,t,{baseOptions:{modelAssetPath:s}})},Up.createFromModelBuffer=function(t,s){return Oo(Up,t,{baseOptions:{modelAssetBuffer:s}})},Up.createFromOptions=function(t,s){return Oo(Up,t,s)},Up.POSE_CONNECTIONS=Lot;let k4=null,mI=null;async function nws(){return k4||mI||(mI=(async()=>{const t=await j5.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm");return k4=await cm.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}),k4})(),mI)}function aws(t,s,r,n,a){const o=new Float32Array(t.length);for(let l=0;l=0&&(i-=t[c+p]);const y=Math.min(f,r-1)-Math.max(p+1,0)+1;o[c+u]=i/y}}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 iws(){k4&&(k4.close(),k4=null,mI=null)}function ows(t,s){const r=C.useRef(null),n=C.useRef(null),a=C.useRef(null),o=C.useRef(null),l=C.useRef(0),i=C.useRef(0),[c,u]=C.useState(null),[p,f]=C.useState(!1),[y,_]=C.useState(null),b=s.type!=="none"&&t!==null;return C.useEffect(()=>{if(s.type==="image"&&s.imageUrl){const w=new Image;w.crossOrigin="anonymous",w.src=s.imageUrl,w.onload=()=>{o.current=w}}else o.current=null},[s.type,s.imageUrl]),C.useEffect(()=>{if(!b||!t){a.current&&(a.current.srcObject=null,a.current=null);return}const w=document.createElement("video");return w.srcObject=t,w.muted=!0,w.playsInline=!0,w.autoplay=!0,w.play().catch(()=>{}),a.current=w,()=>{w.srcObject=null,a.current=null}},[b,t]),C.useEffect(()=>{if(!b){u(null),_(null);return}let w=!1;return(async()=>{f(!0),_(null);try{const N=await nws();if(w)return;f(!1);const S=a.current;if(!S||(await new Promise(je=>{if(S.videoWidth>0)return je();S.onloadedmetadata=()=>je(),setTimeout(je,2e3)}),w))return;const T=S.videoWidth||640,I=S.videoHeight||480,L=r.current;if(!L)return;L.width=T,L.height=I;const R=L.getContext("2d",{willReadFrequently:!1});n.current||(n.current=document.createElement("canvas"));const $=n.current;$.width=T,$.height=I;const q=$.getContext("2d",{willReadFrequently:!0}),U=document.createElement("canvas");U.width=T,U.height=I;const V=U.getContext("2d"),X=L.captureStream(30);((t==null?void 0:t.getAudioTracks())||[]).forEach(je=>X.addTrack(je)),w||u(X);const ee=s.blurRadius??15,Q=s.mirror??!1,de=new Float32Array(T*I),re=new Float32Array(T*I),ne=new Float32Array(T*I);let le=!1;const he=4,we=.6,ye=()=>{if(w||!a.current)return;const je=performance.now();if(je-i.current<30){l.current=requestAnimationFrame(ye);return}i.current=je;const ke=a.current;if(ke.readyState<2){l.current=requestAnimationFrame(ye);return}try{const be=N.segmentForVideo(ke,je).confidenceMasks;if(be&&be.length>0){re.fill(0);for(let Re=1;Reqe?(Rt=Re.height*qe,ct=(Re.width-Rt)/2):(pe=Re.width/qe,De=(Re.height-pe)/2),R.drawImage(Re,ct,De,Rt,pe,0,0,T,I)}q.clearRect(0,0,T,I),q.drawImage(ke,0,0,T,I);const Me=q.getImageData(0,0,T,I),Ae=Me.data;for(let Re=0;Re{w=!0,l.current&&cancelAnimationFrame(l.current),u(null)}},[b,s.type,s.blurRadius,s.imageUrl,t]),C.useEffect(()=>()=>{iws()},[]),{canvasRef:r,compositedStream:c,isLoading:p,isActive:b,error:y}}function cme({maxDurationSeconds:t=30,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=C.useRef(null),i=C.useRef(null),c=C.useRef(null),[u,p]=C.useState(null),f=C.useRef([]),y=C.useRef(null),_=C.useRef(null),b=C.useRef(null),w=C.useRef(null),j=oE(),[N,S]=C.useState(!0),[T,I]=C.useState(!0),[L,R]=C.useState(null),[$,q]=C.useState(!1),[U,V]=C.useState(!1),[X,se]=C.useState(null),[ee,Q]=C.useState(null),[de,re]=C.useState(0),[ne,le]=C.useState("user"),[he,we]=C.useState(0),[ye,je]=C.useState(!1),[ke,We]=C.useState(!0),[be,Me]=C.useState(null),[Ae,Re]=C.useState(!1),[Te,qe]=C.useState(null),ct=C.useRef(null),[De,Rt]=C.useState(()=>{try{const Ms=localStorage.getItem("video-bg-config");if(Ms)return JSON.parse(Ms)}catch{}return{type:"none"}});C.useEffect(()=>{try{localStorage.setItem("video-bg-config",JSON.stringify(De))}catch{}},[De]);const{canvasRef:pe,compositedStream:Je,isLoading:lt,isActive:rt}=ows(u,De),Se=C.useRef(r);Se.current=r;const it=C.useCallback(Ms=>{S(Ms)},[]),$e=C.useRef(N),ot=C.useCallback(async()=>{var jt,As;I(!0),Me(null);const Ms=j&&N;console.log("[VideoRecorder] initCamera start",{isMobile:j,usePortraitMode:N,shouldBePortrait:Ms,facingMode:ne});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(pa=>pa.stop()));const Ps=j&&Ms?{facingMode:{ideal:ne},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:ne},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",Ps);const ar=await navigator.mediaDevices.getUserMedia({video:Ps,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),ar.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");c.current=ar,p(ar),R(!0);const Va=ar.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",Va.width,"x",Va.height),l.current){const pa=l.current;pa.srcObject=ar,pa.muted=!0,pa.playsInline=!0,pa.autoplay=!0,pa.setAttribute("muted",""),pa.setAttribute("playsinline",""),pa.setAttribute("autoplay","");try{(jt=pa.load)==null||jt.call(pa)}catch(Kr){console.warn("[VideoRecorder] videoEl.load failed",Kr)}const qa=async()=>{try{return await pa.play(),console.log("[VideoRecorder] preview play ok"),Re(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:pa.readyState,videoWidth:pa.videoWidth,videoHeight:pa.videoHeight})},300),!0}catch(Kr){return console.warn("[VideoRecorder] preview play blocked",Kr),Re(!0),!1}};await new Promise(Kr=>{let Yn=!1;const mn=()=>{Yn||(Yn=!0,Kr())},Gn=()=>{qa().finally(mn)};pa.onloadedmetadata=Gn,pa.onloadeddata=Gn,setTimeout(mn,1500)})}try{_.current=new AudioContext;const pa=_.current.createMediaStreamSource(ar);b.current=_.current.createAnalyser(),b.current.fftSize=256,pa.connect(b.current);const qa=()=>{if(b.current){const Kr=new Uint8Array(b.current.frequencyBinCount);b.current.getByteFrequencyData(Kr);const Yn=Kr.reduce((mn,Gn)=>mn+Gn)/Kr.length;we(Math.min(100,Yn/128*100))}w.current=requestAnimationFrame(qa)};qa()}catch(pa){console.warn("Audio context not available:",pa)}}catch(Ps){console.error("Camera initialization error:",Ps),R(!1);let ar="Failed to access camera or microphone.";Ps.name==="NotAllowedError"?ar="Camera permission denied. Please allow camera access in your browser settings.":Ps.name==="NotFoundError"?ar="No camera found. Please connect a camera and try again.":Ps.name==="NotReadableError"?ar="Camera is in use by another application. Please close other apps using the camera.":Ps.message&&(ar=Ps.message),Me(ar),(As=Se.current)==null||As.call(Se,ar)}finally{I(!1)}},[ne,j,N]);C.useEffect(()=>{$e.current!==N&&L&&!$&&!ee&&($e.current=N,ot())},[N,L,$,ee,ot]),C.useEffect(()=>(ot(),()=>{c.current&&c.current.getTracks().forEach(Ms=>Ms.stop()),y.current&&clearInterval(y.current),w.current&&cancelAnimationFrame(w.current),_.current&&_.current.close(),ct.current&&clearInterval(ct.current),ee&&URL.revokeObjectURL(ee)}),[ot,ee]),C.useEffect(()=>{if(T||L!==!0||ee)return;const Ms=c.current,jt=l.current;!Ms||!jt||rt||(jt.srcObject!==Ms&&(jt.srcObject=Ms,jt.muted=!0,jt.playsInline=!0,jt.autoplay=!0,jt.setAttribute("muted",""),jt.setAttribute("playsinline",""),jt.setAttribute("autoplay","")),jt.play().then(()=>Re(!1)).catch(As=>{Re(!0),console.warn("Live preview play blocked on mount:",As)}))},[L,T,ee,rt]),C.useEffect(()=>{n==null||n($)},[$,n]);const Ue=C.useCallback(async()=>{if(ee)return;const Ms=l.current;if(Ms)try{await Ms.play(),Re(!1)}catch(jt){Re(!0),console.warn("Live preview still blocked (needs user gesture):",jt)}},[ee]),Ke=C.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),y.current&&(clearInterval(y.current),y.current=null),q(!1),V(!1)},[]),Xe=C.useCallback(()=>{const Ms=rt&&Je?Je:c.current;if(!Ms)return;Ue(),f.current=[],re(0);const As=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"].find(ar=>MediaRecorder.isTypeSupported(ar)),Ps=new MediaRecorder(Ms,As?{mimeType:As,videoBitsPerSecond:25e5}:{videoBitsPerSecond:25e5});Ps.ondataavailable=ar=>{ar.data.size>0&&f.current.push(ar.data)},Ps.onstop=()=>{var pa;const ar=Ps.mimeType||As||((pa=f.current[0])==null?void 0:pa.type)||"video/webm",Dn=new Blob(f.current,{type:ar});se(Dn);const Va=URL.createObjectURL(Dn);Q(Va)},i.current=Ps,Ps.start(100),q(!0),y.current=setInterval(()=>{re(ar=>ar>=t-1?(Ke(),t):ar+1)},1e3)},[Ue,t,Ke,rt,Je]),He=C.useCallback(()=>{ct.current&&(clearInterval(ct.current),ct.current=null),qe(3);let Ms=3;ct.current=setInterval(()=>{Ms-=1,Ms<=0?(ct.current&&clearInterval(ct.current),ct.current=null,qe(null),Xe()):qe(Ms)},1e3)},[Xe]),Ye=C.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),V(!0),y.current&&clearInterval(y.current))},[]),tt=C.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),V(!1),y.current=setInterval(()=>{re(Ms=>Ms>=t-1?(Ke(),t):Ms+1)},1e3))},[t,Ke]),Et=C.useCallback(()=>{ee&&URL.revokeObjectURL(ee),se(null),Q(null),re(0),je(!1),We(!0),l.current&&c.current&&!rt&&(l.current.srcObject=c.current,l.current.muted=!0,Ue())},[Ue,ee,rt]),qt=C.useCallback(()=>{le(Ms=>Ms==="user"?"environment":"user")},[]),ms=C.useCallback(()=>{X&&s(X,de)},[X,de,s]),Xt=C.useCallback(()=>{l.current&&ee&&(ye?l.current.pause():(We(!1),l.current.muted=!1,l.current.play()),je(!ye))},[ee,ye]);C.useEffect(()=>{if(!ee)return;const Ms=l.current;if(!Ms)return;We(!1),Ms.pause(),Ms.removeAttribute("src"),Ms.srcObject=null,Ms.load(),Ms.src=ee,Ms.currentTime=0,Ms.playsInline=!0,Ms.muted=!1,Ms.onended=()=>je(!1);const jt=()=>{var ar;const As=Ms.error,Ps=As?`Recorded video failed to play (code ${As.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",As),(ar=Se.current)==null||ar.call(Se,Ps)};return Ms.addEventListener("error",jt),Ms.load(),()=>{Ms.removeEventListener("error",jt)}},[ee]);const rs=Ms=>{const jt=Math.floor(Ms/60),As=Ms%60;return`${jt}:${As.toString().padStart(2,"0")}`},ps=j&&N?"aspect-[9/16]":"aspect-video";return T?e.jsx("div",{className:At("flex items-center justify-center bg-black rounded-lg",ps,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(Ss,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):L===!1?e.jsx("div",{className:At("flex items-center justify-center bg-black rounded-lg",ps,a),children:e.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[e.jsx(yl,{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:be||"Please allow camera and microphone access to record videos."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(K,{onClick:()=>ot(),variant:"secondary",className:"w-full",children:[e.jsx(Bo,{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:At("flex flex-col gap-2",a),children:[!$&&!ee&&e.jsx(_bs,{value:De,onChange:Rt,isLoading:lt,disabled:$}),j&&!$&&!ee&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(H4,{className:At("h-4 w-4",N?"text-muted-foreground":"text-primary")}),e.jsx(_e,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),e.jsx(Br,{id:"orientation-toggle",checked:N,onCheckedChange:it}),e.jsx(_e,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(i1,{className:At("h-4 w-4",N?"text-primary":"text-muted-foreground")})]}),e.jsxs("div",{className:At("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{Ue()},children:[e.jsx("video",{ref:l,src:ee??void 0,className:At("w-full bg-black",N&&!ee?"object-contain":"object-cover",ps,!ee&&ne==="user"!==(De.mirror??!1)&&"scale-x-[-1]",rt&&!ee&&"hidden"),playsInline:!0,controls:!!ee,muted:ee?ke:!0,autoPlay:!ee},ee??"live"),rt&&!ee&&e.jsx("canvas",{ref:pe,className:At("w-full bg-black",N?"object-contain":"object-cover",ps,ne==="user"!==(De.mirror??!1)&&"scale-x-[-1]")}),rt&<&&!ee&&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(Ss,{className:"h-8 w-8 animate-spin mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Loading virtual background…"})]})}),!ee&&Ae&&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 Ue(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!ee&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),Te!==null&&!ee&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:Te},Te),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),$&&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:At("w-3 h-3 rounded-full",U?"bg-yellow-500":"bg-red-500 animate-pulse")}),e.jsxs("span",{className:"text-white text-sm font-medium",children:[rs(de)," / ",rs(t)]})]}),$&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(Oi,{value:de/t*100,className:"h-1 rounded-none"})}),!ee&&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(XI,{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:`${he}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:ee?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:Et,children:[e.jsx(Bo,{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:Xt,children:ye?e.jsx(cf,{className:"h-5 w-5"}):e.jsx(wl,{className:"h-5 w-5"})}),e.jsxs(K,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:ms,children:[e.jsx(ma,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:qt,disabled:$||Te!==null,children:e.jsx(a1,{className:"h-5 w-5"})}),!$&&Te===null?e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:He,children:e.jsx(Nn,{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:U?tt:Ye,children:U?e.jsx(wl,{className:"h-5 w-5"}):e.jsx(cf,{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:Ke,children:e.jsx(c0,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const Dot="teleprompter_settings",fye={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function lws(){try{const t=localStorage.getItem(Dot);return t?{...fye,...JSON.parse(t)}:fye}catch{return fye}}function cws(t){try{localStorage.setItem(Dot,JSON.stringify(t))}catch{}}function Oot({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=C.useRef(null),c=C.useRef(null),u=C.useRef(0),p=C.useRef(0),[f,y]=C.useState(lws),{scrollSpeed:_,fontSize:b,lineHeight:w,opacity:j,position:N,isMirrored:S}=f,T=C.useCallback((se,ee)=>{y(Q=>{const de={...Q,[se]:ee};return cws(de),de})},[]),[I,L]=C.useState(!1),[R,$]=C.useState(null),q=C.useCallback(se=>{if(!i.current)return;u.current===0&&(u.current=se);const ee=se-u.current;u.current=se,p.current+=_*ee/1e3;const Q=Math.floor(p.current);Q>0&&(i.current.scrollTop+=Q,p.current-=Q);const{scrollTop:de,scrollHeight:re,clientHeight:ne}=i.current;if(de+ne>=re){L(!1);return}c.current=requestAnimationFrame(q)},[_]);C.useEffect(()=>(I?(u.current=0,p.current=0,c.current=requestAnimationFrame(q)):c.current&&cancelAnimationFrame(c.current),()=>{c.current&&cancelAnimationFrame(c.current)}),[I,q]),C.useEffect(()=>{if(n&&s)if(i.current&&(i.current.scrollTop=0),a){$(3);let se=3;const ee=setInterval(()=>{se-=1,se<=0?(clearInterval(ee),$(null),o==null||o(),L(!0)):$(se)},1e3);return()=>clearInterval(ee)}else setTimeout(()=>L(!0),100);else n||(L(!1),$(null))},[n,s,a,o]);const U=C.useCallback(()=>{i.current&&(i.current.scrollTop=0),L(!1)},[]),V=C.useCallback(()=>{L(se=>!se)},[]);if(!s)return e.jsx("div",{className:At("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(va,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const X={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return e.jsxs("div",{className:At("absolute inset-0 pointer-events-none",l),children:[R!==null&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"text-white font-bold drop-shadow-lg animate-scale-in",style:{fontSize:"96px",lineHeight:1,textShadow:"0 4px 16px rgba(0,0,0,0.8)"},children:R},R),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),e.jsx("div",{className:At("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",X[N],R!==null&&"opacity-30"),style:{opacity:R!==null?.3:j},children:e.jsxs("div",{ref:i,className:At("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",S&&"scale-x-[-1]"),style:{maskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)"},children:[e.jsx("div",{className:"h-full",style:{minHeight:"100%"}}),e.jsx("p",{className:"text-white text-center font-medium drop-shadow-lg",style:{fontSize:`${b}px`,lineHeight:w,textShadow:"0 2px 4px rgba(0,0,0,0.8)"},children:t}),e.jsx("div",{className:"h-full"})]})}),e.jsxs("div",{className:"absolute top-4 right-4 flex items-center gap-2 pointer-events-auto",children:[e.jsxs(Lo,{children:[e.jsx(Do,{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(Jl,{className:"h-4 w-4"})})}),e.jsx(Eo,{className:"w-72",side:"left",align:"start",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium",children:"Teleprompter Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-xs",children:"Scroll Speed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:_})]}),e.jsx(Bx,{value:[_],onValueChange:([se])=>T("scrollSpeed",se),min:1,max:100,step:1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-xs",children:"Font Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[b,"px"]})]}),e.jsx(Bx,{value:[b],onValueChange:([se])=>T("fontSize",se),min:16,max:48,step:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-xs",children:"Line Spacing"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:w.toFixed(1)})]}),e.jsx(Bx,{value:[w*10],onValueChange:([se])=>T("lineHeight",se/10),min:12,max:24,step:1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-xs",children:"Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(j*100),"%"]})]}),e.jsx(Bx,{value:[j*100],onValueChange:([se])=>T("opacity",se/100),min:30,max:100,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-xs",children:"Position"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:N==="top"?"default":"outline",size:"sm",onClick:()=>T("position","top"),children:e.jsx(Hx,{className:"h-4 w-4"})}),e.jsx(K,{variant:N==="center"?"default":"outline",size:"sm",onClick:()=>T("position","center"),children:e.jsx(t1,{className:"h-4 w-4"})}),e.jsx(K,{variant:N==="bottom"?"default":"outline",size:"sm",onClick:()=>T("position","bottom"),children:e.jsx(tl,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-xs",children:"Mirror Mode"}),e.jsx(Br,{checked:S,onCheckedChange:se=>T("isMirrored",se)})]})]})})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:V,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:I?e.jsx(cf,{className:"h-4 w-4"}):e.jsx(wl,{className:"h-4 w-4"})}),e.jsx(K,{variant:"secondary",size:"icon",onClick:U,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:e.jsx(a1,{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(xp,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function dws({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=Ra(),[o,l]=C.useState(""),[i,c]=C.useState(null),[u,p]=C.useState("levelup"),{data:f,isLoading:y}=e_s(),{data:_,isLoading:b}=t_s(),{data:w,isLoading:j}=s_s(),N=r_s(),S=C.useMemo(()=>_?_.filter($=>{const q=!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())||$.tags.some(V=>V.toLowerCase().includes(o.toLowerCase())),U=!i||$.category_id===i;return q&&U}):[],[_,o,i]),T=C.useMemo(()=>w?w.filter($=>!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())):[],[w,o]),I=$=>{t({title:$.title,text:$.script_text})},L=async $=>{try{await N.mutateAsync($),a({title:"Script saved to My Scripts"})}catch{a({title:"Failed to save script",variant:"destructive"})}},R=y||b||j;return e.jsxs("div",{className:At("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search scripts...",value:o,onChange:$=>l($.target.value),className:"pl-9"})]})}),e.jsxs(Aa,{value:u,onValueChange:$=>p($),className:"flex-1 flex flex-col",children:[e.jsxs(ja,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(js,{value:"levelup",children:[e.jsx(In,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(js,{value:"my-scripts",children:[e.jsx(Ux,{className:"h-4 w-4 mr-2"}),"My Scripts"]})]}),e.jsxs($s,{value:"levelup",className:"flex-1 flex flex-col mt-0 p-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx(nt,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>c(null),children:"All"}),f==null?void 0:f.map($=>e.jsx(nt,{variant:i===$.id?"default":"outline",className:"cursor-pointer",onClick:()=>c($.id),children:$.name},$.id))]}),e.jsx(Vi,{className:"flex-1 max-h-[50vh]",children:R?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ss,{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(In,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No scripts found"})]}):e.jsx("div",{className:"space-y-2",children:S.map($=>e.jsxs(Ee,{className:At("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>I($),children:[e.jsx(It,{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(Ot,{className:"text-sm font-medium truncate",children:$.title}),$.category&&e.jsx(nt,{variant:"secondary",className:"mt-1 text-xs",children:$.category.name})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:q=>{q.stopPropagation(),L($)},children:e.jsx(Ux,{className:"h-4 w-4"})}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"})]})]})}),e.jsx(Oe,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:$.script_text})})]},$.id))})})]}),e.jsxs($s,{value:"my-scripts",className:"flex-1 flex flex-col mt-0 p-4",children:[s&&e.jsxs(K,{variant:"outline",className:"mb-4",onClick:s,children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),e.jsx(Vi,{className:"flex-1 max-h-[50vh]",children:j?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):T.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ux,{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:T.map($=>e.jsxs(Ee,{className:At("cursor-pointer hover:bg-accent/50 transition-colors",r===$.id&&"ring-2 ring-primary"),onClick:()=>I($),children:[e.jsx(It,{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(Ot,{className:"text-sm font-medium truncate",children:$.title}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:$.is_custom?e.jsx(nt,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(nt,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground ml-2"})]})}),e.jsx(Oe,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:$.script_text})})]},$.id))})})]})]})]})}function uws({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=C.useState(()=>{const i=PM(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(_e,{className:"text-sm font-medium",children:"Share Page Template"}),n&&e.jsx(Ss,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:$6t.map(i=>{const c=q6t(i.id),u=a.has(i.id),p=c.some(f=>f.id===t);return e.jsxs(bg,{open:u,onOpenChange:()=>l(i.id),children:[e.jsxs(wg,{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(tl,{className:At("h-4 w-4 text-muted-foreground transition-transform",u&&"rotate-180")})]}),e.jsx(jg,{className:"pt-2",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:c.map(f=>{const y=t===f.id;return e.jsxs("button",{type:"button",onClick:()=>s(f.id),disabled:n,className:At("relative rounded-lg border-2 p-2.5 text-left transition-all hover:shadow-sm disabled:opacity-50 disabled:cursor-not-allowed",y?"border-primary ring-1 ring-primary/20 bg-primary/5":"border-muted hover:border-muted-foreground/30"),children:[y&&e.jsx("div",{className:"absolute top-1 right-1 w-4 h-4 rounded-full bg-primary flex items-center justify-center",children:e.jsx(ma,{className:"h-2.5 w-2.5 text-primary-foreground"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"opacity-70 shrink-0",children: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: "',PM(t).headerText(r),'"']})]})}function Rot({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=C.useState(r.page_template||"default"),[i,c]=C.useState(!1),[u,p]=C.useState(!1),[f,y]=C.useState(r.page_template||"default"),[_,b]=C.useState([]),[w,j]=C.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[N,S]=C.useState(!1),[T,I]=C.useState(!1),L=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";C.useEffect(()=>{t&&_.length===0&&R()},[t]);const R=async()=>{I(!0);try{const{data:de,error:re}=await G.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(re)throw re;const ne=(de||[]).map(le=>({id:le.id,name:[le.first_name,le.last_name].filter(Boolean).join(" ")||"Unnamed",email:le.email||null}));b(ne)}catch(de){console.error("Failed to fetch contacts:",de)}finally{I(!1)}},$=async de=>{j(de),S(!1),c(!0);try{const{error:re}=await G.from("agent_videos").update({contact_id:(de==null?void 0:de.id)||null,recipient_name:(de==null?void 0:de.name)||null}).eq("id",r.id);if(re)throw re;me.success(de?`Assigned to ${de.name}`:"Contact removed"),a==null||a()}catch(re){console.error("Failed to update contact:",re),me.error("Failed to update contact")}finally{c(!1)}},q=async de=>{l(de),c(!0);try{const{error:re}=await G.from("agent_videos").update({page_template:de}).eq("id",r.id);if(re)throw re;y(de),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)}},U=(w==null?void 0:w.name)||null,V=()=>{const de=r.title||"Video Message",re=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:r.thumbnail_url||"";return``},X=async()=>{if(!r.thumbnail_url){me.error("Video thumbnail not available yet");return}const de=V(),re=`Watch: ${r.title||"Video Message"} ${L}`;try{const ne=new Blob([de],{type:"text/html"}),le=new Blob([re],{type:"text/plain"}),he=new ClipboardItem({"text/html":ne,"text/plain":le});await navigator.clipboard.write([he]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(re+` `+de),me.success("Copied! Paste into your email.")}},se=async()=>{await navigator.clipboard.writeText(L),p(!0),me.success("Share link copied!"),setTimeout(()=>p(!1),2e3)},ee=()=>{const re=PM(o).headerText(U),ne=o==="default"?`Check out this video: ${L}`:`${re} Check out this special video: ${L}`;window.open(`sms:?body=${encodeURIComponent(ne)}`,"_self")},Q=()=>{const de=PM(o),re=de.headerText(U),ne=o==="default"?r.title||"Video Message":re,le=`${de.subText} Watch the video: ${L}`,he=w!=null&&w.email?encodeURIComponent(w.email):"";window.open(`mailto:${he}?subject=${encodeURIComponent(ne)}&body=${encodeURIComponent(le)}`,"_self")};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Vo,{className:"h-5 w-5"}),"Share Video"]}),e.jsx(Zr,{children:"Choose a themed page template and share your video"})]}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Personalize for Contact (Optional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Lo,{open:N,onOpenChange:S,children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":N,className:"flex-1 justify-between",disabled:i,children:[w?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ro,{className:"h-4 w-4 text-muted-foreground"}),w.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(xg,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Eo,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Mg,{children:[e.jsx(Tg,{placeholder:"Search contacts..."}),e.jsxs(Ag,{children:[e.jsx(Eg,{children:T?"Loading...":"No contacts found."}),e.jsx(Pg,{children:_.map(de=>e.jsxs(up,{value:de.name,onSelect:()=>$(de),children:[e.jsx(ma,{className:At("mr-2 h-4 w-4",(w==null?void 0:w.id)===de.id?"opacity-100":"opacity-0")}),de.name]},de.id))})]})]})})]}),w&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>$(null),disabled:i,className:"shrink-0",children:e.jsx(Ur,{className:"h-4 w-4"})})]}),w&&o!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',PM(o).headerText(w.name),'"']})]}),e.jsx(uws,{selectedTemplate:o,onSelect:q,contactName:U,saving:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Share Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:L,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:se,variant:u?"default":"outline",className:"shrink-0 gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ma,{className:"h-4 w-4"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(mi,{className:"h-4 w-4"}),"Copy"]})})]})]}),r.thumbnail_url&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Share for Email"}),e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:X,children:[e.jsx(cl,{className:"h-4 w-4"}),"Copy with Thumbnail (for Gmail)"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste into Gmail to embed a clickable video thumbnail"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Quick Share"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:ee,children:[e.jsx(po,{className:"h-4 w-4"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:Q,children:[e.jsx(br,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(Vn,{children:e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function hws(){var rt;const t=Pr(),[s]=Xc(),{toast:r}=Ra(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:c}=vat(),{data:u}=Fm(),p=nC(),f=l_s(),[y,_]=C.useState("record"),[b,w]=C.useState(""),[j,N]=C.useState(!1),[S,T]=C.useState(!1),[I,L]=C.useState(!1),[R,$]=C.useState(null),[q,U]=C.useState(0),[V,X]=C.useState(0),[se,ee]=C.useState(null),[Q,de]=C.useState(null),[re,ne]=C.useState(n||""),[le,he]=C.useState(""),[we,ye]=C.useState(""),[je,ke]=C.useState(null),[We,be]=C.useState(null),[Me,Ae]=C.useState(null),[Re,Te]=C.useState(!1),qe=C.useCallback(async(Se,it)=>{$(Se),_("uploading");try{const{videoId:$e,uploadUrl:ot}=await GO(le||"Quick Video Touch");ee($e);const{apiKey:Ue}=await KO($e),Ke=new XMLHttpRequest;Ke.upload.onprogress=tt=>{tt.lengthComputable&&U(tt.loaded/tt.total*100)},await new Promise((tt,Et)=>{Ke.onload=()=>{Ke.status>=200&&Ke.status<300?tt():Et(new Error(`Upload failed: ${Ke.status}`))},Ke.onerror=()=>Et(new Error("Upload failed")),Ke.open("PUT",ot),Ke.setRequestHeader("AccessKey",Ue),Ke.send(Se)}),_("processing");let Xe=0;const He=Date.now(),Ye=90*1e3;for(;Xe<4;){if(await new Promise(Et=>setTimeout(Et,3e3)),Date.now()-He>Ye){const Et=Se.size/1048576,qt=`https://iframe.mediadelivery.net/play/${$e}/${$e}`;await p.mutateAsync({bunny_video_id:$e,playback_url:qt,file_size_mb:Et,title:le||"Quick Video Touch",notes:we||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 tt=await rA($e);if(Xe=tt.status,X(tt.encodeProgress||0),Xe===4)de({playbackUrl:tt.directPlayUrl,thumbnailUrl:tt.thumbnailUrl,previewUrl:tt.previewUrl||null,duration:tt.length||it,fileSizeMb:(tt.storageSize||Se.size)/(1024*1024)});else if(Xe===5||Xe===6)throw new Error("Video processing failed")}_("details")}catch($e){console.error("Upload error:",$e),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),_("record")}},[le,r]),ct=async()=>{if(!(!se||!Q))try{const Se=re&&re!=="none"?re:null,it=await p.mutateAsync({bunny_video_id:se,contact_id:Se,playback_url:Q.playbackUrl,thumbnail_url:Q.thumbnailUrl,preview_url:Q.previewUrl,duration_seconds:Q.duration,file_size_mb:Q.fileSizeMb,title:le||"Quick Video Touch",notes:we,task_id:a||null,status:"ready"});ke(it.id),be(it.share_token||null),Se&&await f.mutateAsync({contactId:Se,videoId:it.id,notes:we}),r({title:"Video saved successfully!"}),_("share")}catch(Se){console.error("Save video error:",Se),r({title:"Failed to save video",description:(Se==null?void 0:Se.message)||"Please try again.",variant:"destructive"})}},De=(Se,it)=>{navigator.clipboard.writeText(it),Ae(Se),setTimeout(()=>Ae(null),2e3),r({title:"Copied to clipboard!"})},Rt=()=>We?`https://video.relevelup.com/${We}`:(Q==null?void 0:Q.playbackUrl)||"",pe=()=>{const Se=u==null?void 0:u.find(Ke=>Ke.id===re),it=Se?`${Se.first_name}`:"",$e=(Se==null?void 0:Se.phone)||"",ot=(Se==null?void 0:Se.email)||"",Ue=Rt();return{text:`Hey${it?` ${it}`:""}! I recorded a quick video for you: ${Ue}`,link:Ue,contactPhone:$e,contactEmail:ot}},Je=()=>{const{text:Se,contactPhone:it}=pe(),$e=it?`sms:${it}?body=${encodeURIComponent(Se)}`:`sms:?body=${encodeURIComponent(Se)}`;window.open($e,"_self")},lt=()=>{const{link:Se,contactEmail:it}=pe(),$e="Check out this video",ot=`I recorded a quick video for you: ${Se}`,Ue=it?`mailto:${it}?subject=${encodeURIComponent($e)}&body=${encodeURIComponent(ot)}`:`mailto:?subject=${encodeURIComponent($e)}&body=${encodeURIComponent(ot)}`;window.open(Ue,"_self")};return o?e.jsx(Es,{title:"Quick Video Touch",children:e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>t(-1),children:e.jsx(di,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Quick Video Touch"}),e.jsx("p",{className:"text-muted-foreground",children:"Record a personal video message"})]})]}),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"]})]})]}),y==="record"&&e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsx(cme,{maxDurationSeconds:60,onRecordingComplete:qe,onRecordingStateChange:L,className:"w-full",teleprompterContent:j&&b&&e.jsx(Oot,{text:b,isVisible:j,onToggleVisibility:()=>N(!1),isRecording:I,startCountdown:!0})}),!j&&b&&e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>N(!0),children:[e.jsx(In,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Ee,{className:"lg:col-span-1",children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Ar,{placeholder:"Type or paste your script here...",value:b,onChange:Se=>w(Se.target.value),rows:6}),e.jsxs(DA,{open:S,onOpenChange:T,children:[e.jsx(Uje,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full",children:[e.jsx(In,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(YS,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(OA,{className:"p-4 border-b",children:e.jsx(RA,{children:"Select a Script"})}),e.jsx(dws,{onSelectScript:Se=>{w(Se.text),T(!1),N(!0)},className:"h-[calc(100vh-80px)]"})]})]}),b&&e.jsx(K,{className:"w-full",onClick:()=>N(!0),children:"Use Script"})]})]})]}),y==="uploading"&&e.jsx(Ee,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center",children:[e.jsx(ni,{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(Oi,{value:q,className:"mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[q.toFixed(0),"%"]})]})}),y==="processing"&&e.jsx(Ee,{className:"max-w-md mx-auto",children:e.jsxs(Oe,{className:"pt-6 text-center space-y-4",children:[e.jsx(Ss,{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(Oi,{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.`})]})}),y==="details"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(It,{children:e.jsx(Ot,{children:"Video Details"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title"}),e.jsx(Fe,{value:le,onChange:Se=>he(Se.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Attach to Contact (Optional)"}),e.jsxs(rr,{value:re,onValueChange:ne,children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"No contact - use anywhere"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Vo,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),u==null?void 0:u.map(Se=>e.jsx(Tt,{value:Se.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ro,{className:"h-4 w-4"}),Se.first_name," ",Se.last_name]})},Se.id))]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Notes"}),e.jsx(Ar,{value:we,onChange:Se=>ye(Se.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(K,{className:"w-full",onClick:ct,disabled:p.isPending,children:[p.isPending&&e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),y==="share"&&e.jsxs(Ee,{className:"max-w-lg mx-auto",children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(ma,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Share your video with one click:"}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs(K,{variant:"outline",className:"justify-start",onClick:Je,children:[e.jsx(po,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:lt,children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>De("link",pe().link),children:[e.jsx(Vo,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Me==="link"&&e.jsx(ma,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>Te(!0),children:[e.jsx(Ql,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(K,{variant:"outline",onClick:()=>t("/mission-control/video-library"),children:"View Library"}),e.jsx(K,{onClick:()=>{_("record"),$(null),ee(null),de(null)},children:"Record Another"})]})]})]}),je&&We&&e.jsx(Rot,{open:Re,onOpenChange:Te,video:{id:je,share_token:We,title:le||null,contact_id:re||null,thumbnail_url:(Q==null?void 0:Q.thumbnailUrl)||null},contactName:((rt=u==null?void 0:u.find(Se=>Se.id===re))==null?void 0:rt.first_name)||null})]})}):e.jsx(Es,{title:"Quick Video Touch",children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center py-12",children:[e.jsx(uh,{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 mws({open:t,onOpenChange:s}){const{data:r}=Fm(),{data:n}=Rhe(),a=nC(),o=C.useRef(null),[l,i]=C.useState(null),[c,u]=C.useState(""),[p,f]=C.useState(""),[y,_]=C.useState(""),[b,w]=C.useState(!1),[j,N]=C.useState(0),[S,T]=C.useState("idle"),I=(n==null?void 0:n.total_storage_mb)||0,R=((n==null?void 0:n.max_storage_mb)||1024)-I,$=X=>{var Q;const se=(Q=X.target.files)==null?void 0:Q[0];if(!se)return;if(!se.type.startsWith("video/")){me.error("Please select a video file");return}const ee=se.size/(1024*1024);if(ee>500){me.error("Video file must be less than 500MB");return}if(ee>R){me.error(`Not enough storage. You have ${R.toFixed(1)} MB remaining.`);return}i(se),c||u(se.name.replace(/\.[^/.]+$/,""))},q=async()=>{if(!l){me.error("Please select a video file");return}w(!0),N(0),T("creating");try{const{data:X,error:se}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:c||l.name,isAgentVideo:!0}});if(se)throw new Error(se.message);const{videoId:ee,libraryId:Q}=X;T("uploading");const{data:de,error:re}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:ee,isAgentVideo:!0}});if(re)throw new Error(re.message);await new Promise((he,we)=>{const ye=new XMLHttpRequest;ye.upload.addEventListener("progress",je=>{if(je.lengthComputable){const ke=Math.round(je.loaded/je.total*100);N(ke)}}),ye.addEventListener("load",()=>{ye.status>=200&&ye.status<300?he():we(new Error(`Upload failed with status ${ye.status}`))}),ye.addEventListener("error",()=>we(new Error("Upload failed"))),ye.open("PUT",de.uploadUrl),ye.setRequestHeader("AccessKey",de.apiKey),ye.send(l)}),T("processing");const ne=l.size/(1024*1024),le=`https://iframe.mediadelivery.net/embed/${Q}/${ee}`;await a.mutateAsync({bunny_video_id:ee,playback_url:le,file_size_mb:ne,title:c||l.name,notes:p||void 0,contact_id:y||void 0,status:"processing",touch_type:"video_upload"}),me.success("Video uploaded successfully! Processing may take a few minutes."),U()}catch(X){console.error("Upload error:",X),me.error(X instanceof Error?X.message:"Failed to upload video")}finally{w(!1),T("idle")}},U=()=>{b||(i(null),u(""),f(""),_(""),N(0),T("idle"),s(!1))},V=()=>{switch(S){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${j}%`;case"processing":return"Saving video...";default:return""}};return e.jsx(_s,{open:t,onOpenChange:U,children:e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Upload Video"}),e.jsx(Zr,{children:"Upload a video file from your device to your video library."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Video File"}),l?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(Nn,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:l.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(l.size/(1024*1024)).toFixed(1)," MB"]})]}),!b&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:X=>{X.stopPropagation(),i(null)},children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>{var X;return(X=o.current)==null?void 0:X.click()},children:[e.jsx(ni,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),e.jsx("input",{ref:o,type:"file",accept:"video/*",className:"hidden",onChange:$,disabled:b})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"title",children:"Title"}),e.jsx(Fe,{id:"title",value:c,onChange:X=>u(X.target.value),placeholder:"Enter video title",disabled:b})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Associate with Contact (optional)"}),e.jsxs(rr,{value:y||"__none__",onValueChange:X=>_(X==="__none__"?"":X),disabled:b,children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select a contact"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(X=>e.jsxs(Tt,{value:X.id,children:[X.first_name," ",X.last_name||""]},X.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(Ar,{id:"notes",value:p,onChange:X=>f(X.target.value),placeholder:"Add any notes about this video",rows:2,disabled:b})]}),b&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ss,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:V()})]}),e.jsx(Oi,{value:S==="uploading"?j:S==="processing"?100:10})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:U,disabled:b,children:"Cancel"}),e.jsx(K,{onClick:q,disabled:!l||b,children:b?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ni,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function pws(t){return wt({queryKey:["video-share-recipients",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("video_share_recipients").select("*").eq("video_id",t).order("sent_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function fws(){const{user:t}=Ws();return wt({queryKey:["video-share-stats",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:s,error:r}=await G.from("video_share_recipients").select("*").eq("owner_user_id",t.id);if(r)throw r;const n=s;return{totalSent:n.length,totalOpened:n.filter(a=>a.opened_at).length,totalClicked:n.filter(a=>a.clicked_at).length,totalWatched:n.filter(a=>a.watched_at).length,openRate:n.length>0?Math.round(n.filter(a=>a.opened_at).length/n.length*100):0,clickRate:n.length>0?Math.round(n.filter(a=>a.clicked_at).length/n.length*100):0,watchRate:n.length>0?Math.round(n.filter(a=>a.watched_at).length/n.length*100):0}},enabled:!!(t!=null&&t.id)})}function gws(){const{user:t}=Ws();return wt({queryKey:["video-share-history",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:s,error:r}=await G.from("video_share_recipients").select(` *, agent_videos!inner(id, title, thumbnail_url, share_token, duration_seconds) `).eq("owner_user_id",t.id).order("sent_at",{ascending:!1}).limit(200);if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function xws(){const{user:t}=Ws(),s=ss();return Dt({mutationFn:async r=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:n,error:a}=await G.from("video_share_recipients").insert([{video_id:r.video_id,owner_user_id:t.id,recipient_email:r.recipient_email,recipient_name:r.recipient_name||null,contact_id:r.contact_id||null,sent_via:r.sent_via||"gmail",share_token:"placeholder"}]).select().single();if(a)throw a;return n},onSuccess:r=>{s.invalidateQueries({queryKey:["video-share-recipients",r.video_id]}),s.invalidateQueries({queryKey:["video-share-stats"]}),s.invalidateQueries({queryKey:["video-share-history"]})}})}function yws(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=open`}function vws(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=click`}function _ws({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=C.useState([]),[c,u]=C.useState(null),[p,f]=C.useState(!1),[y,_]=C.useState(!1),[b,w]=C.useState(""),[j,N]=C.useState(""),[S,T]=C.useState(""),[I,L]=C.useState(!1),R=xws(),$=r.share_token?`https://video.relevelup.com/share/video/${r.share_token}`:"",q=r.share_token?`https://video.relevelup.com/thumb/${r.share_token}`:a||r.thumbnail_url||"",U=r.title||"Video Message";C.useEffect(()=>{t&&l.length===0&&V()},[t]),C.useEffect(()=>{if(t&&(N(`I recorded a video for you — ${U}`),T("Hey! I recorded a quick video just for you. Click below to watch it:"),u(null),w(""),r.contact_id)){const re=l.find(ne=>ne.id===r.contact_id);re&&(u(re),w(re.email||""))}},[t,r.contact_id,l]);const V=async()=>{_(!0);try{const{data:re,error:ne}=await G.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ne)throw ne;i(re||[])}catch{console.error("Failed to fetch contacts")}finally{_(!1)}},X=re=>{u(re),f(!1),w(re.email||""),T(`Hey ${re.first_name}! I recorded a quick video just for you. Click below to watch it:`),N(`I recorded a video for you — ${U}`)},se=()=>{u(null),w(""),T("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 ne=S.split(/\n\n+/).map(we=>`

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

`).join(""),le=re?vws(re):$,he=re?``:"";return`
${ne}

▶ Watch Video

${he}
`},de=async()=>{if(!b){me.error("Please enter a recipient email");return}if(!$){me.error("Video does not have a share link");return}L(!0);try{let re;try{const we=c?ee(c):b.split("@")[0];re=(await R.mutateAsync({video_id:r.id,recipient_email:b,recipient_name:we,contact_id:(c==null?void 0:c.id)||null,sent_via:"gmail"})).share_token}catch(we){console.warn("Failed to create tracking record, sending without tracking:",we)}const ne=Q(re),{data:le,error:he}=await G.functions.invoke("gmail-send",{body:{to:b,subject:j,body:ne,contactId:(c==null?void 0:c.id)||null}});if(he)throw he;if(!(le!=null&&le.success))throw new Error((le==null?void 0:le.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{L(!1)}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-[560px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5 text-red-500"}),"Send Video via Gmail"]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending from ",e.jsx("span",{className:"font-medium",children:n})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Send to Contact"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Lo,{open:p,onOpenChange:f,children:[e.jsx(Do,{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(ro,{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(xg,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Eo,{className:"w-[350px] p-0",align:"start",children:e.jsxs(Mg,{children:[e.jsx(Tg,{placeholder:"Search contacts..."}),e.jsxs(Ag,{children:[e.jsx(Eg,{children:y?"Loading...":"No contacts found."}),e.jsx(Pg,{children:l.filter(re=>re.email).map(re=>e.jsxs(up,{value:`${re.first_name} ${re.last_name||""} ${re.email||""}`,onSelect:()=>X(re),children:[e.jsx(ma,{className:At("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:se,className:"shrink-0",children:e.jsx(Ur,{className:"h-4 w-4"})})]})]}),!c&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{htmlFor:"video-to",children:"Or type email address"}),e.jsx(Fe,{id:"video-to",value:b,onChange:re=>w(re.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(Zl,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{htmlFor:"video-subject",children:"Subject"}),e.jsx(Fe,{id:"video-subject",value:j,onChange:re=>N(re.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(Ar,{id:"video-message",value:S,onChange:re=>T(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(_e,{className:"text-xs text-muted-foreground",children:"Video Preview (embedded in email)"}),e.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-black",style:{maxWidth:320},children:[q?e.jsx("img",{src:q,alt:U,className:"w-full aspect-video object-cover"}):e.jsx("div",{className:"w-full aspect-video flex items-center justify-center bg-muted",children:e.jsx(wl,{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(wl,{className:"h-5 w-5 text-primary ml-0.5"})})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Recipients will see the thumbnail with a play button. Clicking opens the video page."})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),disabled:I,children:"Cancel"}),e.jsxs(K,{onClick:de,disabled:I||!b||!j,className:"gap-2",children:[I?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(oa,{className:"h-4 w-4"}),I?"Sending...":"Send Video Email"]})]})]})]})})}const bws=()=>{const{user:t}=Ws();return wt({queryKey:["team-videos",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.rpc("get_team_videos",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})};function wws({recipient:t}){return t.watched_at?e.jsxs(nt,{className:"bg-emerald-100 text-emerald-800 text-[10px]",children:[e.jsx(wl,{className:"h-2.5 w-2.5 mr-0.5"}),"Watched"]}):t.clicked_at?e.jsxs(nt,{className:"bg-blue-100 text-blue-800 text-[10px]",children:[e.jsx(Lh,{className:"h-2.5 w-2.5 mr-0.5"}),"Clicked"]}):t.opened_at?e.jsxs(nt,{className:"bg-amber-100 text-amber-800 text-[10px]",children:[e.jsx(va,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(nt,{variant:"outline",className:"text-[10px]",children:[e.jsx(oa,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]})}function jws({open:t,onOpenChange:s,videoId:r,videoTitle:n}){const{data:a=[],isLoading:o}=pws(r);return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-2xl max-h-[80vh]",children:[e.jsx(Cs,{children:e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(xl,{className:"h-5 w-5"}),"Send Analytics: ",n]})}),o?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((l,i)=>e.jsx(xs,{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(Vi,{className:"h-[400px]",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Recipient"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Sent"}),e.jsx(bt,{children:"Last Activity"})]})}),e.jsx(Pn,{children:a.map(l=>e.jsxs(ks,{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(wws,{recipient:l})}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:ys(new Date(l.sent_at),"MMM d, h:mm a")}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:l.last_activity_at?Yd(new Date(l.last_activity_at),{addSuffix:!0}):"—"})]},l.id))})]})})]})]})})}function kws(){const{data:t,isLoading:s}=fws(),{data:r=[],isLoading:n}=gws(),[a,o]=C.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(It,{className:"pb-2",children:e.jsx(xs,{className:"h-4 w-20"})}),e.jsx(Oe,{children:e.jsx(xs,{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(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx(oa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"text-2xl font-bold",children:(t==null?void 0:t.totalSent)||0})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(va,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.openRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalOpened)||0," opened"]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(Lh,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[(t==null?void 0:t.clickRate)||0,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(t==null?void 0:t.totalClicked)||0," clicked"]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(fr,{children:"Click a video to see individual recipient tracking"})]}),e.jsx(Oe,{children:Object.keys(i).length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No tracked sends yet. Send a video via Gmail to start tracking."}):e.jsx("div",{className:"space-y-2",children:Object.values(i).map(c=>{const u=c.recipients.filter(f=>f.opened_at).length,p=c.recipients.filter(f=>f.clicked_at).length;return e.jsxs("button",{onClick:()=>o({id:c.videoId,title:c.title}),className:"w-full flex items-center gap-3 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-left",children:[e.jsx("div",{className:"h-10 w-16 rounded bg-muted overflow-hidden flex-shrink-0",children:c.thumbnailUrl?e.jsx("img",{src:c.thumbnailUrl,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer",onError:f=>{const y=f.currentTarget;y.style.display="none",y.parentElement.innerHTML='
'}}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(Nn,{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(oa,{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(va,{className:"h-3 w-3"})," ",u]}),e.jsxs("span",{className:"text-xs text-blue-600 flex items-center gap-1",children:[e.jsx(Lh,{className:"h-3 w-3"})," ",p]})]})]}),e.jsx(xc,{className:"h-4 w-4 text-muted-foreground"})]},c.videoId)})})})]}),e.jsx(jws,{open:!!a,onOpenChange:c=>!c&&o(null),videoId:(a==null?void 0:a.id)||null,videoTitle:(a==null?void 0:a.title)||""})]})}function Nws({previewSrc:t,thumbnailSrc:s,alt:r,isHovered:n}){const[a,o]=C.useState(!1),[l,i]=C.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(Nn,{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 Sws({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:y,getContactName:_,getShareUrl:b,copyToClipboard:w,formatDuration:j}){const[N,S]=C.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(Nws,{previewSrc:s,thumbnailSrc:r,alt:t.title||"Video preview",isHovered:N}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("div",{className:"w-12 h-12 rounded-full bg-white/90 flex items-center justify-center",children:e.jsx(wl,{className:"h-6 w-6 text-primary ml-1"})})}),e.jsx("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:j(t.duration_seconds)}),t.status!=="ready"&&e.jsx(nt,{variant:t.status==="processing"?"secondary":"destructive",className:"absolute top-2 left-2",children:t.status})]}),e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-medium truncate",children:t.title||"Untitled Video"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[e.jsx(ro,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:_(t.contact_id)})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),e.jsx("span",{children:ys(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(va,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]}),y&&t.share_token&&e.jsxs(K,{variant:"outline",size:"sm",className:"mt-2 gap-1.5 text-xs h-7",onClick:T=>{T.stopPropagation(),f==null||f()},children:[e.jsx(br,{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(ro,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:_(t.contact_id)})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),e.jsx("span",{children:ys(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(va,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]})]}),e.jsxs(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:T=>T.stopPropagation(),children:e.jsx(ag,{className:"h-4 w-4"})})}),e.jsxs(Jd,{align:"end",className:"bg-popover",children:[e.jsxs(Ta,{onClick:T=>{T.stopPropagation(),n()},children:[e.jsx(va,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(r2,{}),e.jsxs(Ta,{onClick:T=>{T.stopPropagation(),p()},children:[e.jsx(Ql,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(Ta,{onClick:T=>{T.stopPropagation(),w(b(t),"Share link")},children:[e.jsx(Vo,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(Ta,{onClick:T=>{T.stopPropagation(),i()},children:[e.jsx(F4,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(Ta,{onClick:T=>{T.stopPropagation(),c()},children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(Ta,{onClick:T=>{T.stopPropagation(),u()},children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),y&&t.share_token&&e.jsxs(Ta,{onClick:T=>{T.stopPropagation(),f==null||f()},children:[e.jsx(oa,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(Ta,{onClick:T=>{T.stopPropagation(),o()},children:[e.jsx($a,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(r2,{}),t.contact_id&&e.jsxs(Ta,{onClick:T=>{T.stopPropagation(),l()},children:[e.jsx(ro,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(Ta,{onClick:T=>{T.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function Cws(){var tt,Et;const t=Pr(),{data:s,isLoading:r,refetch:n}=n_s(),{data:a}=Rhe(),{data:o}=Fm(),l=o_s(),i=i_s(),{isGmailConnected:c,gmailEmail:u}=D0(),{data:p}=Lg(),{data:f=[],isLoading:y}=bws(),[_,b]=C.useState("my"),[w,j]=C.useState(""),[N,S]=C.useState(null),[T,I]=C.useState(!1),[L,R]=C.useState(!1),[$,q]=C.useState(!1),[U,V]=C.useState(!1),[X,se]=C.useState(!1),[ee,Q]=C.useState(""),[de,re]=C.useState(!1),[ne,le]=C.useState(!1),[he,we]=C.useState(!1),[ye,je]=C.useState(!1),[ke,We]=C.useState(""),[be,Me]=C.useState({}),Ae=qt=>{if(!qt)return"Unassigned";const ms=o==null?void 0:o.find(Xt=>Xt.id===qt);return ms?`${ms.first_name} ${ms.last_name||""}`.trim():"Unknown"},Re=qt=>{if(!qt)return"0:00";const ms=Math.floor(qt/60),Xt=qt%60;return`${ms}:${Xt.toString().padStart(2,"0")}`},Te=s==null?void 0:s.filter(qt=>{if(!w)return!0;const ms=Ae(qt.contact_id).toLowerCase(),Xt=(qt.title||"").toLowerCase(),rs=(qt.notes||"").toLowerCase();return ms.includes(w.toLowerCase())||Xt.includes(w.toLowerCase())||rs.includes(w.toLowerCase())}),[qe,ct]=C.useState(!1);C.useEffect(()=>{if(qe)return;(async()=>{if(!(s!=null&&s.length))return;const ms=s.filter(rs=>rs.status==="processing"&&rs.bunny_video_id);if(!ms.length)return;let Xt=!1;for(const rs of ms)try{const{data:ps,error:Ms}=await G.functions.invoke("bunny-upload",{body:{action:"status",videoId:rs.bunny_video_id,isAgentVideo:!0}});if(Ms||!ps)continue;ps.status===4&&(await G.from("agent_videos").update({status:"ready",playback_url:ps.directPlayUrl,thumbnail_url:ps.thumbnailUrl,preview_url:ps.previewUrl,duration_seconds:ps.length||rs.duration_seconds,updated_at:new Date().toISOString()}).eq("id",rs.id),Xt=!0)}catch(ps){console.warn("Reconcile check failed for video",rs.id,ps)}ct(!0),Xt&&n()})()},[s,qe,n]),C.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const ms=s.filter(jt=>(jt==null?void 0:jt.bunny_video_id)&&!be[jt.id]);if(!ms.length)return;const Xt=ms.map(jt=>jt.bunny_video_id),{data:rs,error:ps}=await G.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Xt,isAgentVideo:!0}});if(ps)throw ps;const Ms=(rs==null?void 0:rs.assets)||{};Me(jt=>{const As={...jt};for(const Ps of ms)Ms[Ps.bunny_video_id]&&(As[Ps.id]={previewUrl:Ms[Ps.bunny_video_id].previewUrl,thumbnailUrl:Ms[Ps.bunny_video_id].thumbnailUrl});return As})})().catch(ms=>console.warn("Failed to load signed Bunny asset URLs",ms))},[s,be]);const De=(a==null?void 0:a.total_storage_mb)||0,Rt=(a==null?void 0:a.max_storage_mb)||1024,pe=De/Rt*100,Je=pe>=80,lt=pe>=100,rt=async(qt,ms)=>{await navigator.clipboard.writeText(qt),me.success(`${ms} copied to clipboard`)},Se=qt=>qt.share_token?`https://video.relevelup.com/${qt.share_token}`:qt.playback_url||"",it=qt=>{const ms=Se(qt),Xt=o==null?void 0:o.find(Ps=>Ps.id===qt.contact_id),rs=Ae(qt.contact_id),ps=rs!=="Unassigned"?rs.split(" ")[0]:"",Ms=(Xt==null?void 0:Xt.phone)||"",jt=`Hey${ps?` ${ps}`:""}! I recorded a quick video message for you. Check it out: ${ms}`,As=Ms?`sms:${Ms}?body=${encodeURIComponent(jt)}`:`sms:?body=${encodeURIComponent(jt)}`;window.open(As,"_self")},$e=qt=>{const ms=o==null?void 0:o.find(As=>As.id===qt.contact_id),Xt=(ms==null?void 0:ms.email)||"",rs=Se(qt),ps="Check out this video",Ms=`I recorded a quick video for you: ${rs}`,jt=Xt?`mailto:${Xt}?subject=${encodeURIComponent(ps)}&body=${encodeURIComponent(Ms)}`:`mailto:?subject=${encodeURIComponent(ps)}&body=${encodeURIComponent(Ms)}`;window.open(jt,"_self")},ot=qt=>{var ps;const ms=Se(qt),Xt=qt.title||"Video Message",rs=qt.share_token?`https://video.relevelup.com/thumb/${qt.share_token}`:((ps=be[qt.id])==null?void 0:ps.thumbnailUrl)||qt.thumbnail_url||"";return``},Ue=async qt=>{if(!qt.thumbnail_url&&!qt.share_token){me.error("Video thumbnail not available yet");return}const ms=ot(qt),Xt=Se(qt),rs=`Watch: ${qt.title||"Video Message"} ${Xt}`;try{const ps=new Blob([ms],{type:"text/html"}),Ms=new Blob([rs],{type:"text/plain"}),jt=new ClipboardItem({"text/html":ps,"text/plain":Ms});await navigator.clipboard.write([jt]),me.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(rs+` `+ms),me.success("Copied! Paste into your email.")}},Ke=async qt=>{try{me.loading("Preparing download...",{id:"download"});const{data:ms,error:Xt}=await G.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:qt.bunny_video_id,isAgentVideo:!0}});if(Xt||!(ms!=null&&ms.downloadUrl))throw new Error((Xt==null?void 0:Xt.message)||"Failed to get download URL");const ps=`${((qt.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,Ms=await fetch(ms.downloadUrl);if(!Ms.ok)throw new Error("Failed to fetch video file");const jt=await Ms.blob(),As=URL.createObjectURL(jt),Ps=document.createElement("a");Ps.href=As,Ps.download=ps,Ps.rel="noreferrer",document.body.appendChild(Ps),Ps.click(),Ps.remove(),URL.revokeObjectURL(As),me.success("Download started",{id:"download"})}catch(ms){console.error("Download error:",ms),me.error("Could not force download (your browser may block it).",{id:"download"})}},Xe=async qt=>{S(qt),re(!0),Q(""),se(!0);try{const{data:ms,error:Xt}=await G.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:qt.bunny_video_id,title:qt.title,isAgentVideo:!0,shareToken:qt.share_token}});if(Xt||!(ms!=null&&ms.html))throw new Error("Failed to generate CRM embed code");Q(ms.html)}catch(ms){console.error("CRM embed error:",ms),me.error("Failed to generate CRM embed code"),se(!1)}finally{re(!1)}},He=qt=>{S(qt),I(!0)},Ye=async()=>{if(N)try{await l.mutateAsync({id:N.id,bunnyVideoId:N.bunny_video_id,hardDelete:!0}),R(!1),S(null),me.success("Video deleted successfully")}catch{me.error("Failed to delete video")}};return e.jsx(Es,{title:"Video Library",description:"Manage your video touches",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Video Library"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage and share your video touches"})]}),e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5 ml-2",children:[e.jsx("button",{onClick:()=>b("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${_==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Videos"}),p&&((tt=p.team)==null?void 0:tt.shared_videos_enabled)&&e.jsxs("button",{onClick:()=>b("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${_==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(mr,{className:"h-3.5 w-3.5"}),"Team"]}),e.jsxs("button",{onClick:()=>b("analytics"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${_==="analytics"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(xl,{className:"h-3.5 w-3.5"}),"Analytics"]})]})]}),_==="my"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>q(!0),children:[e.jsx(ni,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Record New Video"]})]})]}),_==="team"?e.jsx(Mws,{videos:f,isLoading:y,searchTerm:w,setSearchTerm:j}):_==="analytics"?e.jsx(kws,{}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:Je?"border-amber-500":lt?"border-destructive":"",children:e.jsxs(Oe,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx($I,{className:`h-5 w-5 ${lt?"text-destructive":Je?"text-amber-500":"text-muted-foreground"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium",children:"Storage Used"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[De.toFixed(1)," MB / ",Rt>=1024?`${(Rt/1024).toFixed(0)} GB`:`${Rt} MB`]})]}),e.jsx(Oi,{value:Math.min(pe,100),className:`h-2 ${lt?"[&>div]:bg-destructive":Je?"[&>div]:bg-amber-500":""}`})]}),Je&&!lt&&e.jsxs(nt,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(yl,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),lt&&e.jsxs(nt,{variant:"destructive",children:[e.jsx(yl,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),lt&&e.jsx("p",{className:"text-sm text-destructive mt-2",children:"You've reached your storage limit. Delete videos to record more."})]})}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search videos by contact, title, or notes...",value:w,onChange:qt=>j(qt.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"})}):(Te==null?void 0:Te.length)===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(Nn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No videos yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Record your first video touch to get started"}),e.jsxs(K,{onClick:()=>t("/mission-control/video/record"),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Record Video"]})]})}):e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:Te==null?void 0:Te.map(qt=>{var ms,Xt;return e.jsx(Sws,{video:qt,previewSrc:(ms=be[qt.id])==null?void 0:ms.previewUrl,thumbnailSrc:(Xt=be[qt.id])==null?void 0:Xt.thumbnailUrl,onOpen:()=>He(qt),onDelete:()=>{S(qt),R(!0)},onRename:()=>{S(qt),We(qt.title||""),je(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${qt.contact_id}`),onGetEmbedCode:()=>{S(qt),V(!0)},onCopyEmailHtml:()=>Ue(qt),onEmbedToCrm:()=>Xe(qt),onShareWithTemplate:()=>{S(qt),le(!0)},onSendViaGmail:()=>{S(qt),we(!0)},isGmailConnected:c,getContactName:Ae,getShareUrl:Se,copyToClipboard:rt,formatDuration:Re},qt.id)})}),e.jsx(_s,{open:T,onOpenChange:I,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:(N==null?void 0:N.title)||"Video Preview"}),e.jsx(Zr,{children:(N==null?void 0:N.contact_id)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ro,{className:"h-3 w-3"}),Ae(N.contact_id)]})})]}),N&&e.jsxs("div",{className:"space-y-4",children:[N.status==="processing"?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-6 bg-muted/50 rounded-lg border border-dashed border-border text-center space-y-4",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Ss,{className:"h-8 w-8 text-primary animate-spin"})})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Video is still processing"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm",children:"Your video is being encoded and will be ready shortly. This usually takes 1–3 minutes. Check back soon!"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{I(!1),n()},children:[e.jsx(Bo,{className:"h-4 w-4 mr-2"}),"Refresh Library"]})]}):e.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:N.playback_url?(()=>{let qt=N.playback_url;return qt.includes("iframe.mediadelivery.net/play/")&&(qt=qt.replace("/play/","/embed/"),qt+=(qt.includes("?")?"&":"?")+"autoplay=false&responsive=true"),qt.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:qt,title:N.title||"Video preview",className:"absolute top-0 left-0 w-full h-full rounded-lg",style:{border:0},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0}):e.jsx("video",{src:N.playback_url,controls:!0,playsInline:!0,preload:"metadata",poster:N.thumbnail_url||void 0,className:"absolute top-0 left-0 w-full h-full rounded-lg object-cover",onError:()=>me.error("Video preview failed to load")},N.playback_url)})():e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-muted rounded-lg",children:[e.jsx(Nn,{className:"h-12 w-12 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground ml-2",children:"Video not available"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>it(N),children:[e.jsx(po,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!c&&e.jsxs(K,{variant:"outline",onClick:()=>$e(N),children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>rt(Se(N),"Share link"),children:[e.jsx(mi,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ue(N),children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ke(N),children:[e.jsx(ki,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),Xe(N)},children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),le(!0)},children:[e.jsx(Ql,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),c&&(N==null?void 0:N.share_token)&&e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),we(!0)},children:[e.jsx(oa,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]})]}),e.jsx("div",{className:"flex justify-end pt-2 border-t",children:e.jsxs(K,{variant:"destructive",onClick:()=>{I(!1),R(!0)},children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(_s,{open:L,onOpenChange:R,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Delete Video"}),e.jsx(Zr,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Ye,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(mws,{open:$,onOpenChange:q}),e.jsx(_s,{open:U,onOpenChange:V,children:e.jsxs(vs,{className:"sm:max-w-lg",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Embed Video"}),e.jsx(Zr,{children:"Copy this code to embed the video on your website."})]}),N&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Embed Code"}),e.jsx(Ar,{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 qt=``;rt(qt,"Embed code")},children:[e.jsx(mi,{className:"h-4 w-4 mr-2"}),"Copy Embed Code"]})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste this code into your website's HTML where you want the video to appear. The video will automatically resize to fit its container."})]})]})}),N&&e.jsx(Rot,{open:ne,onOpenChange:le,video:N,contactName:Ae(N.contact_id)}),N&&e.jsx(_ws,{open:he,onOpenChange:we,video:N,gmailEmail:u,signedThumbnailUrl:(Et=be[N.id])==null?void 0:Et.thumbnailUrl}),e.jsx(_s,{open:ye,onOpenChange:je,children:e.jsxs(vs,{className:"max-w-sm",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Rename Video"}),e.jsx(Zr,{children:"Enter a new title for this video."})]}),e.jsx(Fe,{value:ke,onChange:qt=>We(qt.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:qt=>{qt.key==="Enter"&&ke.trim()&&i.mutate({id:N.id,title:ke.trim()},{onSuccess:()=>{me.success("Video renamed"),je(!1)}})}}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>je(!1),children:"Cancel"}),e.jsx(K,{disabled:!ke.trim()||i.isPending,onClick:()=>{i.mutate({id:N.id,title:ke.trim()},{onSuccess:()=>{me.success("Video renamed"),je(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(_s,{open:X,onOpenChange:se,children:e.jsxs(vs,{className:"sm:max-w-lg",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(rn,{className:"h-5 w-5"}),"Embed to CRM"]}),e.jsx(Zr,{children:"Copy this HTML code and paste it into your CRM's email editor. It uses a simple image + link format that works in all CRM email programs."})]}),de?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Ss,{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(_e,{children:"CRM Email HTML"}),e.jsx(Ar,{readOnly:!0,rows:12,value:ee,className:"font-mono text-xs"})]}),e.jsxs(K,{className:"w-full",onClick:()=>{rt(ee,"CRM embed code")},children:[e.jsx(mi,{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 Mws({videos:t,isLoading:s,searchTerm:r,setSearchTerm:n}){const a=C.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=C.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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search team videos by title, owner, or recipient...",value:r,onChange:i=>n(i.target.value),className:"pl-10"})]}),s?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):a.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"py-12 text-center",children:[e.jsx(mr,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No team videos"}),e.jsx("p",{className:"text-muted-foreground",children:t.length===0?"Your teammates haven't recorded any videos yet.":"No videos match your search."})]})}):e.jsx("div",{className:"space-y-6",children:o.map(([i,c])=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(yn,{className:"h-7 w-7",children:[e.jsx(Da,{src:c.avatar||""}),e.jsx(vn,{children:(c.name||"?").charAt(0).toUpperCase()})]}),e.jsx("h3",{className:"font-semibold text-sm",children:c.name}),e.jsx(nt,{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(Nn,{className:"h-10 w-10 text-muted-foreground"}),u.duration_seconds&&e.jsx("span",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:l(u.duration_seconds)})]}),e.jsxs(Oe,{className:"p-3",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:u.title||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[u.recipient_name&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ro,{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(va,{className:"h-3 w-3"}),u.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),ys(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const Tws=()=>{const{user:t}=Ws();return wt({queryKey:["team-deals",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.rpc("get_team_deals",{_user_id:t.id});if(r)throw r;return s||[]},enabled:!!t})},D7e=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Aws({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Tws(),[a,o]=C.useState(""),[l,i]=C.useState("all"),c=C.useMemo(()=>{if(!r)return new Map;const b=new Map;let w=0;return r.forEach(j=>{b.has(j.owner_user_id)||(b.set(j.owner_user_id,{name:j.owner_name||"Unknown",avatar:j.owner_avatar_url,color:D7e[w%D7e.length]}),w++)}),b},[r]),u=C.useMemo(()=>Array.from(c.entries()).map(([b,w])=>({id:b,...w})),[c]),p=C.useMemo(()=>{if(!r)return[];let b=r;if(l!=="all"&&(b=b.filter(w=>w.owner_user_id===l)),a.trim()){const w=a.toLowerCase();b=b.filter(j=>{var N,S,T,I;return j.deal_name.toLowerCase().includes(w)||((N=j.contact_name)==null?void 0:N.toLowerCase().includes(w))||((S=j.property_address)==null?void 0:S.toLowerCase().includes(w))||((T=j.city)==null?void 0:T.toLowerCase().includes(w))||((I=j.owner_name)==null?void 0:I.toLowerCase().includes(w))})}return b},[r,a,l]),f=C.useMemo(()=>{const b=new Map;return p.forEach(w=>{const j=w.stage_name||"Unknown";b.has(j)||b.set(j,{name:j,color:w.stage_color,icon:w.stage_icon,deals:[],totalValue:0});const N=b.get(j);N.deals.push(w),N.totalValue+=w.sale_price||0}),Array.from(b.values())},[p]),y=b=>b>=1e6?`$${(b/1e6).toFixed(1)}M`:b>=1e3?`$${(b/1e3).toFixed(0)}K`:`$${b.toFixed(0)}`,_=b=>b?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(b):null;return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-[95vw] w-full max-h-[90vh] flex flex-col",children:[e.jsx(Cs,{children:e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"Team Pipeline"]})}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search deals...",value:a,onChange:b=>o(b.target.value),className:"pl-9"})]}),e.jsxs(rr,{value:l,onValueChange:i,children:[e.jsx(tr,{className:"w-[180px]",children:e.jsx(nr,{placeholder:"All Members"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Members"}),u.map(b=>e.jsx(Tt,{value:b.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full inline-block",style:{backgroundColor:b.color}}),b.name]})},b.id))]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-3 ml-auto text-xs text-muted-foreground",children:[u.slice(0,6).map(b=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:b.color}}),b.name.split(" ")[0]]},b.id)),u.length>6&&e.jsxs("span",{children:["+",u.length-6," more"]})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden mt-2",children:n?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(b=>e.jsxs("div",{className:"min-w-[260px] flex-1",children:[e.jsx(xs,{className:"h-12 w-full mb-2 rounded-lg"}),e.jsx(xs,{className:"h-24 w-full mb-2 rounded-lg"}),e.jsx(xs,{className:"h-24 w-full rounded-lg"})]},b))}):f.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(mr,{className:"h-10 w-10 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No team deals found"}),e.jsx("p",{className:"text-sm",children:"Team members' deals will appear here."})]})}):e.jsx("div",{className:"flex gap-3 h-full overflow-x-auto pb-2",children:f.map(b=>{const w=b.icon&&nwe[b.icon]||pd;return e.jsxs("div",{className:"flex flex-col h-full min-w-[260px] max-w-[300px] flex-1 bg-muted/30 rounded-xl border border-border/50",children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:b.color||"hsl(var(--border))",borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{backgroundColor:b.color?`${b.color}20`:void 0},children:e.jsx(w,{className:"h-3.5 w-3.5",style:{color:b.color||void 0}})}),e.jsx("h3",{className:"font-semibold text-sm",children:b.name})]}),e.jsx(nt,{variant:"secondary",className:"text-xs px-2",children:b.deals.length})]}),b.totalValue>0&&e.jsx("p",{className:"text-xs text-muted-foreground ml-8",children:y(b.totalValue)})]}),e.jsx(Vi,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:b.deals.map(j=>{const N=c.get(j.owner_user_id);return e.jsx(Ews,{deal:j,ownerColor:(N==null?void 0:N.color)||"#888",ownerName:(N==null?void 0:N.name)||"Unknown",ownerAvatar:(N==null?void 0:N.avatar)||null,formatPrice:_},j.id)})})})]},b.name)})})}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-2 border-t shrink-0",children:[p.length," deal",p.length!==1?"s":""," across ",f.length," stage",f.length!==1?"s":""," from ",u.length," member",u.length!==1?"s":""]})]})})}function Ews({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(yn,{className:"h-4 w-4",children:[e.jsx(Da,{src:n||""}),e.jsx(vn,{className:"text-[8px] font-semibold text-white",style:{backgroundColor:s},children:r.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-[10px] font-medium truncate",style:{color:s},children:r})]}),e.jsxs("div",{className:"flex items-start justify-between gap-1",children:[e.jsx("h4",{className:"font-medium text-sm leading-tight line-clamp-2",children:t.deal_name}),l&&e.jsx(nt,{variant:"outline",className:At("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(Rn,{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(Td,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:a(t.sale_price)})]})]})}function Pws({members:t,enabledMembers:s,onToggleMember:r,isOpen:n,onToggleOpen:a}){const o=s.size;return e.jsxs("div",{className:At("shrink-0 border-r border-border/50 bg-muted/20 transition-all duration-300 flex flex-col",n?"w-[220px]":"w-[48px]"),children:[e.jsx("div",{className:"p-2 border-b border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",onClick:a,children:[e.jsx(mr,{className:"h-4 w-4 shrink-0 text-primary"}),n&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs font-semibold flex-1 text-left",children:"Team"}),o>0&&e.jsx("span",{className:"text-[10px] bg-primary text-primary-foreground rounded-full px-1.5 py-0.5",children:o}),e.jsx(Xl,{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(Vi,{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:At("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(yn,{className:"h-7 w-7",children:[e.jsx(Da,{src:l.avatar_url||""}),e.jsx(vn,{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:At("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),e.jsx(Br,{checked:i,onCheckedChange:()=>r(l.id),className:"scale-75",onClick: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(yn,{className:At("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(Da,{src:l.avatar_url||""}),e.jsx(vn,{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 O7e=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Iws(){const t=ai(),{data:s}=Lg(),r=(s==null?void 0:s.role)==="team_leader",n=s==null?void 0:s.teamId,a=wt({queryKey:["team-pipeline-members",n,t],queryFn:async()=>{const{data:o,error:l}=await G.from("team_members").select("user_id, role").eq("team_id",n).neq("user_id",t);if(l)throw l;if(!o||o.length===0)return[];const i=o.map(p=>p.user_id),{data:c,error:u}=await G.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:O7e[f%O7e.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function Lws(t){return wt({queryKey:["team-member-deals",t],queryFn:async()=>{if(t.length===0)return[];const{data:s,error:r}=await G.from("deal_pipeline").select(` *, contact:innercircle_contacts(id, first_name, last_name, email, phone), listing:listings(id, property_address, city, state, price, status, created_at), deal_pipeline_stages(name) `).in("owner_user_id",t).order("updated_at",{ascending:!1});if(r)throw r;return(s||[]).map(n=>{var a;return{...n,_stage_name:((a=n.deal_pipeline_stages)==null?void 0:a.name)||null}})},enabled:t.length>0})}function Fot({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=C.useState(!1),l=t.find(c=>c.id===s),i=c=>{c.id!==s&&r(c.id,c.name),o(!1)};return e.jsxs(ju,{open:a,onOpenChange:o,children:[e.jsx(ku,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",disabled:n,onClick:c=>c.stopPropagation(),children:[l&&e.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:l.color}}),e.jsx("span",{className:"max-w-[80px] truncate",children:(l==null?void 0:l.name)||"Move"}),e.jsx(Xa,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(Jd,{align:"end",className:"w-48 z-50 bg-popover",onClick:c=>c.stopPropagation(),children:t.map(c=>{const u=c.icon&&nwe[c.icon]||pd,p=c.id===s;return e.jsxs(Ta,{onClick:()=>i(c),className:At("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(ma,{className:"h-4 w-4 text-primary"})]},c.id)})})]})}const Dws={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"}},Ows={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 zot({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var S,T;const c=oE(),u=Dws[t.deal_type],p=Ows[t.priority],f=C.useMemo(()=>t.target_close_date?ty(Ml(t.target_close_date),new Date):null,[t.target_close_date]),y=f!==null&&f<0,_=f!==null&&f<=7&&f>=0,b=C.useMemo(()=>{var R;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const I=((R=t.listing)==null?void 0:R.created_at)||t.listing_date;if(!I)return null;const L=t.contract_date?Ml(t.contract_date):new Date;return ty(L,Ml(I))},[t]),w=l&&!t.scorecard_transaction_id,j=!!t.scorecard_transaction_id,N=I=>I?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I):null;return e.jsx(Ee,{className:At("cursor-pointer transition-all duration-200 hover:shadow-md hover:border-primary/30 group overflow-hidden",r&&"opacity-50 rotate-2 shadow-xl",y&&"border-red-200 bg-red-50/30",w&&"border-amber-300 bg-amber-50/30 dark:bg-amber-950/20"),onClick:s,style:i?{borderLeftWidth:4,borderLeftColor:i.color}:void 0,children:e.jsxs(Oe,{className:"p-3 space-y-2.5",children:[i&&e.jsxs("div",{className:"flex items-center gap-1.5 -mt-0.5 mb-1",children:[e.jsxs(yn,{className:"h-4 w-4",children:[e.jsx(Da,{src:i.avatar_url||""}),e.jsx(vn,{className:"text-[8px] font-semibold text-white",style:{backgroundColor:i.color},children:i.name.charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-[10px] font-medium",style:{color:i.color},children:i.name})]}),e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("h4",{className:"font-medium text-sm leading-tight line-clamp-2 group-hover:text-primary transition-colors",children:t.deal_name})}),e.jsx(nt,{variant:"outline",className:At("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(yn,{className:"h-5 w-5",children:e.jsxs(vn,{className:"text-[10px] bg-primary/10 text-primary",children:[(S=t.contact.first_name)==null?void 0:S[0],(T=t.contact.last_name)==null?void 0:T[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(sl,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),w&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 px-2 py-1 rounded",children:[e.jsx(mo,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),j&&l&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx(ha,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:"Synced to Scorecard"})]}),b!==null&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(LI,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsxs("span",{className:At("font-medium",b>90?"text-red-600":b>60?"text-amber-600":"text-muted-foreground"),children:[b," DOM"]}),t.contract_date&&e.jsx("span",{className:"text-muted-foreground",children:"(final)"})]}),!t.listing&&(t.property_address||t.city)&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(Rn,{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(Td,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:N(t.expected_price)}),t.expected_commission&&e.jsxs("span",{className:"text-muted-foreground",children:["• ",N(t.expected_commission)," GCI"]}),(()=>{const I=dg(t);return I!==null&&I!==t.expected_commission?e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:["• ",N(I)," Net"]}):null})()]}),e.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-border/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:At("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",p.color),children:[e.jsx("div",{className:At("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(Fot,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(I,L)=>a(t.id,I,L)}):t.target_close_date?e.jsxs("div",{className:At("flex items-center gap-1 text-[10px]",y&&"text-red-600",_&&!y&&"text-amber-600",!y&&!_&&"text-muted-foreground"),children:[y?e.jsx(yl,{className:"h-3 w-3"}):e.jsx(on,{className:"h-3 w-3"}),e.jsx("span",{children:y?`${Math.abs(f)}d overdue`:_?`${f}d left`:ys(Ml(t.target_close_date),"MMM d")})]}):null]})]})})}function Rws({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:c=!1,getOwnerInfo:u}){const p=C.useRef(null),f=s.reduce((j,N)=>j+(N.expected_price||0),0),y=s.reduce((j,N)=>j+(N.expected_commission||0),0),_=s.reduce((j,N)=>j+(dg(N)||0),0),b=j=>j>=1e6?`$${(j/1e6).toFixed(1)}M`:j>=1e3?`$${(j/1e3).toFixed(0)}K`:`$${j.toFixed(0)}`,w=t.icon&&nwe[t.icon]||pd;return e.jsxs("div",{ref:p,className:At("flex flex-col h-full min-w-[280px] max-w-[320px] bg-muted/30 rounded-xl border border-border/50 transition-all duration-200",i&&"border-primary/50 bg-primary/5 ring-2 ring-primary/20"),onDragOver:j=>o(j,t.id),onDrop:j=>l(j,t.id),children:[e.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:t.color,borderTopWidth:3},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{backgroundColor:`${t.color}20`},children:e.jsx(w,{className:"h-4 w-4",style:{color:t.color}})}),e.jsx("div",{children:e.jsx("h3",{className:"font-semibold text-sm",children:t.name})})]}),e.jsx(nt,{variant:"secondary",className:"text-xs font-medium px-2",children:s.length})]}),f>0&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-wrap",children:[e.jsx("span",{className:"font-medium text-foreground",children:b(f)}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[b(y)," GCI"]}),_>0&&_!==y&&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(Vi,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(j=>e.jsx("div",{draggable:!0,onDragStart:N=>{N.dataTransfer.effectAllowed="move",a(j.id,t.id)},children:e.jsx(zot,{deal:j,onClick:()=>r(j),isWonStage:c,ownerInfo:(u==null?void 0:u(j))||null})},j.id)),s.length===0&&e.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground text-sm",children:[e.jsx("p",{className:"mb-2",children:"No deals yet"}),e.jsx("p",{className:"text-xs",children:"Drag deals here or add new"})]})]})}),e.jsx("div",{className:"p-2 border-t border-border/50 shrink-0",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground hover:text-foreground",onClick:()=>n(t.id),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})})]})}function Fws({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:Am,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Weighted GCI",value:r((t==null?void 0:t.weightedGCI)||0),icon:iL,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:vL,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:II,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:xc,color:"text-amber-500",bgColor:"bg-amber-500/10",tooltip:"YTD Closed Net + Weighted Active Net"}];return s?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[1,2,3,4,5].map(a=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-10 bg-muted rounded"})})},a))}):e.jsx(x2,{children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:n.map(a=>{const o=e.jsx(Ee,{className:"border-border/50 hover:shadow-sm transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:At("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:At("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(hd,{children:[e.jsx(md,{asChild:!0,children:o}),e.jsx(Uc,{children:e.jsx("p",{children:a.tooltip})})]},a.label):o})})})}function zws({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=Ws(),[a,o]=C.useState(t.portal_enabled);if(!n)return e.jsxs("div",{className:"border rounded-lg p-4 opacity-60",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(nt,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Give your clients a premium, real-time view of their transaction — coming soon!"})]});const l=i=>{s({...t,...i})};return e.jsx(bg,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(wg,{className:"w-full p-4 flex items-center justify-between hover:bg-muted/50 transition-colors rounded-t-lg",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(nt,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(tl,{className:At("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(jg,{children:e.jsxs("div",{className:"px-4 pb-4 space-y-5 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Enable Client Portal"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Create a beautiful portal your client can track their deal from"})]}),e.jsx(Br,{checked:t.portal_enabled,onCheckedChange:i=>l({portal_enabled:i})})]}),t.portal_enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Portal Visibility"}),e.jsxs(nke,{value:t.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:At("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(zoe,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(vh,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:"Private"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Link-only access"})]})]}),e.jsxs("label",{className:At("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(zoe,{value:"public"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(yp,{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(Yo,{id:"require_onboarding",checked:t.require_onboarding,onCheckedChange:i=>l({require_onboarding:!!i}),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx(_e,{htmlFor:"require_onboarding",className:"text-sm font-medium cursor-pointer",children:"Require client onboarding before portal access"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Client confirms contact details + preferences before viewing portal. Info is saved to your contacts."})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Yo,{id:"allow_spouse",checked:t.allow_spouse,onCheckedChange:i=>l({allow_spouse:!!i})}),e.jsx(_e,{htmlFor:"allow_spouse",className:"text-sm cursor-pointer",children:"Allow client to add spouse/partner during onboarding"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Client Invite Details"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Client Full Name"}),e.jsx(Fe,{value:t.client_name,onChange:i=>l({client_name:i.target.value}),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Email"}),e.jsx(Fe,{type:"email",value:t.client_email,onChange:i=>l({client_email:i.target.value}),placeholder:"jane@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Phone"}),e.jsx(Fe,{type:"tel",value:t.client_phone,onChange:i=>l({client_phone:i.target.value}),placeholder:"(555) 123-4567"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),e.jsxs(rr,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"email",children:"Email"}),e.jsxs(Tt,{value:"sms",disabled:!t.client_phone,children:["SMS ",!t.client_phone&&"(add phone first)"]})]})]})]})]})]})]})]})})]})})}const Bws=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],$ws=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function qws({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=Fhe(),{data:o}=Fm(),{data:l}=_Ye(),i=uue(),c=Eat(),u=Pat(),p=F4e(),[f,y]=C.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[_,b]=C.useState(""),[w,j]=C.useState(!1),[N,S]=C.useState(!1),[T,I]=C.useState({first_name:"",last_name:"",email:"",phone:""}),L=(l==null?void 0:l.filter(ee=>((r==null?void 0:r.listing_id)===ee.id,!0)))||[],[R,$]=C.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:""});C.useEffect(()=>{var ee,Q,de,re,ne,le,he,we;t&&(r?($({deal_name:r.deal_name,deal_type:r.deal_type,stage_id:r.stage_id||"",contact_id:r.contact_id||"",listing_id:r.listing_id||"",property_address:r.property_address||"",city:r.city||"",state:r.state||"",zip_code:r.zip_code||"",expected_price:((ee=r.expected_price)==null?void 0:ee.toString())||"",commission_percentage:((Q=r.commission_percentage)==null?void 0:Q.toString())||"3",brokerage_split_pct:((de=r.brokerage_split_pct)==null?void 0:de.toString())||"",team_split_pct:((re=r.team_split_pct)==null?void 0:re.toString())||"",referral_fee_pct:((ne=r.referral_fee_pct)==null?void 0:ne.toString())||"",franchise_fee_pct:((le=r.franchise_fee_pct)==null?void 0:le.toString())||"",transaction_fee:((he=r.transaction_fee)==null?void 0:he.toString())||"",commission_calc_method:r.commission_calc_method||"standard",target_close_date:r.target_close_date?Ml(r.target_close_date):void 0,contract_date:r.contract_date?Ml(r.contract_date):void 0,listing_date:r.listing_date?Ml(r.listing_date):void 0,priority:r.priority,probability:r.probability.toString(),notes:r.notes||""}),r.contact&&b(`${r.contact.first_name} ${r.contact.last_name}`)):($({deal_name:"",deal_type:"buyer",stage_id:n||((we=a==null?void 0:a[0])==null?void 0:we.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:""}),b(""),y({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"})))},[t,r,n,a]);const q=o==null?void 0:o.filter(ee=>{var de,re,ne;const Q=_.toLowerCase();return((de=ee.first_name)==null?void 0:de.toLowerCase().includes(Q))||((re=ee.last_name)==null?void 0:re.toLowerCase().includes(Q))||((ne=ee.email)==null?void 0:ne.toLowerCase().includes(Q))}).slice(0,5),U=()=>{const ee=parseFloat(R.expected_price)||0,Q=parseFloat(R.commission_percentage)||0;return ee*(Q/100)},V=()=>{const ee=U();if(!ee)return null;const Q=parseFloat(R.brokerage_split_pct)||0,de=parseFloat(R.team_split_pct)||0,re=parseFloat(R.referral_fee_pct)||0,ne=parseFloat(R.franchise_fee_pct)||0,le=parseFloat(R.transaction_fee)||0;if(R.commission_calc_method==="referral_first"){let we=ee;re&&(we-=ee*re/100);let ye=we;return Q&&(ye-=we*Q/100),de&&(ye-=ee*de/100),ne&&(ye-=ee*ne/100),le&&(ye-=le),Math.max(0,ye)}let he=ee;return Q&&(he=he*((100-Q)/100)),de&&(he=he*((100-de)/100)),re&&(he=he-ee*re/100),ne&&(he=he-ee*ne/100),le&&(he=he-le),Math.max(0,he)},X=async ee=>{var Q,de,re;if(ee.preventDefault(),!R.deal_name.trim()){me.error("Please enter a deal name");return}try{const ne={deal_name:R.deal_name,deal_type:R.deal_type,stage_id:R.stage_id||null,contact_id:R.contact_id||null,listing_id:R.listing_id||null,property_address:R.property_address||null,city:R.city||null,state:R.state||null,zip_code:R.zip_code||null,expected_price:R.expected_price?parseFloat(R.expected_price):null,expected_commission:U()||null,commission_percentage:R.commission_percentage?parseFloat(R.commission_percentage):3,brokerage_split_pct:R.brokerage_split_pct?parseFloat(R.brokerage_split_pct):null,team_split_pct:R.team_split_pct?parseFloat(R.team_split_pct):null,referral_fee_pct:R.referral_fee_pct?parseFloat(R.referral_fee_pct):null,franchise_fee_pct:R.franchise_fee_pct?parseFloat(R.franchise_fee_pct):null,transaction_fee:R.transaction_fee?parseFloat(R.transaction_fee):null,commission_calc_method:R.commission_calc_method,target_close_date:((Q=R.target_close_date)==null?void 0:Q.toISOString().split("T")[0])||null,contract_date:((de=R.contract_date)==null?void 0:de.toISOString().split("T")[0])||null,listing_date:((re=R.listing_date)==null?void 0:re.toISOString().split("T")[0])||null,priority:R.priority,probability:parseInt(R.probability)||50,notes:R.notes||null};if(r)await u.mutateAsync({id:r.id,...ne}),me.success("Deal updated successfully");else{const le=await c.mutateAsync(ne);if(me.success("Deal created successfully"),f.portal_enabled&&(le!=null&&le.id))try{await p.mutateAsync({deal_id:le.id,visibility:f.visibility,require_onboarding:f.require_onboarding,allow_spouse:f.allow_spouse,client_name:f.client_name||null,client_email:f.client_email||null,client_phone:f.client_phone||null,invite_method:f.invite_method}),me.success("Client portal created!")}catch{me.error("Deal created, but portal setup failed")}}s(!1)}catch{me.error("Failed to save deal")}},se=c.isPending||u.isPending;return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:r?"Edit Deal":"Add New Deal"}),e.jsx(Zr,{children:r?"Update the deal details below.":"Enter the details for your new deal."})]}),e.jsxs("form",{onSubmit:X,className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"col-span-2 space-y-2",children:[e.jsx(_e,{htmlFor:"deal_name",children:"Deal Name *"}),e.jsx(Fe,{id:"deal_name",value:R.deal_name,onChange:ee=>$(Q=>({...Q,deal_name:ee.target.value})),placeholder:"e.g., Smith Family - 123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Deal Type"}),e.jsxs(rr,{value:R.deal_type,onValueChange:ee=>$(Q=>({...Q,deal_type:ee})),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:Bws.map(ee=>e.jsx(Tt,{value:ee.value,children:ee.label},ee.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Stage"}),e.jsxs(rr,{value:R.stage_id||"none",onValueChange:ee=>$(Q=>({...Q,stage_id:ee==="none"?"":ee})),children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select stage"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"No Stage"}),a==null?void 0:a.map(ee=>e.jsx(Tt,{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(_e,{children:"Link to Contact"}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{value:_,onChange:ee=>{b(ee.target.value),j(!0),S(!1),ee.target.value||$(Q=>({...Q,contact_id:""}))},onFocus:()=>j(!0),placeholder:"Search contacts...",className:"pl-9"}),w&&_&&e.jsxs("div",{className:"absolute z-10 w-full mt-1 bg-background border rounded-lg shadow-lg max-h-60 overflow-y-auto",children:[q&&q.length>0?q.map(ee=>e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2",onClick:()=>{$(Q=>({...Q,contact_id:ee.id})),b(`${ee.first_name} ${ee.last_name}`),j(!1)},children:[e.jsx(ro,{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=_.trim().split(/\s+/);I({first_name:ee[0]||"",last_name:ee.slice(1).join(" ")||"",email:"",phone:""}),S(!0),j(!1)},children:[e.jsx(Pc,{className:"h-4 w-4"}),e.jsxs("span",{children:['Create new contact "',_.trim(),'"']})]})]})]}),N&&e.jsxs("div",{className:"border rounded-lg p-3 space-y-3 bg-muted/30",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(Pc,{className:"h-3.5 w-3.5"}),"Quick Add Contact"]}),e.jsx(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(Fe,{placeholder:"First name *",value:T.first_name,onChange:ee=>I(Q=>({...Q,first_name:ee.target.value})),className:"h-8 text-sm"}),e.jsx(Fe,{placeholder:"Last name",value:T.last_name,onChange:ee=>I(Q=>({...Q,last_name:ee.target.value})),className:"h-8 text-sm"}),e.jsx(Fe,{placeholder:"Email",type:"email",value:T.email,onChange:ee=>I(Q=>({...Q,email:ee.target.value})),className:"h-8 text-sm"}),e.jsx(Fe,{placeholder:"Phone",type:"tel",value:T.phone,onChange:ee=>I(Q=>({...Q,phone:ee.target.value})),className:"h-8 text-sm"})]}),e.jsx(K,{type:"button",size:"sm",className:"w-full h-8",disabled:!T.first_name.trim()||i.isPending,onClick:async()=>{try{const ee=await i.mutateAsync({first_name:T.first_name.trim(),last_name:T.last_name.trim()||null,email:T.email.trim()||null,phone:T.phone.trim()||null});ee&&($(Q=>({...Q,contact_id:ee.id})),b(`${ee.first_name} ${ee.last_name||""}`.trim()),S(!1))}catch{}},children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Pc,{className:"h-3.5 w-3.5 mr-1"})," Add & Link Contact"]})})]})]}),L.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{className:"flex items-center gap-2",children:[e.jsx(sl,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),e.jsxs(rr,{value:R.listing_id||"none",onValueChange:ee=>{const Q=ee==="none"?"":ee,de=L.find(re=>re.id===Q);$(de?re=>{var ne;return{...re,listing_id:Q,deal_type:"seller",property_address:de.property_address||re.property_address,city:de.city||re.city,state:de.state||re.state,expected_price:((ne=de.price)==null?void 0:ne.toString())||re.expected_price}}:re=>({...re,listing_id:Q}))},children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select a listing to sync status..."})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"None"}),L.map(ee=>e.jsx(Tt,{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(_e,{htmlFor:"property_address",children:"Address"}),e.jsx(Fe,{id:"property_address",value:R.property_address,onChange:ee=>$(Q=>({...Q,property_address:ee.target.value})),placeholder:"123 Main Street"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"city",children:"City"}),e.jsx(Fe,{id:"city",value:R.city,onChange:ee=>$(Q=>({...Q,city:ee.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"state",children:"State"}),e.jsx(Fe,{id:"state",value:R.state,onChange:ee=>$(Q=>({...Q,state:ee.target.value})),maxLength:2,placeholder:"TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"zip_code",children:"ZIP"}),e.jsx(Fe,{id:"zip_code",value:R.zip_code,onChange:ee=>$(Q=>({...Q,zip_code:ee.target.value}))})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Financial Details"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"expected_price",children:"Expected Price"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"$"}),e.jsx(Fe,{id:"expected_price",type:"number",value:R.expected_price,onChange:ee=>$(Q=>({...Q,expected_price:ee.target.value})),className:"pl-7",placeholder:"500000"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"commission_percentage",children:"Commission %"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{id:"commission_percentage",type:"number",step:"0.1",value:R.commission_percentage,onChange:ee=>$(Q=>({...Q,commission_percentage:ee.target.value})),className:"pr-7"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Expected GCI"}),e.jsx(Fe,{value:U()?`$${U().toLocaleString()}`:"-",disabled:!0,className:"bg-muted"})]})]}),e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"text-xs font-medium text-muted-foreground cursor-pointer hover:text-foreground flex items-center gap-1 py-1",children:[e.jsx("span",{className:"group-open:rotate-90 transition-transform text-[10px]",children:"▶"}),"Commission Splits (optional)"]}),e.jsxs("div",{className:"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(_e,{className:"text-xs whitespace-nowrap",children:"Calculation Method:"}),e.jsxs(rr,{value:R.commission_calc_method,onValueChange:ee=>$(Q=>({...Q,commission_calc_method:ee})),children:[e.jsx(tr,{className:"h-7 text-xs",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"standard",children:"Standard (all splits on GCI)"}),e.jsx(Tt,{value:"referral_first",children:"Referral First (brokerage split after referral)"})]})]})]}),R.commission_calc_method==="referral_first"&&e.jsx("p",{className:"text-[10px] text-muted-foreground bg-blue-50 dark:bg-blue-950/30 p-2 rounded",children:"💡 Referral fee is deducted from GCI first, then the brokerage split is applied to the remaining amount."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs",children:"Brokerage Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{type:"number",step:"1",min:"0",max:"100",value:R.brokerage_split_pct,onChange:ee=>$(Q=>({...Q,brokerage_split_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"30"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"% that goes to brokerage"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs",children:"Team Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{type:"number",step:"1",min:"0",max:"100",value:R.team_split_pct,onChange:ee=>$(Q=>({...Q,team_split_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"% that goes to team lead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs",children:"Referral Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{type:"number",step:"1",min:"0",max:"100",value:R.referral_fee_pct,onChange:ee=>$(Q=>({...Q,referral_fee_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs",children:"Franchise Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{type:"number",step:"1",min:"0",max:"100",value:R.franchise_fee_pct,onChange:ee=>$(Q=>({...Q,franchise_fee_pct:ee.target.value})),className:"pr-7 h-8 text-sm",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"%"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs",children:"Transaction Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-xs",children:"$"}),e.jsx(Fe,{type:"number",step:"1",min:"0",value:R.transaction_fee,onChange:ee=>$(Q=>({...Q,transaction_fee:ee.target.value})),className:"pl-7 h-8 text-sm",placeholder:"500"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Flat fee deducted"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs",children:"Net to Agent"}),e.jsx(Fe,{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(_e,{children:"Target Close Date"}),e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:At("w-full justify-start text-left font-normal",!R.target_close_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),R.target_close_date?ys(R.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(Eo,{className:"w-auto p-0",align:"start",children:e.jsx(mf,{mode:"single",selected:R.target_close_date,onSelect:ee=>$(Q=>({...Q,target_close_date:ee})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Contract Date"}),e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:At("w-full justify-start text-left font-normal",!R.contract_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),R.contract_date?ys(R.contract_date,"PPP"):"Pick a date"]})}),e.jsx(Eo,{className:"w-auto p-0",align:"start",children:e.jsx(mf,{mode:"single",selected:R.contract_date,onSelect:ee=>$(Q=>({...Q,contract_date:ee})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),(R.deal_type==="seller"||R.deal_type==="dual")&&!R.listing_id&&e.jsxs("div",{className:"space-y-2 col-span-2",children:[e.jsx(_e,{children:"Listing Date (for Days on Market)"}),e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:At("w-full justify-start text-left font-normal",!R.listing_date&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),R.listing_date?ys(R.listing_date,"PPP"):"Pick a date"]})}),e.jsx(Eo,{className:"w-auto p-0",align:"start",children:e.jsx(mf,{mode:"single",selected:R.listing_date,onSelect:ee=>$(Q=>({...Q,listing_date:ee})),initialFocus:!0,className:"pointer-events-auto"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used to calculate Days on Market. Auto-filled for linked listings."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Priority"}),e.jsxs(rr,{value:R.priority,onValueChange:ee=>$(Q=>({...Q,priority:ee})),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:$ws.map(ee=>e.jsx(Tt,{value:ee.value,children:ee.label},ee.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Win Probability"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{type:"number",min:"0",max:"100",value:R.probability,onChange:ee=>$(Q=>({...Q,probability:ee.target.value})),className:"pr-7"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"notes",children:"Notes"}),e.jsx(Ar,{id:"notes",value:R.notes,onChange:ee=>$(Q=>({...Q,notes:ee.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(zws,{formData:f,onChange:y}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:se,children:[se&&e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function Uws({dealId:t}){const s=ai(),r=ss(),[n,a]=C.useState(""),[o,l]=C.useState(!1),{data:i=[]}=wt({queryKey:["deal-tags",t],queryFn:async()=>{const{data:b,error:w}=await G.from("deal_tags").select("*").eq("deal_id",t).order("created_at");if(w)throw w;return b},enabled:!!t}),{data:c=[]}=wt({queryKey:["all-deal-tags",s],queryFn:async()=>{if(!s)return[];const{data:b,error:w}=await G.from("deal_tags").select("tag").eq("owner_user_id",s);if(w)throw w;return[...new Set(b.map(N=>N.tag))].sort()},enabled:!!s}),u=Dt({mutationFn:async b=>{if(!s)throw new Error("Not authenticated");const{error:w}=await G.from("deal_tags").insert({deal_id:t,owner_user_id:s,tag:b.trim()});if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]}),r.invalidateQueries({queryKey:["all-deal-tags"]}),a("")}}),p=Dt({mutationFn:async b=>{const{error:w}=await G.from("deal_tags").delete().eq("id",b);if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]})}}),f=()=>{const b=n.trim();b&&(i.some(w=>w.tag.toLowerCase()===b.toLowerCase())||u.mutate(b))},y=i.map(b=>b.tag.toLowerCase()),_=c.filter(b=>b.toLowerCase().includes(n.toLowerCase())&&!y.includes(b.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(b=>e.jsxs(nt,{variant:"secondary",className:"gap-1 text-xs",children:[b.tag,e.jsx("button",{type:"button",onClick:()=>p.mutate(b.id),className:"ml-0.5 hover:text-destructive",children:e.jsx(Ur,{className:"h-3 w-3"})})]},b.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(Zs,{className:"h-3 w-3"})," Add tag"]})]}),o&&e.jsxs("div",{className:"relative",children:[e.jsx(Fe,{value:n,onChange:b=>a(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),f()),b.key==="Escape"&&(l(!1),a(""))},placeholder:"Type tag and press Enter...",className:"h-7 text-xs",autoFocus:!0,onBlur:()=>{n.trim()||l(!1)}}),n&&_.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:_.map(b=>e.jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-left text-xs hover:bg-muted",onMouseDown:w=>{w.preventDefault(),u.mutate(b)},children:b},b))})]})]})}function Vws(t){return wt({queryKey:["deal-files",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_files").select("*").eq("deal_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function Hws(){const t=ai(),s=ss();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 G.storage.from("deal-files").upload(o,n);if(l)throw l;const{data:i,error:c}=await G.from("deal_files").insert({deal_id:r,owner_user_id:t,file_name:n.name,file_size:n.size,file_type:n.type||null,storage_path:o}).select().single();if(c)throw c;return i},onSuccess:(r,n)=>{s.invalidateQueries({queryKey:["deal-files",n.dealId]})}})}function Wws(){const t=ss();return Dt({mutationFn:async({fileId:s,storagePath:r,dealId:n})=>{await G.storage.from("deal-files").remove([r]);const{error:a}=await G.from("deal_files").delete().eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}function Gws(){const t=ss();return Dt({mutationFn:async({fileId:s,visible:r,dealId:n})=>{const{error:a}=await G.from("deal_files").update({visible_on_portal:r}).eq("id",s);if(a)throw a;return n},onSuccess:s=>{t.invalidateQueries({queryKey:["deal-files",s]})}})}async function Kws(t){const{data:s,error:r}=await G.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const R7e={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function Zws({open:t,onOpenChange:s}){const{data:r,isLoading:n}=p_s(),a=f_s(),o=g_s(),l=x_s(),[i,c]=C.useState(!1),[u,p]=C.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[f,y]=C.useState(""),_=async()=>{if(u.question_text.trim())try{await a.mutateAsync({question_text:u.question_text.trim(),field_type:u.field_type,options:u.field_type==="dropdown"?u.options:[],is_required:u.is_required,sort_order:((r==null?void 0:r.length)||0)+1}),p({question_text:"",field_type:"text",options:[],is_required:!1}),y(""),c(!1),me.success("Question added")}catch{me.error("Failed to add question")}},b=async S=>{try{await l.mutateAsync(S),me.success("Question removed")}catch{me.error("Failed to remove question")}},w=async(S,T)=>{try{await o.mutateAsync({id:S,is_required:T})}catch{me.error("Failed to update question")}},j=()=>{f.trim()&&(p(S=>({...S,options:[...S.options,f.trim()]})),y(""))},N=S=>{p(T=>({...T,options:T.options.filter((I,L)=>L!==S)}))};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-md max-h-[85vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Custom Intake Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These questions appear on all your portal onboarding forms."})]}),e.jsx(Vi,{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(Ss,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),r==null?void 0:r.map(S=>{var T;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(yh,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:S.question_text}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(nt,{variant:"secondary",className:"text-xs",children:R7e[S.field_type]||S.field_type}),S.is_required&&e.jsx(nt,{variant:"outline",className:"text-xs",children:"Required"})]}),S.field_type==="dropdown"&&((T=S.options)==null?void 0:T.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(Br,{checked:S.is_required,onCheckedChange:I=>w(S.id,I),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>b(S.id),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})},S.id)}),!n&&(r==null?void 0:r.length)===0&&!i&&e.jsxs("div",{className:"text-center py-8 border border-dashed rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"No custom questions yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add questions that clients will answer during onboarding."})]}),i&&e.jsxs("div",{className:"border-2 border-primary/20 rounded-lg p-4 space-y-3 bg-primary/5",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Question"}),e.jsx(Fe,{value:u.question_text,onChange:S=>p(T=>({...T,question_text:S.target.value})),className:"mt-1",placeholder:"e.g., Do you have a home to sell first?",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Answer Type"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(R7e).map(([S,T])=>e.jsx("button",{type:"button",onClick:()=>p(I=>({...I,field_type:S,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${u.field_type===S?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:T},S))})]}),u.field_type==="dropdown"&&e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Options"}),e.jsxs("div",{className:"space-y-1.5 mt-1.5",children:[u.options.map((S,T)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex-1 text-sm bg-muted/50 rounded px-2 py-1",children:S}),e.jsx("button",{onClick:()=>N(T),className:"text-muted-foreground hover:text-destructive",children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]},T)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:f,onChange:S=>y(S.target.value),onKeyDown:S=>S.key==="Enter"&&(S.preventDefault(),j()),placeholder:"Add option...",className:"h-8 text-sm"}),e.jsx(K,{variant:"outline",size:"sm",onClick:j,disabled:!f.trim(),className:"h-8",children:e.jsx(Zs,{className:"h-3 w-3"})})]})]})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:u.is_required,onCheckedChange:S=>p(T=>({...T,is_required:S}))}),e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Required"})]})}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>c(!1),className:"flex-1",children:"Cancel"}),e.jsxs(K,{size:"sm",onClick:_,disabled:!u.question_text.trim()||a.isPending,className:"flex-1",children:[a.isPending?e.jsx(Ss,{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(Zs,{className:"h-4 w-4 mr-1"})," Add Question"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s(!1),children:"Done"})]})]})})}function Yws({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=C.useState(""),[i,c]=C.useState(!1),{data:u,isLoading:p}=wt({queryKey:["all-owner-portals",s],queryFn:async()=>{const{data:b,error:w}=await G.from("client_portals").select(` id, slug, client_name, client_email, deal_id, archived_at, deal_pipeline (id, deal_name, deal_type, property_address) `).eq("owner_user_id",s).neq("id",t).is("archived_at",null).eq("is_enabled",!0);if(w)throw w;return b},enabled:i||!!n}),f=C.useMemo(()=>!n||!u?null:u.find(b=>b.id===n),[n,u]),y=C.useMemo(()=>!u||!r?[]:u.filter(b=>{var w;return((w=b.client_email)==null?void 0:w.toLowerCase())===r.toLowerCase()&&b.id!==t}),[u,r,t]),_=C.useMemo(()=>{if(!u||!o.trim())return[];const b=o.toLowerCase();return u.filter(w=>{var N,S,T,I;const j=w.deal_pipeline;return((N=w.client_name)==null?void 0:N.toLowerCase().includes(b))||((S=w.client_email)==null?void 0:S.toLowerCase().includes(b))||((T=j==null?void 0:j.deal_name)==null?void 0:T.toLowerCase().includes(b))||((I=j==null?void 0:j.property_address)==null?void 0:I.toLowerCase().includes(b))})},[u,o]);if(n){const b=f==null?void 0:f.deal_pipeline;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Linked Portal"}),e.jsxs("div",{className:"flex items-center gap-2 bg-primary/5 border border-primary/20 rounded-lg p-3",children:[e.jsx(sl,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:(f==null?void 0:f.client_name)||(b==null?void 0:b.deal_name)||"Linked Portal"}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[(b==null?void 0:b.deal_type)==="listing"?"🏠 Listing":"🔑 Purchase"," · ",(b==null?void 0:b.property_address)||"No address"]})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"text-xs text-destructive hover:text-destructive shrink-0",onClick:()=>a(null),children:[e.jsx(Z4,{className:"h-3 w-3 mr-1"}),"Unlink"]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Client will see both transactions in a tabbed view on one portal link."})]})}return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Link Another Transaction"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Combine buy + sell into one portal"})]}),e.jsxs(K,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>c(!i),children:[e.jsx(sl,{className:"h-3 w-3 mr-1"}),i?"Cancel":"Link"]})]}),!i&&y.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)"}),y.map(b=>{const w=b.deal_pipeline;return e.jsxs("button",{onClick:()=>a(b.id),className:"w-full flex items-center gap-2 bg-amber-50 border border-amber-200 rounded-lg p-2.5 hover:bg-amber-100 transition-colors text-left",children:[e.jsx(nt,{variant:"outline",className:"text-[10px] shrink-0 bg-amber-100 border-amber-300 text-amber-700",children:(w==null?void 0:w.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(w==null?void 0:w.deal_name)||b.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:w==null?void 0:w.property_address})]}),e.jsx(sl,{className:"h-3.5 w-3.5 text-amber-600 shrink-0"})]},b.id)})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Fe,{value:o,onChange:b=>l(b.target.value),placeholder:"Search by name, email, or address...",className:"pl-8 h-8 text-xs",autoFocus:!0})]}),p&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ss,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),_.length>0&&e.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:_.map(b=>{const w=b.deal_pipeline;return e.jsxs("button",{onClick:()=>{a(b.id),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(nt,{variant:"outline",className:"text-[10px] shrink-0",children:(w==null?void 0:w.deal_type)==="listing"?"Listing":"Purchase"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:(w==null?void 0:w.deal_name)||b.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:b.client_email})]})]},b.id)})}),o&&_.length===0&&!p&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No portals found"})]})]})}function RSe({userId:t,onSelect:s,triggerLabel:r="Library",triggerSize:n="sm",triggerVariant:a="outline",triggerClassName:o}){const[l,i]=C.useState(!1),[c,u]=C.useState([]),[p,f]=C.useState(!1),[y,_]=C.useState("");C.useEffect(()=>{!l||!t||(f(!0),G.from("agent_videos").select("id, title, recipient_name, playback_url, thumbnail_url, created_at, duration_seconds").eq("owner_user_id",t).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1}).limit(50).then(({data:w})=>{u(w||[]),f(!1)}))},[l,t]);const b=c.filter(w=>!y||(w.title||w.recipient_name||"").toLowerCase().includes(y.toLowerCase()));return e.jsxs(_s,{open:l,onOpenChange:i,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{variant:a,size:n,className:o||"gap-1.5 shrink-0",children:[e.jsx(Fu,{className:"h-3.5 w-3.5"}),r]})}),e.jsxs(vs,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Select from Video Library"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a video from your library"})]}),e.jsxs("div",{className:"relative mb-3",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search videos...",value:y,onChange:w=>_(w.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto space-y-2 min-h-0",children:p?e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"h-16 w-full"}),e.jsx(xs,{className:"h-16 w-full"})]}):b.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"}):b.map(w=>e.jsxs("button",{onClick:()=>{s(w.playback_url||""),i(!1)},className:"w-full flex items-center gap-3 p-3 rounded-lg border border-border hover:border-primary/50 hover:bg-accent/50 transition-colors text-left",children:[e.jsx("div",{className:"w-16 h-10 rounded bg-muted flex items-center justify-center shrink-0 overflow-hidden",children:w.thumbnail_url?e.jsx("img",{src:w.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:j=>{const N=j.currentTarget.parentElement;if(N){j.currentTarget.remove();const S=document.createElement("span");S.innerHTML="🎬",S.className="text-lg",N.appendChild(S)}}}):e.jsx(Nn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:w.title||w.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w.duration_seconds?`${Math.round(w.duration_seconds)}s`:"",w.created_at?` · ${new Date(w.created_at).toLocaleDateString()}`:""]})]})]},w.id))})]})]})}function FSe({contactId:t,onVideoReady:s}){const[r,n]=C.useState(!1),[a,o]=C.useState("record"),[l,i]=C.useState(0),[c,u]=C.useState(0),p=nC(),f=()=>{o("record"),i(0),u(0)},y=b=>{!b&&(a==="uploading"||a==="processing")||(n(b),b||f())},_=C.useCallback(async(b,w)=>{o("uploading");try{const j="Card Video",{videoId:N,libraryId:S}=await GO(j),{uploadUrl:T,apiKey:I}=await KO(N),L=new XMLHttpRequest;L.upload.onprogress=se=>{se.lengthComputable&&i(se.loaded/se.total*100)},await new Promise((se,ee)=>{L.onload=()=>L.status>=200&&L.status<300?se():ee(new Error("Upload failed")),L.onerror=()=>ee(new Error("Upload failed")),L.open("PUT",T),L.setRequestHeader("AccessKey",I),L.send(b)}),o("processing");let R=0;const $=Date.now(),q=9e4,U=`https://iframe.mediadelivery.net/embed/${S}/${N}`;for(;R<4;){if(await new Promise(ee=>setTimeout(ee,3e3)),Date.now()-$>q){const ee=b.size/1048576;await p.mutateAsync({bunny_video_id:N,playback_url:`https://iframe.mediadelivery.net/play/${S}/${N}`,file_size_mb:ee,title:j,contact_id:t||void 0,status:"processing",touch_type:"video"}),s(U),me.success("Video saved — still encoding. It will be ready shortly."),o("done"),setTimeout(()=>{n(!1),f()},1500);return}const se=await rA(N);if(R=se.status,u(se.encodeProgress||0),R===5||R===6)throw new Error("Video processing failed")}const V=await rA(N),X=(V.storageSize||b.size)/(1024*1024);await p.mutateAsync({bunny_video_id:N,contact_id:t||void 0,playback_url:V.directPlayUrl||U,thumbnail_url:V.thumbnailUrl,preview_url:V.previewUrl||null,duration_seconds:V.length||w,file_size_mb:X,title:j,status:"ready",touch_type:"video"}),s(U),me.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),f()},1500)}catch(j){console.error("Recording upload error:",j),me.error("Failed to process video. Please try again."),o("record")}},[t,s,p]);return e.jsxs(_s,{open:r,onOpenChange:y,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 w-full",children:[e.jsx(Nn,{className:"h-3.5 w-3.5"}),"Record Video"]})}),e.jsxs(vs,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx(cme,{maxDurationSeconds:60,onRecordingComplete:_,onError:b=>me.error(b)}),a==="uploading"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(Ss,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),e.jsx(Oi,{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(Ss,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),e.jsx(Oi,{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(vi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}function Bot({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=ZO(),[o,l]=C.useState(!1),[i,c]=C.useState(r.next_step_text||""),[u,p]=C.useState(r.next_step_video_url||""),[f,y]=C.useState(r.inspection_date||""),[_,b]=C.useState(r.appraisal_date||""),[w,j]=C.useState(r.welcome_message||""),[N,S]=C.useState(r.review_url||""),[T,I]=C.useState(r.show_post_close_tips),[L,R]=C.useState(r.notify_client),[$,q]=C.useState(r.require_onboarding),[U,V]=C.useState(r.allow_spouse),[X,se]=C.useState(r.visibility),[ee,Q]=C.useState(r.stage_mapping||[]),[de,re]=C.useState(null),[ne,le]=C.useState(r.linked_portal_id||null),{data:he}=wt({queryKey:["pipeline-stages-for-portal",n],queryFn:async()=>{const{data:be,error:Me}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",n).order("sort_order",{ascending:!0});if(Me)throw Me;return be},enabled:t});C.useEffect(()=>{c(r.next_step_text||""),p(r.next_step_video_url||""),y(r.inspection_date||""),b(r.appraisal_date||""),j(r.welcome_message||""),S(r.review_url||""),I(r.show_post_close_tips),R(r.notify_client),q(r.require_onboarding),V(r.allow_spouse),se(r.visibility),Q(r.stage_mapping||[]),le(r.linked_portal_id||null)},[r]);const we=async()=>{try{await a.mutateAsync({id:r.id,next_step_text:i||null,next_step_video_url:u||null,inspection_date:f||null,appraisal_date:_||null,welcome_message:w||null,review_url:N||null,show_post_close_tips:T,notify_client:L,require_onboarding:$,allow_spouse:U,visibility:X,stage_mapping:ee.length>0?ee:null,linked_portal_id:ne});const be=r.linked_portal_id;ne&&ne!==be&&await G.from("client_portals").update({linked_portal_id:r.id}).eq("id",ne),!ne&&be&&await G.from("client_portals").update({linked_portal_id:null}).eq("id",be),me.success("Portal settings saved"),s(!1)}catch{me.error("Failed to save settings")}},ye=()=>{Q([...ee,{label:""}])},je=be=>{Q(ee.filter((Me,Ae)=>Ae!==be)),de===be&&re(null)},ke=(be,Me,Ae)=>{const Re=[...ee];Re[be]={...Re[be],[Me]:Ae},Q(Re)},We=()=>{const Me=qje(null).map(Ae=>({label:Ae.label,description:Ae.description,stageId:void 0}));Q(Me)};return e.jsxs(e.Fragment,{children:[e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-lg max-h-[85vh] flex flex-col",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Portal Settings"})}),e.jsxs(Aa,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(ja,{className:"grid grid-cols-3 shrink-0",children:[e.jsx(js,{value:"general",children:"General"}),e.jsx(js,{value:"timeline",children:"Timeline"}),e.jsx(js,{value:"content",children:"Content"})]}),e.jsxs(Vi,{className:"flex-1 mt-4",children:[e.jsxs($s,{value:"general",className:"space-y-4 mt-0 px-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Visibility"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Public portals appear without restrictions"})]}),e.jsx("div",{className:"flex gap-1",children:["private","public"].map(be=>e.jsx("button",{onClick:()=>se(be),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${X===be?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:be.charAt(0).toUpperCase()+be.slice(1)},be))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Require Onboarding"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Clients must fill out intake form"})]}),e.jsx(Br,{checked:$,onCheckedChange:q})]}),$&&e.jsxs("div",{className:"flex items-center justify-between pl-4 border-l-2 border-primary/20",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Custom Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage intake form questions"})]}),e.jsx(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(_e,{className:"text-sm font-medium",children:"Allow Spouse/Partner"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show spouse fields on onboarding"})]}),e.jsx(Br,{checked:U,onCheckedChange:V})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Post-Close Celebration"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show congrats card when deal closes"})]}),e.jsx(Br,{checked:T,onCheckedChange:I})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Notify Client on Updates"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Email client when you post portal updates"})]}),e.jsx(Br,{checked:L,onCheckedChange:R})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(Yws,{portalId:r.id,ownerId:n,clientEmail:r.client_email,linkedPortalId:ne,onLink:le})}),e.jsx("div",{children:e.jsx(Fe,{type:"date",value:f,onChange:be=>y(be.target.value),className:"mt-1"})}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Appraisal Date"}),e.jsx(Fe,{type:"date",value:_,onChange:be=>b(be.target.value),className:"mt-1"})]})]}),e.jsx($s,{value:"timeline",className:"space-y-4 mt-0 px-1",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Client-Facing Stages"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Customize the client-friendly stage labels shown on the portal timeline"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:We,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.'}),ee.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:We,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:ee.map((be,Me)=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yh,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(Fe,{value:be.label,onChange:Ae=>ke(Me,"label",Ae.target.value),placeholder:`Stage ${Me+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:()=>re(de===Me?null:Me),children:de===Me?"Less":"More"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>je(Me),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]}),de===Me&&e.jsxs("div",{className:"ml-6 space-y-2 pl-2 border-l-2 border-primary/15 pb-2",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("textarea",{value:be.description||"",onChange:Ae=>ke(Me,"description",Ae.target.value),placeholder:"e.g. Now it's time to start actively looking at homes",className:"mt-0.5 w-full rounded-md border border-input bg-background px-3 py-2 text-xs min-h-[50px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Video"}),be.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:be.video_url.length>40?be.video_url.slice(0,40)+"...":be.video_url}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>ke(Me,"video_url",""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(FSe,{onVideoReady:Ae=>ke(Me,"video_url",Ae)}),e.jsx(RSe,{userId:n,onSelect:Ae=>ke(Me,"video_url",Ae),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 Ae=prompt("Paste a YouTube or Loom URL:");Ae&&ke(Me,"video_url",Ae)},children:[e.jsx(Vo,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},Me))}),ee.length>0&&e.jsxs(K,{variant:"outline",size:"sm",onClick:ye,className:"mt-2 text-xs w-full",children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add Stage"]})]})}),e.jsxs($s,{value:"content",className:"space-y-4 mt-0 px-1",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Welcome Message"}),e.jsx("textarea",{value:w,onChange:be=>j(be.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Welcome! Here's everything you need for your transaction."})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"What's Next"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Tell your client what to expect next"}),e.jsx("textarea",{value:i,onChange:be=>c(be.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[60px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"We're waiting on the inspection report..."})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Next Step Video (optional)"}),e.jsx(Fe,{value:u,onChange:be=>p(be.target.value),className:"mt-1",placeholder:"YouTube or Loom URL"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Review URL"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Shown after deal closes"}),e.jsx(Fe,{value:N,onChange:be=>S(be.target.value),className:"mt-1",placeholder:"https://g.page/r/..."})]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:we,disabled:a.isPending,children:[a.isPending?e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Wu,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})}),e.jsx(Zws,{open:o,onOpenChange:l})]})}function $ot({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const[o,l]=C.useState(""),[i,c]=C.useState(""),[u,p]=C.useState(""),[f,y]=C.useState(!1),[_,b]=C.useState(a??!1),w=_at(),j=async()=>{if(o.trim())try{if(await w.mutateAsync({portal_id:r,title:o.trim(),content:i.trim()||void 0,video_url:u.trim()||void 0,is_stage_change:f}),_&&n)try{const N=h1(n);await G.functions.invoke("send-portal-notification",{body:{portal_id:r,update_title:o.trim(),update_content:i.trim()||null,portal_url:N}}),me.success("Update posted & client notified")}catch(N){console.error("Notification failed:",N),me.success("Update posted (notification failed to send)")}else me.success("Update posted to portal");l(""),c(""),p(""),y(!1),s(!1)}catch{me.error("Failed to post update")}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Title *"}),e.jsx(Fe,{value:o,onChange:N=>l(N.target.value),className:"mt-1",placeholder:"Inspection cleared!"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Message"}),e.jsx("textarea",{value:i,onChange:N=>c(N.target.value),className:"mt-1 w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[80px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",placeholder:"Everything looked great during the inspection..."})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Video URL (optional)"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(Fe,{value:u,onChange:N=>p(N.target.value),className:"pl-9",placeholder:"YouTube or Loom link"}),e.jsx(Nn,{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:()=>y(!f),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${f?"bg-emerald-500/10 text-emerald-700 border-emerald-200":"bg-background text-muted-foreground border-input"}`,children:"📊 Stage Change"}),e.jsxs("button",{type:"button",onClick:()=>b(!_),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors flex items-center gap-1.5 ${_?"bg-blue-500/10 text-blue-700 border-blue-200":"bg-background text-muted-foreground border-input"}`,children:[_?e.jsx(gg,{className:"h-3 w-3"}):e.jsx(Mb,{className:"h-3 w-3"}),_?"Notify Client":"No Notification"]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:j,disabled:!o.trim()||w.isPending,children:[w.isPending?e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(oa,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})})}function qot({open:t,onOpenChange:s,portal:r,dealName:n}){const a=ZO(),{isGmailConnected:o,gmailEmail:l}=D0(),[i,c]=C.useState(r.client_name||""),[u,p]=C.useState(r.client_email||""),[f,y]=C.useState(!1),[_,b]=C.useState(!1),w=h1(r.slug),j=i.split(" ")[0]||"there",N=`Your Transaction Portal – ${n}`,S=`Hi ${j}, I've set up a dedicated portal where you can track the progress of your transaction in real-time. Here's your link: ${w} You can view your timeline, key dates, documents, and any updates I post along the way. Let me know if you have any questions!`,T=()=>{navigator.clipboard.writeText(w),b(!0),setTimeout(()=>b(!1),2e3),me.success("Portal link copied!")},I=async()=>{if(!u.trim()){me.error("Please enter the client email");return}y(!0);try{await a.mutateAsync({id:r.id,client_name:i||null,client_email:u||null,invite_sent_at:new Date().toISOString(),invite_method:"email"});const{error:R}=await G.functions.invoke("gmail-send",{body:{to:u,subject:N,body:S.replace(/\n/g,"
")}});if(R)throw R;me.success(`Invite sent to ${u}`),s(!1)}catch(R){me.error(R.message||"Failed to send invite")}finally{y(!1)}},L=()=>{const R=encodeURIComponent(N),$=encodeURIComponent(S);window.open(`mailto:${u}?subject=${R}&body=${$}`,"_blank"),a.mutateAsync({id:r.id,client_name:i||null,client_email:u||null,invite_sent_at:new Date().toISOString(),invite_method:"email"}).catch(()=>{})};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Invite Client to Portal"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Client Name"}),e.jsx(Fe,{value:i,onChange:R=>c(R.target.value),className:"mt-1",placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Client Email"}),e.jsx(Fe,{type:"email",value:u,onChange:R=>p(R.target.value),className:"mt-1",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Portal Link"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-muted/50 rounded-md px-3 py-2",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:w})}),e.jsx(K,{variant:"outline",size:"icon",onClick:T,className:"shrink-0",children:_?e.jsx(ma,{className:"h-4 w-4 text-emerald-600"}):e.jsx(mi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[o?e.jsxs(K,{onClick:I,disabled:f||!u.trim(),className:"w-full",children:[f?e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(br,{className:"h-4 w-4 mr-2"}),"Send via Gmail (",l,")"]}):e.jsxs(K,{onClick:L,disabled:!u.trim(),className:"w-full",variant:"outline",children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),e.jsxs(K,{variant:"ghost",onClick:T,className:"w-full text-muted-foreground",children:[e.jsx(mi,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function Xws({deal:t}){const{isAdmin:s,user:r}=Ws(),{data:n,isLoading:a}=d_s(t.id),o=F4e(),l=ZO(),[i,c]=C.useState(!1),[u,p]=C.useState(!1),[f,y]=C.useState(!1),[_,b]=C.useState(!1);if(a)return e.jsx("div",{className:"border rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(Ss,{className:"h-3 w-3 animate-spin ml-auto"})]})});const w=async()=>{var L,R;c(!0);try{await o.mutateAsync({deal_id:t.id,visibility:"private",require_onboarding:!0,client_name:t.contact?`${t.contact.first_name} ${t.contact.last_name}`:void 0,client_email:((L=t.contact)==null?void 0:L.email)||void 0,client_phone:((R=t.contact)==null?void 0:R.phone)||void 0}),me.success("Client portal enabled!")}catch{me.error("Failed to create portal")}finally{c(!1)}},j=async L=>{if(n)try{await l.mutateAsync({id:n.id,is_enabled:L}),me.success(L?"Portal enabled":"Portal disabled")}catch{me.error("Failed to update portal")}},N=()=>{if(!n)return;const L=h1(n.slug);navigator.clipboard.writeText(L),me.success("Portal link copied!")},S=()=>{if(!n)return;const L=h1(n.slug);window.open(L,"_blank")};if(!n)return e.jsxs("div",{className:"border rounded-lg p-4 border-dashed",children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Create a beautiful portal so your client can track their deal progress in real-time."}),e.jsxs(K,{onClick:w,disabled:i,size:"sm",className:"w-full",children:[i?e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(hn,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const T=h1(n.slug),I=(r==null?void 0:r.id)||"";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(nt,{variant:"outline",className:n.is_enabled?"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-xs bg-muted text-muted-foreground",children:n.is_enabled?"Active":"Disabled"})]}),e.jsx(Br,{checked:n.is_enabled,onCheckedChange:j})]}),e.jsxs("div",{className:"space-y-1.5 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Visibility:"}),e.jsx(nt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:n.visibility==="private"?"Private":"Public"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Onboarding:"}),e.jsx("span",{className:"text-foreground",children:n.require_onboarding?"Required":"Disabled"})]}),n.client_name&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Client:"}),e.jsx("span",{className:"text-foreground",children:n.client_name})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-md p-2 mb-3",children:e.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:T})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:N,className:"text-xs flex-1 min-w-0",children:[e.jsx(mi,{className:"h-3 w-3 mr-1 shrink-0"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:S,className:"text-xs flex-1 min-w-0",children:[e.jsx(rn,{className:"h-3 w-3 mr-1 shrink-0"}),"Preview"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>b(!0),className:"text-xs flex-1 min-w-0",children:[e.jsx(oa,{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:()=>y(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[e.jsx(vM,{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(Jl,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),e.jsx(Bot,{open:u,onOpenChange:p,portal:n,dealOwnerId:I}),e.jsx($ot,{open:f,onOpenChange:y,portalId:n.id,portalSlug:n.slug,notifyClient:n.notify_client}),e.jsx(qot,{open:_,onOpenChange:b,portal:n,dealName:t.deal_name})]})}const Qws=["Client","Co-Buyer","Co-Seller","Spouse","Lender","Title Company","Inspector","Appraiser","Attorney","Contractor","Other"];function Jws(t){return wt({queryKey:["deal-contacts",t],queryFn:async()=>{const{data:s,error:r}=await G.from("deal_contacts").select(` id, deal_id, contact_id, role, created_at, contact:innercircle_contacts(id, first_name, last_name, email, phone) `).eq("deal_id",t).order("created_at");if(r)throw r;return s||[]},enabled:!!t})}function ejs(){const t=ss();return Dt({mutationFn:async({dealId:s,contactId:r,role:n})=>{const{data:a,error:o}=await G.from("deal_contacts").insert({deal_id:s,contact_id:r,role:n}).select().single();if(o)throw o;return a},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),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 tjs(){const t=ss();return Dt({mutationFn:async({id:s,dealId:r})=>{const{error:n}=await G.from("deal_contacts").delete().eq("id",s);if(n)throw n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["deal-contacts",r.dealId]}),me.success("Contact removed from deal")},onError:()=>{me.error("Failed to remove contact")}})}function sjs({dealId:t,primaryContactId:s}){const r=Pr(),{data:n,isLoading:a}=Jws(t),{data:o}=Fm(),l=ejs(),i=tjs(),[c,u]=C.useState(!1),[p,f]=C.useState(""),[y,_]=C.useState("Client"),b=new Set((n==null?void 0:n.map(T=>T.contact_id))||[]);s&&b.add(s);const w=o==null?void 0:o.filter(T=>{var L,R,$;if(b.has(T.id))return!1;if(!p.trim())return!0;const I=p.toLowerCase();return((L=T.first_name)==null?void 0:L.toLowerCase().includes(I))||((R=T.last_name)==null?void 0:R.toLowerCase().includes(I))||(($=T.email)==null?void 0:$.toLowerCase().includes(I))}).slice(0,8),j=T=>{l.mutate({dealId:t,contactId:T,role:y}),u(!1),f("")},N=T=>{i.mutate({id:T,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(mr,{className:"h-4 w-4"}),"Additional Contacts"]})}),e.jsxs(Lo,{open:c,onOpenChange:u,children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"w-full text-muted-foreground",children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"}),"Link a contact (lender, spouse, vendor...)"]})}),e.jsx(Eo,{className:"w-80 p-3",align:"start",children:e.jsx(F7e,{search:p,setSearch:f,selectedRole:y,setSelectedRole:_,filteredContacts:w,onAdd:j})})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),"Linked Contacts",n&&n.length>0&&e.jsx(nt,{variant:"secondary",className:"text-[10px] px-1.5",children:n.length})]}),e.jsxs(Lo,{open:c,onOpenChange:u,children:[e.jsx(Do,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx(Zs,{className:"h-3.5 w-3.5"})})}),e.jsx(Eo,{className:"w-80 p-3",align:"end",children:e.jsx(F7e,{search:p,setSearch:f,selectedRole:y,setSelectedRole:_,filteredContacts:w,onAdd:j})})]})]}),e.jsx("div",{className:"space-y-1.5",children:n==null?void 0:n.map(T=>{var I,L,R,$,q,U,V,X;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/40 group",children:[e.jsx(yn,{className:"h-7 w-7",children:e.jsxs(vn,{className:"text-[10px] bg-primary/10 text-primary",children:[(L=(I=T.contact)==null?void 0:I.first_name)==null?void 0:L[0],($=(R=T.contact)==null?void 0:R.last_name)==null?void 0:$[0]]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("button",{onClick:()=>r(`/mission-control/contacts/${T.contact_id}`),className:"text-sm font-medium hover:underline text-primary truncate block",children:[(q=T.contact)==null?void 0:q.first_name," ",(U=T.contact)==null?void 0:U.last_name]})}),e.jsx(nt,{variant:"outline",className:`text-[10px] px-1.5 py-0 shrink-0 ${S[T.role]||S.Other}`,children:T.role}),e.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[((V=T.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:${T.contact.phone}`,children:e.jsx(ea,{className:"h-3 w-3"})})}),((X=T.contact)==null?void 0:X.email)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",asChild:!0,children:e.jsx("a",{href:`mailto:${T.contact.email}`,children:e.jsx(br,{className:"h-3 w-3"})})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>N(T.id),children:e.jsx(jr,{className:"h-3 w-3"})})]})]},T.id)})})]})}function F7e({search:t,setSearch:s,selectedRole:r,setSelectedRole:n,filteredContacts:a,onAdd:o}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs(rr,{value:r,onValueChange:n,children:[e.jsx(tr,{className:"h-8 text-sm",children:e.jsx(nr,{placeholder:"Role"})}),e.jsx(sr,{children:Qws.map(l=>e.jsx(Tt,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Fe,{value:t,onChange:l=>s(l.target.value),placeholder:"Search contacts...",className:"pl-7 h-8 text-sm",autoFocus:!0})]}),e.jsx(Vi,{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 rjs={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"}},njs={note:po,call:ea,email:br,meeting:on,stage_change:rn,task_completed:ha,document:Rn,system:Tn};function ajs({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var Ae,Re;const{data:l,isLoading:i}=ebs((t==null?void 0:t.id)||""),{data:c,isLoading:u}=sbs((t==null?void 0:t.id)||""),p=tbs(),f=nbs(),y=rbs(),_=J_s(),{data:b,isLoading:w}=Vws((t==null?void 0:t.id)||""),j=Hws(),N=Wws(),S=Gws(),T=C.useRef(null),[I,L]=C.useState(""),[R,$]=C.useState(""),[q,U]=C.useState(!1),[V,X]=C.useState(!1);if(!t)return null;const se=rjs[t.deal_type],ee=(()=>{var ct;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const Te=((ct=t.listing)==null?void 0:ct.created_at)||t.listing_date;if(!Te)return null;const qe=t.contract_date?Ml(t.contract_date):new Date;return ty(qe,Ml(Te))})(),Q=Te=>Te?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Te):"-",de=async()=>{if(I.trim())try{await p.mutateAsync({deal_id:t.id,activity_type:"note",title:"Note added",description:I}),L(""),me.success("Note added")}catch{me.error("Failed to add note")}},re=async()=>{if(R.trim())try{await f.mutateAsync({deal_id:t.id,title:R,sort_order:((c==null?void 0:c.length)||0)+1}),$(""),me.success("Task added")}catch{me.error("Failed to add task")}},ne=async(Te,qe)=>{try{await y.mutateAsync({id:Te,is_completed:qe,deal_id:t.id})}catch{me.error("Failed to update task")}},le=async()=>{try{await _.mutateAsync(t.id),me.success("Deal deleted"),r(!1)}catch{me.error("Failed to delete deal")}},he=(c==null?void 0:c.filter(Te=>Te.is_completed).length)||0,we=(c==null?void 0:c.length)||0,ye=(b==null?void 0:b.length)||0,je=Te=>Te<1024?`${Te} B`:Te<1024*1024?`${(Te/1024).toFixed(1)} KB`:`${(Te/(1024*1024)).toFixed(1)} MB`,ke=Te=>Te?Te.startsWith("image/")?cl:Te.includes("pdf")?In:dM:dM,We=async Te=>{const qe=Te.target.files;if(!(!qe||!t)){X(!0);try{for(const ct of Array.from(qe)){if(ct.size>20*1024*1024){me.error(`${ct.name} exceeds 20MB limit`);continue}await j.mutateAsync({dealId:t.id,file:ct})}me.success("File(s) uploaded")}catch{me.error("Failed to upload file")}finally{X(!1),T.current&&(T.current.value="")}}},be=async(Te,qe)=>{if(t)try{await N.mutateAsync({fileId:Te,storagePath:qe,dealId:t.id}),me.success("File deleted")}catch{me.error("Failed to delete file")}},Me=async(Te,qe)=>{try{const ct=await Kws(Te),De=document.createElement("a");De.href=ct,De.download=qe,De.target="_blank",document.body.appendChild(De),De.click(),document.body.removeChild(De)}catch{me.error("Failed to download file")}};return e.jsxs(e.Fragment,{children:[e.jsx(DA,{open:s,onOpenChange:r,children:e.jsxs(YS,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(OA,{className:"p-6 pb-4 border-b shrink-0",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(nt,{variant:"outline",className:At("text-xs",se.color),children:se.label}),e.jsxs(nt,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx(RA,{className:"text-xl",children:t.deal_name}),e.jsx("div",{className:"mt-2",children:e.jsx(Uws,{dealId:t.id})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(rd,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"text-destructive hover:bg-destructive/10",onClick:()=>U(!0),children:e.jsx(jr,{className:"h-4 w-4"})})]})]})}),e.jsx(Vi,{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(yn,{className:"h-10 w-10",children:e.jsxs(vn,{className:"bg-primary/10 text-primary",children:[(Ae=t.contact.first_name)==null?void 0:Ae[0],(Re=t.contact.last_name)==null?void 0:Re[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(ea,{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(br,{className:"h-4 w-4"})})})]})]}),e.jsx(sjs,{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(Rn,{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(mo,{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(ha,{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:At("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(on,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",ys(Ml(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Td,{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(Xws,{deal:t}),e.jsxs(Aa,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(ja,{className:"w-full grid grid-cols-3",children:[e.jsxs(js,{value:"tasks",className:"gap-1",children:[e.jsx(ha,{className:"h-4 w-4"}),"Tasks ",we>0&&`(${he}/${we})`]}),e.jsxs(js,{value:"files",className:"gap-1",children:[e.jsx(W4,{className:"h-4 w-4"}),"Files ",ye>0&&`(${ye})`]}),e.jsxs(js,{value:"activity",className:"gap-1",children:[e.jsx(Tn,{className:"h-4 w-4"}),"Activity"]})]}),e.jsxs($s,{value:"tasks",className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{placeholder:"Add a new task...",value:R,onChange:Te=>$(Te.target.value),onKeyDown:Te=>Te.key==="Enter"&&re()}),e.jsx(K,{onClick:re,disabled:!R.trim(),children:e.jsx(Zs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[c==null?void 0:c.map(Te=>e.jsxs("div",{className:At("flex items-center gap-3 p-3 rounded-lg border transition-colors",Te.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx(Yo,{checked:Te.is_completed,onCheckedChange:qe=>ne(Te.id,!!qe)}),e.jsx("span",{className:At("flex-1 text-sm",Te.is_completed&&"line-through text-muted-foreground"),children:Te.title}),Te.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(new Date(Te.due_date),"MMM d")})]},Te.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($s,{value:"files",className:"mt-4 space-y-3",children:[e.jsx("input",{type:"file",ref:T,className:"hidden",multiple:!0,onChange:We,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 Te;return(Te=T.current)==null?void 0:Te.click()},disabled:V,children:[V?e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ni,{className:"h-4 w-4 mr-2"}),V?"Uploading...":"Upload Files"]}),e.jsxs("div",{className:"space-y-2",children:[b==null?void 0:b.map(Te=>{const qe=ke(Te.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(qe,{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:Te.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[je(Te.file_size)," · ",ys(new Date(Te.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(x2,{children:e.jsxs(hd,{children:[e.jsx(md,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${Te.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>S.mutate({fileId:Te.id,visible:!Te.visible_on_portal,dealId:t.id}),children:Te.visible_on_portal?e.jsx(va,{className:"h-4 w-4"}):e.jsx(xp,{className:"h-4 w-4"})})}),e.jsx(Uc,{side:"top",children:Te.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Me(Te.storage_path,Te.file_name),children:e.jsx(ki,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>be(Te.id,Te.storage_path),children:e.jsx(Ur,{className:"h-4 w-4"})})]})]},Te.id)}),(b==null?void 0:b.length)===0&&e.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No files yet. Upload contracts, disclosures, or other documents."})]})]}),e.jsxs($s,{value:"activity",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ar,{placeholder:"Add a note...",value:I,onChange:Te=>L(Te.target.value),rows:2}),e.jsxs(K,{onClick:de,disabled:!I.trim(),size:"sm",className:"w-full",children:[e.jsx(oa,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(Te=>{const qe=njs[Te.activity_type]||Tn;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center shrink-0",children:e.jsx(qe,{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:Te.title}),Te.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:Te.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:Yd(new Date(Te.created_at),{addSuffix:!0})})]})]},Te.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(gc,{open:q,onOpenChange:U,children:e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Delete Deal?"}),e.jsxs(Gl,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:le,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function ijs({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=hue(),o=Pat(),{data:l}=FA(),{data:i}=Rg(),[c,u]=C.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:ys(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});C.useEffect(()=>{if(r&&t){const y=r.deal_type==="seller"?"seller":"buyer",_=r.expected_price||0,b=r.commission_percentage||3,w=r.expected_commission||_*b/100;u({property_address:r.property_address||r.deal_name||"",city:r.city||"",state:r.state||"",zip:r.zip_code||"",transaction_type:y,close_date:r.actual_close_date||r.target_close_date||ys(new Date,"yyyy-MM-dd"),sale_price:_,commission_amount:w,lead_source_id:"",client_type_id:"",notes:r.notes||""})}},[r,t]);const p=async y=>{if(y.preventDefault(),!!r)try{const _=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:_.id,actual_close_date:c.close_date}),me.success("Deal added to Scorecard! 🎉"),s(!1),n==null||n()}catch(_){console.error("Error syncing to scorecard:",_),me.error("Failed to add to scorecard")}},f=y=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(y);return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-[550px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{className:"space-y-3",children:[e.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100 dark:bg-green-900/20",children:e.jsx(mo,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),e.jsx(Ns,{className:"text-center text-xl",children:"Congratulations on Closing! 🎉"}),e.jsx(Zr,{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(_e,{htmlFor:"property_address",className:"flex items-center gap-2",children:[e.jsx(Rn,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),e.jsx(Fe,{id:"property_address",value:c.property_address,onChange:y=>u(_=>({..._,property_address:y.target.value})),placeholder:"123 Main St",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"city",children:"City"}),e.jsx(Fe,{id:"city",value:c.city,onChange:y=>u(_=>({..._,city:y.target.value})),placeholder:"City"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"state",children:"State"}),e.jsx(Fe,{id:"state",value:c.state,onChange:y=>u(_=>({..._,state:y.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"zip",children:"Zip"}),e.jsx(Fe,{id:"zip",value:c.zip,onChange:y=>u(_=>({..._,zip:y.target.value})),placeholder:"75001"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Transaction Type *"}),e.jsxs(rr,{value:c.transaction_type,onValueChange:y=>u(_=>({..._,transaction_type:y})),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"buyer",children:"Buyer"}),e.jsx(Tt,{value:"seller",children:"Seller"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{htmlFor:"close_date",className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4 text-muted-foreground"}),"Close Date *"]}),e.jsx(Fe,{id:"close_date",type:"date",value:c.close_date,onChange:y=>u(_=>({..._,close_date:y.target.value})),required:!0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[e.jsx(Td,{className:"h-4 w-4 text-muted-foreground"}),"Sale Price *"]}),e.jsx(Fe,{id:"sale_price",type:"number",value:c.sale_price||"",onChange:y=>u(_=>({..._,sale_price:Number(y.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(_e,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[e.jsx(_M,{className:"h-4 w-4 text-muted-foreground"}),"GCI (Commission)"]}),e.jsx(Fe,{id:"commission_amount",type:"number",value:c.commission_amount||"",onChange:y=>u(_=>({..._,commission_amount:Number(y.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(_e,{children:"Lead Source"}),e.jsxs(rr,{value:c.lead_source_id,onValueChange:y=>u(_=>({..._,lead_source_id:y})),children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select source"})}),e.jsx(sr,{children:l==null?void 0:l.map(y=>e.jsx(Tt,{value:y.id,children:y.name},y.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Client Type"}),e.jsxs(rr,{value:c.client_type_id,onValueChange:y=>u(_=>({..._,client_type_id:y})),children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select type"})}),e.jsx(sr,{children:i==null?void 0:i.map(y=>e.jsx(Tt,{value:y.id,children:y.name},y.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"notes",children:"Notes"}),e.jsx(Ar,{id:"notes",value:c.notes,onChange:y=>u(_=>({..._,notes:y.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(Vn,{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(Ki,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}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"}},z7e={urgent:0,high:1,medium:2,low:3};function ljs({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=C.useState("target_close_date"),[l,i]=C.useState("asc"),c=_=>{a===_?i(b=>b==="asc"?"desc":"asc"):(o(_),i("asc"))},u=C.useMemo(()=>[...t].sort((_,b)=>{var j,N;let w=0;switch(a){case"deal_name":w=_.deal_name.localeCompare(b.deal_name);break;case"stage":{const S=((j=s.find(I=>I.id===_.stage_id))==null?void 0:j.sort_order)||0,T=((N=s.find(I=>I.id===b.stage_id))==null?void 0:N.sort_order)||0;w=S-T;break}case"expected_price":w=(_.expected_price||0)-(b.expected_price||0);break;case"expected_commission":w=(_.expected_commission||0)-(b.expected_commission||0);break;case"target_close_date":{const S=_.target_close_date?Ml(_.target_close_date).getTime():1/0,T=b.target_close_date?Ml(b.target_close_date).getTime():1/0;w=S-T;break}case"priority":w=z7e[_.priority]-z7e[b.priority];break}return l==="asc"?w:-w}),[t,s,a,l]),p=_=>_?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_):"—",f=_=>_?s.find(b=>b.id===_):null,y=({field:_,children:b})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>c(_),children:[b,a===_?l==="asc"?e.jsx(gu,{className:"ml-2 h-4 w-4"}):e.jsx(Oh,{className:"ml-2 h-4 w-4"}):e.jsx(ud,{className:"ml-2 h-4 w-4 opacity-50"})]});return t.length===0?e.jsx("div",{className:"text-center py-16",children:e.jsx("p",{className:"text-muted-foreground",children:"No deals to display"})}):e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{className:"bg-muted/50",children:[e.jsx(bt,{className:"w-[250px]",children:e.jsx(y,{field:"deal_name",children:"Deal Name"})}),e.jsx(bt,{className:"w-[150px]",children:e.jsx(y,{field:"stage",children:"Stage"})}),e.jsx(bt,{className:"w-[100px]",children:"Type"}),e.jsx(bt,{className:"w-[120px]",children:e.jsx(y,{field:"expected_price",children:"Price"})}),e.jsx(bt,{className:"w-[120px]",children:e.jsx(y,{field:"expected_commission",children:"GCI"})}),e.jsx(bt,{className:"w-[130px]",children:e.jsx(y,{field:"target_close_date",children:"Close Date"})}),e.jsx(bt,{className:"w-[100px]",children:e.jsx(y,{field:"priority",children:"Priority"})})]})}),e.jsx(Pn,{children:u.map(_=>{f(_.stage_id);const b=ojs[_.deal_type],w=_.target_close_date?ty(Ml(_.target_close_date),new Date):null,j=w!==null&&w<0,N=w!==null&&w<=7&&w>=0;return e.jsxs(ks,{className:At("cursor-pointer hover:bg-muted/50 transition-colors",j&&"bg-red-50/50"),onClick:()=>r(_),children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{children:[e.jsx("p",{className:"truncate max-w-[230px]",children:_.deal_name}),_.contact&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[_.contact.first_name," ",_.contact.last_name]})]})}),e.jsx(dt,{onClick:S=>S.stopPropagation(),children:e.jsx(Fot,{stages:s,currentStageId:_.stage_id||"",onStageSelect:(S,T)=>n(_.id,S,T)})}),e.jsx(dt,{children:e.jsx(nt,{variant:"outline",className:At("text-xs",b.color),children:b.label})}),e.jsx(dt,{children:e.jsx("span",{className:"font-medium",children:p(_.expected_price)})}),e.jsx(dt,{children:e.jsx("span",{className:"text-emerald-600",children:p(_.expected_commission)})}),e.jsx(dt,{children:_.target_close_date?e.jsxs("div",{className:At("flex items-center gap-1 text-sm",j&&"text-red-600",N&&!j&&"text-amber-600"),children:[j&&e.jsx(yl,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:ys(Ml(_.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{children:e.jsx(nt,{variant:"outline",className:At("text-xs capitalize",_.priority==="urgent"&&"border-red-200 bg-red-50 text-red-700",_.priority==="high"&&"border-orange-200 bg-orange-50 text-orange-700",_.priority==="medium"&&"border-amber-200 bg-amber-50 text-amber-700",_.priority==="low"&&"border-slate-200 bg-slate-50 text-slate-600"),children:_.priority})})]},_.id)})})]})})}function cjs(){const t=ai();return wt({queryKey:["deal-tasks",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_tasks").select(` *, deal:deal_pipeline(id, deal_name, stage_id), contact:innercircle_contacts(id, first_name, last_name), stage:deal_pipeline_stages(id, name, color) `).eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function djs(t){const s=ai();return wt({queryKey:["deal-tasks","deal",t,s],queryFn:async()=>{if(!s||!t)return[];const{data:r,error:n}=await G.from("deal_tasks").select(` *, stage:deal_pipeline_stages(id, name, color) `).eq("owner_user_id",s).eq("deal_id",t).order("sort_order",{ascending:!0});if(n)throw n;return r},enabled:!!s&&!!t})}function ujs(){const t=ai(),s=ss();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("deal_tasks").insert({owner_user_id:t,title:r.title,description:r.description||null,deal_id:r.deal_id||null,contact_id:r.contact_id||null,stage_id:r.stage_id||null,priority:r.priority||"medium",status:r.status||"todo",due_date:r.due_date||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}function hjs(){const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("deal_tasks").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function mjs(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("deal_tasks").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function zSe(){const t=ss();return Dt({mutationFn:async({id:s,status:r})=>{const{data:n,error:a}=await G.from("deal_tasks").update({status:r,completed_at:r==="done"?new Date().toISOString():null}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function pjs(){const t=ss();return Dt({mutationFn:async s=>{if(s.length===0)return;const{error:r}=await G.from("deal_tasks").update({status:"done",completed_at:new Date().toISOString()}).in("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-tasks"]})}})}function fjs(t){const s=ai();return wt({queryKey:["deal-task-templates",s,t],queryFn:async()=>{if(!s)return[];let r=G.from("deal_task_templates").select("*").eq("owner_user_id",s).order("sort_order",{ascending:!0});t&&(r=r.eq("stage_id",t));const{data:n,error:a}=await r;if(a)throw a;return n},enabled:!!s})}function gjs(){const t=ai(),s=ss();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("deal_task_templates").insert({owner_user_id:t,stage_id:r.stage_id,title:r.title,description:r.description||null,priority:r.priority||"medium",default_due_offset_days:r.default_due_offset_days||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-task-templates"]})}})}function xjs(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("deal_task_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-task-templates"]})}})}function yjs(){const t=ai(),s=ss();return Dt({mutationFn:async({dealId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("deal_task_templates").select("*").eq("owner_user_id",t).eq("stage_id",n).order("sort_order");if(o)throw o;if(!a||a.length===0)return[];const{data:l}=await G.from("deal_tasks").select("title, stage_id").eq("deal_id",r).eq("stage_id",n),i=new Set((l||[]).map(f=>f.title)),c=a.filter(f=>!i.has(f.title)).map((f,y)=>({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:y,status:"todo"}));if(c.length===0)return[];const{data:u,error:p}=await G.from("deal_tasks").insert(c).select();if(p)throw p;return u},onSuccess:()=>{s.invalidateQueries({queryKey:["deal-tasks"]})}})}const vjs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function _js({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:c,isLoading:u}=djs(t?r:void 0),p=pjs(),f=yjs(),[y,_]=C.useState(new Set),[b,w]=C.useState(!1),j=(c||[]).filter(I=>I.status!=="done");C.useEffect(()=>{j.length>0&&_(new Set(j.map(I=>I.id)))},[c]);const N=I=>{_(L=>{const R=new Set(L);return R.has(I)?R.delete(I):R.add(I),R})},S=async()=>{w(!0);try{const I=Array.from(y);I.length>0&&await p.mutateAsync(I),await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move failed:",I),me.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{w(!1)}},T=async()=>{w(!0);try{await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move (skip) failed:",I),me.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{w(!1)}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-[480px]",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Move Deal"}),e.jsxs(Zr,{children:["Moving ",e.jsx("span",{className:"font-medium text-foreground",children:n})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2",children:[e.jsx(nt,{variant:"outline",className:"text-sm",children:a}),e.jsx(Ki,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(nt,{className:"text-sm bg-primary",children:o})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):j.length>0?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You have ",e.jsx("span",{className:"font-medium text-foreground",children:j.length})," incomplete task",j.length!==1?"s":"",". Select which to mark as done:"]}),e.jsx(Vi,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:j.map(I=>e.jsxs("label",{className:"flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-muted/50 cursor-pointer transition-colors",children:[e.jsx(Yo,{checked:y.has(I.id),onCheckedChange:()=>N(I.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[vjs[I.priority]," ",I.title]}),I.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full",style:{backgroundColor:I.stage.color+"20",color:I.stage.color},children:I.stage.name})]},I.id))})}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>{y.size===j.length?_(new Set):_(new Set(j.map(I=>I.id)))},children:y.size===j.length?"Deselect All":"Select All"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:T,disabled:b,children:"Skip"}),e.jsxs(K,{size:"sm",onClick:S,disabled:b,children:[b&&e.jsx(Ss,{className:"h-4 w-4 mr-1 animate-spin"}),y.size>0?`Complete ${y.size} & Move`:"Move Deal"]})]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-center py-4",children:[e.jsx(ha,{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:b,children:[b&&e.jsx(Ss,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function bjs(){const t=ai();return wt({queryKey:["all-client-portals",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("client_portals").select("*").eq("owner_user_id",t);if(r)throw r;return s||[]},enabled:!!t})}function wjs({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const c=F4e(),u=ZO(),p=u_s(),f=h_s(),[y,_]=C.useState(!1),b=!!(n!=null&&n.archived_at),w=async()=>{_(!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{_(!1)}},j=async L=>{if(n)try{await u.mutateAsync({id:n.id,is_enabled:L}),me.success(L?"Portal enabled":"Portal disabled")}catch{me.error("Failed to update portal")}},N=()=>{n&&(navigator.clipboard.writeText(h1(n.slug)),me.success("Link copied!"))},S=()=>{n&&window.open(h1(n.slug),"_blank")},T=async()=>{if(n)try{await p.mutateAsync(n.id),me.success("Portal archived")}catch{me.error("Failed to archive portal")}},I=async()=>{if(n)try{await f.mutateAsync(n.id),me.success("Portal restored")}catch{me.error("Failed to restore portal")}};return n?b?e.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg opacity-60 bg-muted/30",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx(nt,{variant:"outline",className:"text-[10px] bg-muted text-muted-foreground",children:"Archived"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:I,className:"text-xs gap-1",children:[e.jsx(SI,{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(jr,{className:"h-3.5 w-3.5"}),"Delete"]})]})]}):e.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx(nt,{variant:"outline",className:n.is_enabled?"text-[10px] bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-[10px] bg-muted text-muted-foreground",children:n.is_enabled?"Active":"Disabled"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||r||"No client name"})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:N,title:"Copy link",children:e.jsx(mi,{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(rn,{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(oa,{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(vM,{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(Jl,{className:"h-3.5 w-3.5"})}),e.jsxs(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(ig,{className:"h-3.5 w-3.5"})})}),e.jsx(Jd,{align:"end",children:e.jsxs(Ta,{onClick:T,children:[e.jsx(aM,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx(Br,{checked:n.is_enabled,onCheckedChange:j,className:"ml-1"})]})]}):e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg border-dashed bg-muted/20",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r||"No contact"})]}),e.jsxs(K,{size:"sm",onClick:w,disabled:y,className:"shrink-0 ml-4",children:[y?e.jsx(Ss,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(hn,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function jjs(){const{data:t,isLoading:s}=zhe(),{data:r,isLoading:n}=bjs(),[a,o]=C.useState(""),[l,i]=C.useState("all"),c=m_s(),[u,p]=C.useState(null),[f,y]=C.useState(null),[_,b]=C.useState(null),[w,j]=C.useState(null),N=ai(),S=s||n,T=new Map;r==null||r.forEach(V=>T.set(V.deal_id,V));const L=[...(t||[]).filter(V=>{var de,re,ne,le,he;const X=T.get(V.id),se=a.toLowerCase(),ee=!se||V.deal_name.toLowerCase().includes(se)||((re=(de=V.contact)==null?void 0:de.first_name)==null?void 0:re.toLowerCase().includes(se))||((le=(ne=V.contact)==null?void 0:ne.last_name)==null?void 0:le.toLowerCase().includes(se))||((he=X==null?void 0:X.client_name)==null?void 0:he.toLowerCase().includes(se));let Q=!0;return l==="active"?Q=!!(X!=null&&X.is_enabled)&&!(X!=null&&X.archived_at):l==="disabled"?Q=!!X&&!X.is_enabled&&!X.archived_at:l==="archived"?Q=!!(X!=null&&X.archived_at):l==="none"?Q=!X:l==="all"&&(Q=!(X!=null&&X.archived_at)||!X),ee&&Q})].sort((V,X)=>{const se=T.get(V.id),ee=T.get(X.id);if(se!=null&&se.archived_at&&!(ee!=null&&ee.archived_at))return 1;if(!(se!=null&&se.archived_at)&&(ee!=null&&ee.archived_at)||se&&!ee)return-1;if(!se&&ee)return 1;if(se&&ee){if(se.is_enabled&&!ee.is_enabled)return-1;if(!se.is_enabled&&ee.is_enabled)return 1}return 0}),R=(r==null?void 0:r.filter(V=>!V.archived_at).length)||0,$=(r==null?void 0:r.filter(V=>V.is_enabled&&!V.archived_at).length)||0,q=(r==null?void 0:r.filter(V=>V.archived_at).length)||0,U=async()=>{if(w)try{await c.mutateAsync({id:w.id,dealId:w.deal_id}),me.success("Portal permanently deleted"),j(null)}catch{me.error("Failed to delete portal")}};return S?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(Ss,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(hn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-medium",children:[R," Portals"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:[$," active · ",R-$," disabled",q>0&&` · ${q} archived`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search deals or clients...",value:a,onChange:V=>o(V.target.value),className:"pl-9 pr-8"}),a&&e.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Ur,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:["all","active","disabled","archived","none"].map(V=>e.jsx(K,{variant:l===V?"secondary":"ghost",size:"sm",onClick:()=>i(V),className:"text-xs px-3 capitalize",children:V==="none"?"No Portal":V},V))})]}),e.jsx(Vi,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[L.map(V=>{const X=T.get(V.id)||null,se=V.contact?`${V.contact.first_name||""} ${V.contact.last_name||""}`.trim():"";return e.jsx(wjs,{dealId:V.id,dealName:V.deal_name,contactName:se,portal:X,onSettingsOpen:p,onComposerOpen:ee=>y(ee),onInviteOpen:(ee,Q)=>b({portal:ee,dealName:Q}),onDeleteConfirm:j},V.id)}),L.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 bg-muted rounded-full flex items-center justify-center",children:e.jsx(hn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("p",{className:"text-sm font-medium",children:"No matching deals"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Try adjusting your search or filters"})]})]})})]}),u&&e.jsx(Bot,{open:!!u,onOpenChange:V=>!V&&p(null),portal:u,dealOwnerId:N||""}),f&&e.jsx($ot,{open:!!f,onOpenChange:V=>!V&&y(null),portalId:f.id,portalSlug:f.slug,notifyClient:f.notify_client}),_&&e.jsx(qot,{open:!!_,onOpenChange:V=>!V&&b(null),portal:_.portal,dealName:_.dealName}),e.jsx(gc,{open:!!w,onOpenChange:V=>!V&&j(null),children:e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Permanently delete this portal?"}),e.jsx(Gl,{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(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class kjs extends C.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(Es,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center h-[60vh] gap-4 text-center px-4",children:[e.jsx("div",{className:"w-16 h-16 bg-destructive/10 rounded-full flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"⚠️"})}),e.jsx("h2",{className:"text-xl font-semibold",children:"Something went wrong"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"There was an error in the deal pipeline. Click below to try again."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>this.setState({hasError:!1,error:null}),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md text-sm font-medium hover:bg-primary/90",children:"Try Again"}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 border border-border rounded-md text-sm font-medium hover:bg-muted",children:"Refresh Page"})]})]})}):this.props.children}}function Njs(){var ms;const t=oE(),{data:s,isLoading:r}=Fhe(),{data:n,isLoading:a,refetch:o}=zhe(),{data:l,isLoading:i}=abs(),c=Aat(),u=Q_s(),[p,f]=C.useState("board"),[y,_]=C.useState(!1),[b,w]=C.useState(!1),[j,N]=C.useState(null),[S,T]=C.useState(null),[I,L]=C.useState(null),[R,$]=C.useState(null),[q,U]=C.useState(!1),[V,X]=C.useState(null),[se,ee]=C.useState(""),[Q,de]=C.useState("all"),[re,ne]=C.useState(!1),[le,he]=C.useState(!1),[we,ye]=C.useState(new Set),[je,ke]=C.useState(null),{data:We}=Lg(),{isTeamLeader:be,teamMembers:Me}=Iws(),Ae=C.useMemo(()=>Array.from(we),[we]),{data:Re}=Lws(Ae),Te=C.useMemo(()=>{const Xt=new Map;return Me.forEach(rs=>Xt.set(rs.id,{name:rs.name,avatar_url:rs.avatar_url,color:rs.color})),Xt},[Me]),qe=C.useCallback(Xt=>Xt.owner_user_id&&Te.get(Xt.owner_user_id)||null,[Te]),ct=C.useCallback(Xt=>{ye(rs=>{const ps=new Set(rs);return ps.has(Xt)?ps.delete(Xt):ps.add(Xt),ps})},[]);C.useEffect(()=>{!r&&s&&s.length===0&&c.mutate()},[r,s]);const[De,Rt]=Xc(),pe=C.useRef(!1);C.useEffect(()=>{const Xt=De.get("deal");if(Xt&&n&&n.length>0&&!pe.current){const rs=n.find(ps=>ps.id===Xt);rs&&(pe.current=!0,N(rs),w(!0),De.delete("deal"),Rt(De,{replace:!0}))}},[n,De]);const Je=C.useMemo(()=>{if(!Re||!s)return[];const Xt=new Map(s.map(rs=>[rs.name,rs.id]));return Re.map(rs=>{const ps=rs._stage_name&&Xt.get(rs._stage_name)||null;return{...rs,stage_id:ps||rs.stage_id}})},[Re,s]),lt=C.useMemo(()=>[...n||[],...Je],[n,Je]),rt=lt.filter(Xt=>{var jt,As,Ps,ar,Dn,Va;const rs=se.toLowerCase(),ps=!rs||Xt.deal_name.toLowerCase().includes(rs)||((As=(jt=Xt.contact)==null?void 0:jt.first_name)==null?void 0:As.toLowerCase().includes(rs))||((ar=(Ps=Xt.contact)==null?void 0:Ps.last_name)==null?void 0:ar.toLowerCase().includes(rs))||((Dn=Xt.property_address)==null?void 0:Dn.toLowerCase().includes(rs))||((Va=Xt.city)==null?void 0:Va.toLowerCase().includes(rs)),Ms=Q==="all"||Xt.deal_type===Q;return ps&&Ms}),Se=C.useMemo(()=>{if(!s)return l||null;const Xt=new Set(s.filter(Ps=>Ps.is_won_stage).map(Ps=>Ps.id)),rs=new Set(s.filter(Ps=>Ps.is_lost_stage).map(Ps=>Ps.id)),ps=lt.filter(Ps=>Ps.stage_id&&!Xt.has(Ps.stage_id)&&!rs.has(Ps.stage_id)),Ms=lt.filter(Ps=>Ps.stage_id&&Xt.has(Ps.stage_id)),jt=new Date().getFullYear(),As=Ms.filter(Ps=>Ps.actual_close_date?new Date(Ps.actual_close_date).getFullYear()===jt:!0);return{totalDeals:lt.length,activeDeals:ps.length,wonDeals:Ms.length,pipelineValue:ps.reduce((Ps,ar)=>Ps+(ar.expected_price||0),0),expectedCommission:ps.reduce((Ps,ar)=>Ps+(ar.expected_commission||0),0),expectedNetToAgent:ps.reduce((Ps,ar)=>Ps+(dg(ar)||0),0),wonValue:Ms.reduce((Ps,ar)=>Ps+(ar.expected_price||0),0),weightedGCI:ps.reduce((Ps,ar)=>Ps+(ar.expected_commission||0)*((ar.probability??50)/100),0),weightedNet:ps.reduce((Ps,ar)=>Ps+(dg(ar)||0)*((ar.probability??50)/100),0),ytdWonDeals:As.length,ytdWonGCI:As.reduce((Ps,ar)=>Ps+(ar.expected_commission||0),0),ytdWonNet:As.reduce((Ps,ar)=>Ps+(dg(ar)||0),0),projectedAnnualNet:As.reduce((Ps,ar)=>Ps+(dg(ar)||0),0)+ps.reduce((Ps,ar)=>Ps+(dg(ar)||0)*((ar.probability??50)/100),0)}},[lt,s,l]),it=Xt=>{N(Xt),w(!0)},$e=Xt=>{T(Xt||null),N(null),_(!0)},ot=Xt=>{N(Xt),w(!1),_(!0)},Ue=(Xt,rs)=>{L(Xt)},Ke=(Xt,rs)=>{Xt.preventDefault(),Xt.dataTransfer.dropEffect="move",$(rs)},Xe=async(Xt,rs)=>{if(Xt.preventDefault(),$(null),!I)return;const ps=n==null?void 0:n.find(As=>As.id===I),Ms=s==null?void 0:s.find(As=>As.id===rs),jt=s==null?void 0:s.find(As=>As.id===(ps==null?void 0:ps.stage_id));if(!ps||!Ms||ps.stage_id===rs){L(null);return}ke({dealId:I,dealName:ps.deal_name,fromStageName:(jt==null?void 0:jt.name)||"Unknown",toStageName:Ms.name,toStageId:rs,isWonStage:Ms.is_won_stage,deal:ps}),L(null)},He=async()=>{if(!je)return;const{dealId:Xt,toStageId:rs,toStageName:ps,isWonStage:Ms,deal:jt}=je;if(await u.mutateAsync({dealId:Xt,stageId:rs,stageName:ps}),me.success(`Moved to ${ps}`),Ms&&!jt.scorecard_transaction_id){const As={...jt,stage_id:rs};X(As),U(!0)}},Ye=C.useCallback(async(Xt,rs,ps)=>{const Ms=n==null?void 0:n.find(Ps=>Ps.id===Xt),jt=s==null?void 0:s.find(Ps=>Ps.id===rs),As=s==null?void 0:s.find(Ps=>Ps.id===(Ms==null?void 0:Ms.stage_id));!Ms||!jt||Ms.stage_id===rs||ke({dealId:Xt,dealName:Ms.deal_name,fromStageName:(As==null?void 0:As.name)||"Unknown",toStageName:ps,toStageId:rs,isWonStage:jt.is_won_stage,deal:Ms})},[n,s]),tt=Xt=>rt.filter(rs=>rs.stage_id===Xt),Et=r||a,qt=t?"list":p;return e.jsxs(Es,{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(Bo,{className:"h-4 w-4"})}),!t&&e.jsx(x2,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(hd,{children:[e.jsx(md,{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(lf,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),e.jsx(Uc,{children:"Kanban board view"})]}),e.jsxs(hd,{children:[e.jsx(md,{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(Mm,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(Uc,{children:"Grouped list view"})]}),e.jsxs(hd,{children:[e.jsx(md,{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(jM,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(Uc,{children:"Sortable table view"})]}),e.jsxs(hd,{children:[e.jsx(md,{asChild:!0,children:e.jsxs(K,{variant:p==="portals"?"secondary":"ghost",size:"sm",onClick:()=>f("portals"),className:"px-3 gap-1.5",children:[e.jsx(hn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(Uc,{children:"Client portal management"})]})]})}),We&&!be&&e.jsxs(K,{variant:"outline",onClick:()=>ne(!0),children:[e.jsx(mr,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(K,{onClick:()=>$e(),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),qt!=="portals"&&e.jsx(Fws,{stats:Se,isLoading:i}),qt!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search deals, contacts, addresses...",value:se,onChange:Xt=>ee(Xt.target.value),className:"pl-9 pr-8"}),se&&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(Ur,{className:"h-4 w-4"})})]}),e.jsxs(rr,{value:Q,onValueChange:de,children:[e.jsx(tr,{className:"w-[140px]",children:e.jsx(nr,{placeholder:"All Types"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Types"}),e.jsx(Tt,{value:"buyer",children:"Buyer"}),e.jsx(Tt,{value:"seller",children:"Seller"}),e.jsx(Tt,{value:"dual",children:"Dual"}),e.jsx(Tt,{value:"referral",children:"Referral"}),e.jsx(Tt,{value:"lease",children:"Lease"})]})]}),(se||Q!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[rt.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[be&&!t&&Me.length>0&&e.jsx(Pws,{members:Me,enabledMembers:we,onToggleMember:ct,isOpen:le,onToggleOpen:()=>he(Xt=>!Xt)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:Et?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(Xt=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(xs,{className:"h-full rounded-xl"})},Xt))}):qt==="board"?e.jsxs(Vi,{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(Xt=>e.jsx(Rws,{stage:Xt,deals:tt(Xt.id),onDealClick:it,onAddDeal:$e,onDragStart:Ue,onDragOver:Ke,onDrop:Xe,isDragOver:R===Xt.id,isWonStage:Xt.is_won_stage,getOwnerInfo:qe},Xt.id))}),e.jsx(Kde,{orientation:"horizontal"})]}):qt==="table"?e.jsx(Vi,{className:"h-full",children:e.jsx(ljs,{deals:rt,stages:s||[],onDealClick:it,onStageChange:Ye})}):qt==="portals"?e.jsx(jjs,{}):e.jsx(Vi,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(Xt=>{const rs=tt(Xt.id);return rs.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Xt.color}}),e.jsx("h3",{className:"font-semibold",children:Xt.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",rs.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:rs.map(ps=>e.jsx(zot,{deal:ps,onClick:()=>it(ps),stages:s,onStageChange:Ye,showStagePicker:!0,isWonStage:Xt.is_won_stage,ownerInfo:qe(ps)},ps.id))})]},Xt.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(lf,{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:()=>$e(),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&rt.length===0&&e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center",children:e.jsx(xn,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No matching deals"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Try adjusting your search or filters"}),e.jsx(K,{variant:"outline",onClick:()=>{ee(""),de("all")},children:"Clear Filters"})]})]})})})]})]}),e.jsx(qws,{open:y,onOpenChange:_,deal:j,defaultStageId:S}),e.jsx(ajs,{deal:j,open:b,onOpenChange:w,onEdit:ot,isWonStage:j?(ms=s==null?void 0:s.find(Xt=>Xt.id===j.stage_id))==null?void 0:ms.is_won_stage:!1,onAddToScorecard:Xt=>{X(Xt),U(!0),w(!1)}}),e.jsx(ijs,{open:q,onOpenChange:U,deal:V,onComplete:()=>{o(),X(null)}}),je&&e.jsx(_js,{open:!!je,onOpenChange:Xt=>{Xt||ke(null)},dealId:je.dealId,dealName:je.dealName,fromStageName:je.fromStageName,toStageName:je.toStageName,toStageId:je.toStageId,onConfirm:He}),e.jsx(Aws,{open:re,onOpenChange:ne})]})}function Sjs(){return e.jsx(kjs,{children:e.jsx(Njs,{})})}function Uot({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var ee;const o=ujs(),l=hjs(),{data:i}=zhe(),c=ai(),{data:u}=wt({queryKey:["contacts-for-tasks",c],queryFn:async()=>{if(!c)return[];const{data:Q,error:de}=await G.from("innercircle_contacts").select("id, first_name, last_name").eq("owner_user_id",c).order("first_name").limit(500);if(de)throw de;return Q},enabled:!!c&&t}),[p,f]=C.useState(""),[y,_]=C.useState(""),[b,w]=C.useState("none"),[j,N]=C.useState("none"),[S,T]=C.useState("medium"),[I,L]=C.useState("todo"),[R,$]=C.useState(),[q,U]=C.useState(!1),[V,X]=C.useState(!1);C.useEffect(()=>{r?(f(r.title),_(r.description||""),w(r.deal_id||"none"),N(r.contact_id||"none"),T(r.priority),L(r.status),$(r.due_date?gm(r.due_date):void 0)):(f(""),_(""),w(n||"none"),N("none"),T("medium"),L("todo"),$(void 0))},[r,t,n]);const se=async()=>{if(!p.trim()){me.error("Task title is required");return}try{const Q={title:p.trim(),description:y.trim()||null,deal_id:b==="none"?null:b,contact_id:j==="none"?null:j,stage_id:a||null,priority:S,status:I,due_date:R?ys(R,"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(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-[480px]",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:r?"Edit Task":"New Task"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title *"}),e.jsx(Fe,{value:p,onChange:Q=>f(Q.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Description"}),e.jsx(Ar,{value:y,onChange:Q=>_(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(_e,{children:"Priority"}),e.jsxs(rr,{value:S,onValueChange:Q=>T(Q),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"low",children:"🟢 Low"}),e.jsx(Tt,{value:"medium",children:"🟡 Medium"}),e.jsx(Tt,{value:"high",children:"🟠 High"}),e.jsx(Tt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Status"}),e.jsxs(rr,{value:I,onValueChange:Q=>L(Q),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"todo",children:"To Do"}),e.jsx(Tt,{value:"in_progress",children:"In Progress"}),e.jsx(Tt,{value:"done",children:"Done"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Due Date"}),e.jsxs(Lo,{children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:At("w-full justify-start text-left font-normal",!R&&"text-muted-foreground"),children:[e.jsx(on,{className:"mr-2 h-4 w-4"}),R?ys(R,"PPP"):"Pick a date"]})}),e.jsx(Eo,{className:"w-auto p-0",align:"start",children:e.jsx(mf,{mode:"single",selected:R,onSelect:$,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Link to Deal"}),e.jsxs(Lo,{open:q,onOpenChange:U,children:[e.jsx(Do,{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(La,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),b!=="none"?((ee=i==null?void 0:i.find(Q=>Q.id===b))==null?void 0:ee.deal_name)||"Select deal":"No Deal"]}),e.jsx(xg,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Eo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Mg,{children:[e.jsx(Tg,{placeholder:"Search deals..."}),e.jsxs(Ag,{children:[e.jsx(Eg,{children:"No deals found."}),e.jsxs(Pg,{children:[e.jsxs(up,{value:"no-deal",onSelect:()=>{w("none"),U(!1)},children:[e.jsx(ma,{className:At("mr-2 h-4 w-4",b==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(Q=>e.jsxs(up,{value:Q.deal_name,onSelect:()=>{w(Q.id),U(!1)},children:[e.jsx(ma,{className:At("mr-2 h-4 w-4",b===Q.id?"opacity-100":"opacity-0")}),Q.deal_name]},Q.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Link to Contact"}),e.jsxs(Lo,{open:V,onOpenChange:X,children:[e.jsx(Do,{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(ro,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),j!=="none"?(()=>{const Q=u==null?void 0:u.find(de=>de.id===j);return Q?`${Q.first_name} ${Q.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(xg,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Eo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Mg,{children:[e.jsx(Tg,{placeholder:"Search contacts..."}),e.jsxs(Ag,{children:[e.jsx(Eg,{children:"No contacts found."}),e.jsxs(Pg,{children:[e.jsxs(up,{value:"no-contact",onSelect:()=>{N("none"),X(!1)},children:[e.jsx(ma,{className:At("mr-2 h-4 w-4",j==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(Q=>e.jsxs(up,{value:`${Q.first_name} ${Q.last_name}`,onSelect:()=>{N(Q.id),X(!1)},children:[e.jsx(ma,{className:At("mr-2 h-4 w-4",j===Q.id?"opacity-100":"opacity-0")}),Q.first_name," ",Q.last_name]},Q.id))]})]})]})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(K,{onClick:se,disabled:o.isPending||l.isPending,children:r?"Save Changes":"Create Task"})]})]})]})})}const Cjs={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 Mjs({tasks:t}){const s=zSe(),r=mjs(),n=Pr(),[a,o]=C.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(ha,{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(B7e,{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(La,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:f.dealName}),e.jsxs(nt,{variant:"secondary",className:"ml-auto text-xs",children:[f.tasks.filter(y=>y.status==="done").length,"/",f.tasks.length]}),e.jsx(Xa,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),f.tasks.map(y=>e.jsx(B7e,{task:y,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:_=>n(`/mission-control/pipeline?deal=${_}`)},y.id))]},p)),a&&e.jsx(Uot,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function B7e({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&u0(gm(t.due_date))&&!uu(gm(t.due_date)),i=!o&&t.due_date&&uu(gm(t.due_date)),c=Cjs[t.priority];return e.jsxs("div",{className:At("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(ha,{className:"h-5 w-5 text-emerald-500"}):e.jsx(pd,{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:At("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(ro,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]})]}),e.jsxs(nt,{variant:"outline",className:At("text-[10px] shrink-0",c.color),children:[c.dot," ",c.label]}),t.due_date&&e.jsxs("span",{className:At("text-xs shrink-0 flex items-center gap-1",l&&"text-destructive font-medium",i&&"text-amber-600 font-medium",!l&&!i&&"text-muted-foreground"),children:[e.jsx(Tn,{className:"h-3 w-3"}),ys(gm(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(rd,{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(jr,{className:"h-3.5 w-3.5 text-destructive"})})]})]})}const Tjs=[{status:"todo",label:"To Do",icon:pd,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:ap,color:"border-t-blue-500"},{status:"done",label:"Done",icon:ha,color:"border-t-emerald-500"}],Ajs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Ejs({tasks:t}){const s=zSe(),r=C.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:Tjs.map(o=>e.jsxs("div",{className:At("border rounded-lg border-t-4 bg-muted/20",o.color),onDragOver:l=>l.preventDefault(),onDrop:l=>a(l,o.status),children:[e.jsxs("div",{className:"px-4 py-3 flex items-center gap-2",children:[e.jsx(o.icon,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold text-sm",children:o.label}),e.jsx(nt,{variant:"secondary",className:"ml-auto text-xs",children:r[o.status].length})]}),e.jsxs("div",{className:"p-2 space-y-2 min-h-[200px]",children:[r[o.status].map(l=>e.jsx(Pjs,{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 Pjs({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&u0(gm(t.due_date))&&!uu(gm(t.due_date)),a=!r&&t.due_date&&uu(gm(t.due_date));return e.jsx("div",{draggable:!0,onDragStart:o=>s(o,t.id),className:At("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:Ajs[t.priority]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:At("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(La,{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(ro,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]}),t.due_date&&e.jsxs("div",{className:At("text-[10px] mt-1.5 flex items-center gap-1",n&&"text-destructive font-medium",a&&"text-amber-600 font-medium",!n&&!a&&"text-muted-foreground"),children:[e.jsx(Tn,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",ys(gm(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 $7e={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Ijs({tasks:t}){const[s,r]=C.useState(new Date),n=zSe(),a=Mc(s),o=eg(s),l=Uh(a),i=Ude(o),c=MNt({start:l,end:i}),u=C.useMemo(()=>{const y=new Map;return t.forEach(_=>{if(!_.due_date)return;const b=_.due_date,w=y.get(b)||[];w.push(_),y.set(b,w)}),y},[t]),p=C.useMemo(()=>t.filter(y=>!y.due_date),[t]),f=async y=>{const _=y.status==="done"?"todo":"done";try{await n.mutateAsync({id:y.id,status:_})}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(d4(s,1)),children:e.jsx(Xl,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:ys(s,"MMMM yyyy")}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(Em(s,1)),children:e.jsx(Xa,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"grid grid-cols-7 text-center",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(y=>e.jsx("div",{className:"text-xs font-medium text-muted-foreground py-2",children:y},y))}),e.jsx("div",{className:"grid grid-cols-7 border-l border-t",children:c.map(y=>{const _=ys(y,"yyyy-MM-dd"),b=u.get(_)||[],w=Hde(y,s),j=uu(y);return e.jsxs("div",{className:At("border-r border-b min-h-[100px] p-1",!w&&"bg-muted/30",j&&"bg-primary/5"),children:[e.jsx("div",{className:At("text-xs font-medium mb-1 text-right px-1",!w&&"text-muted-foreground/40",j&&"text-primary font-bold"),children:ys(y,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[b.slice(0,3).map(N=>e.jsxs("button",{onClick:()=>f(N),className:At("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",N.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[N.status==="done"?e.jsx(ha,{className:"h-2.5 w-2.5 text-emerald-500 shrink-0"}):e.jsx(pd,{className:"h-2.5 w-2.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[$7e[N.priority]," ",N.title]})]},N.id)),b.length>3&&e.jsxs("p",{className:"text-[9px] text-muted-foreground text-center",children:["+",b.length-3," more"]})]})]},_)})}),p.length>0&&e.jsxs("div",{className:"border rounded-lg p-3",children:[e.jsxs("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:["No Due Date (",p.length,")"]}),e.jsx("div",{className:"space-y-1",children:p.map(y=>e.jsxs("button",{onClick:()=>f(y),className:At("w-full text-left text-xs px-2 py-1.5 rounded flex items-center gap-2 hover:bg-muted transition-colors",y.status==="done"&&"opacity-50 line-through"),children:[y.status==="done"?e.jsx(ha,{className:"h-3.5 w-3.5 text-emerald-500 shrink-0"}):e.jsx(pd,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[$7e[y.priority]," ",y.title]}),y.deal&&e.jsxs("span",{className:"text-muted-foreground ml-auto shrink-0",children:["• ",y.deal.deal_name]})]},y.id))})]})]})}const Ljs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function Djs({open:t,onOpenChange:s,stages:r}){var N;const[n,a]=C.useState(((N=r[0])==null?void 0:N.id)||""),{data:o,isLoading:l}=fjs(n||void 0),i=gjs(),c=xjs(),[u,p]=C.useState(""),[f,y]=C.useState("medium"),[_,b]=C.useState(""),w=async()=>{if(!(!u.trim()||!n))try{await i.mutateAsync({stage_id:n,title:u.trim(),priority:f,default_due_offset_days:_?parseInt(_):null,sort_order:((o==null?void 0:o.length)||0)+1}),p(""),b(""),me.success("Template added")}catch{me.error("Failed to add template")}},j=async S=>{try{await c.mutateAsync(S),me.success("Template deleted")}catch{me.error("Failed to delete template")}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-[560px]",children:[e.jsx(Cs,{children:e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(RI,{className:"h-5 w-5"}),"Task Templates by Stage"]})}),e.jsx("p",{className:"text-sm text-muted-foreground -mt-2",children:"Create default tasks that auto-populate when a deal enters a stage."}),e.jsxs("div",{children:[e.jsx(_e,{children:"Pipeline Stage"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:r.filter(S=>!S.is_won_stage&&!S.is_lost_stage).map(S=>e.jsx("button",{onClick:()=>a(S.id),className:At("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(Vi,{className:"max-h-[250px]",children:e.jsxs("div",{className:"space-y-1.5",children:[o==null?void 0:o.map((S,T)=>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:Ljs[S.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:S.title}),S.default_due_offset_days&&e.jsxs(nt,{variant:"outline",className:"text-[10px]",children:["+",S.default_due_offset_days,"d"]}),e.jsx("button",{onClick:()=>j(S.id),className:"opacity-0 group-hover:opacity-100 p-1 hover:bg-destructive/10 rounded transition-opacity",children:e.jsx(jr,{className:"h-3.5 w-3.5 text-destructive"})})]},S.id)),(o==null?void 0:o.length)===0&&n&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No templates for this stage yet"})]})}),n&&e.jsxs("div",{className:"space-y-3 border-t pt-3",children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Add Template Task"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{placeholder:"Task title...",value:u,onChange:S=>p(S.target.value),className:"flex-1",onKeyDown:S=>S.key==="Enter"&&w()}),e.jsxs(rr,{value:f,onValueChange:S=>y(S),children:[e.jsx(tr,{className:"w-[100px]",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"low",children:"🟢 Low"}),e.jsx(Tt,{value:"medium",children:"🟡 Med"}),e.jsx(Tt,{value:"high",children:"🟠 High"}),e.jsx(Tt,{value:"urgent",children:"🔴 Urgent"})]})]})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(_e,{className:"text-xs",children:"Due offset (days from entering stage)"}),e.jsx(Fe,{type:"number",placeholder:"e.g., 7",value:_,onChange:S=>b(S.target.value)})]}),e.jsxs(K,{onClick:w,disabled:!u.trim()||i.isPending,children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function Ojs(){const{data:t,isLoading:s}=cjs(),{data:r}=Fhe(),[n,a]=C.useState("list"),[o,l]=C.useState(""),[i,c]=C.useState("active"),[u,p]=C.useState("all"),[f,y]=C.useState("all"),[_,b]=C.useState(!1),[w,j]=C.useState(!1),N=C.useMemo(()=>{if(!t)return[];const I=new Map;return t.forEach(L=>{L.deal&&I.set(L.deal.id,L.deal.deal_name)}),Array.from(I,([L,R])=>({id:L,name:R}))},[t]),S=C.useMemo(()=>t?t.filter(I=>{var V,X,se,ee;const L=o.toLowerCase(),R=!L||I.title.toLowerCase().includes(L)||((X=(V=I.deal)==null?void 0:V.deal_name)==null?void 0:X.toLowerCase().includes(L))||`${((se=I.contact)==null?void 0:se.first_name)||""} ${((ee=I.contact)==null?void 0:ee.last_name)||""}`.toLowerCase().includes(L),$=i==="all"||i==="active"&&I.status!=="done"||i==="todo"&&I.status==="todo"||i==="in_progress"&&I.status==="in_progress"||i==="done"&&I.status==="done"||i==="overdue"&&I.status!=="done"&&I.due_date&&u0(gm(I.due_date))&&!uu(gm(I.due_date)),q=u==="all"||I.priority===u,U=f==="all"||f==="no_deal"&&!I.deal_id||I.deal_id===f;return R&&$&&q&&U}):[],[t,o,i,u,f]),T=C.useMemo(()=>{if(!t)return{total:0,overdue:0,dueToday:0,dueThisWeek:0,completed:0};const I=t.filter(L=>L.status!=="done");return{total:I.length,overdue:I.filter(L=>L.due_date&&u0(gm(L.due_date))&&!uu(gm(L.due_date))).length,dueToday:I.filter(L=>L.due_date&&uu(gm(L.due_date))).length,dueThisWeek:I.filter(L=>L.due_date&&kSt(gm(L.due_date))).length,completed:t.filter(L=>L.status==="done").length}},[t]);return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-6 max-w-[1600px] mx-auto",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Tasks"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage tasks across deals and contacts"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>j(!0),children:[e.jsx(a0,{className:"h-4 w-4 mr-1"}),"Templates"]}),e.jsxs(K,{size:"sm",onClick:()=>b(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"}),"New Task"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[e.jsxs("button",{onClick:()=>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(Mm,{className:"h-3.5 w-3.5"}),"Active"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:T.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(uh,{className:"h-3.5 w-3.5"}),"Overdue"]}),e.jsx("p",{className:"text-xl font-bold mt-1 text-destructive",children:T.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(Tn,{className:"h-3.5 w-3.5"}),"Due Today"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:T.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(Md,{className:"h-3.5 w-3.5"}),"This Week"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:T.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(ha,{className:"h-3.5 w-3.5"}),"Completed"]}),e.jsx("p",{className:"text-xl font-bold mt-1",children:T.completed})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 items-start md:items-center",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search tasks...",value:o,onChange:I=>l(I.target.value),className:"pl-9"})]}),e.jsxs(rr,{value:u,onValueChange:p,children:[e.jsx(tr,{className:"w-[130px]",children:e.jsx(nr,{placeholder:"Priority"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Priorities"}),e.jsx(Tt,{value:"urgent",children:"🔴 Urgent"}),e.jsx(Tt,{value:"high",children:"🟠 High"}),e.jsx(Tt,{value:"medium",children:"🟡 Medium"}),e.jsx(Tt,{value:"low",children:"🟢 Low"})]})]}),e.jsxs(rr,{value:f,onValueChange:y,children:[e.jsx(tr,{className:"w-[160px]",children:e.jsx(nr,{placeholder:"Deal"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Deals"}),e.jsx(Tt,{value:"no_deal",children:"No Deal"}),N.map(I=>e.jsx(Tt,{value:I.id,children:I.name},I.id))]})]}),e.jsxs("div",{className:"flex items-center border rounded-lg p-0.5 ml-auto",children:[e.jsx("button",{onClick:()=>a("list"),className:`p-1.5 rounded-md transition-colors ${n==="list"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:e.jsx(Mm,{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(i0,{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(Md,{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(Mjs,{tasks:S}),n==="kanban"&&e.jsx(Ejs,{tasks:S}),n==="calendar"&&e.jsx(Ijs,{tasks:S})]}),e.jsx(Uot,{open:_,onOpenChange:b}),e.jsx(Djs,{open:w,onOpenChange:j,stages:r||[]})]})})}const Zbe=[{value:"video_intro",label:"Video Intro",icon:Nn,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:YI,description:"Client testimonials carousel"},{value:"specialties",label:"Specialties",icon:Tm,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:sl,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:Ad,description:"Links to your social profiles"}],Rjs=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],Fjs={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function Vot({cardId:t}){const{data:s,isLoading:r}=jkt(t),n=kkt(),a=Nkt(),o=Skt(),[l,i]=C.useState(!1),[c,u]=C.useState(""),[p,f]=C.useState(null);if(r)return e.jsxs("div",{className:"space-y-3",children:[e.jsx(xs,{className:"h-16 w-full"}),e.jsx(xs,{className:"h-16 w-full"})]});const y=()=>{c&&n.mutate({card_id:t,block_type:c,sort_order:(s==null?void 0:s.length)||0,config:Fjs[c]||{}},{onSuccess:()=>{i(!1),u("")}})},_=S=>{a.mutate({id:S.id,is_visible:!S.is_visible})},b=(S,T)=>{if(!s)return;const I=s.findIndex($=>$.id===S.id),L=T==="up"?I-1:I+1;if(L<0||L>=s.length)return;const R=s[L];a.mutate({id:S.id,sort_order:R.sort_order}),a.mutate({id:R.id,sort_order:S.sort_order})},w=S=>{confirm("Remove this block from this card?")&&o.mutate(S.id)},j=(S,T)=>{a.mutate({id:S.id,config:T},{onSuccess:()=>f(null)})},N=S=>Zbe.find(T=>T.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(Zs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}):e.jsxs(e.Fragment,{children:[s.map((S,T)=>{const I=N(S.block_type),L=(I==null?void 0:I.icon)||Tm;return e.jsx(Ee,{className:S.is_visible?"":"opacity-50",children:e.jsx(Oe,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yh,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx(L,{className:"h-4 w-4 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs",children:(I==null?void 0:I.label)||S.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:zjs(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:()=>b(S,"up"),disabled:T===0,children:e.jsx(gu,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(S,"down"),disabled:T===s.length-1,children:e.jsx(Oh,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(S),children:S.is_visible?e.jsx(va,{className:"h-3 w-3"}):e.jsx(xp,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>f(S),children:"Edit"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>w(S),children:e.jsx(jr,{className:"h-3 w-3"})})]})]})})},S.id)}),e.jsxs(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>i(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}),e.jsx(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Add Block"})}),e.jsx("div",{className:"grid gap-3",children:Zbe.map(S=>{const T=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(T,{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(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{onClick:y,disabled:!c||n.isPending,children:"Add Block"})]})]})}),p&&e.jsx(Bjs,{block:p,onSave:S=>j(p,S),onClose:()=>f(null)})]})}function zjs(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 Bjs({block:t,onSave:s,onClose:r}){const[n,a]=C.useState(t.config),o=Zbe.find(l=>l.value===t.block_type);return e.jsx(_s,{open:!0,onOpenChange:r,children:e.jsxs(vs,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:["Edit ",o==null?void 0:o.label]})}),t.block_type==="video_intro"&&e.jsx($js,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx(qjs,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(Ujs,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx(Vjs,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(Hjs,{config:n,onChange:a}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(K,{onClick:()=>s(n),children:"Save"})]})]})})}function $js({config:t,onChange:s,cardId:r}){var _,b;const[n,a]=C.useState(""),[o,l]=C.useState((_=t.video_url)!=null&&_.includes("youtube")||(b=t.video_url)!=null&&b.includes("youtu.be")?"youtube":"library"),{data:i}=wt({queryKey:["card-owner",r],queryFn:async()=>{const{data:w}=await G.from("agent_cards").select("user_id").eq("id",r).single();return w==null?void 0:w.user_id},enabled:!!r}),{data:c,isLoading:u}=wt({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:w,error:j}=await G.from("agent_videos").select("id, title, bunny_video_id, thumbnail_url, playback_url, created_at").eq("owner_user_id",i).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1});if(j)throw j;return w||[]},enabled:!!i}),p=(c==null?void 0:c.filter(w=>!n||(w.title||"").toLowerCase().includes(n.toLowerCase())))||[],f=t.bunny_video_id,y=w=>{var T;const j=(T=w.playback_url)==null?void 0:T.match(/\/(?:play|embed)\/(\d+)\//),S=`https://iframe.mediadelivery.net/embed/${j?j[1]:"570924"}/${w.bunny_video_id}?autoplay=false&responsive=true`;s({...t,video_url:S,bunny_video_id:w.bunny_video_id,video_source:"library"})};return e.jsx("div",{className:"space-y-4",children:e.jsxs(Aa,{value:o,onValueChange:l,children:[e.jsxs(ja,{className:"w-full",children:[e.jsx(js,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(js,{value:"youtube",className:"flex-1",children:"YouTube URL"})]}),e.jsxs($s,{value:"library",className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search videos...",value:n,onChange:w=>a(w.target.value),className:"pl-9"})]}),e.jsx(Vi,{className:"h-[240px]",children:u?e.jsxs("div",{className:"space-y-2",children:[e.jsx(xs,{className:"h-14 w-full"}),e.jsx(xs,{className:"h-14 w-full"})]}):p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:(c==null?void 0:c.length)===0?"No videos in library yet":"No matching videos"}):e.jsx("div",{className:"space-y-1.5 pr-3",children:p.map(w=>e.jsxs("button",{onClick:()=>y(w),className:`w-full flex items-center gap-3 p-2 rounded-lg border text-left transition-colors ${f===w.bunny_video_id?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[w.thumbnail_url?e.jsx("img",{src:w.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:j=>{var N;j.currentTarget.style.display="none",(N=j.currentTarget.nextElementSibling)==null||N.classList.remove("hidden")}}):null,e.jsx("div",{className:`h-10 w-16 rounded bg-muted flex items-center justify-center flex-shrink-0 ${w.thumbnail_url?"hidden":""}`,children:e.jsx(Nn,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:w.title||"Untitled Video"}),f===w.bunny_video_id&&e.jsx(ma,{className:"h-4 w-4 text-primary flex-shrink-0"})]},w.id))})})]}),e.jsx($s,{value:"youtube",className:"space-y-3 mt-3",children:e.jsxs("div",{children:[e.jsx(_e,{children:"YouTube URL"}),e.jsx(Fe,{placeholder:"https://www.youtube.com/watch?v=...",value:t.video_source==="youtube"&&t.video_url||"",onChange:w=>s({...t,video_url:w.target.value,bunny_video_id:null,video_source:"youtube"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Paste a YouTube video link"})]})})]})})}function qjs({config:t,onChange:s}){const r=t.testimonials||[],n=(l,i,c)=>{const u=[...r];u[l]={...u[l],[i]:c},s({...t,testimonials:u})},a=()=>s({...t,testimonials:[...r,{name:"",quote:"",role:""}]}),o=l=>s({...t,testimonials:r.filter((i,c)=>c!==l)});return e.jsxs("div",{className:"space-y-4",children:[r.map((l,i)=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(_e,{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(jr,{className:"h-3 w-3"})})]}),e.jsx(Fe,{placeholder:"Client name",value:l.name,onChange:c=>n(i,"name",c.target.value)}),e.jsx(Fe,{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(Zs,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function Ujs({config:t,onChange:s}){const r=t.tags||[],[n,a]=C.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(_e,{className:"text-sm mb-2 block",children:"Preset Specialties"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Rjs.map(i=>e.jsx("button",{onClick:()=>o(i),className:`px-3 py-1.5 text-xs rounded-full border transition-colors ${r.includes(i)?"bg-primary text-primary-foreground border-primary":"bg-muted border-border hover:bg-muted/80"}`,children:i},i))})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm mb-2 block",children:"Custom Tag"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{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(_e,{className:"text-xs text-muted-foreground mb-1 block",children:["Selected (",r.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(i=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs bg-primary/10 text-primary rounded-full",children:[i,e.jsx("button",{onClick:()=>o(i),className:"hover:text-destructive",children:"×"})]},i))})]})]})}function Vjs({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(Fe,{placeholder:"Button label",value:l.label,onChange:c=>n(i,"label",c.target.value)}),e.jsx(Fe,{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(jr,{className:"h-3 w-3"})})]},i)),e.jsxs(K,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const q7e=[{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 Hjs({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=q7e.filter(c=>!r.find(u=>u.platform===c.value)),i=c=>{const u=yve[c],p=q7e.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(Fe,{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(jr,{className:"h-3.5 w-3.5"})})]},u)})}),l.length>0&&e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-muted-foreground mb-2 block",children:"Add a platform"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(c=>{const u=yve[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 Wjs=Object.defineProperty,Wce=Object.getOwnPropertySymbols,Hot=Object.prototype.hasOwnProperty,Wot=Object.prototype.propertyIsEnumerable,U7e=(t,s,r)=>s in t?Wjs(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,Ybe=(t,s)=>{for(var r in s||(s={}))Hot.call(s,r)&&U7e(t,r,s[r]);if(Wce)for(var r of Wce(s))Wot.call(s,r)&&U7e(t,r,s[r]);return t},Xbe=(t,s)=>{var r={};for(var n in t)Hot.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Wce)for(var n of Wce(t))s.indexOf(n)<0&&Wot.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var qS;(t=>{const s=class uo{constructor(c,u,p,f){if(this.version=c,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],cuo.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 y=[];for(let b=0;b7)throw new RangeError("Invalid value");let b,w;for(b=p;;b++){const T=uo.getNumDataCodewords(b,u)*8,I=l.getTotalBits(c,b);if(I<=T){w=I;break}if(b>=f)throw new RangeError("Data too long")}for(const T of[uo.Ecc.MEDIUM,uo.Ecc.QUARTILE,uo.Ecc.HIGH])_&&w<=uo.getNumDataCodewords(b,T)*8&&(u=T);let j=[];for(const T of c){r(T.mode.modeBits,4,j),r(T.numChars,T.mode.numCharCountBits(b),j);for(const I of T.getData())j.push(I)}a(j.length==w);const N=uo.getNumDataCodewords(b,u)*8;a(j.length<=N),r(0,Math.min(4,N-j.length),j),r(0,(8-j.length%8)%8,j),a(j.length%8==0);for(let T=236;j.lengthS[I>>>3]|=T<<7-(I&7)),new uo(b,u,S,y)}getModule(c,u){return 0<=c&&c>>9)*1335;const f=(u<<10|p)^21522;a(f>>>15==0);for(let y=0;y<=5;y++)this.setFunctionModule(8,y,n(f,y));this.setFunctionModule(8,7,n(f,6)),this.setFunctionModule(8,8,n(f,7)),this.setFunctionModule(7,8,n(f,8));for(let y=9;y<15;y++)this.setFunctionModule(14-y,8,n(f,y));for(let y=0;y<8;y++)this.setFunctionModule(this.size-1-y,8,n(f,y));for(let y=8;y<15;y++)this.setFunctionModule(8,this.size-15+y,n(f,y));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),y=this.size-11+p%3,_=Math.floor(p/3);this.setFunctionModule(y,_,f),this.setFunctionModule(_,y,f)}}drawFinderPattern(c,u){for(let p=-4;p<=4;p++)for(let f=-4;f<=4;f++){const y=Math.max(Math.abs(f),Math.abs(p)),_=c+f,b=u+p;0<=_&&_{(T!=w-y||L>=b)&&S.push(I[T])});return a(S.length==_),S}drawCodewords(c){if(c.length!=Math.floor(uo.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(b,w),_||(c+=this.finderPenaltyCountPatterns(w)*uo.PENALTY_N3),_=this.modules[y][j],b=1);c+=this.finderPenaltyTerminateAndCount(_,b,w)*uo.PENALTY_N3}for(let y=0;y5&&c++):(this.finderPenaltyAddHistory(b,w),_||(c+=this.finderPenaltyCountPatterns(w)*uo.PENALTY_N3),_=this.modules[j][y],b=1);c+=this.finderPenaltyTerminateAndCount(_,b,w)*uo.PENALTY_N3}for(let y=0;y_+(b?1:0),u);const p=this.size*this.size,f=Math.ceil(Math.abs(u*20-p*10)/p)-1;return a(0<=f&&f<=9),c+=f*uo.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.lengthuo.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(uo.getNumRawDataModules(c)/8)-uo.ECC_CODEWORDS_PER_BLOCK[u.ordinal][c]*uo.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 y=f^p.shift();p.push(0),u.forEach((_,b)=>p[b]^=uo.reedSolomonMultiply(_,y))}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 td{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 td(td.Mode.BYTE,c.length,u)}static makeNumeric(c){if(!td.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={}))})(qS||(qS={}));(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={}))})(qS||(qS={}));var Z5=qS;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var Gjs={L:Z5.QrCode.Ecc.LOW,M:Z5.QrCode.Ecc.MEDIUM,Q:Z5.QrCode.Ecc.QUARTILE,H:Z5.QrCode.Ecc.HIGH},Got=128,Kot="L",Zot="#FFFFFF",Yot="#000000",Xot=!1,Qot=1,Kjs=4,Zjs=0,Yjs=.1;function Jot(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 elt(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 Xjs(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*Yjs),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 y=null;if(n.excavate){let b=Math.floor(u),w=Math.floor(p),j=Math.ceil(i+u-b),N=Math.ceil(c+p-w);y={x:b,y:w,w:j,h:N}}const _=n.crossOrigin;return{x:u,y:p,h:c,w:i,excavation:y,opacity:f,crossOrigin:_}}function Qjs(t,s){return s!=null?Math.max(Math.floor(s),0):t?Kjs:Zjs}function tlt({value:t,level:s,minVersion:r,includeMargin:n,marginSize:a,imageSettings:o,size:l,boostLevel:i}){let c=ht.useMemo(()=>{const b=(Array.isArray(t)?t:[t]).reduce((w,j)=>(w.push(...Z5.QrSegment.makeSegments(j)),w),[]);return Z5.QrCode.encodeSegments(b,Gjs[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:u,margin:p,numCells:f,calculatedImageSettings:y}=ht.useMemo(()=>{let _=c.getModules();const b=Qjs(n,a),w=_.length+b*2,j=Xjs(_,l,b,o);return{cells:_,margin:b,numCells:w,calculatedImageSettings:j}},[c,l,o,n,a]);return{qrcode:c,margin:p,cells:u,numCells:f,calculatedImageSettings:y}}var Jjs=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),eks=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=Got,level:l=Kot,bgColor:i=Zot,fgColor:c=Yot,includeMargin:u=Xot,minVersion:p=Qot,boostLevel:f,marginSize:y,imageSettings:_}=n,w=Xbe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:j}=w,N=Xbe(w,["style"]),S=_==null?void 0:_.src,T=ht.useRef(null),I=ht.useRef(null),L=ht.useCallback(Q=>{T.current=Q,typeof r=="function"?r(Q):r&&(r.current=Q)},[r]),[R,$]=ht.useState(!1),{margin:q,cells:U,numCells:V,calculatedImageSettings:X}=tlt({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:y,imageSettings:_,size:o});ht.useEffect(()=>{if(T.current!=null){const Q=T.current,de=Q.getContext("2d");if(!de)return;let re=U;const ne=I.current,le=X!=null&&ne!==null&&ne.complete&&ne.naturalHeight!==0&&ne.naturalWidth!==0;le&&X.excavation!=null&&(re=elt(U,X.excavation));const he=window.devicePixelRatio||1;Q.height=Q.width=o*he;const we=o/V*he;de.scale(we,we),de.fillStyle=i,de.fillRect(0,0,V,V),de.fillStyle=c,Jjs?de.fill(new Path2D(Jot(re,q))):U.forEach(function(ye,je){ye.forEach(function(ke,We){ke&&de.fillRect(We+q,je+q,1,1)})}),X&&(de.globalAlpha=X.opacity),le&&de.drawImage(ne,X.x+q,X.y+q,X.w,X.h)}}),ht.useEffect(()=>{$(!1)},[S]);const se=Ybe({height:o,width:o},j);let ee=null;return S!=null&&(ee=ht.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{$(!0)},ref:I,crossOrigin:X==null?void 0:X.crossOrigin})),ht.createElement(ht.Fragment,null,ht.createElement("canvas",Ybe({style:se,height:o,width:o,ref:L,role:"img"},N)),ee)});eks.displayName="QRCodeCanvas";var nR=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=Got,level:l=Kot,bgColor:i=Zot,fgColor:c=Yot,includeMargin:u=Xot,minVersion:p=Qot,boostLevel:f,title:y,marginSize:_,imageSettings:b}=n,w=Xbe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:j,cells:N,numCells:S,calculatedImageSettings:T}=tlt({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:_,imageSettings:b,size:o});let I=N,L=null;b!=null&&T!=null&&(T.excavation!=null&&(I=elt(N,T.excavation)),L=ht.createElement("image",{href:b.src,height:T.h,width:T.w,x:T.x+j,y:T.y+j,preserveAspectRatio:"none",opacity:T.opacity,crossOrigin:T.crossOrigin}));const R=Jot(I,j);return ht.createElement("svg",Ybe({height:o,width:o,viewBox:`0 0 ${S} ${S}`,ref:r,role:"img"},w),!!y&&ht.createElement("title",null,y),ht.createElement("path",{fill:i,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),ht.createElement("path",{fill:c,d:R,shapeRendering:"crispEdges"}),L)});nR.displayName="QRCodeSVG";function tks({slug:t,agentName:s}){const r=C.useRef(null),n=`https://cards.relevelup.com/${t}`,a=C.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 y=document.createElement("a");y.download=`${t}-qr-code.png`,y.href=l.toDataURL("image/png"),y.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(_e,{className:"text-sm font-medium",children:"QR Code"}),e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{ref:r,className:"bg-white p-3 rounded-lg border shadow-sm shrink-0",children:e.jsx(nR,{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(ki,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function gye(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 sks(){const{user:t}=Ws(),{data:s,isLoading:r}=_kt(t==null?void 0:t.id),n=oE(),[a,o]=C.useState(null),l=C.useMemo(()=>a||(s?gye(s):null),[a,s]);if(r)return e.jsx(Es,{children:e.jsxs("div",{className:"max-w-2xl mx-auto p-4 space-y-4",children:[e.jsx(xs,{className:"h-8 w-48"}),e.jsx(xs,{className:"h-32 w-full"}),e.jsx(xs,{className:"h-32 w-full"})]})});if(!s)return e.jsx(Es,{children:e.jsx(nks,{userId:t==null?void 0:t.id})});const i=l||gye(s),c=u=>{o(p=>{const f=p||gye(s);return typeof u=="function"?u(f):u})};return e.jsx(Es,{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(aks,{card:s}),e.jsx(cks,{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(H4,{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(rks,{card:s,form:i})})]})})]})})}function rks({card:t,form:s}){const{data:r}=wt({queryKey:["card-preview-profile",t.user_id],queryFn:async()=>{const{data:a}=await G.from("profiles").select("name, email, phone, avatar_url, brokerage_id").eq("id",t.user_id).single();let o=(a==null?void 0:a.avatar_url)||null;if(!o){const{data:l}=await G.storage.from("avatars").list(`${t.user_id}`);if(l&&l.length>0){const{data:i}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${l[0].name}`);o=`${i.publicUrl}?t=${Date.now()}`}}return{...a,avatar_url:o}}}),n=C.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(Qwe,{card:n})})}function nks({userId:t}){var c;const[s,r]=C.useState(""),n=kWe(),{data:a}=wt({queryKey:["my-profile-for-card",t],queryFn:async()=>{if(!t)return null;const{data:u}=await G.from("profiles").select("name").eq("id",t).single();return u},enabled:!!t}),o=((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:yp,title:"Shareable Link",desc:"One link that works everywhere"},{icon:wp,title:"Lead Capture",desc:"Collect leads automatically"},{icon:Bh,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:Ql,title:"Fully Customizable",desc:"Themes, colors, and content blocks"}];return e.jsxs("div",{className:"max-w-2xl mx-auto p-4 animate-fade-in",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary/90 via-primary to-primary/80 p-8 md:p-12 mb-8 text-primary-foreground",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_30%_20%,rgba(255,255,255,0.15),transparent_50%)]"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_80%_80%,rgba(0,0,0,0.1),transparent_50%)]"}),e.jsxs("div",{className:"relative z-10",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-white/20 backdrop-blur-sm text-sm font-medium mb-4",children:[e.jsx(hn,{className:"h-3.5 w-3.5"}),"New Feature"]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3 tracking-tight",children:"Your Digital Business Card"}),e.jsx("p",{className:"text-primary-foreground/80 text-lg max-w-md leading-relaxed",children:"Ditch the paper. Share a beautiful, interactive card that captures leads and makes a lasting impression."})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 mb-8",children:i.map(u=>e.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl border bg-card hover:shadow-md transition-shadow",children:[e.jsx("div",{className:"mt-0.5 p-2 rounded-lg bg-primary/10 shrink-0",children:e.jsx(u.icon,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:u.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u.desc})]})]},u.title))}),e.jsxs(Ee,{className:"shadow-lg border-2",children:[e.jsxs(It,{className:"text-center pb-2",children:[e.jsx(Ot,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(fr,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),e.jsxs(Oe,{className:"p-6 pt-2 space-y-5",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-medium",children:"Your Card URL"}),e.jsxs("div",{className:"flex items-center gap-0 mt-1.5",children:[e.jsx("span",{className:"inline-flex items-center px-3 h-10 rounded-l-md border border-r-0 bg-muted text-sm text-muted-foreground whitespace-nowrap",children:"cards.relevelup.com/"}),e.jsx(Fe,{value:s||o,onChange:u=>r(u.target.value),placeholder:"your-name",className:"rounded-l-none"})]})]}),e.jsxs(K,{onClick:l,disabled:n.isPending,className:"w-full h-11 text-base font-semibold",size:"lg",children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function aks({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(nt,{variant:t.is_published?"default":"secondary",className:"text-[10px] uppercase tracking-wider",children:t.is_published?"Live":"Draft"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(yp,{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(mi,{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(rn,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function iks({userId:t}){const s=ss(),r=C.useRef(null),[n,a]=C.useState(!1),[o,l]=C.useState(""),{data:i,isLoading:c}=wt({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:X}=await G.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let se=(X==null?void 0:X.avatar_url)||null;if(!se){const{data:ee}=await G.storage.from("avatars").list(`${t}`);if(ee&&ee.length>0){const{data:Q}=G.storage.from("avatars").getPublicUrl(`${t}/${ee[0].name}`);se=`${Q.publicUrl}?t=${Date.now()}`,await G.from("profiles").update({avatar_url:se}).eq("id",t)}}return{...X,avatar_url:se}}}),[u,p]=C.useState(null),[f,y]=C.useState(null),[_,b]=C.useState(null),[w,j]=C.useState(!1),N=u??(i==null?void 0:i.name)??"",S=f??(i==null?void 0:i.phone)??"",T=_??(i==null?void 0:i.email)??"",I=i==null?void 0:i.avatar_url,L=((i==null?void 0:i.name)||"A").split(" ").map(X=>X[0]).join("").toUpperCase().slice(0,2),R=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),$=Dt({mutationFn:async X=>{const{error:se}=await G.from("profiles").update(X).eq("id",t);if(se)throw se},onSuccess:()=>{s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),me.success("Profile updated!")},onError:()=>me.error("Failed to update profile")}),q=()=>{const X={};if(u!==null&&u!==(i==null?void 0:i.name)&&(X.name=u),f!==null&&f!==(i==null?void 0:i.phone)&&(X.phone=f||null),_!==null&&_!==(i==null?void 0:i.email)&&(X.email=_),Object.keys(X).length===0){me.info("No changes to save");return}$.mutate(X)},U=X=>{var Q;const se=(Q=X.target.files)==null?void 0:Q[0];if(!se)return;if(!se.type.startsWith("image/")){me.error("Please select an image file");return}const ee=new FileReader;ee.onloadend=()=>{l(ee.result),a(!0)},ee.readAsDataURL(se),X.target.value=""},V=async X=>{j(!0);try{const{data:se}=await G.storage.from("avatars").list(`${t}`);se&&se.length>0&&await G.storage.from("avatars").remove(se.map(ne=>`${t}/${ne.name}`));const ee=`${t}/avatar.jpg`,{error:Q}=await G.storage.from("avatars").upload(ee,X,{upsert:!0,contentType:"image/jpeg"});if(Q)throw Q;const{data:de}=G.storage.from("avatars").getPublicUrl(ee),re=de.publicUrl+"?t="+Date.now();await G.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{j(!1)}};return c?e.jsx(xs,{className:"h-32 w-full rounded-xl"}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:R?"border-amber-300 dark:border-amber-700":"",children:e.jsxs(Oe,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(_e,{className:"text-sm font-semibold",children:"Profile Info"}),R&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 font-medium",children:[e.jsx(yl,{className:"h-3 w-3"}),"Missing info — complete below so your card looks great"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground -mt-3",children:"This info shows on your digital card and updates your profile everywhere."}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative group cursor-pointer",onClick:()=>{var X;return(X=r.current)==null?void 0:X.click()},children:[e.jsxs(yn,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx(Da,{src:I||void 0,alt:N}),e.jsx(vn,{className:"text-lg font-semibold bg-primary/10 text-primary",children:L})]}),e.jsx("div",{className:"absolute inset-0 bg-black/40 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Vx,{className:"h-5 w-5 text-white"})}),e.jsx("input",{ref:r,type:"file",accept:"image/*",className:"hidden",onChange:U})]}),e.jsxs("div",{className:"flex-1 space-y-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:w?"Uploading...":I?"Tap to change photo":"Add a profile photo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This photo appears on your card, profile, and community posts"})]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),e.jsx(Fe,{value:N,onChange:X=>p(X.target.value),placeholder:"Your full name",className:"h-10"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Phone Number"}),e.jsx(Fe,{value:S,onChange:X=>y(X.target.value),placeholder:"(555) 123-4567",className:"h-10",type:"tel"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Email"}),e.jsx(Fe,{value:T,onChange:X=>b(X.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:q,disabled:$.isPending,className:"w-full",children:$.isPending?"Saving...":"Update Profile Info"})]})}),e.jsx(sNe,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:V,aspectRatio:1})]})}function oks({form:t,setForm:s,userId:r}){const[n,a]=C.useState(null),[o,l]=C.useState(t.brokerage_logo_url?"logo":"name"),[i,c]=C.useState(t.team_logo_url?"logo":"name"),u=_=>{l(_),s(_==="name"?b=>({...b,brokerage_logo_url:""}):b=>({...b,brokerage_display_name:""}))},p=_=>{c(_),s(_==="name"?b=>({...b,team_logo_url:""}):b=>({...b,team_name:""}))},f=async(_,b)=>{var j;const w=(j=_.target.files)==null?void 0:j[0];if(w){if(!w.type.startsWith("image/")){me.error("Please select an image file");return}a(b);try{const N=w.name.split(".").pop()||"png",T=`${r}/${b==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${N}`,{error:I}=await G.storage.from("card-logos").upload(T,w,{upsert:!0});if(I)throw I;const{data:L}=G.storage.from("card-logos").getPublicUrl(T),R=L.publicUrl+"?t="+Date.now();s(b==="brokerage_logo_url"?$=>({...$,[b]:R,brokerage_display_name:""}):$=>({...$,[b]:R,team_name:""})),me.success("Logo uploaded!")}catch{me.error("Failed to upload logo")}finally{a(null),_.target.value=""}}},y=_=>{s(b=>({...b,[_]:""}))};return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-semibold",children:"Brokerage & Team Branding"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Choose either a name or a logo for each — not both."})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(_e,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(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(_e,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Name"}),e.jsx(Fe,{value:t.brokerage_display_name,onChange:_=>s(b=>({...b,brokerage_display_name:_.target.value})),placeholder:"e.g. Keller Williams Realty",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Logo"}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.brokerage_logo_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${t.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>y("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(Vx,{className:"h-3.5 w-3.5"}),n==="brokerage_logo_url"?"Uploading...":t.brokerage_logo_url?"Change":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:_=>f(_,"brokerage_logo_url"),disabled:n!==null})]})]}),t.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.brokerage_logo_size||56,"px"]})]}),e.jsx(Bx,{value:[t.brokerage_logo_size||56],onValueChange:([_])=>s(b=>({...b,brokerage_logo_size:_})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(_e,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(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(_e,{className:"text-xs font-medium text-muted-foreground",children:"Team Name"}),e.jsx(Fe,{value:t.team_name,onChange:_=>s(b=>({...b,team_name:_.target.value})),placeholder:"e.g. The Smith Group",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Team Logo"}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.team_logo_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.team_logo_url,alt:"Team logo",style:{height:`${t.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),e.jsx("button",{onClick:()=>y("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(Vx,{className:"h-3.5 w-3.5"}),n==="team_logo_url"?"Uploading...":t.team_logo_url?"Change":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:_=>f(_,"team_logo_url"),disabled:n!==null})]})]}),t.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.team_logo_size||56,"px"]})]}),e.jsx(Bx,{value:[t.team_logo_size||56],onValueChange:([_])=>s(b=>({...b,team_logo_size:_})),min:24,max:120,step:4})]})]})]})]})})}function lks({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(_e,{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(Ql,{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(Fe,{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 cks({card:t,form:s,setForm:r}){var w;const n=NWe(),a=ss(),{data:o}=SWe(t.id),[l,i]=C.useState(t.slug),[c,u]=C.useState(!1),[p,f]=C.useState("idle"),y=C.useRef(JSON.stringify(s)),_=C.useRef(null);C.useEffect(()=>{const j=JSON.stringify(s);if(j!==y.current)return _.current&&clearTimeout(_.current),_.current=setTimeout(()=>{f("saving"),n.mutate({id:t.id,...s,is_published:!0,title:s.title||null,positioning_statement:s.positioning_statement||null,bio:s.bio||null,review_snippet:s.review_snippet||null,review_source_url:s.review_source_url||null,booking_url:s.booking_url||null,custom_cta_label:s.custom_cta_label||null,brokerage_display_name:s.brokerage_display_name||null,brokerage_logo_url:s.brokerage_logo_url||null,brokerage_logo_size:s.brokerage_logo_size,team_name:s.team_name||null,team_logo_url:s.team_logo_url||null,team_logo_size:s.team_logo_size,bold_theme_colors:s.bold_theme_colors||null,display_email:s.display_email||null},{onSuccess:()=>{y.current=j,f("saved"),setTimeout(()=>f("idle"),2e3)},onError:()=>f("idle")})},1500),()=>{_.current&&clearTimeout(_.current)}},[s]);const b=async()=>{const j=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!j){me.error("Please enter a valid URL");return}if(j===t.slug){me.info("No changes to save");return}u(!0);try{const{data:N}=await G.from("agent_cards").select("id").eq("slug",j).neq("id",t.id).maybeSingle();if(N){me.error("This URL is already taken. Try another one.");return}const{error:S}=await G.from("agent_cards").update({slug:j}).eq("id",t.id);if(S)throw S;i(j),a.invalidateQueries({queryKey:["agent-card"]}),me.success("Card address updated!")}catch{me.error("Failed to update card address")}finally{u(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Aa,{defaultValue:"content",children:[e.jsxs(ja,{className:"w-full h-11 p-1",children:[e.jsxs(js,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(yg,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),e.jsxs(js,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(va,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(js,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(wp,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),e.jsxs(js,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(r1,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),e.jsxs(js,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Lb,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Analytics"]})]}),e.jsxs($s,{value:"content",className:"mt-4 space-y-4",children:[e.jsx(iks,{userId:t.user_id}),e.jsx(oks,{form:s,setForm:r,userId:t.user_id}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-sm font-semibold",children:"Card Status"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Toggle your card on or off"})]}),e.jsx(Br,{checked:s.is_published,onCheckedChange:j=>r(N=>({...N,is_published:j}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Card Address"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-1",children:[e.jsx("span",{className:"inline-flex items-center px-3 rounded-l-md border border-r-0 bg-muted text-muted-foreground text-xs whitespace-nowrap",children:"cards.relevelup.com/"}),e.jsx(Fe,{value:l,onChange:j=>i(j.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"your-name",className:"rounded-l-none h-10"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:b,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(_e,{className:"text-sm font-medium",children:"Card Email (Override)"}),e.jsx(Fe,{value:s.display_email,onChange:j=>r(N=>({...N,display_email:j.target.value})),placeholder:"you@yourbusiness.com",className:"h-11",type:"email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional — use a different email on your card instead of your sign-in email."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Theme"}),e.jsxs(rr,{value:s.theme,onValueChange:j=>r(N=>({...N,theme:j})),children:[e.jsx(tr,{className:"h-11",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"standard",children:"✨ Standard — Modern & Clean"}),e.jsx(Tt,{value:"luxury",children:"🌙 Luxury — Dark & Gold"}),e.jsx(Tt,{value:"bold",children:"🔥 Bold — Vibrant & Punchy"}),e.jsx(Tt,{value:"classic",children:"📋 Classic — Professional"})]})]})]}),s.theme==="bold"&&e.jsx(lks,{form:s,setForm:r}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Title / Tagline"}),e.jsx(Fe,{value:s.title,onChange:j=>r(N=>({...N,title:j.target.value})),placeholder:"e.g. Luxury Real Estate Specialist",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown below your name on the card"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Positioning Statement"}),e.jsx(Fe,{value:s.positioning_statement,onChange:j=>r(N=>({...N,positioning_statement:j.target.value})),placeholder:"Your home journey, handled with care.",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Bio"}),e.jsx(Ar,{value:s.bio,onChange:j=>r(N=>({...N,bio:j.target.value})),placeholder:"A short intro about you and what makes you different...",rows:3})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Review Snippet"}),e.jsx(Fe,{value:s.review_snippet,onChange:j=>r(N=>({...N,review_snippet:j.target.value})),placeholder:"Best agent we've ever worked with...",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Review Source URL"}),e.jsx(Fe,{value:s.review_source_url,onChange:j=>r(N=>({...N,review_source_url:j.target.value})),placeholder:"https://g.page/your-business/review",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Booking URL"}),e.jsx(Fe,{value:s.booking_url,onChange:j=>r(N=>({...N,booking_url:j.target.value})),placeholder:"https://calendly.com/your-link",className:"h-11"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty to show a built-in lead form instead"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Custom CTA Label"}),e.jsx(Fe,{value:s.custom_cta_label,onChange:j=>r(N=>({...N,custom_cta_label:j.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx($s,{value:"sections",className:"mt-4",children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-5 divide-y",children:[{key:"show_photo",label:"Photo",desc:"Uses the photo from your Profile Info above"},{key:"show_bio",label:"Bio Section",desc:"Display your bio on the card"},{key:"show_credentials",label:"Credentials",desc:"Show star rating and reviews"},{key:"show_social_links",label:"Social Links",desc:"Display your social media links"},{key:"show_save_contact",label:"Save Contact",desc:"Let visitors save you as a contact"},{key:"show_leave_review",label:"Leave Review",desc:"Link to your review page"},{key:"show_refer_friend",label:"Refer a Friend",desc:"Enable referral submissions"}].map(({key:j,label:N,desc:S})=>e.jsxs("div",{className:"flex items-center justify-between py-4 first:pt-0 last:pb-0",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:N}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S})]}),e.jsx(Br,{checked:s[j],onCheckedChange:T=>r(I=>({...I,[j]:T}))})]},j))})})}),e.jsx($s,{value:"blocks",className:"mt-4",children:e.jsx(Vot,{cardId:t.id})}),e.jsx($s,{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:va,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:Lb,color:"text-amber-600 bg-amber-100 dark:text-amber-400 dark:bg-amber-900/30"},{label:"Leads",value:((w=o==null?void 0:o.leads)==null?void 0:w.length)??0,icon:Pc,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(j=>e.jsx(Ee,{className:"overflow-hidden",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`p-1.5 rounded-md ${j.color}`,children:e.jsx(j.icon,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:j.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:j.value})]})},j.label))}),o&&o.leads.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsx(Ot,{className:"text-base",children:"Recent Leads"})}),e.jsx(Oe,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(j=>e.jsxs("div",{className:"flex items-center justify-between text-sm p-3 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:j.name}),j.phone&&e.jsx("span",{className:"text-muted-foreground ml-2",children:j.phone})]}),j.intent&&e.jsx(nt,{variant:"secondary",className:"text-xs",children:j.intent})]},j.id))})]}),(!o||o.leads.length===0)&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-8 text-center",children:[e.jsx(Lb,{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($s,{value:"qrcode",className:"mt-4 space-y-4",children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6",children:e.jsx(tks,{slug:t.slug})})})})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[p==="saving"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-400 animate-pulse"})," Saving..."]}),p==="saved"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"})," All changes saved"]}),p==="idle"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30"})," Changes auto-save"]})]})]})}function dks(){const t=ss(),[s,r]=C.useState(""),[n,a]=C.useState(!1),[o,l]=C.useState(!1),[i,c]=C.useState(null),[u,p]=C.useState(!1),[f,y]=C.useState(!1),[_,b]=C.useState(null),[w,j]=C.useState(null),[N,S]=C.useState(0),{data:T,isLoading:I}=wt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:ee,error:Q}=await G.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(Q)throw Q;return ee}}),L=Dt({mutationFn:async ee=>{const{data:Q,error:de}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:ee}});if(de)throw de;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")}}),R=Dt({mutationFn:async()=>{const{data:ee,error:Q}=await G.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")}),$=Dt({mutationFn:async ee=>{const{data:Q,error:de}=await G.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:ee}});if(de)throw de;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")}}),q=Dt({mutationFn:async()=>{const{data:ee,error:Q}=await G.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=>{b(null),c(ee),a(!0)},onError:ee=>{me.error(ee.message||"Failed to generate sync preview")}}),U=Dt({mutationFn:async()=>{j("Initializing sync..."),S(5);const{data:ee,error:Q}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:se}});if(Q)throw Q;if(ee!=null&&ee.error)throw new Error(ee.error);const de=ee;let re=de.sync_log_id,ne=de.next_phase,le=de.next_offset;const he=de.push_total||0,we=de.pull_total||0,ye=he+we;let je=0,ke=0;for(;ne!=="finalize";){ne==="push"?(j(`Pushing contacts to BoldTrail... (${je}/${he})`),S(ye>0?je/ye*100:0)):ne==="pull"&&(j(`Pulling contacts from BoldTrail... (${ke}/${we})`),S(ye>0?(he+ke)/ye*100:0));const{data:Me,error:Ae}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:ne,offset:le,sync_log_id:re,sync_direction:se}});if(Ae)throw Ae;if(Me!=null&&Me.error)throw new Error(Me.error);const Re=Me;je+=Re.chunk_pushed||0,ke+=Re.chunk_pulled||0,Re.progress&&j(Re.progress),ne==="pull"&&we>0?S(Math.min(95,ke/we*100)):ne==="push"&&he>0&&S(Math.min(95,je/he*100)),ne=Re.next_phase,le=Re.next_offset}j("Finalizing sync..."),S(95);const{data:We,error:be}=await G.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:re,sync_direction:se}});if(be)throw be;return S(100),We},onSuccess:ee=>{j(null),S(0),a(!1),t.invalidateQueries({queryKey:["boldtrail-status"]}),t.invalidateQueries({queryKey:["contacts"]}),t.invalidateQueries({queryKey:["innercircle-contacts"]}),t.invalidateQueries({queryKey:["innercircle-contact-counts"]}),t.invalidateQueries({queryKey:["contacts-last-touch"]}),me.success(`Sync complete! Pushed ${ee.contacts_pushed||0}, pulled ${ee.contacts_pulled||0}, skipped ${ee.contacts_skipped||0} duplicates.`)},onError:ee=>{j(null),S(0),me.error(ee.message||"Sync failed")}}),V=T==null?void 0:T.connected,X=(T==null?void 0:T.sync_direction)||"bidirectional",se=_??X;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{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(ud,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["BoldTrail",V&&e.jsx(nt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}),e.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(ap,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(fr,{children:"Sync contacts bidirectionally between Agent OS and your BoldTrail (kvCORE) CRM."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(vi,{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(vi,{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(vi,{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"}),(T==null?void 0:T.last_sync_at)&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sync: ",new Date(T.last_sync_at).toLocaleString(),T.last_sync_status&&e.jsx(nt,{variant:T.last_sync_status==="success"?"default":"secondary",className:"ml-2 text-[10px]",children:T.last_sync_status})]}),(T==null?void 0:T.boldtrail_contact_count)!=null&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[T.boldtrail_contact_count," contacts in BoldTrail"]}),(T==null?void 0:T.last_sync_message)&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:T.last_sync_message})]}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Disconnect BoldTrail?"}),e.jsx(Gl,{children:"This will remove your API token. Previously synced contacts will remain in both systems."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>R.mutate(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]})}),e.jsx("div",{className:"rounded-lg border p-3",children:e.jsx(Cbe,{value:X,onChange:ee=>$.mutate(ee)})}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(K,{onClick:()=>q.mutate(),disabled:q.isPending||U.isPending,variant:"outline",className:"gap-2",children:[q.isPending?e.jsx(Bo,{className:"h-4 w-4 animate-spin"}):e.jsx(va,{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(Fe,{type:"password",placeholder:"Paste your BoldTrail API token",value:s,onChange:ee=>r(ee.target.value),className:"flex-1"}),e.jsxs(K,{onClick:()=>L.mutate(s),disabled:!s||s.length<10||L.isPending,children:[L.isPending?e.jsx(Bo,{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(_s,{open:n,onOpenChange:ee=>{U.isPending||a(ee)},children:e.jsxs(vs,{className:"sm:max-w-lg",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(ud,{className:"h-5 w-5 text-emerald-600"}),"Sync Preview"]}),e.jsx(Zr,{children:"Review what will happen when you sync your contacts."})]}),i&&(()=>{const ee=se==="pull_only"?0:i.to_push,Q=se==="push_only"?0:i.to_pull;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Cbe,{value:se,onChange:b,size:"sm"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:`rounded-lg border p-3 text-center ${se==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:ee}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(gu,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${se==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:Q}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Oh,{className:"h-3 w-3"})," Pull to Agent OS"]})]}),e.jsxs("div",{className:"rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-muted-foreground",children:i.already_synced}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(mr,{className:"h-3 w-3"})," Already synced"]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground text-center",children:["Agent OS: ",i.agent_os_total," contacts · BoldTrail: ",i.boldtrail_total," contacts"]}),U.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(Oi,{value:N||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:w||"Sync in progress..."})]}),ee>0&&e.jsxs(bg,{open:u,onOpenChange:p,children:[e.jsx(wg,{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(gu,{className:"h-3 w-3 text-emerald-600"}),ee," contacts to push to BoldTrail"]}),e.jsx(tl,{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`})]})}),e.jsx(jg,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.push_preview.map((de,re)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:de.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:de.email})]},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(bg,{open:f,onOpenChange:y,children:[e.jsx(wg,{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(Oh,{className:"h-3 w-3 text-blue-600"}),Q," contacts to pull from BoldTrail"]}),e.jsx(tl,{className:`h-3 w-3 transition-transform ${f?"rotate-180":""}`})]})}),e.jsx(jg,{children:e.jsxs("div",{className:"rounded border divide-y max-h-40 overflow-y-auto",children:[i.pull_preview.map((de,re)=>e.jsxs("div",{className:"px-3 py-1.5 text-xs flex justify-between",children:[e.jsx("span",{className:"font-medium",children:de.name||"No name"}),e.jsx("span",{className:"text-muted-foreground",children:de.email})]},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:U.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>U.mutate(),disabled:U.isPending||ee===0&&Q===0,className:"gap-2",children:[U.isPending?e.jsx(Bo,{className:"h-4 w-4 animate-spin"}):e.jsx(ud,{className:"h-4 w-4"}),U.isPending?"Syncing...":"Sync Now"]})]})]})})()]})}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{className:"sm:max-w-2xl p-0 overflow-hidden",children:[e.jsx(Cs,{className:"p-6 pb-0",children:e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(ud,{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=Pr(),[s,r]=C.useState(""),[n,a]=C.useState(""),[o,l]=C.useState("Test from ReLevelUp"),[i,c]=C.useState(!1),{data:u,isLoading:p}=wt({queryKey:["ses-config"],queryFn:async()=>{const{data:{session:_}}=await G.auth.getSession();if(!_)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 ${_.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:_}}=await G.auth.getSession();if(!_)throw new Error("Not authenticated");const w=await(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-send-campaign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${_.access_token}`},body:JSON.stringify({action:"test_send",to:s,from_email:n,subject:o,body_html:"

Test Email

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

If you received this, SES is configured correctly! 🎉

"})})).json();w.success?me.success(`Test email sent! Message ID: ${w.messageId}`):me.error(w.error||"Failed to send test email")}catch(_){me.error(_.message||"Failed to send test email")}finally{c(!1)}},y=(u==null?void 0:u.configured)===!0;return e.jsxs(Ee,{children:[e.jsx(It,{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(br,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Amazon SES — Mass Email"}),e.jsx(fr,{children:"Send bulk email campaigns via Amazon SES"})]})]}),e.jsx(nt,{variant:y?"default":"secondary",children:p?"Checking...":y?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(vi,{className:"h-3 w-3"})," Connected"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(yl,{className:"h-3 w-3"})," Not Configured"]})})]})}),y&&e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-3",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Send Test Email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Verify your SES setup by sending a test email. The "From" address must be verified in SES or belong to a verified domain.'}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(_e,{className:"text-xs",children:"From Email"}),e.jsx(Fe,{placeholder:"notifications@mail.relevelup.com",value:n,onChange:_=>a(_.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(_e,{className:"text-xs",children:"To Email"}),e.jsx(Fe,{placeholder:"your@email.com",value:s,onChange:_=>r(_.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(_e,{className:"text-xs",children:"Subject"}),e.jsx(Fe,{value:o,onChange:_=>l(_.target.value),className:"text-sm"})]})]}),e.jsxs(K,{onClick:f,disabled:i,size:"sm",children:[i?e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(oa,{className:"h-4 w-4 mr-2"}),"Send Test"]})]}),e.jsxs(K,{onClick:()=>t("/admin/email-campaigns"),className:"w-full",children:[e.jsx(bp,{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)"]})]})]}),!y&&!p&&e.jsx(Oe,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["AWS SES credentials are not configured. Add ",e.jsx("code",{children:"AWS_SES_ACCESS_KEY_ID"}),", ",e.jsx("code",{children:"AWS_SES_SECRET_ACCESS_KEY"}),", and ",e.jsx("code",{children:"AWS_SES_REGION"})," as secrets to enable."]})})]})}function uks(){var b,w,j,N;const{user:t}=Ws(),s=ss(),[r,n]=C.useState(!1),[a,o]=C.useState(""),[l,i]=C.useState(""),{data:c}=wt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:S,error:T}=await G.from("mass_email_settings").select("*").eq("user_id",t.id).maybeSingle();if(T)throw T;return S}}),{data:u}=wt({queryKey:["agent-profile-email",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:S,error:T}=await G.from("profiles").select("email, name").eq("id",t.id).single();if(T)throw T;return S}}),p=((b=c==null?void 0:c.reply_to_email)==null?void 0:b.trim())||((w=u==null?void 0:u.email)==null?void 0:w.trim())||"",f=((j=c==null?void 0:c.display_name)==null?void 0:j.trim())||((N=u==null?void 0:u.name)==null?void 0:N.trim())||"";C.useEffect(()=>{r||(o(p),i(f))},[r,p,f]);const y=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:T}=await G.from("mass_email_settings").update(S).eq("user_id",t.id);if(T)throw T}else{const{error:T}=await G.from("mass_email_settings").insert({user_id:t.id,...S});if(T)throw T}},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)}),_=!!p;return e.jsxs(Ee,{children:[e.jsx(It,{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(oa,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Mass Email",_?e.jsxs(nt,{variant:"default",className:"text-xs bg-green-600",children:[e.jsx(vi,{className:"h-3 w-3 mr-1"})," Set Up"]}):e.jsx(nt,{variant:"secondary",className:"text-xs",children:"Setup Required"})]}),e.jsx(fr,{children:"Set the email address where replies from your campaigns will be sent. If you haven't customized it yet, we'll use your profile email."})]})]})}),e.jsx(Oe,{className:"space-y-3",children:_&&!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($a,{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(_e,{className:"text-xs",children:"Display Name"}),e.jsx(Fe,{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(_e,{className:"text-xs",children:"Reply-To Email *"}),e.jsx(Fe,{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:()=>y.mutate(),disabled:y.isPending||!a.trim(),children:[e.jsx(Wu,{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(Ur,{className:"h-4 w-4 mr-1"})," Cancel"]})]})]})})]})}function hks(){const{isAdmin:t}=Ws(),s=ss(),[r,n]=C.useState(!1),[a,o]=C.useState(!1),[l,i]=C.useState(!1),{data:c,isLoading:u}=wt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:I,error:L}=await G.from("gmail_integrations").select("*").maybeSingle();if(L)throw L;return I}}),{data:p}=wt({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:I}}=await G.auth.getUser();if(!I)return[];const{data:L,error:R}=await G.from("social_accounts").select("*").eq("user_id",I.id).order("created_at",{ascending:!1});if(R)throw R;return L}}),f=async()=>{n(!0);try{const{data:I,error:L}=await G.functions.invoke("gmail-oauth",{body:{action:"get_auth_url"}});if(L)throw L;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get authorization URL")}catch(I){console.error("Gmail OAuth error:",I),me.error("Failed to start Gmail connection"),n(!1)}},y=async()=>{o(!0);try{const{data:I,error:L}=await G.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(L)throw L;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get authorization URL")}catch(I){console.error("Meta OAuth error:",I),me.error("Failed to start connection. Make sure Meta App credentials are configured."),o(!1)}},_=async()=>{i(!0);try{const{data:I,error:L}=await G.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(L)throw L;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(I){console.error("LinkedIn OAuth error:",I),me.error("Failed to start LinkedIn connection. Please try again."),i(!1)}},b=Dt({mutationFn:async I=>{const{error:L}=await G.from("gmail_integrations").delete().eq("id",I);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["gmail-integration"]}),me.success("Gmail disconnected")},onError:()=>{me.error("Failed to disconnect Gmail")}}),w=Dt({mutationFn:async I=>{const{error:L}=await G.from("social_accounts").delete().eq("id",I);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["social-accounts"]}),me.success("Account disconnected")},onError:()=>{me.error("Failed to disconnect account")}}),j=!!(c!=null&&c.is_active),N=(p==null?void 0:p.filter(I=>I.platform==="facebook"))||[],S=(p==null?void 0:p.filter(I=>I.platform==="instagram"))||[],T=(p==null?void 0:p.filter(I=>I.platform==="linkedin"))||[];return e.jsx(Es,{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(It,{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(br,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Gmail",j&&e.jsx(nt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(fr,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(vi,{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(vi,{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(vi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Quick compose from any contact detail page"})]}),j?e.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:c.gmail_email}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Gmail account"})]}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Disconnect Gmail?"}),e.jsx(Gl,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>b.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(Bo,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(br,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx(Ki,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(It,{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(xu,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Facebook",t?N.length>0?e.jsx(nt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(vh,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(fr,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[N.length>0&&e.jsx("div",{className:"space-y-2",children:N.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(yn,{className:"h-8 w-8",children:[e.jsx(Da,{src:I.profile_picture_url||""}),e.jsx(vn,{children:e.jsx(xu,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.page_name||I.platform_username||"Facebook Page"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Facebook Page"})]})]}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Disconnect Facebook?"}),e.jsx(Gl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>w.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(K,{onClick:y,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Bo,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),"Connect Facebook Page"]})]})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(It,{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(yu,{className:"h-5 w-5 text-pink-600"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Instagram",t?S.length>0?e.jsx(nt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(vh,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(fr,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[S.length>0&&e.jsx("div",{className:"space-y-2",children:S.map(I=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(yn,{className:"h-8 w-8",children:[e.jsx(Da,{src:I.profile_picture_url||""}),e.jsx(vn,{children:e.jsx(yu,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:["@",I.platform_username||"Instagram Account"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Instagram account"})]})]}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Disconnect Instagram?"}),e.jsx(Gl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>w.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(K,{onClick:y,disabled:a,variant:"outline",className:"gap-2",children:[a?e.jsx(Bo,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),"Connect Instagram Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Instagram Business accounts must be connected to a Facebook Page."})]})]}),e.jsxs(Ee,{className:t?"":"opacity-70",children:[e.jsx(It,{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(_p,{className:"h-5 w-5 text-blue-700"})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?T.length>0?e.jsx(nt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(nt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(vh,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(fr,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs(Oe,{className:"space-y-3",children:[T.length>0&&e.jsx("div",{className:"space-y-2",children:T.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(yn,{className:"h-8 w-8",children:[e.jsx(Da,{src:I.profile_picture_url||""}),e.jsx(vn,{children:e.jsx(_p,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.platform_username||"LinkedIn Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected LinkedIn profile"})]})]}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Disconnect LinkedIn?"}),e.jsx(Gl,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>w.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(K,{onClick:_,disabled:l,variant:"outline",className:"gap-2",children:[l?e.jsx(Bo,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]}),e.jsx(dks,{}),e.jsx(uks,{}),t&&e.jsx(slt,{})]})})}function mks(){const[t]=Xc(),s=Pr(),[r,n]=C.useState("loading"),[a,o]=C.useState("Connecting your Gmail account...");return C.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:y}=await G.functions.invoke("gmail-oauth",{body:{action:"exchange_code",code:i,state:p}});if(y)throw y;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(It,{className:"text-center",children:[r==="loading"&&e.jsx(Ss,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(vi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx($c,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ot,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(fr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function pks(){const t=Pr();return C.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 fks(){const[t]=Xc(),s=Pr(),[r,n]=C.useState("loading"),[a,o]=C.useState("Processing your connection...");return C.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:y,error:_}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/mission-control/integrations/meta/callback"}});if(_)throw _;if(y!=null&&y.success)n("success"),o(`Successfully connected ${((f=y.accounts)==null?void 0:f.length)||0} account(s)!`),me.success("Social accounts connected successfully!");else throw new Error((y==null?void 0:y.error)||"Unknown error")}catch(y){console.error("OAuth callback error:",y),n("error"),o(y instanceof Error?y.message:"Failed to connect accounts"),me.error("Failed to connect: "+(y instanceof Error?y.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(It,{className:"text-center",children:[r==="loading"&&e.jsx(Ss,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(vi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx($c,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ot,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(fr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const rlt=new Date().getFullYear(),gks=Array.from({length:5},(t,s)=>rlt-s);function xks(){const[t,s]=C.useState(rlt),r=Pr(),{data:n,isLoading:a}=cLt();return a?e.jsx(Es,{title:"Scorecard Admin",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(xs,{className:"h-24"},o))}),e.jsx(xs,{className:"h-96"})]})}):e.jsx(Es,{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(rr,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(tr,{className:"w-[120px]",children:e.jsx(nr,{})}),e.jsx(sr,{children:gks.map(o=>e.jsx(Tt,{value:String(o),children:o},o))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(mr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Agents Tracking"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(n==null?void 0:n.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xl,{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(It,{children:[e.jsx(Ot,{children:"Agents with Scorecards"}),e.jsx(fr,{children:"Click to view individual agent scorecards"})]}),e.jsx(Oe,{children:!n||n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(xl,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Agent"}),e.jsx(bt,{children:"Email"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:n.map(o=>e.jsxs(ks,{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(va,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const nlt=new Date().getFullYear(),yks=Array.from({length:10},(t,s)=>nlt-s);function V7e(){var b;const{userId:t}=Po(),s=Pr(),n=Qu().pathname.startsWith("/mission-control"),[a,o]=C.useState(nlt),{data:l,isLoading:i}=wt({queryKey:["agent-profile",t],queryFn:async()=>{const{data:w,error:j}=await G.from("profiles").select("id, name, email").eq("id",t).single();if(j)throw j;return w},enabled:!!t}),{data:c,isLoading:u}=mke(a,t),{yearStats:p,lifetimeStats:f,showCommission:y}=EYe(a,t),{data:_}=AYe(a,t);return i?e.jsx(Es,{title:"Agent Scorecard",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(w=>e.jsx(xs,{className:"h-24"},w))})]})}):e.jsx(Es,{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(di,{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(rr,{value:String(a),onValueChange:w=>o(Number(w)),children:[e.jsx(tr,{className:"w-[120px]",children:e.jsx(nr,{})}),e.jsx(sr,{children:yks.map(w=>e.jsx(Tt,{value:String(w),children:w},w))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Rn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:p.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.totalTransactions," lifetime"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(mr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[p.buyerCount,"/",p.sellerCount]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Td,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:$l(p.totalVolume,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xc,{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:$l(p.averagePrice,!0)})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(fc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),e.jsx("p",{className:"text-lg font-bold truncate",children:((b=p.topLeadSource)==null?void 0:b.name)||"-"})]})})]}),_&&e.jsx(wat,{goals:_,stats:p,year:a,showCommission:y}),e.jsxs(Aa,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(ja,{children:[e.jsx(js,{value:"transactions",children:"Transactions"}),e.jsx(js,{value:"charts",children:"Charts"}),e.jsxs(js,{value:"map",children:[e.jsx(Ui,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx($s,{value:"transactions",children:e.jsx(z4e,{transactions:c||[],showCommission:y,isLoading:u})}),e.jsx($s,{value:"charts",children:e.jsx(B4e,{stats:p,year:a})}),e.jsx($s,{value:"map",children:e.jsx($4e,{transactions:c||[],isLoading:u})})]})]})})}function vks(){const t=ss(),[s,r]=C.useState(""),[n,a]=C.useState("all");aZe();const{data:o,refetch:l}=wt({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:I}=await G.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(I==null?void 0:I.enabled)??!1}}),{data:i,isLoading:c}=wt({queryKey:["admin-listings"],queryFn:async()=>{const{data:I,error:L}=await G.from("listings").select(` *, agent:profiles!listings_agent_id_fkey(id, name, email), photos:listing_photos(id, photo_url, is_primary) `).order("created_at",{ascending:!1});if(L)throw L;return I}}),{data:u}=wt({queryKey:["admin-listing-stats"],queryFn:async()=>{const{data:I}=await G.from("listings").select("id, is_approved, status"),{data:L}=await G.from("listing_shares").select("id"),{data:R}=await G.from("listing_views").select("id");return{total:(I==null?void 0:I.length)||0,pending:(I==null?void 0:I.filter($=>!$.is_approved).length)||0,active:(I==null?void 0:I.filter($=>$.status==="active").length)||0,totalShares:(L==null?void 0:L.length)||0,totalViews:(R==null?void 0:R.length)||0}}}),p=async(I,L,R="submit_url")=>{try{const{data:{session:$}}=await G.auth.getSession();if(!$)return;const{data:q,error:U}=await G.functions.invoke("google-indexing",{body:{action:R,listing_id:I,listing_slug:L}});if(U)throw U;if((q==null?void 0:q.configured)===!1)return;q!=null&&q.success&&me.success("Submitted to Google for indexing")}catch($){console.error("Google indexing submission failed:",$)}},f=Dt({mutationFn:async()=>{const{data:{session:I}}=await G.auth.getSession();if(!I)throw new Error("Not authenticated");const{data:L,error:R}=await G.functions.invoke("google-indexing",{body:{action:"submit_all"}});if(R)throw R;return L},onSuccess:I=>{if((I==null?void 0:I.configured)===!1){me.error("Google Indexing API not configured. Add the GOOGLE_INDEXING_SERVICE_ACCOUNT secret.");return}me.success(`Submitted ${(I==null?void 0:I.succeeded)||0} URLs to Google (${(I==null?void 0:I.failed)||0} failed)`)},onError:I=>{me.error("Failed to submit to Google"),console.error(I)}}),y=Dt({mutationFn:async({id:I,approved:L,slug:R})=>{const{error:$}=await G.from("listings").update({is_approved:L}).eq("id",I);if($)throw $;return{id:I,approved:L,slug:R}},onSuccess:I=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),me.success(I.approved?"Listing approved":"Listing unapproved"),I.approved?p(I.id,I.slug||null,"submit_url"):p(I.id,I.slug||null,"remove_url")}}),_=Dt({mutationFn:async({id:I,featured:L})=>{const{error:R}=await G.from("listings").update({is_featured:L}).eq("id",I);if(R)throw R},onSuccess:(I,{featured:L})=>{t.invalidateQueries({queryKey:["admin-listings"]}),me.success(L?"Listing featured":"Listing unfeatured")}}),b=Dt({mutationFn:async I=>{const{error:L}=await G.from("listings").delete().eq("id",I);if(L)throw L},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),me.success("Listing deleted")}}),w=Dt({mutationFn:async I=>{const{error:L}=await G.from("feature_flags").update({enabled:I}).eq("key","listing_exchange_enabled");if(L)throw L},onSuccess:()=>{l(),me.success("Feature flag updated")}}),j=o??!1,N=i==null?void 0:i.filter(I=>{var $,q,U,V;const L=(($=I.city)==null?void 0:$.toLowerCase().includes(s.toLowerCase()))||((U=(q=I.agent)==null?void 0:q.name)==null?void 0:U.toLowerCase().includes(s.toLowerCase()))||((V=I.property_address)==null?void 0:V.toLowerCase().includes(s.toLowerCase())),R=n==="all"||n==="pending"&&!I.is_approved||n==="approved"&&I.is_approved;return L&&R}),S=I=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I),T=I=>{const L={active:"bg-green-500/10 text-green-600 border-green-200",coming_soon:"bg-blue-500/10 text-blue-600 border-blue-200",price_improvement:"bg-amber-500/10 text-amber-600 border-amber-200",under_contract:"bg-purple-500/10 text-purple-600 border-purple-200",sold:"bg-gray-500/10 text-gray-600 border-gray-200"};return L[I]||L.active};return e.jsx(Es,{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(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(yp,{className:"h-4 w-4"}),"Submit All to Google"]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Feature visible to agents"}),e.jsx(Br,{checked:j,onCheckedChange:I=>w.mutate(I)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(La,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Listings"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.total)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xc,{className:"h-4 w-4 text-green-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Active"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.active)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Pending Review"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.pending)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(va,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Views"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.totalViews)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ad,{className:"h-4 w-4 text-purple-500"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Shares"})]}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:(u==null?void 0:u.totalShares)||0})]})})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by city, address, or agent...",value:s,onChange:I=>r(I.target.value),className:"pl-9"})]}),e.jsx(Aa,{value:n,onValueChange:I=>a(I),children:e.jsxs(ja,{children:[e.jsx(js,{value:"all",children:"All"}),e.jsx(js,{value:"pending",children:"Pending"}),e.jsx(js,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{children:["Listings (",(N==null?void 0:N.length)||0,")"]})}),e.jsx(Oe,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Property"}),e.jsx(bt,{children:"Agent"}),e.jsx(bt,{children:"Price"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-center",children:"Approved"}),e.jsx(bt,{className:"text-center",children:"Featured"}),e.jsx(bt,{children:"Views"}),e.jsx(bt,{children:"Shares"}),e.jsx(bt,{children:"Date"}),e.jsx(bt,{})]})}),e.jsx(Pn,{children:c?e.jsx(ks,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(N==null?void 0:N.length)===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):N==null?void 0:N.map(I=>{var L,R,$,q,U;return e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[(R=(L=I.photos)==null?void 0:L[0])!=null&&R.photo_url?e.jsx("img",{src:I.photos[0].photo_url,alt:"",className:"w-12 h-12 object-cover rounded"}):e.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:e.jsx(La,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.property_address||`${I.city}, ${I.state}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:($=I.property_type)==null?void 0:$.replace("_"," ")})]})]})}),e.jsx(dt,{children:e.jsx("p",{className:"text-sm",children:((q=I.agent)==null?void 0:q.name)||"Unknown"})}),e.jsx(dt,{className:"font-medium",children:S(I.price)}),e.jsx(dt,{children:e.jsx(nt,{variant:"outline",className:T(I.status),children:(U=I.status)==null?void 0:U.replace("_"," ")})}),e.jsx(dt,{className:"text-center",children:e.jsx(Br,{checked:I.is_approved??!1,onCheckedChange:V=>y.mutate({id:I.id,approved:V,slug:I.slug})})}),e.jsx(dt,{className:"text-center",children:e.jsx(Br,{checked:I.is_featured??!1,onCheckedChange:V=>_.mutate({id:I.id,featured:V})})}),e.jsx(dt,{children:I.view_count||0}),e.jsx(dt,{children:I.share_count||0}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:ys(new Date(I.created_at),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsxs(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(ig,{className:"h-4 w-4"})})}),e.jsxs(Jd,{align:"end",children:[e.jsxs(Ta,{onClick:()=>window.open(`/mission-control/listings/${I.id}`,"_blank"),children:[e.jsx(va,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(Ta,{onClick:()=>_.mutate({id:I.id,featured:!I.is_featured}),children:[e.jsx(Kn,{className:"h-4 w-4 mr-2"}),I.is_featured?"Unfeature":"Feature"]}),e.jsxs(Ta,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&b.mutate(I.id)},children:[e.jsx(Ur,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},I.id)})})]})})})]})]})})}const _ks=()=>{var f,y;const[t,s]=C.useState(""),[r,n]=C.useState(null),{data:a,isLoading:o}=wt({queryKey:["membership-reviews"],queryFn:async()=>{const{data:_,error:b}=await G.from("membership_reviews").select("*").order("created_at",{ascending:!1});if(b)throw b;const w=(_==null?void 0:_.map(S=>S.user_id))||[],{data:j}=await G.from("profiles").select("id, name, email").in("id",w);return _==null?void 0:_.map(S=>({...S,profiles:(j==null?void 0:j.find(T=>T.id===S.user_id))||null}))}}),l=a==null?void 0:a.filter(_=>{var w,j,N,S,T;const b=t.toLowerCase();return((j=(w=_.profiles)==null?void 0:w.name)==null?void 0:j.toLowerCase().includes(b))||((S=(N=_.profiles)==null?void 0:N.email)==null?void 0:S.toLowerCase().includes(b))||((T=_.review_text)==null?void 0:T.toLowerCase().includes(b))}),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,_),{}),u=(a==null?void 0:a.filter(_=>_.posted_to_google).length)||0,p=_=>e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(b=>e.jsx(Kn,{className:At("h-4 w-4",_>=b?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},b))});return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{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(It,{className:"pb-2",children:[e.jsx(fr,{children:"Total Reviews"}),e.jsx(Ot,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(fr,{children:"Average Rating"}),e.jsxs(Ot,{className:"flex items-center gap-2 text-3xl",children:[i,e.jsx(Kn,{className:"h-6 w-6 fill-yellow-400 text-yellow-400"})]})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(fr,{children:"5-Star Reviews"}),e.jsx(Ot,{className:"text-3xl",children:(c==null?void 0:c[5])||0})]})}),e.jsx(Ee,{children:e.jsxs(It,{className:"pb-2",children:[e.jsx(fr,{children:"Posted to Google"}),e.jsxs(Ot,{className:"flex items-center gap-2 text-3xl",children:[u,e.jsx(rn,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name, email, or review...",value:t,onChange:_=>s(_.target.value),className:"pl-9"})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Member"}),e.jsx(bt,{children:"Rating"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Review"}),e.jsx(bt,{children:"Google"}),e.jsx(bt,{children:"Date"})]})}),e.jsx(Pn,{children:o?e.jsx(ks,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No reviews found"})}):l==null?void 0:l.map(_=>{var b,w;return e.jsxs(ks,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>n(_),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:((b=_.profiles)==null?void 0:b.name)||"Unknown"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:(w=_.profiles)==null?void 0:w.email})]})}),e.jsx(dt,{children:p(_.rating)}),e.jsx(dt,{className:"hidden md:table-cell max-w-xs",children:e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:_.review_text||"-"})}),e.jsx(dt,{children:_.posted_to_google?e.jsx(nt,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(nt,{variant:"outline",children:"No"})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:ys(new Date(_.created_at),"MMM d, yyyy")})]},_.id)})})]})})}),e.jsx(_s,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Review Details"})}),r&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-4 p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold text-lg",children:((f=r.profiles)==null?void 0:f.name)||"Unknown Member"}),((y=r.profiles)==null?void 0:y.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(br,{className:"h-3 w-3"}),r.profiles.email]})]}),e.jsxs("div",{className:"text-right",children:[p(r.rating),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r.rating," out of 5 stars"]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Review"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:r.review_text||"No written review provided."})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(on,{className:"h-4 w-4"}),ys(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(nt,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(rn,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):e.jsx(nt,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},bks=[{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"}],wks=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 jks(){const t=ss(),{user:s}=Ws(),[r,n]=C.useState(!1),[a,o]=C.useState(!1),[l,i]=C.useState(!1),{data:c,isLoading:u}=wt({queryKey:["weekly-digest-settings"],queryFn:async()=>{const{data:q,error:U}=await G.from("weekly_digest_settings").select("*").single();if(U)throw U;return q}}),{data:p,isLoading:f}=wt({queryKey:["weekly-digest-logs"],queryFn:async()=>{const{data:q,error:U}=await G.from("weekly_digest_logs").select("*").order("sent_at",{ascending:!1}).limit(100);if(U)throw U;return q}}),{data:y}=wt({queryKey:["digest-subscriber-count"],queryFn:async()=>{const{count:q,error:U}=await G.from("profiles").select("id",{count:"exact",head:!0}).eq("digest_opt_out",!1).not("email","is",null);if(U)throw U;return q||0}}),{data:_,refetch:b}=wt({queryKey:["digest-queue-status"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const[U,V,X,se]=await Promise.all([G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","pending").gte("created_at",q.toISOString()),G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","processing").gte("created_at",q.toISOString()),G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","sent").gte("created_at",q.toISOString()),G.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","failed").gte("created_at",q.toISOString())]);return{pending:U.count||0,processing:V.count||0,sent:X.count||0,failed:se.count||0,total:(U.count||0)+(V.count||0)+(X.count||0)+(se.count||0)}},refetchInterval:5e3});C.useEffect(()=>{if(_&&(_.pending>0||_.processing>0)){const q=setInterval(()=>{b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})},5e3);return()=>clearInterval(q)}},[_,b,t]);const{data:w=0}=wt({queryKey:["digest-today-failed-count"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const{count:U,error:V}=await G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString());if(V)throw V;return U||0}}),j=Dt({mutationFn:async q=>{const{error:U}=await G.from("weekly_digest_settings").update(q).eq("id",c==null?void 0:c.id);if(U)throw U},onSuccess:()=>{t.invalidateQueries({queryKey:["weekly-digest-settings"]}),me.success("Settings updated")},onError:q=>{me.error("Failed to update settings: "+q.message)}}),N=async()=>{n(!0);try{const{data:q,error:U}=await G.functions.invoke("send-weekly-digest",{body:{manual:!0}});if(U)throw U;q.queued?me.success(`${q.queued.toLocaleString()} emails queued! They'll be sent automatically (~80/minute).`):q.sent!==void 0&&me.success(`Digest sent! ${q.sent} emails delivered, ${q.failed} failed`),b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]})}catch(q){me.error("Failed to send digest: "+q.message)}finally{n(!1)}},S=async()=>{var q,U,V,X,se,ee;if(!(s!=null&&s.email)){me.error("No email found for your account");return}o(!0);try{const{data:Q,error:de}=await G.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(de)throw de;const re=Q==null?void 0:Q.resendId,ne=Q==null?void 0:Q.resendDetails,le=ne==null?void 0:ne.status,he=((q=ne==null?void 0:ne.body)==null?void 0:q.status)||((V=(U=ne==null?void 0:ne.body)==null?void 0:U.data)==null?void 0:V.status),we=((se=(X=ne==null?void 0:ne.body)==null?void 0:X.error)==null?void 0:se.message)||((ee=ne==null?void 0:ne.body)==null?void 0:ee.message);me.success(re?`Preview accepted by email provider (id: ${re})${le?`, status check: ${le}`:""}${he?`, provider: ${he}`:""}${we?` (${we})`:""}. 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)}},T=async()=>{i(!0);try{const{data:q,error:U}=await G.functions.invoke("send-weekly-digest",{body:{retryFailed:!0}});if(U)throw U;q.queued===0||q.sent===0&&q.failed===0&&!q.queued?me.info("No failed emails to retry"):q.queued?me.success(`${q.queued} emails queued for retry!`):me.success(`Retry complete! ${q.sent} emails delivered, ${q.failed} failed`),b(),t.invalidateQueries({queryKey:["weekly-digest-logs"]}),t.invalidateQueries({queryKey:["digest-today-failed-count"]}),t.invalidateQueries({queryKey:["digest-today-missing-count"]})}catch(q){me.error("Failed to retry: "+q.message)}finally{i(!1)}},I=_!=null&&_.total?Math.round((_.sent+_.failed)/_.total*100):0,L=((_==null?void 0:_.pending)||0)>0||((_==null?void 0:_.processing)||0)>0,{data:R}=wt({queryKey:["digest-delivery-stats"],queryFn:async()=>{var ee,Q;const q=new Date;q.setUTCHours(0,0,0,0);const[U,V,X,se]=await Promise.all([G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","sent").gte("sent_at",q.toISOString()),G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString()),G.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("has_agent_os_activity",!0).gte("sent_at",q.toISOString()),G.from("weekly_digest_logs").select("sent_at").order("sent_at",{ascending:!1}).limit(1)]);return{totalSent:U.count||0,totalFailed:V.count||0,agentOsEngaged:X.count||0,lastSent:((Q=(ee=se.data)==null?void 0:ee[0])==null?void 0:Q.sent_at)||null}},refetchInterval:L?5e3:!1}),$={totalSent:(R==null?void 0:R.totalSent)||0,totalFailed:(R==null?void 0:R.totalFailed)||0,lastSent:R==null?void 0:R.lastSent,agentOsEngaged:(R==null?void 0:R.agentOsEngaged)||0};return u?e.jsx(Es,{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(Es,{title:"Weekly Digest",description:"Configure and manage automated weekly email digests for members",children:e.jsxs(Aa,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(ja,{children:[e.jsxs(js,{value:"settings",className:"flex items-center gap-2",children:[e.jsx(Jl,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(js,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(xl,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs($s,{value:"settings",className:"space-y-6",children:[L&&_&&e.jsx(Ee,{className:"border-primary/50 bg-primary/5",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(Ss,{className:"h-5 w-5 animate-spin text-primary"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:"Sending emails..."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[_.sent.toLocaleString()," sent, ",_.pending.toLocaleString()," pending",_.failed>0&&`, ${_.failed} failed`]})]}),e.jsxs("span",{className:"text-sm font-medium",children:[I,"%"]})]}),e.jsx(Oi,{value:I,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Processing ~80 emails per minute. Estimated time remaining: ~",Math.ceil(_.pending/80)," min"]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(mr,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:y}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscribers"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-emerald-500/10",children:e.jsx(ha,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.totalSent}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Delivered"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-destructive/10",children:e.jsx($c,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.totalFailed}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:e.jsx(Tn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:$.lastSent?ys(new Date($.lastSent),"MMM d"):"Never"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last Sent"})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(fr,{children:"Configure when the digest is sent"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Enable Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Send automated weekly emails to members"})]}),e.jsx(Br,{checked:c==null?void 0:c.is_enabled,onCheckedChange:q=>j.mutate({is_enabled:q})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Cron Frequency"}),e.jsxs(rr,{value:(c==null?void 0:c.cron_frequency)||"daily",onValueChange:q=>j.mutate({cron_frequency:q}),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"daily",children:"Daily (runs once at selected time)"}),e.jsx(Tt,{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(_e,{children:"Day of Week"}),e.jsxs(rr,{value:String(c==null?void 0:c.send_day),onValueChange:q=>j.mutate({send_day:parseInt(q)}),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:bks.map(q=>e.jsx(Tt,{value:q.value,children:q.label},q.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Time (UTC)"}),e.jsxs(rr,{value:String(c==null?void 0:c.send_hour),onValueChange:q=>j.mutate({send_hour:parseInt(q)}),disabled:(c==null?void 0:c.cron_frequency)==="daily",children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:wks.map(q=>e.jsx(Tt,{value:q.value,children:q.label},q.value))})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{onClick:S,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(va,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(K,{onClick:N,disabled:r,className:"flex-1",children:[e.jsx(oa,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),w>0&&e.jsxs(K,{onClick:T,disabled:l,variant:"outline",className:"w-full",children:[e.jsx(Bo,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${w} Failed`]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(fr,{children:"Choose what to include in the digest"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(_e,{children:"New Resources"})]}),e.jsx(Br,{checked:c==null?void 0:c.include_new_resources,onCheckedChange:q=>j.mutate({include_new_resources:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(_e,{children:"Community Highlights"})]}),e.jsx(Br,{checked:c==null?void 0:c.include_community_posts,onCheckedChange:q=>j.mutate({include_community_posts:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xl,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(_e,{children:"Agent OS Stats"})]}),e.jsx(Br,{checked:c==null?void 0:c.include_agent_os_stats,onCheckedChange:q=>j.mutate({include_agent_os_stats:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(_e,{children:"Upcoming Events"})]}),e.jsx(Br,{checked:c==null?void 0:c.include_upcoming_events,onCheckedChange:q=>j.mutate({include_upcoming_events:q})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Am,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(_e,{children:"Goals Progress"})]}),e.jsx(Br,{checked:c==null?void 0:c.include_goals_progress,onCheckedChange:q=>j.mutate({include_goals_progress:q})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Custom Introduction"}),e.jsx(fr,{children:"Personalize the intro message (optional)"})]}),e.jsx(Oe,{children:e.jsx(Ar,{placeholder:"Here's what's new this week to help you grow your business...",value:(c==null?void 0:c.custom_intro_text)||"",onChange:q=>j.mutate({custom_intro_text:q.target.value||null}),rows:3})})]})]}),e.jsx($s,{value:"stats",children:e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(fr,{children:"Recent digest emails sent to members"})]}),e.jsx(Oe,{children:f?e.jsx("div",{className:"animate-pulse space-y-2",children:[1,2,3,4,5].map(q=>e.jsx("div",{className:"h-12 bg-muted rounded"},q))}):p&&p.length>0?e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Email"}),e.jsx(bt,{children:"Sent At"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{children:"Resources"}),e.jsx(bt,{children:"Agent OS"})]})}),e.jsx(Pn,{children:p.map(q=>e.jsxs(ks,{children:[e.jsx(dt,{className:"font-medium",children:q.email_sent_to}),e.jsx(dt,{children:ys(new Date(q.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{children:e.jsx(nt,{variant:q.delivery_status==="sent"?"default":"destructive",children:q.delivery_status})}),e.jsx(dt,{children:q.resources_count}),e.jsx(dt,{children:q.has_agent_os_activity?e.jsx(nt,{variant:"secondary",children:"Active"}):e.jsx(nt,{variant:"outline",children:"Not Started"})})]},q.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(br,{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 kks={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 Nks(){var je,ke,We;const t=ss(),[s,r]=C.useState(""),[n,a]=C.useState(null),[o,l]=C.useState(!1),[i,c]=C.useState(!1),[u,p]=C.useState(""),[f,y]=C.useState(""),[_,b]=C.useState(!0),[w,j]=C.useState(!1),[N,S]=C.useState(""),[T,I]=C.useState(null),{data:L,isLoading:R}=wt({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:be,error:Me}=await G.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Me)throw Me;const Ae=(be==null?void 0:be.map(qe=>qe.user_id))||[],{data:Re}=await G.from("profiles").select("id, name, email").in("id",Ae),Te=new Map((Re==null?void 0:Re.map(qe=>[qe.id,{name:qe.name,email:qe.email}]))||[]);return be==null?void 0:be.map(qe=>({...qe,profile:Te.get(qe.user_id)||null}))}}),{data:$}=wt({queryKey:["all-profiles-for-points",L],queryFn:async()=>{const Me=[];let Ae=0;for(;;){const{data:Re,error:Te}=await G.from("profiles").select("id, name, email").order("name").range(Ae,Ae+1e3-1);if(Te)throw Te;if(Me.push(...Re),!Re||Re.length<1e3)break;Ae+=1e3}return Me}}),U=(($==null?void 0:$.filter(be=>!(L!=null&&L.some(Me=>Me.user_id===be.id))))||[]).filter(be=>{var Ae,Re;if(!N)return!0;const Me=N.toLowerCase();return((Ae=be.name)==null?void 0:Ae.toLowerCase().includes(Me))||((Re=be.email)==null?void 0:Re.toLowerCase().includes(Me))}),{data:V,isLoading:X}=wt({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:be,error:Me}=await G.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Me)throw Me;return be},enabled:!!(n!=null&&n.user_id)&&i}),{data:se}=wt({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:be,error:Me}=await G.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Me)throw Me;return be},enabled:!!(n!=null&&n.user_id)}),ee=Dt({mutationFn:async({userId:be,points:Me,reason:Ae})=>{const{error:Re}=await G.from("agent_points").insert({user_id:be,points:Me,reason:Ae});if(Re)throw Re;const{data:Te}=await G.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",be).maybeSingle(),qe=((Te==null?void 0:Te.total_points)||0)+Me,ct=((Te==null?void 0:Te.spendable_points)||0)+Me,{error:De}=await G.from("agent_attendance_stats").upsert({user_id:be,total_points:Math.max(0,qe),spendable_points:Math.max(0,ct),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(De)throw De},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-agent-points"]}),t.invalidateQueries({queryKey:["agent-point-history"]}),l(!1),p(""),y(""),me.success(_?"Points awarded successfully!":"Points deducted successfully!")},onError:be=>{console.error("Error modifying points:",be),me.error("Failed to modify points")}}),Q=()=>{if(!n||!u||!f){me.error("Please fill in all fields");return}const be=parseInt(u);if(isNaN(be)||be<=0){me.error("Please enter a valid positive number");return}ee.mutate({userId:n.user_id,points:_?be:-be,reason:f})},de=()=>{if(!T||!u||!f){me.error("Please fill in all fields");return}const be=parseInt(u);if(isNaN(be)||be<=0){me.error("Please enter a valid positive number");return}ee.mutate({userId:T.id,points:be,reason:f},{onSuccess:()=>{j(!1),I(null),S("")}})},re=(be,Me)=>{a(be),b(Me),l(!0)},ne=be=>{a(be),c(!0)},le=L==null?void 0:L.filter(be=>{var Te,qe,ct,De;const Me=((qe=(Te=be.profile)==null?void 0:Te.name)==null?void 0:qe.toLowerCase())||"",Ae=((De=(ct=be.profile)==null?void 0:ct.email)==null?void 0:De.toLowerCase())||"",Re=s.toLowerCase();return Me.includes(Re)||Ae.includes(Re)}),he=(L==null?void 0:L.reduce((be,Me)=>be+Me.total_points,0))||0,we=(L==null?void 0:L.length)||0,ye=we>0?Math.round(he/we):0;return R?e.jsx(Es,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-8 w-64"}),e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(be=>e.jsx(xs,{className:"h-24"},be))}),e.jsx(xs,{className:"h-96"})]})}):e.jsx(Es,{title:"Agent Points",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Agent Points Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Track, view, and manage agent gamification points"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(mr,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),e.jsx("p",{className:"text-2xl font-bold",children:we}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(mo,{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:he.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Average Points"})]}),e.jsx("p",{className:"text-2xl font-bold",children:ye}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"per agent"})]})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[e.jsxs("div",{className:"relative max-w-sm w-full",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search agents...",value:s,onChange:be=>r(be.target.value),className:"pl-10"})]}),e.jsxs(K,{onClick:()=>j(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsx(Ot,{children:"Agent Leaderboard"}),e.jsx(fr,{children:"All agents with their points, events, and streaks"})]}),e.jsx(Oe,{children:!le||le.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(mo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents with points yet"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"w-12",children:"#"}),e.jsx(bt,{children:"Agent"}),e.jsx(bt,{className:"text-center",children:"Total Points"}),e.jsx(bt,{className:"text-center",children:"Spendable"}),e.jsx(bt,{className:"text-center",children:"Events"}),e.jsx(bt,{className:"text-center",children:"Streak"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:le.map((be,Me)=>{var Ae,Re,Te,qe;return e.jsxs(ks,{children:[e.jsx(dt,{className:"font-medium",children:Me<3?e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${Me===0?"bg-yellow-100 text-yellow-700":Me===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:Me+1}):e.jsx("span",{className:"text-muted-foreground",children:Me+1})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(yn,{className:"h-8 w-8",children:e.jsx(vn,{children:((Re=(Ae=be.profile)==null?void 0:Ae.name)==null?void 0:Re.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Te=be.profile)==null?void 0:Te.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(qe=be.profile)==null?void 0:qe.email})]})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(nt,{variant:"secondary",className:"font-bold",children:[e.jsx(Kn,{className:"h-3 w-3 mr-1"}),be.total_points]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(nt,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(bo,{className:"h-3 w-3 mr-1"}),be.spendable_points||0]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(on,{className:"h-3 w-3 text-muted-foreground"}),be.total_events_attended]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Fh,{className:"h-3 w-3 text-orange-500"}),be.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(be,!0),title:"Award points",children:e.jsx(Zs,{className:"h-4 w-4 text-green-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>re(be,!1),title:"Deduct points",children:e.jsx(t1,{className:"h-4 w-4 text-red-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ne(be),title:"View history",children:e.jsx(hM,{className:"h-4 w-4"})})]})})]},be.user_id)})})]})})]}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:_?"Award Points":"Deduct Points"}),e.jsxs(Zr,{children:[_?"Award":"Deduct"," points ",_?"to":"from"," ",((je=n==null?void 0:n.profile)==null?void 0:je.name)||"this agent"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"points",children:"Points Amount"}),e.jsx(Fe,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:be=>p(be.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"reason",children:"Reason"}),e.jsx(Ar,{id:"reason",placeholder:"Enter reason for this adjustment...",value:f,onChange:be=>y(be.target.value)})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:Q,disabled:ee.isPending,className:_?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700",children:ee.isPending?"Saving...":_?"Award Points":"Deduct Points"})]})]})}),e.jsx(_s,{open:i,onOpenChange:c,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{children:["Point History: ",(ke=n==null?void 0:n.profile)==null?void 0:ke.name]}),e.jsx(Zr,{children:"View all point transactions and badges for this agent"})]}),e.jsxs(Aa,{defaultValue:"history",className:"w-full",children:[e.jsxs(ja,{className:"grid w-full grid-cols-2",children:[e.jsx(js,{value:"history",children:"Point History"}),e.jsx(js,{value:"badges",children:"Badges"})]}),e.jsx($s,{value:"history",className:"mt-4",children:X?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(be=>e.jsx(xs,{className:"h-12"},be))}):!V||V.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(hM,{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(be=>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:be.reason}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ys(new Date(be.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(nt,{variant:be.points>=0?"default":"destructive",className:be.points>=0?"bg-green-100 text-green-800":"",children:[be.points>=0?"+":"",be.points]})]},be.id))})}),e.jsx($s,{value:"badges",className:"mt-4",children:!se||se.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(fc,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No badges earned yet"})]}):e.jsx("div",{className:"grid grid-cols-2 gap-3",children:se.map(be=>e.jsxs("div",{className:`p-3 rounded-lg ${kks[be.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fc,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:be.badge_name})]}),be.badge_description&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:be.badge_description}),e.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",ys(new Date(be.earned_at),"MMM d, yyyy")]})]},be.id))})})]})]})}),e.jsx(_s,{open:w,onOpenChange:be=>{j(be),be||(I(null),S(""),p(""),y(""))},children:e.jsxs(vs,{className:"max-w-md",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Award Points to New Agent"}),e.jsx(Zr,{children:"Select an agent who doesn't have points yet and award them points"})]}),e.jsx("div",{className:"space-y-4 py-4",children:T?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(yn,{className:"h-10 w-10",children:e.jsx(vn,{children:((We=T.name)==null?void 0:We.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:T.name||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:T.email})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>I(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"new-points",children:"Points Amount"}),e.jsx(Fe,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:be=>p(be.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"new-reason",children:"Reason"}),e.jsx(Ar,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:f,onChange:be=>y(be.target.value)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Search Agent"}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name or email...",value:N,onChange:be=>S(be.target.value),className:"pl-10"})]})]}),e.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg",children:U.length===0?e.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[e.jsx(mr,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:N?"No matching agents found":"All agents already have points"})]}):U.slice(0,20).map(be=>{var Me;return e.jsxs("button",{onClick:()=>I(be),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(yn,{className:"h-8 w-8",children:e.jsx(vn,{children:((Me=be.name)==null?void 0:Me.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:be.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:be.email})]})]},be.id)})})]})}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),T&&e.jsxs(K,{onClick:de,disabled:ee.isPending,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function Sks(){const{data:t,isLoading:s}=vkt(),[r,n]=C.useState(null),[a,o]=C.useState(!1),[l,i]=C.useState(""),[c,u]=C.useState("all"),[p,f]=C.useState("newest"),[y,_]=C.useState("table"),b=C.useMemo(()=>(t==null?void 0:t.map(T=>T.user_id))||[],[t]),w=C.useMemo(()=>(t==null?void 0:t.map(T=>T.id))||[],[t]),{data:j}=wt({queryKey:["card-profiles-lookup",b],queryFn:async()=>{if(b.length===0)return{};const{data:T}=await G.from("profiles").select("id, name, email").in("id",b),I={};return T==null||T.forEach(L=>{I[L.id]={name:L.name||"",email:L.email||""}}),I},enabled:b.length>0}),{data:N}=wt({queryKey:["card-stats-all",w],queryFn:async()=>{if(w.length===0)return{};const T={};w.forEach(R=>{T[R]={views:0,leads:0}});const{data:I}=await G.from("agent_card_interactions").select("card_id").in("card_id",w).eq("interaction_type","card_view");I==null||I.forEach(R=>{T[R.card_id]&&T[R.card_id].views++});const{data:L}=await G.from("agent_card_leads").select("card_id").in("card_id",w);return L==null||L.forEach(R=>{T[R.card_id]&&T[R.card_id].leads++}),T},enabled:w.length>0}),S=C.useMemo(()=>{if(!t)return[];let T=[...t];if(c==="live"?T=T.filter(I=>I.is_published):c==="draft"&&(T=T.filter(I=>!I.is_published)),l.trim()){const I=l.toLowerCase();T=T.filter(L=>{var $,q;const R=j==null?void 0:j[L.user_id];return L.slug.toLowerCase().includes(I)||(($=R==null?void 0:R.name)==null?void 0:$.toLowerCase().includes(I))||((q=R==null?void 0:R.email)==null?void 0:q.toLowerCase().includes(I))})}return p==="newest"?T.sort((I,L)=>new Date(L.created_at).getTime()-new Date(I.created_at).getTime()):p==="oldest"?T.sort((I,L)=>new Date(I.created_at).getTime()-new Date(L.created_at).getTime()):p==="name"?T.sort((I,L)=>{var R,$;return(((R=j==null?void 0:j[I.user_id])==null?void 0:R.name)||"").localeCompare((($=j==null?void 0:j[L.user_id])==null?void 0:$.name)||"")}):p==="slug"?T.sort((I,L)=>I.slug.localeCompare(L.slug)):p==="views_desc"?T.sort((I,L)=>{var R,$;return(((R=N==null?void 0:N[L.id])==null?void 0:R.views)||0)-((($=N==null?void 0:N[I.id])==null?void 0:$.views)||0)}):p==="views_asc"?T.sort((I,L)=>{var R,$;return(((R=N==null?void 0:N[I.id])==null?void 0:R.views)||0)-((($=N==null?void 0:N[L.id])==null?void 0:$.views)||0)}):p==="leads_desc"?T.sort((I,L)=>{var R,$;return(((R=N==null?void 0:N[L.id])==null?void 0:R.leads)||0)-((($=N==null?void 0:N[I.id])==null?void 0:$.leads)||0)}):p==="leads_asc"&&T.sort((I,L)=>{var R,$;return(((R=N==null?void 0:N[I.id])==null?void 0:R.leads)||0)-((($=N==null?void 0:N[L.id])==null?void 0:$.leads)||0)}),T},[t,c,l,p,j]);return e.jsxs(Es,{title:"Digital Agent Cards",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Digital Agent Cards"}),e.jsx("p",{className:"text-muted-foreground",children:"Create and manage agent digital business cards"})]}),e.jsxs(K,{onClick:()=>o(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Card"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name, email, or slug...",value:l,onChange:T=>i(T.target.value),className:"pl-9"})]}),e.jsxs(rr,{value:c,onValueChange:u,children:[e.jsx(tr,{className:"w-full sm:w-36",children:e.jsx(nr,{placeholder:"Status"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Status"}),e.jsx(Tt,{value:"live",children:"Live"}),e.jsx(Tt,{value:"draft",children:"Draft"})]})]}),e.jsxs(rr,{value:p,onValueChange:f,children:[e.jsx(tr,{className:"w-full sm:w-44",children:e.jsx(nr,{placeholder:"Sort by"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"newest",children:"Newest First"}),e.jsx(Tt,{value:"oldest",children:"Oldest First"}),e.jsx(Tt,{value:"name",children:"Name A–Z"}),e.jsx(Tt,{value:"slug",children:"Slug A–Z"}),e.jsx(Tt,{value:"views_desc",children:"Most Views"}),e.jsx(Tt,{value:"views_asc",children:"Fewest Views"}),e.jsx(Tt,{value:"leads_desc",children:"Most Leads"}),e.jsx(Tt,{value:"leads_asc",children:"Fewest Leads"})]})]}),e.jsxs("div",{className:"flex border rounded-md",children:[e.jsx(K,{variant:y==="table"?"default":"ghost",size:"sm",onClick:()=>_("table"),className:"rounded-r-none",children:e.jsx(jM,{className:"h-4 w-4"})}),e.jsx(K,{variant:y==="grid"?"default":"ghost",size:"sm",onClick:()=>_("grid"),className:"rounded-l-none",children:e.jsx(lf,{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(T=>e.jsx(xs,{className:"h-48"},T))}):S.length>0?y==="table"?e.jsx(Cks,{cards:S,cardProfiles:j,cardStats:N,onEdit:n,sortBy:p,setSortBy:f}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:S.map(T=>e.jsx(Mks,{card:T,onEdit:()=>n(T),stats:N==null?void 0:N[T.id]},T.id))}):t&&t.length>0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(xn,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No matching cards"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Try adjusting your search or filters"})]})}):e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(mr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No cards yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Create your first digital agent card"}),e.jsxs(K,{onClick:()=>o(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Card"]})]})})]}),e.jsx(Tks,{open:a,onOpenChange:o}),r&&e.jsx(Aks,{card:r,open:!!r,onOpenChange:T=>!T&&n(null)})]})}function Cks({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(Oh,{className:"h-3 w-3"}):a===`${c}_asc`?e.jsx(gu,{className:"h-3 w-3"}):e.jsx(ud,{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(gu,{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(nt,{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($a,{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(mi,{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(rn,{className:"h-3.5 w-3.5"})})})]})})]},c.id)})})]})})})}function Mks({card:t,onEdit:s,stats:r}){const[n,a]=C.useState(null);C.useEffect(()=>{(async()=>{const{data:c}=await G.from("profiles").select("name").eq("id",t.user_id).single();let u=null;try{const{data:p}=await G.storage.from("avatars").list(`${t.user_id}`);if(p&&p.length>0){const{data:f}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${p[0].name}`);u=f.publicUrl}}catch{}a({name:(c==null?void 0:c.name)||"Unknown",avatar_url:u})})()},[t.user_id]);const o=`https://cards.relevelup.com/${t.slug}`,l=()=>{navigator.clipboard.writeText(o),me.success("Link copied!")};return e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsxs(yn,{className:"h-10 w-10",children:[e.jsx(Da,{src:(n==null?void 0:n.avatar_url)||void 0}),e.jsx(vn,{children:((n==null?void 0:n.name)||"U")[0]})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold truncate",children:(n==null?void 0:n.name)||"Loading..."}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["/card/",t.slug]})]}),e.jsx(nt,{variant:t.is_published?"default":"secondary",children:t.is_published?"Live":"Draft"})]}),e.jsxs("div",{className:"flex items-center gap-3 mb-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(va,{className:"h-3.5 w-3.5"}),(r==null?void 0:r.views)??0," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mr,{className:"h-3.5 w-3.5"}),(r==null?void 0:r.leads)??0," leads"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:s,className:"flex-1",children:[e.jsx($a,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:l,children:e.jsx(mi,{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(rn,{className:"h-3 w-3"})})})]})]})})}function Tks({open:t,onOpenChange:s}){const[r,n]=C.useState(""),[a,o]=C.useState(""),[l,i]=C.useState(""),[c,u]=C.useState(!1),p=kWe(),f=l.trim(),{data:y}=wt({queryKey:["profiles-search-for-cards",f],queryFn:async()=>{let S=G.from("profiles").select("id, name, email").order("name").limit(50);f.length>=2&&(S=S.or(`name.ilike.%${f}%,email.ilike.%${f}%`));const{data:T}=await S;return T||[]},enabled:t}),[_,b]=C.useState(null),w=(y==null?void 0:y.find(S=>S.id===r))||_,j=()=>{if(!r||!a.trim()){me.error("Select an agent and enter a slug");return}p.mutate({user_id:r,slug:a.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-"),is_published:!0},{onSuccess:()=>{s(!1),n(""),o(""),i("")}})},N=S=>{var I;n(S),u(!1);const T=y==null?void 0:y.find(L=>L.id===S);T&&(b(T),o(((I=T.name)==null?void 0:I.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Create Agent Card"}),e.jsx(Zr,{children:"Select an agent and set their card URL slug."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Agent"}),e.jsxs(Lo,{open:c,onOpenChange:u,children:[e.jsx(Do,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":c,className:"w-full justify-between font-normal",children:[w?`${w.name} (${w.email})`:"Search for an agent...",e.jsx(xg,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Eo,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Mg,{shouldFilter:!1,children:[e.jsx(Tg,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(Ag,{children:[e.jsx(Eg,{children:"No agents found."}),e.jsx(Pg,{children:(y||[]).map(S=>e.jsxs(up,{value:S.id,onSelect:N,children:[e.jsx(ma,{className:At("mr-2 h-4 w-4",r===S.id?"opacity-100":"opacity-0")}),S.name," (",S.email,")"]},S.id))})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"URL Slug"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"/card/"}),e.jsx(Fe,{value:a,onChange:S=>o(S.target.value),placeholder:"john-doe"})]})]}),e.jsx(K,{onClick:j,disabled:p.isPending,className:"w-full",children:p.isPending?"Creating...":"Create Card"})]})]})})}function Aks({card:t,open:s,onOpenChange:r}){const n=NWe(),{data:a}=SWe(t.id),o=ss(),[l,i]=C.useState(null),[c,u]=C.useState(!1),[p,f]=C.useState(!1),[y,_]=C.useState(""),[b,w]=C.useState(t.slug),[j,N]=C.useState(!1),[S,T]=C.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});C.useEffect(()=>{s&&(async()=>{try{const{data:V}=await G.storage.from("avatars").list(`${t.user_id}`);if(V&&V.length>0){const{data:X}=G.storage.from("avatars").getPublicUrl(`${t.user_id}/${V[0].name}`);i(`${X.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const I=U=>{var se;const V=(se=U.target.files)==null?void 0:se[0];if(!V)return;if(!V.type.startsWith("image/")){me.error("Please select an image file");return}if(V.size>5*1024*1024){me.error("Image must be under 5MB");return}const X=new FileReader;X.onloadend=()=>{_(X.result),f(!0)},X.readAsDataURL(V),U.target.value=""},L=async U=>{u(!0);try{const{data:V}=await G.storage.from("avatars").list(`${t.user_id}`);V&&V.length>0&&await G.storage.from("avatars").remove(V.map(de=>`${t.user_id}/${de.name}`));const X=`${t.user_id}/avatar.jpg`,{error:se}=await G.storage.from("avatars").upload(X,U,{upsert:!0,contentType:"image/jpeg"});if(se)throw se;const{data:ee}=G.storage.from("avatars").getPublicUrl(X),Q=`${ee.publicUrl}?t=${Date.now()}`;i(Q),await G.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)}},R=async()=>{const U=b.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!U){me.error("Please enter a valid URL");return}if(U===t.slug){me.info("No changes to save");return}N(!0);try{const{data:V}=await G.from("agent_cards").select("id").eq("slug",U).neq("id",t.id).maybeSingle();if(V){me.error("This URL is already taken. Try another one.");return}const{error:X}=await G.from("agent_cards").update({slug:U}).eq("id",t.id);if(X)throw X;w(U),o.invalidateQueries({queryKey:["agent-cards-admin"]}),me.success("Card address updated!")}catch{me.error("Failed to update card address")}finally{N(!1)}},$=async(U,V)=>{var se;const X=(se=U.target.files)==null?void 0:se[0];if(X){if(!X.type.startsWith("image/")){me.error("Please select an image file");return}try{const ee=X.name.split(".").pop()||"png",Q=V==="brokerage_logo_url"?"brokerage-logo":"team-logo",de=`${t.user_id}/${Q}.${ee}`,{error:re}=await G.storage.from("card-logos").upload(de,X,{upsert:!0});if(re)throw re;const{data:ne}=G.storage.from("card-logos").getPublicUrl(de),le=ne.publicUrl+"?t="+Date.now();T(V==="brokerage_logo_url"?he=>({...he,[V]:le,brokerage_display_name:""}):he=>({...he,[V]:le,team_name:""})),me.success("Logo uploaded!")}catch{me.error("Failed to upload logo")}finally{U.target.value=""}}},q=()=>{n.mutate({id:t.id,...S,title:S.title||null,positioning_statement:S.positioning_statement||null,bio:S.bio||null,review_snippet:S.review_snippet||null,review_source_url:S.review_source_url||null,booking_url:S.booking_url||null,custom_cta_label:S.custom_cta_label||null,custom_cta_url:S.custom_cta_url||null,brokerage_display_name:S.brokerage_display_name||null,brokerage_logo_url:S.brokerage_logo_url||null,brokerage_logo_size:S.brokerage_logo_size,team_name:S.team_name||null,team_logo_url:S.team_logo_url||null,team_logo_size:S.team_logo_size},{onSuccess:()=>r(!1)})};return e.jsxs(e.Fragment,{children:[e.jsx(_s,{open:s,onOpenChange:r,children:e.jsxs(vs,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Edit Agent Card"}),e.jsxs(Zr,{children:["/card/",t.slug]})]}),e.jsxs(Aa,{defaultValue:"content",children:[e.jsxs(ja,{className:"w-full",children:[e.jsx(js,{value:"content",className:"flex-1",children:"Content"}),e.jsx(js,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(js,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(js,{value:"analytics",className:"flex-1",children:"Analytics"})]}),e.jsxs($s,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Published"}),e.jsx(Br,{checked:S.is_published,onCheckedChange:U=>T(V=>({...V,is_published:U}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[e.jsxs(yn,{className:"h-16 w-16",children:[e.jsx(Da,{src:l||void 0}),e.jsx(vn,{children:"?"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:I,disabled:c}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:c,children:e.jsx("span",{children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ni,{className:"h-3 w-3 mr-1"}),"Change Photo"]})})})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Card Address"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs("div",{className:"flex flex-1",children:[e.jsx("span",{className:"inline-flex items-center px-3 rounded-l-md border border-r-0 bg-muted text-muted-foreground text-xs whitespace-nowrap",children:"cards.relevelup.com/"}),e.jsx(Fe,{value:b,onChange:U=>w(U.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:R,disabled:j||b===t.slug,className:"shrink-0",children:j?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Theme"}),e.jsxs(rr,{value:S.theme,onValueChange:U=>T(V=>({...V,theme:U})),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"standard",children:"✨ Standard (Modern Clean)"}),e.jsx(Tt,{value:"luxury",children:"🌙 Luxury (Dark & Gold)"}),e.jsx(Tt,{value:"bold",children:"🔥 Bold (Vibrant & Punchy)"}),e.jsx(Tt,{value:"classic",children:"📋 Classic (Professional)"})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Title / Tagline"}),e.jsx(Fe,{value:S.title,onChange:U=>T(V=>({...V,title:U.target.value})),placeholder:"e.g. Luxury Real Estate Specialist"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Shown below the agent's name on the card"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Positioning Statement"}),e.jsx(Fe,{value:S.positioning_statement,onChange:U=>T(V=>({...V,positioning_statement:U.target.value})),placeholder:"Your home journey, handled with care."})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Bio"}),e.jsx(Ar,{value:S.bio,onChange:U=>T(V=>({...V,bio:U.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Review Snippet"}),e.jsx(Fe,{value:S.review_snippet,onChange:U=>T(V=>({...V,review_snippet:U.target.value})),placeholder:"Best agent we've ever worked with..."})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Review Source URL"}),e.jsx(Fe,{value:S.review_source_url,onChange:U=>T(V=>({...V,review_source_url:U.target.value})),placeholder:"https://g.page/your-business/review"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Booking URL (optional — if empty, shows lead form)"}),e.jsx(Fe,{value:S.booking_url,onChange:U=>T(V=>({...V,booking_url:U.target.value})),placeholder:"https://calendly.com/your-link"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Custom CTA Label (optional)"}),e.jsx(Fe,{value:S.custom_cta_label,onChange:U=>T(V=>({...V,custom_cta_label:U.target.value})),placeholder:"Book a Call"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Custom CTA URL (optional)"}),e.jsx(Fe,{value:S.custom_cta_url,onChange:U=>T(V=>({...V,custom_cta_url:U.target.value})),placeholder:"https://example.com/landing"})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(_e,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Fe,{value:S.brokerage_display_name,onChange:U=>T(V=>({...V,brokerage_display_name:U.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:()=>T(U=>({...U,brokerage_logo_url:""})),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(ni,{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:U=>$(U,"brokerage_logo_url")})]})]}),S.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.brokerage_logo_size||56,"px"]})]}),e.jsx(Bx,{value:[S.brokerage_logo_size||56],onValueChange:([U])=>T(V=>({...V,brokerage_logo_size:U})),min:24,max:120,step:4})]})]})]}),e.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[e.jsx(_e,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team Branding"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Fe,{value:S.team_name,onChange:U=>T(V=>({...V,team_name:U.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:()=>T(U=>({...U,team_logo_url:""})),className:"absolute -top-1.5 -right-1.5 h-5 w-5 rounded-full bg-destructive text-destructive-foreground text-xs flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-xs font-medium hover:bg-muted transition-colors",children:[e.jsx(ni,{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:U=>$(U,"team_logo_url")})]})]}),S.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.team_logo_size||56,"px"]})]}),e.jsx(Bx,{value:[S.team_logo_size||56],onValueChange:([U])=>T(V=>({...V,team_logo_size:U})),min:24,max:120,step:4})]})]})]})]}),e.jsx($s,{value:"sections",className:"space-y-4 mt-4",children:[{key:"show_photo",label:"Show Photo",hint:"Photo is pulled from the agent's profile."},{key:"show_bio",label:"Show Bio"},{key:"show_credentials",label:"Show Credentials"},{key:"show_social_links",label:"Show Social Links"},{key:"show_save_contact",label:"Save Contact Button"},{key:"show_leave_review",label:"Leave Review Button"},{key:"show_refer_friend",label:"Refer a Friend Button"}].map(({key:U,label:V,hint:X})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(_e,{children:V}),X&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[X," ",U==="show_photo"&&e.jsx("a",{href:"/profile",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:"Update Profile"})]})]}),e.jsx(Br,{checked:S[U],onCheckedChange:se=>T(ee=>({...ee,[U]:se}))})]},U))}),e.jsx($s,{value:"blocks",className:"mt-4",children:e.jsx(Vot,{cardId:t.id})}),e.jsx($s,{value:"analytics",className:"mt-4",children:a?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.views}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Views"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.clicks}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Clicks"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:a.leads.length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Leads"})]})})]}),a.leads.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Recent Leads"}),e.jsx("div",{className:"space-y-2",children:a.leads.slice(0,5).map(U=>e.jsxs("div",{className:"text-sm p-2 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"font-medium",children:U.name}),U.phone&&e.jsxs("span",{className:"text-muted-foreground",children:[" · ",U.phone]}),U.intent&&e.jsx(nt,{variant:"secondary",className:"ml-2 text-xs",children:U.intent})]},U.id))})]})]}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No analytics data yet"})})]}),e.jsx(K,{onClick:q,disabled:n.isPending,className:"w-full mt-4",children:n.isPending?"Saving...":"Save Changes"})]})}),e.jsx(sNe,{open:p,onClose:()=>f(!1),imageSrc:y,onCropComplete:L,aspectRatio:1})]})}const HM={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"},BSe={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 $Se(t=!0){return wt({queryKey:["marketplace-categories",t],queryFn:async()=>{let s=G.from("marketplace_categories").select("*").order("sort_order",{ascending:!0});t&&(s=s.eq("is_active",!0));const{data:r,error:n}=await s;if(n)throw n;return r}})}function Eks(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),me.success("Category created successfully")},onError:s=>{me.error("Failed to create category: "+s.message)}})}function Pks(){const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("marketplace_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),me.success("Category updated successfully")},onError:s=>{me.error("Failed to update category: "+s.message)}})}function Iks(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("marketplace_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-categories"]}),me.success("Category deleted successfully")},onError:s=>{me.error("Failed to delete category: "+s.message)}})}function alt(t,s=!0){return wt({queryKey:["marketplace-products",t,s],queryFn:async()=>{let r=G.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).order("sort_order",{ascending:!0});t&&(r=r.eq("category_id",t)),s&&(r=r.eq("is_active",!0));const{data:n,error:a}=await r;if(a)throw a;return n}})}function Lks(t){return wt({queryKey:["marketplace-product",t],queryFn:async()=>{const{data:s,error:r}=await G.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function Dks(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_products").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),me.success("Product created successfully")},onError:s=>{me.error("Failed to create product: "+s.message)}})}function Oks(){const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("marketplace_products").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.id]}),me.success("Product updated successfully")},onError:s=>{me.error("Failed to update product: "+s.message)}})}function Rks(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("marketplace_products").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["marketplace-products"]}),me.success("Product deleted successfully")},onError:s=>{me.error("Failed to delete product: "+s.message)}})}function Fks(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_product_images").insert([s]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.product_id]})}})}function zks(){const t=ss();return Dt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await G.from("marketplace_product_images").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),me.success("Image deleted successfully")},onError:s=>{me.error("Failed to delete image: "+s.message)}})}function Bks(){const t=ss();return Dt({mutationFn:async({imageId:s,productId:r})=>{const{error:n}=await G.from("marketplace_product_images").update({is_primary:!1}).eq("product_id",r);if(n)throw n;const{error:a}=await G.from("marketplace_product_images").update({is_primary:!0}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),me.success("Primary image updated")},onError:s=>{me.error("Failed to set primary image: "+s.message)}})}function $ks(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("marketplace_product_variants").insert([s]).select().single();if(n)throw n;return r},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.product_id]}),me.success("Variant added successfully")}})}function qks(){const t=ss();return Dt({mutationFn:async({id:s,productId:r})=>{const{error:n}=await G.from("marketplace_product_variants").delete().eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",s]}),me.success("Variant deleted successfully")}})}function Uks(){const t=ss();return Dt({mutationFn:async({productId:s,videoUrl:r})=>{await G.from("marketplace_product_videos").delete().eq("product_id",s);const{data:n,error:a}=await G.from("marketplace_product_videos").insert({product_id:s,video_url:r}).select().single();if(a)throw a;return n},onSuccess:(s,r)=>{t.invalidateQueries({queryKey:["marketplace-products"]}),t.invalidateQueries({queryKey:["marketplace-product",r.productId]}),me.success("Video updated successfully")}})}function Vks(t){const{isAdmin:s}=Ws();return wt({queryKey:["marketplace-orders",t,s],queryFn:async()=>{let r=G.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).order("created_at",{ascending:!1});const{data:n,error:a}=await r;if(a)throw a;if(s&&n){const o=[...new Set(n.map(c=>c.user_id))],{data:l}=await G.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 Hks(){const{user:t}=Ws();return wt({queryKey:["my-marketplace-orders",t==null?void 0:t.id],queryFn:async()=>{const{data:s,error:r}=await G.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("user_id",t.id).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!(t!=null&&t.id)})}function Wks(t){return wt({queryKey:["marketplace-order",t],queryFn:async()=>{const{data:s,error:r}=await G.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("id",t).single();if(r)throw r;return s},enabled:!!t})}function Gks(){const t=ss(),{user:s}=Ws();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 G.from("marketplace_orders").update(c).eq("id",r);if(u)throw u;const{error:p}=await G.from("marketplace_order_status_history").insert({order_id:r,status:n,notes:a,created_by:s==null?void 0:s.id});if(p)throw p;if(["shipped","in_production","processing","completed"].includes(n)&&n!==i)try{await G.functions.invoke("marketplace-order-notify",{body:{orderId:r,notificationType:n==="shipped"?"shipped":"status_update",newStatus:n,trackingNumber:o,trackingUrl:l}})}catch(y){console.error("Failed to send notification email:",y)}},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 Kks(){const t=ss();return Dt({mutationFn:async({itemId:s,proofUrl:r,proofNotes:n,orderId:a})=>{const{error:o}=await G.from("marketplace_order_items").update({proof_url:r,proof_notes:n,proof_status:"pending"}).eq("id",s);if(o)throw o;await G.from("marketplace_orders").update({status:"awaiting_proof_approval"}).eq("id",a);try{await G.functions.invoke("marketplace-order-notify",{body:{orderId:a,notificationType:"proof_ready"}})}catch(l){console.error("Failed to send proof notification:",l)}return a},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Proof uploaded & customer notified")}})}function Zks(){const t=ss();return Dt({mutationFn:async({itemId:s,orderId:r})=>{const{error:n}=await G.from("marketplace_order_items").update({proof_status:"approved"}).eq("id",s);if(n)throw n;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Proof approved")}})}function Yks(){const t=ss();return Dt({mutationFn:async({itemId:s,orderId:r,reason:n})=>{const{error:a}=await G.from("marketplace_order_items").update({proof_status:"rejected",proof_notes:n}).eq("id",s);if(a)throw a;return r},onSuccess:s=>{t.invalidateQueries({queryKey:["marketplace-orders"]}),t.invalidateQueries({queryKey:["marketplace-order",s]}),t.invalidateQueries({queryKey:["my-marketplace-orders"]}),me.success("Proof rejected - please upload a new proof")}})}function Xks(){const{data:t,isLoading:s}=$Se(!1),r=Eks(),n=Pks(),a=Iks(),[o,l]=C.useState(!1),[i,c]=C.useState(null),[u,p]=C.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)},y=w=>{c(w),p({name:w.name,description:w.description||"",image_url:w.image_url||"",sort_order:w.sort_order,is_active:w.is_active}),l(!0)},_=async w=>{w.preventDefault(),i?await n.mutateAsync({id:i.id,...u}):await r.mutateAsync(u),l(!1),f()},b=async w=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(w)};return s?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(xs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(w=>e.jsx(xs,{className:"h-12 w-full"},w))})})]}):e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{children:"Categories"}),e.jsxs(_s,{open:o,onOpenChange:w=>{l(w),w||f()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:i?"Edit Category":"Add Category"})}),e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"name",children:"Name"}),e.jsx(Fe,{id:"name",value:u.name,onChange:w=>p({...u,name:w.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",value:u.description,onChange:w=>p({...u,description:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"image_url",children:"Image URL"}),e.jsx(Fe,{id:"image_url",value:u.image_url,onChange:w=>p({...u,image_url:w.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Fe,{id:"sort_order",type:"number",value:u.sort_order,onChange:w=>p({...u,sort_order:parseInt(w.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_active",checked:u.is_active,onCheckedChange:w=>p({...u,is_active:w})}),e.jsx(_e,{htmlFor:"is_active",children:"Active"})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:r.isPending||n.isPending,children:i?"Update Category":"Create Category"})]})]})]})]}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{children:"Sort Order"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(w=>e.jsxs(ks,{children:[e.jsx(dt,{className:"font-medium",children:w.name}),e.jsx(dt,{className:"max-w-xs truncate",children:w.description}),e.jsx(dt,{children:w.sort_order}),e.jsx(dt,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${w.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:w.is_active?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>y(w),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>b(w.id),disabled:a.isPending,children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},w.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function Qks(){var ye,je;const{data:t,isLoading:s}=alt(void 0,!1),{data:r}=$Se(!1),n=Dks(),a=Oks(),o=Rks(),l=Fks(),i=zks(),c=Bks(),u=$ks(),p=qks(),f=Uks(),[y,_]=C.useState(!1),[b,w]=C.useState(!1),[j,N]=C.useState(!1),[S,T]=C.useState(null),[I,L]=C.useState(null),[R,$]=C.useState(!1),[q,U]=C.useState({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),[V,X]=C.useState({name:"",price_adjustment:0}),[se,ee]=C.useState(""),Q=()=>{U({name:"",description:"",base_price:0,shipping_fee:0,category_id:"",allow_artwork_upload:!1,requires_proof_approval:!1,is_active:!0,sort_order:0}),T(null)},de=ke=>{T(ke),U({name:ke.name,description:ke.description||"",base_price:Number(ke.base_price),shipping_fee:Number(ke.shipping_fee),category_id:ke.category_id||"",allow_artwork_upload:ke.allow_artwork_upload,requires_proof_approval:ke.requires_proof_approval,is_active:ke.is_active,sort_order:ke.sort_order}),_(!0)},re=async ke=>{ke.preventDefault();const We={...q,category_id:q.category_id||null};S?await a.mutateAsync({id:S.id,...We}):await n.mutateAsync(We),_(!1),Q()},ne=async ke=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(ke)},le=async ke=>{if(!I||!ke.target.files||ke.target.files.length===0)return;$(!0);const We=ke.target.files[0],be=We.name.split(".").pop(),Me=`products/${I.id}/${Date.now()}.${be}`;try{const{error:Ae}=await G.storage.from("marketplace").upload(Me,We);if(Ae)throw Ae;const{data:{publicUrl:Re}}=G.storage.from("marketplace").getPublicUrl(Me);await l.mutateAsync({product_id:I.id,image_url:Re,is_primary:!I.images||I.images.length===0}),me.success("Image uploaded successfully")}catch(Ae){me.error("Failed to upload image: "+Ae.message)}finally{$(!1)}},he=async ke=>{ke.preventDefault(),I&&(await u.mutateAsync({product_id:I.id,name:V.name,price_adjustment:V.price_adjustment}),X({name:"",price_adjustment:0}))},we=async()=>{!I||!se||(await f.mutateAsync({productId:I.id,videoUrl:se}),ee(""))};return s?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(xs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(ke=>e.jsx(xs,{className:"h-64 w-full"},ke))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{children:"Products"}),e.jsxs(_s,{open:y,onOpenChange:ke=>{_(ke),ke||Q()},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Product"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{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(_e,{htmlFor:"name",children:"Product Name"}),e.jsx(Fe,{id:"name",value:q.name,onChange:ke=>U({...q,name:ke.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"category",children:"Category"}),e.jsxs(rr,{value:q.category_id,onValueChange:ke=>U({...q,category_id:ke}),children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select category"})}),e.jsx(sr,{children:r==null?void 0:r.map(ke=>e.jsx(Tt,{value:ke.id,children:ke.name},ke.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"description",children:"Description"}),e.jsx(Ar,{id:"description",value:q.description,onChange:ke=>U({...q,description:ke.target.value}),rows:4})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"base_price",children:"Base Price ($)"}),e.jsx(Fe,{id:"base_price",type:"number",step:"0.01",min:"0",value:q.base_price,onChange:ke=>U({...q,base_price:parseFloat(ke.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),e.jsx(Fe,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:q.shipping_fee,onChange:ke=>U({...q,shipping_fee:parseFloat(ke.target.value)||0})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(Fe,{id:"sort_order",type:"number",value:q.sort_order,onChange:ke=>U({...q,sort_order:parseInt(ke.target.value)||0})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"allow_artwork_upload",checked:q.allow_artwork_upload,onCheckedChange:ke=>U({...q,allow_artwork_upload:ke})}),e.jsx(_e,{htmlFor:"allow_artwork_upload",children:"Allow customer to upload artwork"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"requires_proof_approval",checked:q.requires_proof_approval,onCheckedChange:ke=>U({...q,requires_proof_approval:ke})}),e.jsx(_e,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"is_active",checked:q.is_active,onCheckedChange:ke=>U({...q,is_active:ke})}),e.jsx(_e,{htmlFor:"is_active",children:"Active"})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:S?"Update Product":"Create Product"})]})]})]})]}),e.jsx(Oe,{children:t&&t.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(ke=>{var We,be;return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[ke.images&&ke.images.length>0?e.jsx("img",{src:((We=ke.images.find(Me=>Me.is_primary))==null?void 0:We.image_url)||ke.images[0].image_url,alt:ke.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:"No image"}),!ke.is_active&&e.jsx(nt,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1",children:ke.name}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:((be=ke.category)==null?void 0:be.name)||"No category"}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("span",{className:"font-bold",children:["$",Number(ke.base_price).toFixed(2)]}),Number(ke.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["+$",Number(ke.shipping_fee).toFixed(2)," shipping"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[ke.allow_artwork_upload&&e.jsx(nt,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),ke.requires_proof_approval&&e.jsx(nt,{variant:"outline",className:"text-xs",children:"Proof Required"}),ke.variants&&ke.variants.length>0&&e.jsxs(nt,{variant:"outline",className:"text-xs",children:[ke.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>de(ke),children:[e.jsx($a,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(ke),w(!0)},children:[e.jsx(Qv,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(ke),N(!0)},children:[e.jsx(Tm,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>ne(ke.id),children:e.jsx(jr,{className:"h-3 w-3 text-destructive"})})]})]})]},ke.id)})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No products yet. Create your first product to get started."})})]}),e.jsx(_s,{open:b,onOpenChange:w,children:e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:["Manage Images - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-4",children:(ye=I==null?void 0:I.images)==null?void 0:ye.map(ke=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:ke.image_url,alt:"",className:"w-full aspect-square object-cover rounded-lg"}),ke.is_primary&&e.jsx(nt,{className:"absolute top-2 left-2",variant:"default",children:"Primary"}),e.jsxs("div",{className:"absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[!ke.is_primary&&e.jsx(K,{variant:"secondary",size:"icon",onClick:async()=>{var We;await c.mutateAsync({imageId:ke.id,productId:I.id}),L({...I,images:(We=I.images)==null?void 0:We.map(be=>({...be,is_primary:be.id===ke.id}))})},disabled:c.isPending,title:"Set as primary",children:e.jsx(Kn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"destructive",size:"icon",onClick:async()=>{var be;await i.mutateAsync({id:ke.id,productId:I.id});const We=t==null?void 0:t.find(Me=>Me.id===I.id);We&&L({...We,images:(be=We.images)==null?void 0:be.filter(Me=>Me.id!==ke.id)})},disabled:i.isPending,children:e.jsx(jr,{className:"h-4 w-4"})})]})]},ke.id))}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:le,className:"hidden",id:"image-upload",disabled:R}),e.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer",children:[e.jsx(Qv,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:R?"Uploading...":"Click to upload an image"})]})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx(_e,{children:"Product Video (optional)"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(Fe,{placeholder:"Enter video URL (YouTube, Vimeo, etc.)",value:se,onChange:ke=>ee(ke.target.value)}),e.jsxs(K,{onClick:we,disabled:!se,children:[e.jsx(Nn,{className:"h-4 w-4 mr-2"}),"Set Video"]})]}),(I==null?void 0:I.video)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Current video: ",I.video.video_url]})]})]})]})}),e.jsx(_s,{open:j,onOpenChange:N,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:["Manage Variants - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:he,className:"flex gap-2",children:[e.jsx(Fe,{placeholder:"Variant name (e.g., 500 count)",value:V.name,onChange:ke=>X({...V,name:ke.target.value}),required:!0}),e.jsx(Fe,{type:"number",step:"0.01",placeholder:"Price adj.",value:V.price_adjustment,onChange:ke=>X({...V,price_adjustment:parseFloat(ke.target.value)||0}),className:"w-32"}),e.jsx(K,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(je=I==null?void 0:I.variants)==null?void 0:je.map(ke=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:ke.name}),e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:[Number(ke.price_adjustment)>=0?"+":"","$",Number(ke.price_adjustment).toFixed(2)]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutateAsync({id:ke.id,productId:I.id}),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]},ke.id)),(!(I!=null&&I.variants)||I.variants.length===0)&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:'No variants yet. Add variants like "250 count", "500 count", etc.'})]})]})]})})]})}const Jks=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function eNs(){var w,j,N;const{data:t,isLoading:s}=Vks(),r=Gks(),n=Kks(),[a,o]=C.useState(null),[l,i]=C.useState(!1),[c,u]=C.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[p,f]=C.useState(!1),y=S=>{o(S),u({status:S.status,notes:"",trackingNumber:S.tracking_number||"",trackingUrl:S.tracking_url||""}),i(!0)},_=async()=>{a&&(await r.mutateAsync({orderId:a.id,status:c.status,notes:c.notes,trackingNumber:c.trackingNumber,trackingUrl:c.trackingUrl,previousStatus:a.status}),i(!1))},b=async(S,T)=>{if(!a||!S.target.files||S.target.files.length===0)return;f(!0);const I=S.target.files[0],L=I.name.split(".").pop(),R=`proofs/${a.id}/${T}/${Date.now()}.${L}`;try{const{error:$}=await G.storage.from("marketplace").upload(R,I);if($)throw $;const{data:{publicUrl:q}}=G.storage.from("marketplace").getPublicUrl(R);await n.mutateAsync({itemId:T,proofUrl:q,orderId:a.id}),me.success("Proof uploaded successfully")}catch($){me.error("Failed to upload proof: "+$.message)}finally{f(!1)}};return s?e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(xs,{className:"h-8 w-48"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(S=>e.jsx(xs,{className:"h-16 w-full"},S))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Orders"})}),e.jsx(Oe,{children:t&&t.length>0?e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Order #"}),e.jsx(bt,{children:"Customer"}),e.jsx(bt,{children:"Date"}),e.jsx(bt,{children:"Total"}),e.jsx(bt,{children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:t.map(S=>{var T,I;return e.jsxs(ks,{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:((T=S.user)==null?void 0:T.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(I=S.user)==null?void 0:I.email})]})}),e.jsx(dt,{children:ys(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(nt,{className:BSe[S.status],children:HM[S.status]})}),e.jsx(dt,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>y(S),children:[e.jsx(va,{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(_s,{open:l,onOpenChange:i,children:e.jsxs(vs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:["Order ",a==null?void 0:a.order_number]})}),a&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Customer"}),e.jsx("p",{children:(w=a.user)==null?void 0:w.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(j=a.user)==null?void 0:j.email})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Shipping Address"}),e.jsx("p",{children:a.shipping_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.shipping_address,e.jsx("br",{}),a.shipping_city,", ",a.shipping_state," ",a.shipping_zip]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-2",children:"Order Items"}),e.jsx("div",{className:"space-y-3",children:(N=a.items)==null?void 0:N.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name})]}),e.jsxs("p",{className:"font-bold",children:["$",Number(S.unit_price).toFixed(2)," x ",S.quantity]})]}),S.artwork_url&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Customer Artwork:"}),e.jsx("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Artwork"})]}),e.jsx("div",{className:"mt-3 pt-3 border-t",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Proof Status: "}),e.jsx(nt,{variant:S.proof_status==="approved"?"default":"secondary",children:S.proof_status||"No proof yet"})]}),S.proof_url?e.jsx("a",{href:S.proof_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Proof"}):e.jsxs("div",{children:[e.jsx("input",{type:"file",accept:"image/*,.pdf",onChange:T=>b(T,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(ni,{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(_e,{children:"Status"}),e.jsxs(rr,{value:c.status,onValueChange:S=>u({...c,status:S}),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:Jks.map(S=>e.jsx(Tt,{value:S,children:HM[S]},S))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Tracking Number"}),e.jsx(Fe,{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(_e,{children:"Tracking URL"}),e.jsx(Fe,{value:c.trackingUrl,onChange:S=>u({...c,trackingUrl:S.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Notes (optional)"}),e.jsx(Ar,{value:c.notes,onChange:S=>u({...c,notes:S.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(K,{onClick:_,disabled:r.isPending,className:"w-full",children:[e.jsx(bl,{className:"h-4 w-4 mr-2"}),"Update Status"]})]})]}),a.status_history&&a.status_history.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Status History"}),e.jsx("div",{className:"space-y-2",children:a.status_history.map(S=>e.jsxs("div",{className:"flex justify-between text-sm p-2 bg-muted rounded",children:[e.jsxs("div",{children:[e.jsx(nt,{variant:"outline",children:HM[S.status]}),S.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:S.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:ys(new Date(S.created_at),"MMM d, h:mm a")})]},S.id))})]})]})]})})]})}function tNs(){const[t,s]=C.useState("products"),r=Pr();return e.jsx(Es,{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(rn,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(Aa,{value:t,onValueChange:s,children:[e.jsxs(ja,{className:"grid w-full grid-cols-3",children:[e.jsxs(js,{value:"products",className:"flex items-center gap-2",children:[e.jsx(bl,{className:"h-4 w-4"}),"Products"]}),e.jsxs(js,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(Cm,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(js,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(dp,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx($s,{value:"products",children:e.jsx(Qks,{})}),e.jsx($s,{value:"categories",children:e.jsx(Xks,{})}),e.jsx($s,{value:"orders",children:e.jsx(eNs,{})})]})]})})}function ilt(){return wt({queryKey:["reward-categories"],queryFn:async()=>{const{data:t,error:s}=await G.from("reward_store_categories").select("*").order("sort_order",{ascending:!0});if(s)throw s;return t}})}function sNs(t){return wt({queryKey:["reward-items",t],queryFn:async()=>{let s=G.from("reward_store_items").select(` *, category:reward_store_categories(*) `).order("created_at",{ascending:!1});const{data:r,error:n}=await s;if(n)throw n;return r}})}function rNs(t){return wt({queryKey:["active-reward-items",t],queryFn:async()=>{let s=G.from("reward_store_items").select(` *, category:reward_store_categories(*) `).eq("is_active",!0).order("created_at",{ascending:!1});t&&(s=s.eq("category_id",t));const{data:r,error:n}=await s;if(n)throw n;return r}})}function nNs(t){return wt({queryKey:["user-purchases",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).eq("user_id",t).order("purchased_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function aNs(){return wt({queryKey:["all-reward-purchases"],queryFn:async()=>{const{data:t,error:s}=await G.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).order("purchased_at",{ascending:!1});if(s)throw s;if(!t||t.length===0)return[];const r=[...new Set(t.map(l=>l.user_id))],{data:n,error:a}=await G.from("profiles").select("id, name, email").in("id",r);if(a)throw a;const o=new Map((n==null?void 0:n.map(l=>[l.id,l]))||[]);return t.map(l=>({...l,user:o.get(l.user_id)||null}))}})}function iNs(t){return wt({queryKey:["spendable-points",t],queryFn:async()=>{if(!t)return 0;const{data:s,error:r}=await G.from("agent_attendance_stats").select("spendable_points").eq("user_id",t).single();if(r&&r.code!=="PGRST116")throw r;return(s==null?void 0:s.spendable_points)||0},enabled:!!t})}function oNs(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.rpc("purchase_reward_item",{p_item_id:s});if(n)throw n;const a=r;if(!a.success)throw new Error(a.error||"Purchase failed");return a},onSuccess:()=>{t.invalidateQueries({queryKey:["user-purchases"]}),t.invalidateQueries({queryKey:["spendable-points"]}),t.invalidateQueries({queryKey:["active-reward-items"]}),t.invalidateQueries({queryKey:["reward-items"]})}})}function lNs(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("reward_store_categories").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function cNs(){const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("reward_store_categories").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function dNs(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("reward_store_categories").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-categories"]})}})}function uNs(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("reward_store_items").insert([s]).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function hNs(){const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("reward_store_items").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function mNs(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("reward_store_items").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["reward-items"]}),t.invalidateQueries({queryKey:["active-reward-items"]})}})}function pNs(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function xye(t,s){const r=pNs(t);if(r)try{const{data:n,error:a}=await G.storage.from(r.bucket).download(r.path);if(a){console.error("Error downloading file:",a),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 olt(){return wt({queryKey:["point-reward-settings"],queryFn:async()=>{const{data:t,error:s}=await G.from("point_reward_settings").select("*").order("action_name");if(s)throw s;return t}})}function fNs(){const t=ss();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 G.from("point_reward_settings").update(a).eq("id",s).select().single();if(l)throw l;return o},onSuccess:()=>{t.invalidateQueries({queryKey:["point-reward-settings"]})}})}function gNs(){const{user:t}=Ws(),[s,r]=C.useState("items"),[n,a]=C.useState(!1),[o,l]=C.useState(null),[i,c]=C.useState(""),[u,p]=C.useState(""),[f,y]=C.useState(""),[_,b]=C.useState(null),[w,j]=C.useState(!1),[N,S]=C.useState(null),[T,I]=C.useState(""),[L,R]=C.useState(""),[$,q]=C.useState(null),[U,V]=C.useState(""),[X,se]=C.useState("file"),[ee,Q]=C.useState(""),[de,re]=C.useState(""),[ne,le]=C.useState(""),[he,we]=C.useState(!0),[ye,je]=C.useState(null),[ke,We]=C.useState(!1),[be,Me]=C.useState(!1),Ae=C.useRef(null),Re=C.useRef(null),{data:Te,isLoading:qe}=ilt(),{data:ct,isLoading:De}=sNs(),{data:Rt,isLoading:pe}=aNs(),{data:Je,isLoading:lt}=olt(),rt=lNs(),Se=cNs(),it=dNs(),$e=uNs(),ot=hNs(),Ue=mNs(),Ke=fNs(),[Xe,He]=C.useState({}),Ye=jt=>{jt?(l(jt),c(jt.name),p(jt.description||""),y(jt.icon||"")):(l(null),c(""),p(""),y("")),a(!0)},tt=async()=>{if(!i.trim()){me.error("Please enter a category name");return}try{o?(await Se.mutateAsync({id:o.id,name:i,description:u||null,icon:f||null}),me.success("Category updated successfully")):(await rt.mutateAsync({name:i,description:u||null,icon:f||null,sort_order:((Te==null?void 0:Te.length)||0)+1}),me.success("Category created successfully")),a(!1)}catch(jt){console.error("Error saving category:",jt),me.error("Failed to save category")}},Et=async()=>{if(_)try{await it.mutateAsync(_),me.success("Category deleted successfully"),b(null)}catch(jt){console.error("Error deleting category:",jt),me.error("Failed to delete category")}},qt=jt=>{var As;jt?(S(jt),I(jt.name),R(jt.description||""),q(jt.category_id),V(jt.points_cost.toString()),se(jt.item_type),Q(jt.file_url||""),re(jt.preview_image_url||""),le(((As=jt.max_quantity)==null?void 0:As.toString())||""),we(jt.is_active)):(S(null),I(""),R(""),q(null),V(""),se("file"),Q(""),re(""),le(""),we(!0)),j(!0)},ms=async(jt,As)=>{As==="file"?We(!0):Me(!0);try{const Ps=jt.name.split(".").pop(),ar=`${Date.now()}-${Math.random().toString(36).substring(7)}.${Ps}`,Dn=`${As==="file"?"items":"previews"}/${ar}`,{error:Va}=await G.storage.from("reward-store").upload(Dn,jt);if(Va)throw Va;const{data:{publicUrl:pa}}=G.storage.from("reward-store").getPublicUrl(Dn);As==="file"?Q(pa):re(pa),me.success("File uploaded successfully")}catch(Ps){console.error("Error uploading file:",Ps),me.error("Failed to upload file")}finally{As==="file"?We(!1):Me(!1)}},Xt=async()=>{if(!T.trim()){me.error("Please enter an item name");return}if(!U||parseInt(U)<0){me.error("Please enter a valid points cost");return}try{const jt={name:T,description:L||null,category_id:$,points_cost:parseInt(U),item_type:X,file_url:ee||null,preview_image_url:de||null,max_quantity:ne?parseInt(ne):null,current_quantity:ne?parseInt(ne):null,is_active:he,created_by:t==null?void 0:t.id};N?(await ot.mutateAsync({id:N.id,...jt,current_quantity:N.max_quantity!==(ne?parseInt(ne):null)?ne?parseInt(ne):null:N.current_quantity}),me.success("Item updated successfully")):(await $e.mutateAsync(jt),me.success("Item created successfully")),j(!1)}catch(jt){console.error("Error saving item:",jt),me.error("Failed to save item")}},rs=async()=>{if(ye)try{await Ue.mutateAsync(ye),me.success("Item deleted successfully"),je(null)}catch(jt){console.error("Error deleting item:",jt),me.error("Failed to delete item")}},ps=async(jt,As)=>{const Ps=Xe[jt];if(Ps===void 0||Ps===As.toString())return;const ar=parseInt(Ps);if(isNaN(ar)||ar<0){me.error("Please enter a valid positive number");return}try{await Ke.mutateAsync({id:jt,points:ar}),me.success("Points updated successfully"),He(Dn=>{const Va={...Dn};return delete Va[jt],Va})}catch(Dn){console.error("Error updating points:",Dn),me.error("Failed to update points")}};return qe||De||pe||lt?e.jsx(Es,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{className:"h-8 w-64"}),e.jsx(xs,{className:"h-96"})]})}):e.jsxs(Es,{title:"Reward Store",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Reward Store Management"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage store items that agents can purchase with their points"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(bl,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Total Items"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(ct==null?void 0:ct.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(ct==null?void 0:ct.filter(jt=>jt.is_active).length)||0," active"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Cm,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(Te==null?void 0:Te.length)||0})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Kn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Avg. Cost"})]}),e.jsxs("p",{className:"text-2xl font-bold",children:[ct&&ct.length>0?Math.round(ct.reduce((jt,As)=>jt+As.points_cost,0)/ct.length):0," pts"]})]})})]}),e.jsxs(Aa,{value:s,onValueChange:r,children:[e.jsxs(ja,{children:[e.jsx(js,{value:"items",children:"Items"}),e.jsx(js,{value:"categories",children:"Categories"}),e.jsx(js,{value:"purchases",children:"Purchases"}),e.jsx(js,{value:"point-settings",children:"Point Settings"})]}),e.jsx($s,{value:"items",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Store Items"}),e.jsx(fr,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(K,{onClick:()=>qt(),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx(Oe,{children:!ct||ct.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 items yet. Add your first reward item!"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Item"}),e.jsx(bt,{children:"Category"}),e.jsx(bt,{className:"text-center",children:"Cost"}),e.jsx(bt,{className:"text-center",children:"Type"}),e.jsx(bt,{className:"text-center",children:"Quantity"}),e.jsx(bt,{className:"text-center",children:"Status"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:ct.map(jt=>e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[jt.preview_image_url?e.jsx("img",{src:jt.preview_image_url,alt:jt.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(bo,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:jt.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:jt.description||"No description"})]})]})}),e.jsx(dt,{children:jt.category?e.jsx(nt,{variant:"outline",children:jt.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-center",children:e.jsxs(nt,{variant:"secondary",className:"font-bold",children:[e.jsx(Kn,{className:"h-3 w-3 mr-1"}),jt.points_cost]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[jt.item_type==="file"?e.jsx(In,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Vo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:jt.item_type})]})}),e.jsx(dt,{className:"text-center",children:jt.max_quantity!==null?e.jsxs("span",{className:jt.current_quantity===0?"text-red-500":"",children:[jt.current_quantity,"/",jt.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(dt,{className:"text-center",children:e.jsx(nt,{variant:jt.is_active?"default":"secondary",children:jt.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:()=>qt(jt),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>je(jt.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},jt.id))})]})})]})}),e.jsx($s,{value:"categories",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Categories"}),e.jsx(fr,{children:"Organize your store items into categories"})]}),e.jsxs(K,{onClick:()=>Ye(),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Oe,{children:!Te||Te.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Cm,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No categories yet. Add your first category!"})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Name"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{className:"text-center",children:"Items"}),e.jsx(bt,{className:"text-right",children:"Actions"})]})}),e.jsx(Pn,{children:Te.map(jt=>e.jsxs(ks,{children:[e.jsxs(dt,{className:"font-medium",children:[jt.icon&&e.jsx("span",{className:"mr-2",children:jt.icon}),jt.name]}),e.jsx(dt,{className:"text-muted-foreground",children:jt.description||"—"}),e.jsx(dt,{className:"text-center",children:(ct==null?void 0:ct.filter(As=>As.category_id===jt.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:()=>Ye(jt),children:e.jsx($a,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(jt.id),children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})})]})})]},jt.id))})]})})]})}),e.jsx($s,{value:"purchases",className:"mt-4",children:e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(dp,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(fr,{children:"View all reward redemptions by agents"})]}),e.jsx(Oe,{children:!Rt||Rt.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(dp,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No purchases yet."})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Date"}),e.jsx(bt,{children:"Agent"}),e.jsx(bt,{children:"Item"}),e.jsx(bt,{className:"text-center",children:"Points Spent"})]})}),e.jsx(Pn,{children:Rt.map(jt=>{var As,Ps,ar,Dn;return e.jsxs(ks,{children:[e.jsx(dt,{className:"text-muted-foreground",children:ys(new Date(jt.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(ro,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((As=jt.user)==null?void 0:As.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((Ps=jt.user)==null?void 0:Ps.email)||"—"})]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(ar=jt.item)!=null&&ar.preview_image_url?e.jsx("img",{src:jt.item.preview_image_url,alt:jt.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(bo,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((Dn=jt.item)==null?void 0:Dn.name)||"Deleted item"})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(nt,{variant:"secondary",className:"font-bold",children:[e.jsx(Kn,{className:"h-3 w-3 mr-1"}),jt.points_spent]})})]},jt.id)})})]})})]})})]})]}),e.jsx(_s,{open:n,onOpenChange:a,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:o?"Edit Category":"Add Category"}),e.jsx(Zr,{children:o?"Update the category details":"Create a new category for your store items"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"categoryName",children:"Name"}),e.jsx(Fe,{id:"categoryName",value:i,onChange:jt=>c(jt.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(Ar,{id:"categoryDescription",value:u,onChange:jt=>p(jt.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(Fe,{id:"categoryIcon",value:f,onChange:jt=>y(jt.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{onClick:tt,disabled:rt.isPending||Se.isPending,children:rt.isPending||Se.isPending?"Saving...":"Save"})]})]})}),e.jsx(_s,{open:w,onOpenChange:j,children:e.jsxs(vs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:N?"Edit Item":"Add Item"}),e.jsx(Zr,{children:N?"Update the item details":"Create a new reward item for agents to purchase"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"itemName",children:"Name *"}),e.jsx(Fe,{id:"itemName",value:T,onChange:jt=>I(jt.target.value),placeholder:"e.g., Premium Template Pack"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"itemDescription",children:"Description"}),e.jsx(Ar,{id:"itemDescription",value:L,onChange:jt=>R(jt.target.value),placeholder:"Describe the item..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"itemCategory",children:"Category"}),e.jsxs(rr,{value:$||"none",onValueChange:jt=>q(jt==="none"?null:jt),children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select category"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"No category"}),Te==null?void 0:Te.map(jt=>e.jsxs(Tt,{value:jt.id,children:[jt.icon&&`${jt.icon} `,jt.name]},jt.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(Fe,{id:"itemPointsCost",type:"number",min:"0",value:U,onChange:jt=>V(jt.target.value),placeholder:"e.g., 100"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"itemType",children:"Type"}),e.jsxs(rr,{value:X,onValueChange:se,children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"file",children:"File Download"}),e.jsx(Tt,{value:"link",children:"External Link"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),e.jsx(Fe,{id:"itemMaxQuantity",type:"number",min:"1",value:ne,onChange:jt=>le(jt.target.value),placeholder:"Leave empty for unlimited"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"File / Link URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:ee,onChange:jt=>Q(jt.target.value),placeholder:X==="file"?"Upload a file or paste URL":"Paste external link"}),X==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var jt;return(jt=Ae.current)==null?void 0:jt.click()},disabled:ke,children:e.jsx(ni,{className:"h-4 w-4"})}),e.jsx("input",{ref:Ae,type:"file",className:"hidden",onChange:jt=>{var Ps;const As=(Ps=jt.target.files)==null?void 0:Ps[0];As&&ms(As,"file")}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Preview Image"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:de,onChange:jt=>re(jt.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var jt;return(jt=Re.current)==null?void 0:jt.click()},disabled:be,children:e.jsx(cl,{className:"h-4 w-4"})}),e.jsx("input",{ref:Re,type:"file",accept:"image/*",className:"hidden",onChange:jt=>{var Ps;const As=(Ps=jt.target.files)==null?void 0:Ps[0];As&&ms(As,"preview")}})]}),de&&e.jsx("img",{src:de,alt:"Preview",className:"mt-2 h-24 rounded object-cover"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{id:"itemIsActive",checked:he,onCheckedChange:we}),e.jsx(_e,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(K,{onClick:Xt,disabled:$e.isPending||ot.isPending,children:$e.isPending||ot.isPending?"Saving...":"Save"})]})]})}),e.jsx(gc,{open:!!_,onOpenChange:()=>b(null),children:e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Delete Category"}),e.jsx(Gl,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:Et,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(gc,{open:!!ye,onOpenChange:()=>je(null),children:e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Delete Item"}),e.jsx(Gl,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:rs,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Ee,{className:"mt-4",children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Jl,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(Ot,{children:"Point Reward Settings"}),e.jsx(fr,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx(Oe,{children:!Je||Je.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Jl,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No point settings configured."})]}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Action"}),e.jsx(bt,{children:"Description"}),e.jsx(bt,{className:"text-center w-32",children:"Points"}),e.jsx(bt,{className:"text-right w-24",children:"Save"})]})}),e.jsx(Pn,{children:Je.map(jt=>e.jsxs(ks,{children:[e.jsx(dt,{children:e.jsx("p",{className:"font-medium",children:jt.action_name})}),e.jsx(dt,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:jt.description})}),e.jsx(dt,{className:"text-center",children:e.jsx(Fe,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:Xe[jt.id]??jt.points.toString(),onChange:As=>He(Ps=>({...Ps,[jt.id]:As.target.value}))})}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{size:"sm",variant:"outline",disabled:Xe[jt.id]===void 0||Xe[jt.id]===jt.points.toString()||Ke.isPending,onClick:()=>ps(jt.id,jt.points),children:e.jsx(Wu,{className:"h-4 w-4"})})})]},jt.id))})]})})]})]})}const H7e=()=>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"})]}),W7e=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function xNs(){const t=ss(),[s,r]=C.useState(!1),[n,a]=C.useState(!1),[o,l]=C.useState(!1),[i,c]=C.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:u,isLoading:p}=wt({queryKey:["canva-integration"],queryFn:async()=>{const{data:S,error:T}=await G.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(T)throw T;return S}}),{data:f}=wt({queryKey:["brokerages-list"],queryFn:async()=>{const{data:S,error:T}=await G.from("brokerages").select("id, name").order("name");if(T)throw T;return S}}),{data:y}=wt({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:S,error:T}=await G.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(T)throw T;return S}}),_=async()=>{var S;r(!0);try{const{data:T}=await G.auth.getSession(),I=(S=T==null?void 0:T.session)==null?void 0:S.access_token;if(!I)throw new Error("Not authenticated");const $=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"get_auth_url"})}),q=await $.json();if(!$.ok||q!=null&&q.error)throw new Error((q==null?void 0:q.error)||"Failed to get authorization URL");if(q!=null&&q.authUrl){localStorage.setItem("canva_code_verifier",q.codeVerifier),localStorage.setItem("canva_oauth_state",q.state);const U=window.open(q.authUrl,"canva-oauth","width=600,height=700,scrollbars=yes,resizable=yes");if(!U){me.error("Popup was blocked. Please allow popups for this site and try again."),r(!1);return}const V=se=>{var ee,Q;se.origin===window.location.origin&&(((ee=se.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=se.data)==null?void 0:Q.type)==="canva-oauth-error"&&(window.removeEventListener("message",V),me.error("Canva connection failed: "+(se.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",V);const X=setInterval(()=>{U.closed&&(clearInterval(X),window.removeEventListener("message",V),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(T){console.error("Canva connect error:",T);const I=(T==null?void 0:T.message)||"";I.includes("CANVA_CLIENT_ID")?me.error("Canva app credentials not configured yet."):me.error(I||"Failed to start Canva connection"),r(!1)}},b=Dt({mutationFn:async S=>{var U;const{data:T}=await G.auth.getSession(),I=(U=T==null?void 0:T.session)==null?void 0:U.access_token;if(!I)throw new Error("Not authenticated");const $=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"disconnect",integrationId:S})}),q=await $.json();if(!$.ok||q!=null&&q.error)throw new Error((q==null?void 0:q.error)||"Failed to disconnect")},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-integration"]}),me.success("Canva disconnected")},onError:S=>{me.error(S.message||"Failed to disconnect Canva")}}),w=Dt({mutationFn:async S=>{const{error:T}=await G.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:(y==null?void 0:y.length)||0});if(T)throw T},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),me.success("Folder added"),l(!1),c({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""})},onError:()=>me.error("Failed to add folder")}),j=Dt({mutationFn:async S=>{const{error:T}=await G.from("canva_brokerage_folders").delete().eq("id",S);if(T)throw T},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),me.success("Folder removed")},onError:()=>me.error("Failed to remove folder")}),N=!!u;return e.jsxs(e.Fragment,{children:[e.jsxs(Ee,{children:[e.jsx(It,{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(H7e,{})}),e.jsxs("div",{children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:["Canva Connect",N&&e.jsx(nt,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(nt,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(fr,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[e.jsx(vi,{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(vi,{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(vi,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),e.jsx("span",{children:"Multiple folders per brokerage (templates, brand assets, listings)"})]}),e.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-muted border border-dashed",children:[e.jsx("p",{className:"text-xs font-medium text-foreground mb-1",children:"Canva App Redirect URL"}),e.jsx("code",{className:"text-xs text-muted-foreground break-all select-all",children:"https://dashboard.relevelup.com/canva-callback.html"})]}),N?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:u.canva_team_id?`Team: ${u.canva_team_id}`:"Canva Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:u.expires_at?`Token expires ${new Date(u.expires_at).toLocaleDateString()}`:"Platform integration active"})]}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Disconnect Canva?"}),e.jsx(Gl,{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(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>b.mutate(u.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}),e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-center justify-between p-3 text-sm font-medium hover:bg-muted transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cm,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",y&&y.length>0&&e.jsx(nt,{variant:"secondary",className:"text-xs",children:y.length})]}),n?e.jsx(Hx,{className:"h-4 w-4"}):e.jsx(tl,{className:"h-4 w-4"})]}),n&&e.jsxs("div",{className:"border-t p-3 space-y-2",children:[y&&y.length>0?y.map(S=>{var T,I;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-muted/50 text-sm",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",children:S.folder_name}),e.jsx(nt,{variant:"outline",className:"text-xs shrink-0",children:((T=W7e.find(L=>L.value===S.folder_type))==null?void 0:T.label)||S.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(I=S.brokerages)==null?void 0:I.name," · ID: ",e.jsx("span",{className:"font-mono",children:S.folder_id})]})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive shrink-0 ml-2",onClick:()=>j.mutate(S.id),children:e.jsx(Ur,{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(Zs,{className:"h-3.5 w-3.5"}),"Add Folder Mapping"]})]})]})]}):e.jsxs(K,{className:"mt-4",onClick:_,disabled:s||p,children:[s?e.jsx(Bo,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx("div",{className:"mr-2",children:e.jsx(H7e,{})}),"Connect Canva",e.jsx(Ki,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Add Brokerage Folder Mapping"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Brokerage"}),e.jsxs(rr,{value:i.brokerage_id,onValueChange:S=>c(T=>({...T,brokerage_id:S})),children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select a brokerage…"})}),e.jsx(sr,{children:f==null?void 0:f.map(S=>e.jsx(Tt,{value:S.id,children:S.name},S.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Canva Folder ID"}),e.jsx(Fe,{placeholder:"e.g. FABCdef123456",value:i.folder_id,onChange:S=>c(T=>({...T,folder_id:S.target.value}))}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Found in the Canva folder URL: canva.com/folder/",e.jsx("strong",{children:"FOLDER_ID"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Folder Display Name"}),e.jsx(Fe,{placeholder:"e.g. Brand Templates 2024",value:i.folder_name,onChange:S=>c(T=>({...T,folder_name:S.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_e,{children:"Folder Type"}),e.jsxs(rr,{value:i.folder_type,onValueChange:S=>c(T=>({...T,folder_type:S})),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:W7e.map(S=>e.jsx(Tt,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(_e,{children:["Description ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(Fe,{placeholder:"What's in this folder?",value:i.description,onChange:S=>c(T=>({...T,description:S.target.value}))})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>w.mutate(i),disabled:!i.brokerage_id||!i.folder_id||!i.folder_name||w.isPending,children:[w.isPending?e.jsx(Bo,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function yNs(){return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(Ju,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx(xNs,{}),e.jsx(slt,{})]})})}const vNs={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 W6(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function _Ns(){var X,se,ee,Q,de;const t=ss(),[s,r]=C.useState("Test Push"),[n,a]=C.useState("Testing web push notification"),[o,l]=C.useState("/community"),[i,c]=C.useState(!1),[u,p]=C.useState(!1),[f,y]=C.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[_,b]=C.useState(null),[w,j]=C.useState(null),{data:N,isLoading:S}=wt({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:re,error:ne}=await G.from("push_notification_settings").select("*").order("setting_key");if(ne)throw ne;return re}}),{data:T,isLoading:I}=wt({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:re,error:ne}=await G.from("push_subscriptions").select("*",{count:"exact",head:!0});if(ne)throw ne;return{totalSubscriptions:re||0}}}),L=Dt({mutationFn:async({settingKey:re,isEnabled:ne})=>{const{error:le}=await G.from("push_notification_settings").update({is_enabled:ne}).eq("setting_key",re);if(le)throw le},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),me.success("Notification setting updated")},onError:re=>{me.error("Failed to update setting: "+re.message)}}),R=C.useMemo(()=>{var re,ne;return f.isSupported?`perm=${f.permission??"unknown"} · controller=${f.controllerPresent?"yes":"no"} · sw=${((re=f.serviceWorker)==null?void 0:re.activeState)??"unknown"} · sub=${(ne=f.subscription)!=null&&ne.endpoint?"yes":"no"}`:"Push not supported in this browser."},[f]);C.useEffect(()=>{let re=!0;const ne=async()=>{var ye,je,ke,We,be,Me,Ae;const he="serviceWorker"in navigator&&"PushManager"in window,we={isSupported:he,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((ye=navigator.serviceWorker)!=null&&ye.controller)};if(!he){re&&y(we);return}try{const{data:Re,error:Te}=await G.functions.invoke("get-vapid-public-key",{body:{}});if(Te)throw Te;we.vapidPublicKey=Re==null?void 0:Re.vapidPublicKey;const ct=(await navigator.serviceWorker.getRegistrations()).find(De=>{var pe,Je,lt;return(((pe=De.active)==null?void 0:pe.scriptURL)||((Je=De.waiting)==null?void 0:Je.scriptURL)||((lt=De.installing)==null?void 0:lt.scriptURL)||"").includes("/sw.js")});if(ct){we.pushWorkerScriptUrl=((je=ct.active)==null?void 0:je.scriptURL)||((ke=ct.waiting)==null?void 0:ke.scriptURL)||((We=ct.installing)==null?void 0:We.scriptURL),we.serviceWorker={scope:ct.scope,activeState:(be=ct.active)==null?void 0:be.state};const De=await ct.pushManager.getSubscription();if(De){const Rt=De.toJSON();we.subscription={endpoint:Rt.endpoint,p256dh:(Me=Rt.keys)==null?void 0:Me.p256dh,auth:(Ae=Rt.keys)==null?void 0:Ae.auth}}}}catch(Re){we.error=(Re==null?void 0:Re.message)||String(Re)}re&&y(we)};ne();const le=window.setInterval(ne,4e3);return()=>{re=!1,window.clearInterval(le)}},[]);const $=async()=>{if(typeof Notification>"u"){me.error("Notifications API not available in this browser.");return}try{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted"){me.error("Notification permission not granted.");return}new Notification("Local notification test",{body:"If you see this, OS/browser notifications can display."}),me.success("Triggered a local notification (not push).")}catch(re){me.error(`Local notification failed: ${(re==null?void 0:re.message)||String(re)}`)}},q=async()=>{c(!0),b(null);try{const{data:re,error:ne}=await G.functions.invoke("send-push-notification",{body:{title:s,body:n,url:o}});if(ne)throw ne;b({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),b({error:(re==null?void 0:re.message)||String(re)}),me.error("Failed to send test notification: "+(re.message||"Unknown error"))}finally{c(!1)}},U=async()=>{p(!0),j(null);try{const{data:re,error:ne}=await G.functions.invoke("generate-vapid-keys",{body:{}});if(ne)throw ne;const le=re==null?void 0:re.publicKey,he=re==null?void 0:re.privateKey;if(!le||!he)throw new Error("generate-vapid-keys did not return keys");j({publicKey:le,privateKey:he}),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 G.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(Es,{title:"Notification Settings",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(fr,{children:"Current active push notification subscriptions"})]}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-4xl font-bold",children:I?"...":(T==null?void 0:T.totalSubscriptions)||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Jl,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(fr,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(Oe,{children:S?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:N==null?void 0:N.map(re=>{const ne=vNs[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:ne.icon}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:ne.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:re.description})]})]}),e.jsx(Br,{checked:re.is_enabled,onCheckedChange:le=>L.mutate({settingKey:re.setting_key,isEnabled:le}),disabled:L.isPending})]},re.id)})})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(gg,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(fr,{children:"Send a test push notification to all subscribed users"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Client push debug"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:R}),f.error&&e.jsx("div",{className:"mt-2 text-destructive",children:f.error}),e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Backend VAPID public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:f.vapidPublicKey?W6(f.vapidPublicKey):"(not loaded)"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Service worker"}),e.jsxs("div",{className:"rounded-md border bg-background p-2 font-mono text-xs",children:[e.jsxs("div",{children:["scope: ",(X=f.serviceWorker)!=null&&X.scope?W6(f.serviceWorker.scope,24,8):"none"]}),e.jsxs("div",{children:["active: ",((se=f.serviceWorker)==null?void 0:se.activeState)??"none"]})]})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Current browser subscription"}),e.jsxs("div",{className:"rounded-md border bg-background p-2 font-mono text-xs",children:[e.jsxs("div",{children:["endpoint: ",(ee=f.subscription)!=null&&ee.endpoint?W6(f.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(Q=f.subscription)!=null&&Q.p256dh?W6(f.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(de=f.subscription)!=null&&de.auth?W6(f.subscription.auth,22,10):"none"]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(K,{variant:"outline",onClick:$,children:"Local notification test"}),e.jsx(K,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload page"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"test-title",children:"Notification Title"}),e.jsx(Fe,{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(_e,{htmlFor:"test-body",children:"Notification Body"}),e.jsx(Ar,{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(_e,{htmlFor:"test-url",children:"Click URL (optional)"}),e.jsx(Fe,{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:q,disabled:i||!s||!n,className:"w-full sm:w-auto",children:[e.jsx(oa,{className:"h-4 w-4 mr-2"}),i?"Sending...":"Send Test Notification"]}),_&&e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"Last send debug"}),_.error?e.jsxs("div",{className:"mt-1 text-destructive",children:["Error: ",_.error]}):e.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[e.jsxs("div",{children:["Result: ",_.sent??0," sent, ",_.failed??0," failed, ",_.expiredCleaned??0," expired cleaned"]}),_.vapidPublicKey?e.jsxs("div",{className:"break-all",children:["Backend VAPID public key: ",e.jsx("span",{className:"font-mono",children:_.vapidPublicKey})]}):e.jsx("div",{children:"Backend VAPID public key: (not returned)"})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(jr,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(fr,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"If you've recently updated the VAPID keys, existing subscriptions will no longer work. Use this to clear all subscriptions so users can re-subscribe with the new keys."}),e.jsxs(K,{variant:"destructive",onClick:()=>V.mutate(),disabled:V.isPending,children:[e.jsx(jr,{className:"h-4 w-4 mr-2"}),V.isPending?"Clearing...":"Clear All Subscriptions"]}),e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[e.jsx("div",{className:"font-medium",children:"VAPID key rotation helper"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:"If you suspect the backend public/private keys don’t match, generate a fresh pair, update backend secrets, then clear subscriptions and have users re-enable push."}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:e.jsx(K,{variant:"outline",onClick:U,disabled:u,children:u?"Generating…":"Generate VAPID keys"})}),w&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"text-muted-foreground",children:["Copy these into backend secrets ",e.jsx("span",{className:"font-mono",children:"VAPID_PUBLIC_KEY"})," and ",e.jsx("span",{className:"font-mono",children:"VAPID_PRIVATE_KEY"}),"."]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Public key"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.publicKey})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Private key (keep secret)"}),e.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.privateKey})]})]})]})]})]})]})})}function bNs(){const{toast:t}=Ra(),[s,r]=C.useState([]),[n,a]=C.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=C.useState(!0),{sortKey:i,sortDirection:c,handleSort:u,sortData:p}=EO("presentation_count","desc"),f=p(s,{name:b=>{var w;return((w=b.name)==null?void 0:w.toLowerCase())||""},presentations:b=>b.presentation_count,views:b=>b.total_views,leads:b=>b.total_leads,cta_clicks:b=>b.total_cta_clicks,conversion:b=>b.total_views>0?b.total_leads/b.total_views*100:0});C.useEffect(()=>{y()},[]);const y=async()=>{try{l(!0);const{data:b,error:w}=await G.rpc("get_admin_presentation_stats");if(w)throw w;if(!b||b.length===0){l(!1);return}const j=b.map(L=>L.owner_user_id),{data:N,error:S}=await G.from("profiles").select("id, name, email, avatar_url").in("id",j);if(S)throw S;const T=new Map((N==null?void 0:N.map(L=>[L.id,L]))||[]),I=b.map(L=>{const R=T.get(L.owner_user_id);return{owner_user_id:L.owner_user_id,name:(R==null?void 0:R.name)||"Unknown",email:(R==null?void 0:R.email)||"",avatar_url:(R==null?void 0:R.avatar_url)||null,presentation_count:Number(L.presentation_count),total_views:Number(L.total_views),total_leads:Number(L.total_leads),total_cta_clicks:Number(L.total_cta_clicks)}});r(I),r(I),a({totalPresentations:I.reduce((L,R)=>L+R.presentation_count,0),totalViews:I.reduce((L,R)=>L+R.total_views,0),totalLeads:I.reduce((L,R)=>L+R.total_leads,0),totalCtaClicks:I.reduce((L,R)=>L+R.total_cta_clicks,0),agentsUsing:I.length})}catch(b){console.error("Error loading presentation stats:",b),t({title:"Error",description:"Failed to load presentation analytics",variant:"destructive"})}finally{l(!1)}},_=[{label:"Agents Using",value:n.agentsUsing,icon:mr,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:Gx,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:va,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:Pc,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:Lb,color:"text-rose-600"}];return e.jsx(Es,{title:"Presentation Analytics",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Presentation Analytics"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Track Smart Presentations usage and engagement across all agents"})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:_.map(b=>e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:b.label}),e.jsx(b.icon,{className:`h-4 w-4 ${b.color}`})]}),e.jsx(Oe,{children:o?e.jsx(xs,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:b.value.toLocaleString()})})]},b.label))}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(xc,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((b,w)=>e.jsx(xs,{className:"h-12 w-full"},w))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No presentations created yet."}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(dl,{sortKey:"name",currentSortKey:i,currentDirection:c,onSort:u,children:"Agent"}),e.jsx(dl,{sortKey:"presentations",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Presentations"}),e.jsx(dl,{sortKey:"views",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Views"}),e.jsx(dl,{sortKey:"leads",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Leads"}),e.jsx(dl,{sortKey:"cta_clicks",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"CTA Clicks"}),e.jsx(dl,{sortKey:"conversion",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Conversion"})]})}),e.jsx(Pn,{children:f.map(b=>{var j,N;const w=b.total_views>0?(b.total_leads/b.total_views*100).toFixed(1):"0.0";return e.jsxs(ks,{children:[e.jsx(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:b.avatar_url?e.jsx("img",{src:b.avatar_url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((N=(j=b.name)==null?void 0:j.charAt(0))==null?void 0:N.toUpperCase())||"?"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:b.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:b.email})]})]})}),e.jsx(dt,{className:"text-center font-medium",children:b.presentation_count}),e.jsx(dt,{className:"text-center",children:b.total_views.toLocaleString()}),e.jsx(dt,{className:"text-center",children:b.total_leads>0?e.jsx(nt,{variant:"secondary",children:b.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:b.total_cta_clicks}),e.jsx(dt,{className:"text-center",children:e.jsxs("span",{className:Number(w)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[w,"%"]})})]},b.owner_user_id)})})]})})]})]})})}function wNs(){const{toast:t}=Ra(),[s,r]=C.useState([]),[n,a]=C.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=C.useState(!0);C.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:u,error:p}=await G.rpc("get_admin_guest_book_stats");if(p)throw p;if(!u||u.length===0){l(!1);return}const f=u.map(j=>j.agent_id),{data:y,error:_}=await G.from("profiles").select("id, name, email, avatar_url").in("id",f);if(_)throw _;const b=new Map((y==null?void 0:y.map(j=>[j.id,j]))||[]),w=u.map(j=>{const N=b.get(j.agent_id);return{agent_id:j.agent_id,name:(N==null?void 0:N.name)||"Unknown",email:(N==null?void 0:N.email)||"",avatar_url:(N==null?void 0:N.avatar_url)||null,open_house_count:Number(j.open_house_count),total_visitors:Number(j.total_visitors),total_leads:Number(j.total_leads),active_count:Number(j.active_count)}});w.sort((j,N)=>N.total_visitors-j.total_visitors),r(w),a({totalOpenHouses:w.reduce((j,N)=>j+N.open_house_count,0),totalVisitors:w.reduce((j,N)=>j+N.total_visitors,0),totalLeads:w.reduce((j,N)=>j+N.total_leads,0),activeOpenHouses:w.reduce((j,N)=>j+N.active_count,0),agentsUsing:w.length})}catch(u){console.error("Error loading guest book stats:",u),t({title:"Error",description:"Failed to load guest book analytics",variant:"destructive"})}finally{l(!1)}},c=[{label:"Agents Using",value:n.agentsUsing,icon:mr,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:Rn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:vi,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:va,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:Pc,color:"text-rose-600"}];return e.jsx(Es,{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(It,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(Ot,{className:"text-sm font-medium",children:u.label}),e.jsx(u.icon,{className:`h-4 w-4 ${u.color}`})]}),e.jsx(Oe,{children:o?e.jsx(xs,{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(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(xc,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Oe,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((u,p)=>e.jsx(xs,{className:"h-12 w-full"},p))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No open houses created yet."}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Agent"}),e.jsx(bt,{className:"text-center",children:"Open Houses"}),e.jsx(bt,{className:"text-center",children:"Active"}),e.jsx(bt,{className:"text-center",children:"Visitors"}),e.jsx(bt,{className:"text-center",children:"Leads"}),e.jsx(bt,{className:"text-center",children:"Conversion"})]})}),e.jsx(Pn,{children:s.map(u=>{var f,y;const p=u.total_visitors>0?(u.total_leads/u.total_visitors*100).toFixed(1):"0.0";return e.jsxs(ks,{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:((y=(f=u.name)==null?void 0:f.charAt(0))==null?void 0:y.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(nt,{variant:"secondary",className:"bg-emerald-100 text-emerald-700",children:u.active_count}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(dt,{className:"text-center",children:u.total_visitors.toLocaleString()}),e.jsx(dt,{className:"text-center",children:u.total_leads>0?e.jsx(nt,{variant:"secondary",children:u.total_leads}):e.jsx("span",{className:"text-muted-foreground",children:"0"})}),e.jsx(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 jNs(){const[t]=Xc(),s=Pr(),[r,n]=C.useState("loading"),[a,o]=C.useState("Processing connection...");return C.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:y}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p}});if(y)throw y;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(It,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[r==="loading"&&e.jsx(Ss,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(vi,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx($c,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(Ot,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(fr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function kNs(){const t=ss(),[s,r]=C.useState(""),[n,a]=C.useState(""),[o,l]=C.useState([]),i=C.useRef(null),{data:c,isLoading:u}=wt({queryKey:["prospect-emails"],queryFn:async()=>{const{data:j,error:N}=await G.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(N)throw N;return j}}),p={total:(c==null?void 0:c.length)||0,sent:(c==null?void 0:c.filter(j=>j.status==="sent").length)||0,converted:(c==null?void 0:c.filter(j=>j.status==="converted").length)||0,conversionRate:c!=null&&c.length?Math.round(c.filter(j=>j.status==="converted").length/c.length*100):0},f=Dt({mutationFn:async j=>{const{data:N,error:S}=await G.functions.invoke("send-prospect-email",{body:{emails:j}});if(S)throw S;return N},onSuccess:j=>{t.invalidateQueries({queryKey:["prospect-emails"]}),me.success(`${j.sent} email${j.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:j=>{me.error("Failed to send: "+j.message)}}),y=Dt({mutationFn:async()=>{var T,I;const{data:{user:j}}=await G.auth.getUser();if(!(j!=null&&j.email))throw new Error("Could not get your email");const{data:N,error:S}=await G.functions.invoke("send-prospect-email",{body:{emails:[{email:j.email,first_name:(I=(T=j.user_metadata)==null?void 0:T.name)==null?void 0:I.split(" ")[0]}],test_mode:!0}});if(S)throw S;return N},onSuccess:()=>{me.success("Test email sent to your inbox!")},onError:j=>{me.error("Failed to send test: "+j.message)}}),_=()=>{if(!s.trim()){me.error("Please enter an email address");return}if(c==null?void 0:c.find(N=>N.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}])},b=j=>{var T;const N=(T=j.target.files)==null?void 0:T[0];if(!N)return;const S=new FileReader;S.onload=I=>{var U,V;const R=((U=I.target)==null?void 0:U.result).split(` `).filter(X=>X.trim()),$=[],q=(V=R[0])!=null&&V.toLowerCase().includes("email")?1:0;for(let X=q;Xde.trim().replace(/"/g,"")),ee=se[0],Q=se[1];ee&&ee.includes("@")&&$.push({email:ee,first_name:Q||void 0})}l($),me.success(`${$.length} entries loaded from CSV`)},S.readAsText(N),i.current&&(i.current.value="")},w=()=>{if(o.length===0){me.error("No entries to send");return}const j=new Set((c==null?void 0:c.map(S=>S.email.toLowerCase()))||[]),N=o.filter(S=>!j.has(S.email.toLowerCase()));if(N.length===0){me.error("All emails have already been prospected");return}N.lengthy.mutate(),disabled:y.isPending,className:"gap-2 ml-4 shrink-0",children:[y.isPending?e.jsx(Ss,{className:"h-3 w-3 animate-spin"}):e.jsx(br,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),e.jsx(Oe,{children:e.jsxs(Aa,{defaultValue:"single",children:[e.jsxs(ja,{className:"mb-4",children:[e.jsxs(js,{value:"single",children:[e.jsx(oa,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(js,{value:"bulk",children:[e.jsx(ni,{className:"h-4 w-4 mr-2"}),"Bulk CSV"]})]}),e.jsx($s,{value:"single",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(_e,{htmlFor:"prospect-email",className:"sr-only",children:"Email"}),e.jsx(Fe,{id:"prospect-email",type:"email",placeholder:"agent@example.com",value:s,onChange:j=>r(j.target.value),onKeyDown:j=>j.key==="Enter"&&_()})]}),e.jsxs("div",{className:"w-full sm:w-48",children:[e.jsx(_e,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),e.jsx(Fe,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:j=>a(j.target.value),onKeyDown:j=>j.key==="Enter"&&_()})]}),e.jsxs(K,{onClick:_,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(oa,{className:"h-4 w-4"}),"Send Invite"]})]})}),e.jsx($s,{value:"bulk",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{ref:i,type:"file",accept:".csv",onChange:b,className:"hidden"}),e.jsxs(K,{variant:"outline",onClick:()=>{var j;return(j=i.current)==null?void 0:j.click()},className:"gap-2",children:[e.jsx(In,{className:"h-4 w-4"}),"Upload CSV"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Format: email, first_name (one per line)"})]}),o.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(mr,{className:"h-3 w-3"}),o.length," entries ready"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[e.jsx(Ur,{className:"h-4 w-4"}),"Clear"]})]}),e.jsxs("div",{className:"max-h-40 overflow-y-auto border rounded-lg p-3 bg-muted/30 text-sm font-mono space-y-1",children:[o.slice(0,20).map((j,N)=>e.jsxs("div",{className:"text-muted-foreground",children:[j.email,j.first_name?` — ${j.first_name}`:""]},N)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(K,{onClick:w,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(oa,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(br,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(fr,{children:"Track all sent invitations and their conversion status"})]}),e.jsx(Oe,{children:u?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((j,N)=>e.jsx(xs,{className:"h-12 w-full"},N))}):c&&c.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Email"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Name"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Sent"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Converted"})]})}),e.jsx("tbody",{children:c.map(j=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-3 px-4 text-sm font-medium text-foreground",children:j.email}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:j.first_name||"—"}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:ys(new Date(j.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:j.status==="converted"?e.jsxs(nt,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[e.jsx(ha,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(nt,{variant:"secondary",className:"gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:j.converted_at?ys(new Date(j.converted_at),"MMM d, yyyy"):"—"})]},j.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Am,{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 dme(t){const s=ss(),{toast:r}=Ra(),n=wt({queryKey:["recruit-stages",t],queryFn:async()=>{if(!t)return[];const{data:c,error:u}=await G.from("recruit_pipeline_stages").select("*").eq("brokerage_id",t).order("sort_order");if(u)throw u;return c},enabled:!!t}),a=wt({queryKey:["recruit-prospects",t],queryFn:async()=>{if(!t)return[];const{data:c,error:u}=await G.from("recruit_prospects").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(u)throw u;return c},enabled:!!t}),o=Dt({mutationFn:async c=>{const{data:{user:u}}=await G.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:y}=await G.from("recruit_prospects").insert(p).select().single();if(y)throw y;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 G.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 G.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 NNs(t){const s=ss(),{toast:r}=Ra(),n=wt({queryKey:["recruit-activities",t],queryFn:async()=>{if(!t)return[];const{data:o,error:l}=await G.from("recruit_activities").select("*").eq("prospect_id",t).order("created_at",{ascending:!1});if(l)throw l;return o},enabled:!!t}),a=Dt({mutationFn:async o=>{const{data:{user:l}}=await G.auth.getUser();if(!l)throw new Error("Not authenticated");const{data:i,error:c}=await G.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 G7e=(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 llt({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=C.useState(G7e(n,r)),c=p=>f=>i(y=>({...y,[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(G7e(n,r)),s(!1)};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Add Recruit Prospect"})}),e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs(Aa,{defaultValue:"basic",className:"w-full",children:[e.jsxs(ja,{className:"grid w-full grid-cols-4",children:[e.jsx(js,{value:"basic",children:"Basic Info"}),e.jsx(js,{value:"production",children:"Production"}),e.jsx(js,{value:"social",children:"Social & Web"}),e.jsx(js,{value:"personal",children:"Personal"})]}),e.jsxs($s,{value:"basic",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"First Name *"}),e.jsx(Fe,{required:!0,value:l.first_name,onChange:c("first_name")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Last Name"}),e.jsx(Fe,{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(_e,{children:"Email"}),e.jsx(Fe,{type:"email",value:l.email,onChange:c("email")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Phone"}),e.jsx(Fe,{value:l.phone,onChange:c("phone")})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Current Brokerage"}),e.jsx(Fe,{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(_e,{children:"License #"}),e.jsx(Fe,{value:l.license_number,onChange:c("license_number")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Experience (years)"}),e.jsx(Fe,{type:"number",min:"0",value:l.experience_years,onChange:c("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Address"}),e.jsx(Fe,{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(_e,{children:"City"}),e.jsx(Fe,{value:l.city,onChange:c("city")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"State"}),e.jsx(Fe,{value:l.state,onChange:c("state")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Zip"}),e.jsx(Fe,{value:l.zip_code,onChange:c("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Pipeline Stage"}),e.jsxs(rr,{value:l.stage_id,onValueChange:p=>i(f=>({...f,stage_id:p})),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:r.map(p=>e.jsx(Tt,{value:p.id,children:p.name},p.id))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Referred By"}),e.jsx(Fe,{placeholder:"Who referred this prospect?",value:l.referred_by,onChange:c("referred_by")})]})]}),e.jsxs($s,{value:"production",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Annual Production Volume"}),e.jsx(Fe,{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(_e,{children:"Last Year Volume"}),e.jsx(Fe,{placeholder:"e.g. $8.2M",value:l.last_year_volume,onChange:c("last_year_volume")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Last Year Transactions"}),e.jsx(Fe,{type:"number",min:"0",placeholder:"e.g. 24",value:l.last_year_transactions,onChange:c("last_year_transactions")})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Avg Sale Price"}),e.jsx(Fe,{placeholder:"e.g. $350K",value:l.avg_sale_price,onChange:c("avg_sale_price")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Specialties / Niche"}),e.jsx(Fe,{placeholder:"e.g. Luxury, First-time buyers, Investment",value:l.specialties,onChange:c("specialties")})]})]}),e.jsxs($s,{value:"social",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"LinkedIn URL"}),e.jsx(Fe,{type:"url",placeholder:"https://linkedin.com/in/...",value:l.linkedin_url,onChange:c("linkedin_url")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Website URL"}),e.jsx(Fe,{type:"url",placeholder:"https://...",value:l.website_url,onChange:c("website_url")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Instagram Handle"}),e.jsx(Fe,{placeholder:"@handle",value:l.instagram_handle,onChange:c("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Facebook URL"}),e.jsx(Fe,{type:"url",placeholder:"https://facebook.com/...",value:l.facebook_url,onChange:c("facebook_url")})]})]}),e.jsxs($s,{value:"personal",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Birthday"}),e.jsx(Fe,{type:"date",value:l.birthday,onChange:c("birthday")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Spouse / Partner Name"}),e.jsx(Fe,{value:l.spouse_name,onChange:c("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Interests / Hobbies"}),e.jsx(Fe,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:c("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Notes"}),e.jsx(Ar,{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 Qbe=[{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 SNs(t){return wt({queryKey:["recruit-videos",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("recruit_videos").select(` *, prospect:recruit_prospects(id, first_name, last_name, email, phone, current_brokerage), video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status) `).eq("brokerage_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function CNs(t){return wt({queryKey:["recruit-videos-prospect",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("recruit_videos").select(` *, video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status) `).eq("prospect_id",t).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function MNs(){const t=ss(),{toast:s}=Ra();return Dt({mutationFn:async r=>{const{data:{user:n}}=await G.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("recruit_videos").insert({prospect_id:r.prospect_id,video_id:r.video_id,brokerage_id:r.brokerage_id,message:r.message||null,created_by:n.id}).select("*, prospect:recruit_prospects(id, first_name, last_name, email, phone, current_brokerage), video:agent_videos(id, title, thumbnail_url, playback_url, preview_url, duration_seconds, status)").single();if(o)throw o;return a},onSuccess:r=>{t.invalidateQueries({queryKey:["recruit-videos"]}),t.invalidateQueries({queryKey:["recruit-videos-prospect",r.prospect_id]}),s({title:"Video linked to prospect"})},onError:r=>s({title:"Error",description:r.message,variant:"destructive"})})}function clt(){const t=ss();return Dt({mutationFn:async({id:s,sent_via:r})=>{const{error:n}=await G.from("recruit_videos").update({sent_at:new Date().toISOString(),sent_via:r,updated_at:new Date().toISOString()}).eq("id",s);if(n)throw n},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-videos"]})}})}function dlt(t){return wt({queryKey:["recruit-video-scripts",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("recruit_video_scripts").select("*").or(`brokerage_id.eq.${t},is_global.eq.true`).order("created_at",{ascending:!1});if(r)throw r;return s},enabled:!!t})}function TNs(){const t=ss(),{toast:s}=Ra();return Dt({mutationFn:async r=>{const{data:{user:n}}=await G.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("recruit_video_scripts").insert({...r,created_by:n.id}).select().single();if(o)throw o;return a},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]}),s({title:"Script saved"})},onError:r=>s({title:"Error",description:r.message,variant:"destructive"})})}function ANs(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("recruit_video_scripts").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["recruit-video-scripts"]})}})}function ENs({prospectId:t,prospectName:s,brokerageId:r}){var U;const{data:n=[],isLoading:a}=CNs(t),{data:o=[]}=dlt(r),l=MNs(),i=nC(),c=clt(),[u,p]=C.useState("idle"),[f,y]=C.useState(0),[_,b]=C.useState(0),[w,j]=C.useState(""),[N,S]=C.useState(""),[T,I]=C.useState(!1),L=((U=o.find(V=>V.id===w))==null?void 0:U.script_text)||"",R=()=>{p("idle"),y(0),b(0),j(""),S("")},$=C.useCallback(async(V,X)=>{p("uploading");try{const se=`Recruiting: ${s}`,{videoId:ee,libraryId:Q}=await GO(se),{uploadUrl:de,apiKey:re}=await KO(ee),ne=new XMLHttpRequest;ne.upload.onprogress=be=>{be.lengthComputable&&y(be.loaded/be.total*100)},await new Promise((be,Me)=>{ne.onload=()=>ne.status>=200&&ne.status<300?be():Me(new Error("Upload failed")),ne.onerror=()=>Me(new Error("Upload failed")),ne.open("PUT",de),ne.setRequestHeader("AccessKey",re),ne.send(V)}),p("processing");let le=0;const he=Date.now(),we=9e4,ye=`https://iframe.mediadelivery.net/embed/${Q}/${ee}`;for(;le<4&&(await new Promise(Me=>setTimeout(Me,3e3)),!(Date.now()-he>we));){const be=await rA(ee);if(le=be.status,b(be.encodeProgress||0),le===5||le===6)throw new Error("Video processing failed")}const je=await rA(ee),ke=(je.storageSize||V.size)/(1024*1024),We=await i.mutateAsync({bunny_video_id:ee,playback_url:je.directPlayUrl||ye,thumbnail_url:je.thumbnailUrl,preview_url:je.previewUrl||null,duration_seconds:je.length||X,file_size_mb:ke,title:se,status:le>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:We.id,brokerage_id:r,message:N||void 0}),p("done"),me.success("Video recorded and linked to prospect!"),setTimeout(()=>{I(!1),R()},1500)}catch(se){me.error(se.message||"Failed to upload video"),p("record")}},[t,s,r,N,i,l]),q=V=>{V&&(navigator.clipboard.writeText(`${window.location.origin}/recruit-video/${V}`),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(Nn,{className:"h-4 w-4"})," Video Outreach"]}),e.jsxs(_s,{open:T,onOpenChange:V=>{!V&&(u==="uploading"||u==="processing")||(I(V),V||R())},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>p("script"),children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Record Video"]})}),e.jsxs(vs,{className:"max-w-2xl",children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:["Record Video for ",s]})}),u==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Choose a Script (optional)"}),e.jsxs(rr,{value:w,onValueChange:j,children:[e.jsx(tr,{className:"mt-1",children:e.jsx(nr,{placeholder:"No script — speak freely"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"none",children:"No script"}),o.map(V=>{var X;return e.jsx(Tt,{value:V.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[V.title,e.jsx(nt,{variant:"outline",className:"text-[9px] ml-1",children:(X=Qbe.find(se=>se.value===V.category))==null?void 0:X.label})]})},V.id)})]})]}),L&&e.jsx("div",{className:"mt-2 p-3 bg-muted/50 rounded-md text-sm max-h-32 overflow-y-auto whitespace-pre-wrap",children:L})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Personal Message (shown on landing page)"}),e.jsx(Ar,{value:N,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(Nn,{className:"h-4 w-4 mr-2"})," Start Recording"]})]}),u==="record"&&e.jsx(cme,{maxDurationSeconds:60,onRecordingComplete:$,teleprompterContent:L||void 0}),u==="uploading"&&e.jsxs("div",{className:"py-8 space-y-4 text-center",children:[e.jsx("p",{className:"font-medium",children:"Uploading video…"}),e.jsx(Oi,{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(Oi,{value:_,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(_),"%"]})]}),u==="done"&&e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-3",children:e.jsx(wl,{className:"h-6 w-6 text-emerald-600"})}),e.jsx("p",{className:"font-medium text-emerald-600",children:"Video ready!"})]})]})]})]}),a?e.jsx("div",{className:"text-center py-4",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent mx-auto"})}):n.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No videos sent yet"}):e.jsx("div",{className:"space-y-2",children:n.map(V=>{var X,se;return e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-md border text-sm",children:[e.jsx("div",{className:"h-10 w-16 rounded bg-muted overflow-hidden flex-shrink-0",children:(X=V.video)!=null&&X.thumbnail_url?e.jsx("img",{src:V.video.thumbnail_url,alt:"",className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center",children:e.jsx(Nn,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-xs truncate",children:((se=V.video)==null?void 0:se.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[V.view_count>0?e.jsxs(nt,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(va,{className:"h-2.5 w-2.5 mr-0.5"}),V.view_count]}):V.sent_at?e.jsxs(nt,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(oa,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(nt,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(Tn,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ys(new Date(V.created_at),"MMM d")})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>q(V.share_token),children:e.jsx(mi,{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(oa,{className:"h-3 w-3"})})]})]},V.id)})})]})}const K7e=[{value:"call",label:"Phone Call",icon:ea},{value:"email",label:"Email",icon:br},{value:"text",label:"Text Message",icon:po},{value:"meeting",label:"Meeting",icon:on},{value:"note",label:"Note",icon:In}];function Vp({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 Iz({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(rn,{className:"h-3 w-3 opacity-50"})]}):null}function oc({label:t,value:s,onChange:r,type:n="text",placeholder:a}){return e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:t}),e.jsx(Fe,{type:n,value:s,onChange:o=>r(o.target.value),placeholder:a,className:"mt-1 h-8 text-sm"})]})}function ult({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:c}=NNs((t==null?void 0:t.id)||null),[u,p]=C.useState({type:"note",title:"",description:""}),[f,y]=C.useState(!1),[_,b]=C.useState(!1),[w,j]=C.useState({});if(!t)return null;const N=()=>{var X,se;j({first_name:t.first_name||"",last_name:t.last_name||"",email:t.email||"",phone:t.phone||"",current_brokerage:t.current_brokerage||"",license_number:t.license_number||"",experience_years:((X=t.experience_years)==null?void 0:X.toString())||"",notes:t.notes||"",source:t.source||"",address:t.address||"",city:t.city||"",state:t.state||"",zip_code:t.zip_code||"",last_year_volume:t.last_year_volume||"",last_year_transactions:((se=t.last_year_transactions)==null?void 0:se.toString())||"",avg_sale_price:t.avg_sale_price||"",specialties:t.specialties||"",annual_production:t.annual_production||"",linkedin_url:t.linkedin_url||"",website_url:t.website_url||"",instagram_handle:t.instagram_handle||"",facebook_url:t.facebook_url||"",birthday:t.birthday||"",spouse_name:t.spouse_name||"",interests:t.interests||"",referred_by:t.referred_by||""}),b(!0)},S=()=>{const X={id:t.id};for(const[se,ee]of Object.entries(w))se==="experience_years"||se==="last_year_transactions"?X[se]=ee?parseInt(ee):null:X[se]=ee||null;o(X),b(!1)},T=()=>b(!1),I=X=>se=>j(ee=>({...ee,[X]:se})),L=()=>{u.title.trim()&&(c.mutate({prospect_id:t.id,activity_type:u.type,title:u.title,description:u.description||null}),p({type:"note",title:"",description:""}),y(!1))},R=s.find(X=>X.id===t.stage_id),$=t.address||t.city||t.state,q=t.last_year_volume||t.last_year_transactions||t.avg_sale_price||t.specialties||t.annual_production,U=t.linkedin_url||t.website_url||t.instagram_handle||t.facebook_url,V=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(DA,{open:n,onOpenChange:X=>{X||b(!1),a(X)},children:e.jsx(YS,{className:"w-full sm:max-w-lg p-0",children:e.jsx(Vi,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(OA,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(RA,{className:"text-xl",children:[t.first_name," ",t.last_name]}),R&&e.jsx(nt,{variant:"outline",style:{borderColor:R.color,color:R.color},className:"mt-1",children:R.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[_?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:T,children:e.jsx(Ur,{className:"h-4 w-4"})}),e.jsx(K,{variant:"default",size:"icon",onClick:S,children:e.jsx(Wu,{className:"h-4 w-4"})})]}):e.jsx(K,{variant:"ghost",size:"icon",onClick:N,title:"Edit prospect",children:e.jsx($a,{className:"h-4 w-4"})}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Delete prospect?"}),e.jsx(Gl,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{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(br,{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(ea,{className:"h-3.5 w-3.5"})," ",t.phone]}),$&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Ui,{className:"h-3.5 w-3.5"}),[t.address,t.city,t.state,t.zip_code].filter(Boolean).join(", ")]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Move to Stage"}),e.jsxs(rr,{value:t.stage_id||"",onValueChange:X=>o({id:t.id,stage_id:X}),children:[e.jsx(tr,{className:"mt-1",children:e.jsx(nr,{})}),e.jsx(sr,{children:s.map(X=>e.jsx(Tt,{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(Aa,{defaultValue:"details",className:"w-full",children:[e.jsxs(ja,{className:"grid w-full grid-cols-4 h-8 text-xs",children:[e.jsx(js,{value:"details",className:"text-xs",children:"Details"}),e.jsx(js,{value:"production",className:"text-xs",children:"Production"}),e.jsx(js,{value:"social",className:"text-xs",children:"Social"}),e.jsx(js,{value:"personal",className:"text-xs",children:"Personal"})]}),_?e.jsxs(e.Fragment,{children:[e.jsxs($s,{value:"details",className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(oc,{label:"First Name",value:w.first_name,onChange:I("first_name")}),e.jsx(oc,{label:"Last Name",value:w.last_name,onChange:I("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(oc,{label:"Email",value:w.email,onChange:I("email"),type:"email"}),e.jsx(oc,{label:"Phone",value:w.phone,onChange:I("phone")})]}),e.jsx(oc,{label:"Current Brokerage",value:w.current_brokerage,onChange:I("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(oc,{label:"License #",value:w.license_number,onChange:I("license_number")}),e.jsx(oc,{label:"Experience (years)",value:w.experience_years,onChange:I("experience_years"),type:"number"})]}),e.jsx(oc,{label:"Address",value:w.address,onChange:I("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(oc,{label:"City",value:w.city,onChange:I("city")}),e.jsx(oc,{label:"State",value:w.state,onChange:I("state")}),e.jsx(oc,{label:"Zip",value:w.zip_code,onChange:I("zip_code")})]}),e.jsx(oc,{label:"Source",value:w.source,onChange:I("source")}),e.jsx(oc,{label:"Referred By",value:w.referred_by,onChange:I("referred_by")}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Notes"}),e.jsx(Ar,{value:w.notes,onChange:X=>j(se=>({...se,notes:X.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs($s,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(oc,{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(oc,{label:"Last Year Volume",value:w.last_year_volume,onChange:I("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(oc,{label:"Last Year Transactions",value:w.last_year_transactions,onChange:I("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(oc,{label:"Avg Sale Price",value:w.avg_sale_price,onChange:I("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(oc,{label:"Specialties / Niche",value:w.specialties,onChange:I("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs($s,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(oc,{label:"LinkedIn URL",value:w.linkedin_url,onChange:I("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(oc,{label:"Website URL",value:w.website_url,onChange:I("website_url"),type:"url",placeholder:"https://..."}),e.jsx(oc,{label:"Instagram Handle",value:w.instagram_handle,onChange:I("instagram_handle"),placeholder:"@handle"}),e.jsx(oc,{label:"Facebook URL",value:w.facebook_url,onChange:I("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs($s,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(oc,{label:"Birthday",value:w.birthday,onChange:I("birthday"),type:"date"}),e.jsx(oc,{label:"Spouse / Partner",value:w.spouse_name,onChange:I("spouse_name")}),e.jsx(oc,{label:"Interests / Hobbies",value:w.interests,onChange:I("interests"),placeholder:"Golf, travel, community events..."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs($s,{value:"details",className:"mt-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Vp,{label:"Current Brokerage",value:t.current_brokerage}),e.jsx(Vp,{label:"License #",value:t.license_number}),e.jsx(Vp,{label:"Experience",value:t.experience_years!=null?`${t.experience_years} years`:null}),e.jsx(Vp,{label:"Referred By",value:t.referred_by}),e.jsx(Vp,{label:"Source",value:t.source})]}),t.notes&&e.jsxs("div",{className:"mt-3",children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Notes"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.notes})]})]}),e.jsx($s,{value:"production",className:"mt-3",children:q?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Vp,{label:"Annual Production",value:t.annual_production}),e.jsx(Vp,{label:"Last Year Volume",value:t.last_year_volume}),e.jsx(Vp,{label:"Last Year Transactions",value:t.last_year_transactions}),e.jsx(Vp,{label:"Avg Sale Price",value:t.avg_sale_price}),e.jsx(Vp,{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($s,{value:"social",className:"mt-3",children:U?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Iz,{label:"LinkedIn",url:t.linkedin_url,icon:_p}),e.jsx(Iz,{label:"Website",url:t.website_url,icon:yp}),t.instagram_handle&&e.jsx(Iz,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:yu}),e.jsx(Iz,{label:"Facebook",url:t.facebook_url,icon:xu})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No social profiles added yet"})}),e.jsx($s,{value:"personal",className:"mt-3",children:V?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Vp,{label:"Birthday",value:t.birthday?ys(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:bo}),e.jsx(Vp,{label:"Spouse / Partner",value:t.spouse_name,icon:Ii}),e.jsx("div",{className:"col-span-2",children:e.jsx(Vp,{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(ENs,{prospectId:t.id,prospectName:`${t.first_name} ${t.last_name||""}`,brokerageId:r}),e.jsx(Zl,{}),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:()=>y(!f),children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Log Activity"]})]}),f&&e.jsxs("div",{className:"border rounded-lg p-3 mb-4 space-y-3 bg-muted/30",children:[e.jsxs(rr,{value:u.type,onValueChange:X=>p(se=>({...se,type:X})),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:K7e.map(X=>e.jsx(Tt,{value:X.value,children:X.label},X.value))})]}),e.jsx(Fe,{placeholder:"Subject / Title",value:u.title,onChange:X=>p(se=>({...se,title:X.target.value}))}),e.jsx(Ar,{placeholder:"Details (optional)",value:u.description,onChange:X=>p(se=>({...se,description:X.target.value})),rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>y(!1),children:"Cancel"}),e.jsx(K,{size:"sm",onClick:L,disabled:!u.title.trim(),children:"Save"})]})]}),e.jsxs("div",{className:"space-y-3",children:[i.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"}),i.map(X=>{const se=K7e.find(Q=>Q.value===X.activity_type),ee=(se==null?void 0:se.icon)||In;return e.jsxs("div",{className:"flex gap-3 text-sm",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx("div",{className:"h-7 w-7 rounded-full bg-muted flex items-center justify-center",children:e.jsx(ee,{className:"h-3.5 w-3.5 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",children:X.title}),X.description&&e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:X.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ys(new Date(X.created_at),"MMM d, yyyy h:mm a")})]})]},X.id)})]})]})]})})})})}const Z7e=["first_name","last_name","email","phone","current_brokerage","license_number","experience_years","annual_production","notes"];function hlt({open:t,onOpenChange:s,brokerageId:r,stages:n}){var V;const{toast:a}=Ra(),o=ss(),l=C.useRef(null),[i,c]=C.useState([]),[u,p]=C.useState([]),[f,y]=C.useState({}),[_,b]=C.useState(((V=n[0])==null?void 0:V.id)||""),[w,j]=C.useState(!1),[N,S]=C.useState("upload"),[T,I]=C.useState(0),L=()=>{c([]),p([]),y({}),S("upload"),I(0)},R=X=>{var Q;const se=(Q=X.target.files)==null?void 0:Q[0];if(!se)return;const ee=new FileReader;ee.onload=de=>{var ye;const ne=((ye=de.target)==null?void 0:ye.result).split(/\r?\n/).filter(je=>je.trim());if(ne.length<2){a({title:"Invalid CSV",description:"File must have a header row and at least one data row",variant:"destructive"});return}const le=$(ne[0]);p(le);const he={};le.forEach((je,ke)=>{const We=je.toLowerCase().replace(/[^a-z]/g,"_").replace(/_+/g,"_"),be=Z7e.find(Me=>We.includes(Me)||Me.includes(We)||Me==="first_name"&&(We.includes("first")||We==="name")||Me==="last_name"&&We.includes("last")||Me==="current_brokerage"&&(We.includes("brokerage")||We.includes("company"))||Me==="license_number"&&We.includes("license")||Me==="experience_years"&&(We.includes("experience")||We.includes("years"))||Me==="annual_production"&&(We.includes("production")||We.includes("volume")));be&&(he[String(ke)]=be)}),y(he);const we=ne.slice(1).map(je=>{const ke=$(je),We={};return le.forEach((be,Me)=>{We[String(Me)]=ke[Me]||""}),We});c(we),S("map")},ee.readAsText(se)},$=X=>{const se=[];let ee="",Q=!1;for(const de of X)de==='"'?Q=!Q:de===","&&!Q?(se.push(ee.trim()),ee=""):ee+=de;return se.push(ee.trim()),se},q=async()=>{j(!0);try{const{data:{user:X}}=await G.auth.getUser();if(!X)throw new Error("Not authenticated");const se=i.map(Q=>{const de={brokerage_id:r,created_by:X.id,stage_id:_,source:"csv_import",first_name:"Unknown"};return Object.entries(f).forEach(([re,ne])=>{var he;const le=(he=Q[re])==null?void 0:he.trim();le&&(ne==="experience_years"?de[ne]=parseInt(le)||null:de[ne]=le)}),de});let ee=0;for(let Q=0;Q{const X=`first_name,last_name,email,phone,current_brokerage,license_number,experience_years,annual_production,notes Jane,Smith,jane@example.com,555-0100,ABC Realty,RE12345,8,$5M,Met at conference`,se=new Blob([X],{type:"text/csv"}),ee=URL.createObjectURL(se),Q=document.createElement("a");Q.href=ee,Q.download="recruit-prospects-template.csv",Q.click(),URL.revokeObjectURL(ee)};return e.jsx(_s,{open:t,onOpenChange:X=>{X||L(),s(X)},children:e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Import Prospects from CSV"})}),N==="upload"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[e.jsx(Yv,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Upload a CSV file with prospect data"}),e.jsx("input",{ref:l,type:"file",accept:".csv",className:"hidden",onChange:R}),e.jsxs(K,{onClick:()=>{var X;return(X=l.current)==null?void 0:X.click()},children:[e.jsx(ni,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(K,{variant:"link",className:"text-xs",onClick:U,children:"Download CSV template"})]}),N==="map"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[i.length," rows found"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:"Import to stage:"}),e.jsxs(rr,{value:_,onValueChange:b,children:[e.jsx(tr,{className:"w-[180px]",children:e.jsx(nr,{})}),e.jsx(sr,{children:n.map(X=>e.jsx(Tt,{value:X.id,children:X.name},X.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"w-[140px]",children:"CSV Column"}),e.jsx(bt,{className:"w-[160px]",children:"Map To"}),e.jsx(bt,{children:"Preview"})]})}),e.jsx(Pn,{children:u.map((X,se)=>{var ee;return e.jsxs(ks,{children:[e.jsx(dt,{className:"font-medium text-xs",children:X}),e.jsx(dt,{children:e.jsxs(rr,{value:f[String(se)]||"skip",onValueChange:Q=>y(de=>({...de,[String(se)]:Q==="skip"?"":Q})),children:[e.jsx(tr,{className:"h-8 text-xs",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"skip",children:"— Skip —"}),Z7e.map(Q=>e.jsx(Tt,{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(se)])||"—"})]},se)})})]})}),!Object.values(f).includes("first_name")&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-sm",children:[e.jsx(yl,{className:"h-4 w-4"}),' Map at least "first name" to proceed']}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",onClick:()=>{L()},children:"Back"}),e.jsx(K,{onClick:q,disabled:w||!Object.values(f).includes("first_name"),children:w?"Importing...":`Import ${i.length} Prospects`})]})]}),N==="done"&&e.jsxs("div",{className:"text-center py-6 space-y-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-green-500/10 flex items-center justify-center mx-auto",children:e.jsx(ma,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[T," prospects imported successfully!"]}),e.jsx(K,{onClick:()=>{L(),s(!1)},children:"Close"})]})]})})}function PNs({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=dme(t),[i,c]=C.useState(!1),[u,p]=C.useState(),[f,y]=C.useState(null),[_,b]=C.useState(!1),[w,j]=C.useState(!1),[N,S]=C.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 T=U=>r.filter(V=>V.stage_id===U),I=(U,V)=>{S(V),U.dataTransfer.effectAllowed="move"},L=U=>{U.preventDefault(),U.dataTransfer.dropEffect="move"},R=(U,V)=>{U.preventDefault(),N&&(o.mutate({id:N,stage_id:V}),S(null))},$=U=>{p(U),c(!0)},q=U=>{y(U),b(!0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.length," prospect",r.length!==1?"s":""]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>j(!0),children:[e.jsx(ni,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>{p(void 0),c(!0)},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsxs(Vi,{className:"w-full",children:[e.jsx("div",{className:"flex gap-4 pb-4",style:{minWidth:s.length*300},children:s.map(U=>{const V=T(U.id);return e.jsxs("div",{className:"w-[280px] flex-shrink-0 flex flex-col",onDragOver:L,onDrop:X=>R(X,U.id),children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:U.color}}),e.jsx("h3",{className:"font-semibold text-sm",children:U.name}),e.jsx(nt,{variant:"secondary",className:"text-xs h-5 px-1.5",children:V.length})]}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>$(U.id),children:e.jsx(Zs,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"space-y-2 min-h-[200px] bg-muted/30 rounded-lg p-2",children:V.map(X=>e.jsx(Ee,{className:"p-3 cursor-pointer hover:shadow-md transition-shadow border-l-4 group",style:{borderLeftColor:U.color},draggable:!0,onDragStart:se=>I(se,X.id),onClick:()=>q(X),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(yh,{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(ro,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-sm truncate",children:[X.first_name," ",X.last_name]})]}),X.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(La,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:X.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[X.email&&e.jsx(br,{className:"h-3 w-3 text-muted-foreground"}),X.phone&&e.jsx(ea,{className:"h-3 w-3 text-muted-foreground"}),X.experience_years!=null&&e.jsxs(nt,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[X.experience_years,"yr"]})]})]})]})},X.id))})]},U.id)})}),e.jsx(Kde,{orientation:"horizontal"})]}),e.jsx(llt,{open:i,onOpenChange:c,stages:s,defaultStageId:u,onSubmit:U=>a.mutate(U),isSubmitting:a.isPending}),e.jsx(ult,{prospect:f,stages:s,brokerageId:t,open:_,onOpenChange:b,onUpdate:U=>{o.mutate(U),y(V=>V?{...V,...U}:null)},onDelete:U=>l.mutate(U)}),e.jsx(hlt,{open:w,onOpenChange:j,brokerageId:t,stages:s})]})}function INs({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=dme(t),[i,c]=C.useState(!1),[u,p]=C.useState(null),[f,y]=C.useState(!1),[_,b]=C.useState(!1),[w,j]=C.useState(""),[N,S]=C.useState("all"),[T,I]=C.useState(null),[L,R]=C.useState("asc"),$=X=>{T===X?R(se=>se==="asc"?"desc":"asc"):(I(X),R("asc"))},q=({column:X})=>T!==X?e.jsx(ud,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):L==="asc"?e.jsx(gu,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(Oh,{className:"h-3.5 w-3.5 ml-1 text-primary"}),U=X=>s.find(se=>se.id===X),V=C.useMemo(()=>{let X=r.filter(se=>{var de,re;const ee=!w||`${se.first_name} ${se.last_name}`.toLowerCase().includes(w.toLowerCase())||((de=se.email)==null?void 0:de.toLowerCase().includes(w.toLowerCase()))||((re=se.current_brokerage)==null?void 0:re.toLowerCase().includes(w.toLowerCase())),Q=N==="all"||se.stage_id===N;return ee&&Q});return T&&(X=[...X].sort((se,ee)=>{var ne,le;let Q=null,de=null;switch(T){case"name":Q=`${se.first_name} ${se.last_name||""}`.toLowerCase(),de=`${ee.first_name} ${ee.last_name||""}`.toLowerCase();break;case"stage":Q=((ne=U(se.stage_id))==null?void 0:ne.sort_order)??999,de=((le=U(ee.stage_id))==null?void 0:le.sort_order)??999;break;case"brokerage":Q=(se.current_brokerage||"").toLowerCase(),de=(ee.current_brokerage||"").toLowerCase();break;case"experience":Q=se.experience_years??-1,de=ee.experience_years??-1;break;case"production":Q=(se.annual_production||"").toLowerCase(),de=(ee.annual_production||"").toLowerCase();break;case"source":Q=(se.source||"").toLowerCase(),de=(ee.source||"").toLowerCase();break;default:return 0}if(Q===de)return 0;if(Q==null)return 1;if(de==null)return-1;const re=Qj(X.target.value),className:"pl-8"})]}),e.jsxs(rr,{value:N,onValueChange:S,children:[e.jsx(tr,{className:"w-[180px]",children:e.jsx(nr,{placeholder:"All stages"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All stages"}),s.map(X=>e.jsx(Tt,{value:X.id,children:X.name},X.id))]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>b(!0),children:[e.jsx(ni,{className:"h-4 w-4 mr-2"})," Import CSV"]}),e.jsxs(K,{onClick:()=>c(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Add Prospect"]})]})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{className:"cursor-pointer select-none",onClick:()=>$("name"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Name ",e.jsx(q,{column:"name"})]})}),e.jsx(bt,{className:"cursor-pointer select-none",onClick:()=>$("stage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Stage ",e.jsx(q,{column:"stage"})]})}),e.jsx(bt,{className:"hidden md:table-cell cursor-pointer select-none",onClick:()=>$("brokerage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Brokerage ",e.jsx(q,{column:"brokerage"})]})}),e.jsx(bt,{className:"hidden md:table-cell",children:"Contact"}),e.jsx(bt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>$("experience"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Experience ",e.jsx(q,{column:"experience"})]})}),e.jsx(bt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>$("production"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Production ",e.jsx(q,{column:"production"})]})}),e.jsx(bt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>$("source"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Source ",e.jsx(q,{column:"source"})]})}),e.jsx(bt,{className:"w-[50px]"})]})}),e.jsx(Pn,{children:V.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:8,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):V.map(X=>{const se=U(X.stage_id);return e.jsxs(ks,{className:"cursor-pointer",onClick:()=>{p(X),y(!0)},children:[e.jsxs(dt,{className:"font-medium",children:[X.first_name," ",X.last_name]}),e.jsx(dt,{children:se?e.jsxs(nt,{variant:"outline",className:"text-xs gap-1 whitespace-nowrap",style:{borderColor:se.color,color:se.color,backgroundColor:`${se.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:se.color}}),se.name]}):e.jsx("span",{className:"text-muted-foreground text-xs",children:"—"})}),e.jsx(dt,{className:"hidden md:table-cell",children:X.current_brokerage?e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx(La,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate max-w-[150px]",children:X.current_brokerage})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-2",children:[X.email&&e.jsx(br,{className:"h-3.5 w-3.5 text-muted-foreground"}),X.phone&&e.jsx(ea,{className:"h-3.5 w-3.5 text-muted-foreground"}),!X.email&&!X.phone&&e.jsx("span",{className:"text-muted-foreground",children:"—"})]})}),e.jsx(dt,{className:"hidden lg:table-cell",children:X.experience_years!=null?`${X.experience_years} yr`:"—"}),e.jsx(dt,{className:"hidden lg:table-cell",children:X.annual_production||"—"}),e.jsx(dt,{className:"hidden lg:table-cell",children:X.source?e.jsx(nt,{variant:"secondary",className:"text-xs",children:X.source}):"—"}),e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:ee=>{ee.stopPropagation(),l.mutate(X.id)},children:e.jsx(jr,{className:"h-3.5 w-3.5"})})})]},X.id)})})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[V.length," of ",r.length," prospects"]}),e.jsx(llt,{open:i,onOpenChange:c,stages:s,onSubmit:X=>a.mutate(X),isSubmitting:a.isPending}),e.jsx(ult,{prospect:u,stages:s,brokerageId:t,open:f,onOpenChange:y,onUpdate:X=>{o.mutate(X),p(se=>se?{...se,...X}:null)},onDelete:X=>l.mutate(X)}),e.jsx(hlt,{open:_,onOpenChange:b,brokerageId:t,stages:s})]})}function LNs({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=dme(t),a=C.useMemo(()=>{if(!s.length||!r.length)return null;const o=r.length,l=s.find(N=>N.name==="Signed"),i=s.find(N=>N.name==="Onboarded"),c=r.filter(N=>N.stage_id===(l==null?void 0:l.id)||N.stage_id===(i==null?void 0:i.id)).length,u=o>0?(c/o*100).toFixed(1):"0",p=new Date,f=o>0?Math.round(r.reduce((N,S)=>N+ty(p,new Date(S.created_at)),0)/o):0,y=s.map(N=>({...N,count:r.filter(S=>S.stage_id===N.id).length})),_={};r.forEach(N=>{const S=N.source||"unknown";_[S]=(_[S]||0)+1});const b=Object.entries(_).sort((N,S)=>S[1]-N[1]),w=new Date;w.setDate(w.getDate()-30);const j=r.filter(N=>new Date(N.created_at)>=w).length;return{total:o,signed:c,conversionRate:u,avgDays:f,byStage:y,bySrc:b,recentCount:j}},[s,r]);return n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:e.jsx(mr,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Prospects"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-500/10 flex items-center justify-center",children:e.jsx(xc,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:[a.conversionRate,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Conversion Rate"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-amber-500/10 flex items-center justify-center",children:e.jsx(Tn,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:[a.avgDays,"d"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Avg Days in Pipeline"})]})]})})}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-violet-500/10 flex items-center justify-center",children:e.jsx(Am,{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(It,{children:e.jsx(Ot,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx(Oe,{className:"space-y-3",children:a.byStage.map(o=>{const l=a.total>0?o.count/a.total*100:0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:o.color}}),e.jsx("span",{children:o.name})]}),e.jsx("span",{className:"font-medium",children:o.count})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${l}%`,backgroundColor:o.color}})})]},o.id)})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Oe,{className:"space-y-3",children:[a.bySrc.map(([o,l])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(nt,{variant:"secondary",className:"capitalize",children:o.replace(/_/g," ")}),e.jsx("span",{className:"text-sm font-medium",children:l})]},o)),a.bySrc.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No source data"})]})]})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No prospect data yet. Add prospects to see metrics."})}const Y7e=[{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 DNs({brokerageId:t}){const{toast:s}=Ra(),[r,n]=C.useState(null),[a,o]=C.useState(null),l=(c,u)=>{navigator.clipboard.writeText(c),n(u),s({title:"Copied to clipboard!"}),setTimeout(()=>n(null),2e3)},i=[...new Set(Y7e.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(br,{className:"h-4 w-4"})," ",c]}),Y7e.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(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{className:"text-sm",children:u.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",u.subject]})]}),e.jsx(nt,{variant:"secondary",className:"text-[10px]",children:u.category})]})}),a===u.id&&e.jsxs(Oe,{className:"pt-0 space-y-3",children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Subject Line:"}),e.jsx("p",{className:"text-sm mb-3",children:u.subject}),e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Body:"}),e.jsx("pre",{className:"text-sm whitespace-pre-wrap font-sans",children:u.body})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:p=>{p.stopPropagation(),l(u.subject,u.id+"-subject")},children:[r===u.id+"-subject"?e.jsx(ma,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(mi,{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(ma,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(mi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Body"]})]})]})]},u.id))]},c))]})}const X7e={call:ea,email:br,text:po,meeting:on,note:In};function ONs({brokerageId:t}){const{data:s,isLoading:r}=wt({queryKey:["recruit-activity-report",t],queryFn:async()=>{const{data:n,error:a}=await G.from("recruit_prospects").select("id, created_by").eq("brokerage_id",t);if(a)throw a;const o=(n==null?void 0:n.map(_=>_.id))||[];if(o.length===0)return{recruiters:[],recentActivities:[]};const{data:l,error:i}=await G.from("recruit_activities").select("*").in("prospect_id",o).order("created_at",{ascending:!1});if(i)throw i;const c=[...new Set([...n.map(_=>_.created_by),...(l||[]).map(_=>_.created_by)])],{data:u}=await G.from("profiles").select("id, name, email").in("id",c),p=Object.fromEntries((u||[]).map(_=>[_.id,_])),f=aie(new Date,30);return{recruiters:c.map(_=>{var S,T;const b=(l||[]).filter(I=>I.created_by===_),w=b.filter(I=>new Date(I.created_at)>=f),j={};w.forEach(I=>{j[I.activity_type]=(j[I.activity_type]||0)+1});const N=n.filter(I=>I.created_by===_).length;return{id:_,name:((S=p[_])==null?void 0:S.name)||"Unknown",email:((T=p[_])==null?void 0:T.email)||"",totalActivities:b.length,recentActivities:w.length,byType:j,prospectsCreated:N}}).sort((_,b)=>b.recentActivities-_.recentActivities),recentActivities:(l||[]).slice(0,20)}},enabled:!!t});return r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):s!=null&&s.recruiters.length?e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Recruiter Leaderboard (Last 30 Days)"})}),e.jsx(Oe,{className:"space-y-4",children:s.recruiters.map((n,a)=>e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg bg-muted/30",children:[e.jsx("div",{className:"flex items-center justify-center h-8 w-8 rounded-full bg-primary/10 text-primary font-bold text-sm",children:a+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ro,{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=X7e[o]||In;return e.jsxs(nt,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(i,{className:"h-2.5 w-2.5"})," ",l," ",o,l!==1?"s":""]},o)})})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-bold",children:n.recentActivities}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"activities"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-lg font-bold",children:n.prospectsCreated}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:"prospects"})]})]},n.id))})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Recent Activity"})}),e.jsx(Oe,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=X7e[n.activity_type]||In;return e.jsxs("div",{className:"flex items-start gap-3 text-sm",children:[e.jsx("div",{className:"h-7 w-7 rounded-full bg-muted flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(a,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium",children:n.title}),n.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:ys(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 RNs({brokerageId:t}){const{toast:s}=Ra(),r=ss(),[n,a]=C.useState(!1),[o,l]=C.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:c}=wt({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:j,error:N}=await G.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(N)throw N;return j}}),u=[...new Set(i.map(j=>j.referred_by))],{data:p=[]}=wt({queryKey:["referral-profiles",u],queryFn:async()=>{if(!u.length)return[];const{data:j}=await G.from("profiles").select("id, name, email").in("id",u);return j||[]},enabled:u.length>0}),f=Object.fromEntries(p.map(j=>[j.id,j])),y=Dt({mutationFn:async j=>{const{data:{user:N}}=await G.auth.getUser();if(!N)throw new Error("Not authenticated");const{error:S}=await G.from("recruit_referrals").insert({brokerage_id:t,referred_by:N.id,referee_first_name:j.first_name,referee_last_name:j.last_name||null,referee_email:j.email||null,referee_phone:j.phone||null,referee_current_brokerage:j.current_brokerage||null,notes:j.notes||null});if(S)throw S},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-referrals",t]}),s({title:"Referral submitted!"}),l({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),a(!1)},onError:j=>s({title:"Error",description:j.message,variant:"destructive"})}),_=Dt({mutationFn:async({id:j,status:N,incentive_status:S})=>{const T={updated_at:new Date().toISOString()};N&&(T.status=N),S&&(T.incentive_status=S);const{error:I}=await G.from("recruit_referrals").update(T).eq("id",j);if(I)throw I},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),b=j=>j==="approved"||j==="signed"?e.jsx(ma,{className:"h-3 w-3"}):j==="rejected"?e.jsx($c,{className:"h-3 w-3"}):e.jsx(Tn,{className:"h-3 w-3"}),w=j=>j==="approved"||j==="signed"||j==="paid"?"bg-green-500/10 text-green-600 border-green-200":j==="rejected"?"bg-red-500/10 text-red-600 border-red-200":"bg-amber-500/10 text-amber-600 border-amber-200";return 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(Zs,{className:"h-4 w-4 mr-2"})," Submit Referral"]})]}),i.length===0?e.jsxs(Ee,{className:"py-12 text-center",children:[e.jsx(Pc,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No referrals yet. Agents can refer potential recruits here."})]}):e.jsx("div",{className:"space-y-3",children:i.map(j=>{var N;return e.jsx(Ee,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-medium",children:[j.referee_first_name," ",j.referee_last_name]}),e.jsxs(nt,{variant:"outline",className:w(j.status),children:[b(j.status)," ",j.status]}),j.incentive_status&&e.jsxs(nt,{variant:"outline",className:w(j.incentive_status),children:[e.jsx(bo,{className:"h-3 w-3 mr-1"})," ",j.incentive_status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[j.referee_email&&e.jsx("p",{children:j.referee_email}),j.referee_phone&&e.jsx("p",{children:j.referee_phone}),j.referee_current_brokerage&&e.jsxs("p",{children:["Currently at: ",j.referee_current_brokerage]}),e.jsxs("p",{children:["Referred by: ",((N=f[j.referred_by])==null?void 0:N.name)||"Unknown"," • ",ys(new Date(j.created_at),"MMM d, yyyy")]})]}),j.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 italic",children:j.notes})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(rr,{value:j.status,onValueChange:S=>_.mutate({id:j.id,status:S}),children:[e.jsx(tr,{className:"h-7 text-xs w-[110px]",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"pending",children:"Pending"}),e.jsx(Tt,{value:"contacted",children:"Contacted"}),e.jsx(Tt,{value:"approved",children:"Approved"}),e.jsx(Tt,{value:"signed",children:"Signed"}),e.jsx(Tt,{value:"rejected",children:"Rejected"})]})]}),e.jsxs(rr,{value:j.incentive_status||"pending",onValueChange:S=>_.mutate({id:j.id,incentive_status:S}),children:[e.jsx(tr,{className:"h-7 text-xs w-[100px]",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"pending",children:"Unpaid"}),e.jsx(Tt,{value:"paid",children:"Paid"}),e.jsx(Tt,{value:"n/a",children:"N/A"})]})]})]})]})},j.id)})}),e.jsx(_s,{open:n,onOpenChange:a,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Submit a Recruit Referral"})}),e.jsxs("form",{onSubmit:j=>{j.preventDefault(),y.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"First Name *"}),e.jsx(Fe,{required:!0,value:o.first_name,onChange:j=>l(N=>({...N,first_name:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Last Name"}),e.jsx(Fe,{value:o.last_name,onChange:j=>l(N=>({...N,last_name:j.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Email"}),e.jsx(Fe,{type:"email",value:o.email,onChange:j=>l(N=>({...N,email:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Phone"}),e.jsx(Fe,{value:o.phone,onChange:j=>l(N=>({...N,phone:j.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Current Brokerage"}),e.jsx(Fe,{value:o.current_brokerage,onChange:j=>l(N=>({...N,current_brokerage:j.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Notes"}),e.jsx(Ar,{value:o.notes,onChange:j=>l(N=>({...N,notes:j.target.value})),rows:2})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:y.isPending,children:"Submit"})]})]})]})})]})}function FNs({brokerageId:t}){const{toast:s}=Ra(),r=ss(),[n,a]=C.useState(!1),{data:o}=wt({queryKey:["brokerage-recruit-form",t],queryFn:async()=>{const{data:y,error:_}=await G.from("brokerages").select("id, name, recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(_)throw _;return y}}),{data:l=[]}=wt({queryKey:["recruit-interest-submissions",t],queryFn:async()=>{const{data:y,error:_}=await G.from("recruit_interest_submissions").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(_)throw _;return y}}),i=Dt({mutationFn:async y=>{const{error:_}=await G.from("brokerages").update({recruit_form_enabled:y}).eq("id",t);if(_)throw _},onSuccess:()=>{r.invalidateQueries({queryKey:["brokerage-recruit-form",t]}),s({title:o!=null&&o.recruit_form_enabled?"Form disabled":"Form enabled"})}}),c=Dt({mutationFn:async({id:y,status:_})=>{const{error:b}=await G.from("recruit_interest_submissions").update({status:_}).eq("id",y);if(b)throw b},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-interest-submissions",t]})}),u=`${window.location.origin}/join-brokerage/${(o==null?void 0:o.recruit_form_slug)||""}`,p=()=>{navigator.clipboard.writeText(u),a(!0),s({title:"Link copied!"}),setTimeout(()=>a(!1),2e3)},f=y=>y==="contacted"||y==="converted"?"bg-green-500/10 text-green-600":y==="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(It,{children:e.jsx(Ot,{className:"text-base",children:"Public Interest Form"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Enable Public Form"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow agents to express interest in joining via a public link"})]}),e.jsx(Br,{checked:(o==null?void 0:o.recruit_form_enabled)||!1,onCheckedChange:y=>i.mutate(y)})]}),(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(ma,{className:"h-3.5 w-3.5"}):e.jsx(mi,{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(rn,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"text-base",children:["Interest Submissions (",l.length,")"]})}),e.jsx(Oe,{children:l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Pc,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No submissions yet"})]}):e.jsx("div",{className:"space-y-3",children:l.map(y=>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:[y.first_name," ",y.last_name]}),e.jsx(nt,{variant:"outline",className:f(y.status),children:y.status})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-muted-foreground",children:[y.email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(br,{className:"h-3 w-3"}),y.email]}),y.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ea,{className:"h-3 w-3"}),y.phone]}),y.current_brokerage&&e.jsxs("span",{children:["From: ",y.current_brokerage]}),y.experience_years&&e.jsxs("span",{children:[y.experience_years,"yr exp"]})]}),y.why_interested&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 italic",children:['"',y.why_interested,'"']}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:ys(new Date(y.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(rr,{value:y.status,onValueChange:_=>c.mutate({id:y.id,status:_}),children:[e.jsx(tr,{className:"h-7 text-xs w-[110px]",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"new",children:"New"}),e.jsx(Tt,{value:"contacted",children:"Contacted"}),e.jsx(Tt,{value:"converted",children:"Converted"}),e.jsx(Tt,{value:"dismissed",children:"Dismissed"})]})]})]},y.id))})})]})]})}function zNs({brokerageId:t}){const{toast:s}=Ra(),r=ss(),[n,a]=C.useState(!1),[o,l]=C.useState({prospect_id:"",title:"",description:"",due_date:ys(kl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,c]=C.useState("pending"),{data:u=[]}=wt({queryKey:["recruit-prospects-list",t],queryFn:async()=>{const{data:L,error:R}=await G.from("recruit_prospects").select("id, first_name, last_name").eq("brokerage_id",t).order("first_name");if(R)throw R;return L}}),{data:p=[],isLoading:f}=wt({queryKey:["recruit-follow-ups",t],queryFn:async()=>{const L=u.map(q=>q.id);if(!L.length)return[];const{data:R,error:$}=await G.from("recruit_follow_ups").select("*").in("prospect_id",L).order("due_date");if($)throw $;return R},enabled:u.length>0}),y=Object.fromEntries(u.map(L=>[L.id,L])),_=Dt({mutationFn:async L=>{const{data:{user:R}}=await G.auth.getUser();if(!R)throw new Error("Not authenticated");const{error:$}=await G.from("recruit_follow_ups").insert({prospect_id:L.prospect_id,assigned_to:R.id,title:L.title,description:L.description||null,due_date:new Date(L.due_date).toISOString()});if($)throw $},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-follow-ups",t]}),s({title:"Follow-up scheduled"}),l({prospect_id:"",title:"",description:"",due_date:ys(kl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:L=>s({title:"Error",description:L.message,variant:"destructive"})}),b=Dt({mutationFn:async({id:L,completed:R})=>{const{error:$}=await G.from("recruit_follow_ups").update({completed_at:R?new Date().toISOString():null}).eq("id",L);if($)throw $},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-follow-ups",t]})}),w=p.filter(L=>i==="pending"?!L.completed_at:i==="completed"?!!L.completed_at:!0),j=w.filter(L=>!L.completed_at&&u0(new Date(L.due_date))&&!uu(new Date(L.due_date))),N=w.filter(L=>!L.completed_at&&uu(new Date(L.due_date))),S=w.filter(L=>!L.completed_at&&!u0(new Date(L.due_date))&&!uu(new Date(L.due_date))),T=w.filter(L=>!!L.completed_at),I=L=>{const R=y[L.prospect_id],$=!L.completed_at&&u0(new Date(L.due_date))&&!uu(new Date(L.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Yo,{checked:!!L.completed_at,onCheckedChange:q=>b.mutate({id:L.id,completed:q}),className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium ${L.completed_at?"line-through text-muted-foreground":""}`,children:L.title}),L.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:L.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[R&&e.jsxs(nt,{variant:"secondary",className:"text-[10px]",children:[R.first_name," ",R.last_name]}),e.jsxs("span",{className:`flex items-center gap-1 ${$?"text-destructive font-medium":""}`,children:[$?e.jsx(yl,{className:"h-3 w-3"}):e.jsx(on,{className:"h-3 w-3"}),ys(new Date(L.due_date),"MMM d, h:mm a")]}),L.is_automated&&e.jsx(nt,{variant:"outline",className:"text-[10px]",children:"Auto"})]})]})]},L.id)};return f?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex gap-2",children:["pending","completed","all"].map(L=>e.jsxs(K,{size:"sm",variant:i===L?"default":"outline",onClick:()=>c(L),className:"capitalize text-xs",children:[L," ",L==="pending"&&j.length+N.length+S.length>0&&`(${j.length+N.length+S.length})`]},L))}),e.jsxs(K,{size:"sm",onClick:()=>a(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Follow-up"]})]}),i!=="completed"&&j.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-destructive flex items-center gap-1",children:[e.jsx(yl,{className:"h-3.5 w-3.5"})," Overdue (",j.length,")"]}),j.map(I)]}),i!=="completed"&&N.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-amber-600 flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"})," Today (",N.length,")"]}),N.map(I)]}),i!=="completed"&&S.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(on,{className:"h-3.5 w-3.5"})," Upcoming (",S.length,")"]}),S.map(I)]}),i!=="pending"&&T.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-xs font-semibold text-muted-foreground flex items-center gap-1",children:[e.jsx(ma,{className:"h-3.5 w-3.5"})," Completed (",T.length,")"]}),T.map(I)]}),w.length===0&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-8",children:["No follow-ups ",i!=="all"?`(${i})`:""]}),e.jsx(_s,{open:n,onOpenChange:a,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Schedule Follow-up"})}),e.jsxs("form",{onSubmit:L=>{L.preventDefault(),_.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Prospect *"}),e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",required:!0,value:o.prospect_id,onChange:L=>l(R=>({...R,prospect_id:L.target.value})),children:[e.jsx("option",{value:"",children:"Select prospect..."}),u.map(L=>e.jsxs("option",{value:L.id,children:[L.first_name," ",L.last_name]},L.id))]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Task *"}),e.jsx(Fe,{required:!0,value:o.title,onChange:L=>l(R=>({...R,title:L.target.value})),placeholder:"e.g. Follow-up call"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Details"}),e.jsx(Ar,{value:o.description,onChange:L=>l(R=>({...R,description:L.target.value})),rows:2})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Due Date *"}),e.jsx(Fe,{type:"datetime-local",required:!0,value:o.due_date,onChange:L=>l(R=>({...R,due_date:L.target.value}))})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:_.isPending,children:"Schedule"})]})]})]})})]})}const BNs=[{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 $Ns({brokerageId:t}){const{toast:s}=Ra(),r=ss(),[n,a]=C.useState(null),{data:o,isLoading:l}=wt({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:j,error:N}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(N)throw N;return j}}),[i,c]=C.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:BNs,testimonials:[],gallery_images:[]});C.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 j={brokerage_id:t,hero_headline:i.hero_headline,hero_subtext:i.hero_subtext,hero_image_url:i.hero_image_url,logo_url:i.logo_url,primary_color:i.primary_color,accent_color:i.accent_color,benefits:JSON.parse(JSON.stringify(i.benefits)),testimonials:JSON.parse(JSON.stringify(i.testimonials)),gallery_images:JSON.parse(JSON.stringify(i.gallery_images)),updated_at:new Date().toISOString()};if(i.id){const{error:N}=await G.from("recruit_landing_page_settings").update(j).eq("id",i.id);if(N)throw N}else{const{error:N}=await G.from("recruit_landing_page_settings").insert(j);if(N)throw N}},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-landing-settings",t]}),s({title:"Landing page saved!"})},onError:j=>s({title:"Error",description:j.message,variant:"destructive"})}),p=async(j,N)=>{const S=j.name.split(".").pop(),T=`${t}/${N}-${Date.now()}.${S}`,{error:I}=await G.storage.from("recruit-landing").upload(T,j);if(I)throw I;const{data:{publicUrl:L}}=G.storage.from("recruit-landing").getPublicUrl(T);return L},f=async(j,N)=>{var T;const S=(T=j.target.files)==null?void 0:T[0];if(S){a(N);try{const I=await p(S,N);c(L=>({...L,[N]:I})),s({title:"Image uploaded!"})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},y=async j=>{var S;const N=(S=j.target.files)==null?void 0:S[0];if(N){a("gallery");try{const T=await p(N,"gallery");c(I=>({...I,gallery_images:[...I.gallery_images,T]})),s({title:"Gallery image added!"})}catch(T){s({title:"Upload failed",description:T.message,variant:"destructive"})}finally{a(null)}}},_=async(j,N)=>{var T;const S=(T=j.target.files)==null?void 0:T[0];if(S){a(`testimonial-${N}`);try{const I=await p(S,`testimonial-${N}`);c(L=>{const R=[...L.testimonials];return R[N]={...R[N],photo_url:I},{...L,testimonials:R}})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},{data:b}=wt({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:j,error:N}=await G.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(N)throw N;return j}}),w=`${window.location.origin}/join-brokerage/${(b==null?void 0:b.recruit_form_slug)||""}`;return l?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-6",children:[(b==null?void 0:b.recruit_form_enabled)&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Live page:"}),e.jsx("code",{className:"text-xs flex-1 truncate",children:w}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Branding"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.logo_url&&e.jsx("img",{src:i.logo_url,alt:"Logo",className:"h-10 w-auto rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:n==="logo_url",children:e.jsxs("span",{children:[e.jsx(ni,{className:"h-3.5 w-3.5 mr-1"}),n==="logo_url"?"Uploading...":"Upload Logo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:j=>f(j,"logo_url")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.primary_color,onChange:j=>c(N=>({...N,primary_color:j.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Fe,{value:i.primary_color,onChange:j=>c(N=>({...N,primary_color:j.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:i.accent_color,onChange:j=>c(N=>({...N,accent_color:j.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Fe,{value:i.accent_color,onChange:j=>c(N=>({...N,accent_color:j.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Hero Section"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Headline"}),e.jsx(Fe,{value:i.hero_headline,onChange:j=>c(N=>({...N,hero_headline:j.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Subtext"}),e.jsx(Ar,{value:i.hero_subtext,onChange:j=>c(N=>({...N,hero_subtext:j.target.value})),rows:2,placeholder:"Take your career to the next level..."})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.hero_image_url&&e.jsx("img",{src:i.hero_image_url,alt:"Hero",className:"h-16 w-28 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:n==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(ni,{className:"h-3.5 w-3.5 mr-1"}),n==="hero_image_url"?"Uploading...":"Upload Image"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:j=>f(j,"hero_image_url")})]}),i.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(j=>({...j,hero_image_url:null})),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>c(j=>({...j,benefits:[...j.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.benefits.map((j,N)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(yh,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(Fe,{value:j.icon,onChange:S=>{const T=[...i.benefits];T[N]={...j,icon:S.target.value},c(I=>({...I,benefits:T}))},className:"w-14 text-center"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(Fe,{value:j.title,onChange:S=>{const T=[...i.benefits];T[N]={...j,title:S.target.value},c(I=>({...I,benefits:T}))},placeholder:"Benefit title"}),e.jsx(Fe,{value:j.description,onChange:S=>{const T=[...i.benefits];T[N]={...j,description:S.target.value},c(I=>({...I,benefits:T}))},placeholder:"Short description"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(S=>({...S,benefits:S.benefits.filter((T,I)=>I!==N)})),children:e.jsx(jr,{className:"h-3.5 w-3.5 text-destructive"})})]},N)),i.benefits.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No benefits added yet"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{className:"text-base",children:"Testimonials"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>c(j=>({...j,testimonials:[...j.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Oe,{className:"space-y-3",children:[i.testimonials.map((j,N)=>{var S;return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[j.photo_url?e.jsx("img",{src:j.photo_url,alt:j.name,className:"h-10 w-10 rounded-full object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-muted flex items-center justify-center text-xs text-muted-foreground",children:((S=j.name)==null?void 0:S[0])||"?"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-primary hover:underline",children:n===`testimonial-${N}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:T=>_(T,N)})]})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Fe,{value:j.name,onChange:T=>{const I=[...i.testimonials];I[N]={...j,name:T.target.value},c(L=>({...L,testimonials:I}))},placeholder:"Name"}),e.jsx(Fe,{value:j.role,onChange:T=>{const I=[...i.testimonials];I[N]={...j,role:T.target.value},c(L=>({...L,testimonials:I}))},placeholder:"Role / Title"})]}),e.jsx(Ar,{value:j.quote,onChange:T=>{const I=[...i.testimonials];I[N]={...j,quote:T.target.value},c(L=>({...L,testimonials:I}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(T=>({...T,testimonials:T.testimonials.filter((I,L)=>L!==N)})),children:e.jsx(jr,{className:"h-3.5 w-3.5 text-destructive"})})]},N)}),i.testimonials.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No testimonials added yet"})]})]}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{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(cl,{className:"h-3.5 w-3.5 mr-1"}),n==="gallery"?"Uploading...":"Add Photo"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:y})]})]}),e.jsx(Oe,{children:i.gallery_images.length>0?e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:i.gallery_images.map((j,N)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:j,alt:`Gallery ${N+1}`,className:"h-24 w-full object-cover rounded-lg"}),e.jsx(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((T,I)=>I!==N)})),children:e.jsx(jr,{className:"h-3 w-3"})})]},N))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No gallery images added yet"})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:()=>u.mutate(),disabled:u.isPending,size:"lg",children:[e.jsx(Wu,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Landing Page"]})})]})}function qNs(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function UNs({video:t}){return t.cta_clicked_at?e.jsx(nt,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(nt,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(va,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(nt,{variant:"secondary",children:[e.jsx(oa,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(nt,{variant:"outline",children:[e.jsx(Tn,{className:"h-3 w-3 mr-1"}),"Draft"]})}function VNs({brokerageId:t}){const{data:s=[],isLoading:r}=SNs(t),{data:n=[]}=dlt(t),a=TNs(),o=ANs(),l=clt(),[i,c]=C.useState(""),[u,p]=C.useState(!1),[f,y]=C.useState({title:"",script_text:"",category:"general"}),_=s.filter(S=>{var I,L,R,$;return i?`${((I=S.prospect)==null?void 0:I.first_name)||""} ${((L=S.prospect)==null?void 0:L.last_name)||""}`.toLowerCase().includes(i.toLowerCase())||(($=(R=S.video)==null?void 0:R.title)==null?void 0:$.toLowerCase().includes(i.toLowerCase())):!0}),b={total:s.length,sent:s.filter(S=>S.sent_at).length,viewed:s.filter(S=>S.view_count>0).length,ctaClicked:s.filter(S=>S.cta_clicked_at).length},w=C.useCallback(S=>{if(!S)return;const T=`${window.location.origin}/recruit-video/${S}`;navigator.clipboard.writeText(T),me.success("Share link copied")},[]),j=C.useCallback((S,T)=>{l.mutate({id:S,sent_via:T})},[l]),N=()=>{!f.title.trim()||!f.script_text.trim()||a.mutate({brokerage_id:t,...f},{onSuccess:()=>{y({title:"",script_text:"",category:"general"}),p(!1)}})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[{label:"Total Videos",value:b.total,icon:Nn,color:"text-primary"},{label:"Sent",value:b.sent,icon:oa,color:"text-blue-500"},{label:"Viewed",value:b.viewed,icon:va,color:"text-amber-500"},{label:"CTA Clicked",value:b.ctaClicked,icon:ha,color:"text-emerald-500"}].map(S=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:`h-10 w-10 rounded-lg bg-muted flex items-center justify-center ${S.color}`,children:e.jsx(S.icon,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:S.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:S.label})]})]})},S.label))}),e.jsxs(Aa,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(ja,{children:[e.jsxs(js,{value:"videos",children:[e.jsx(Nn,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(js,{value:"scripts",children:[e.jsx(In,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(js,{value:"analytics",children:[e.jsx(xl,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx($s,{value:"videos",children:e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ot,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name or title...",value:i,onChange:S=>c(S.target.value),className:"pl-9"})]})]})}),e.jsx(Oe,{children:r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(Nn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No video outreach yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Record a personalized video from any prospect's profile card"})]}):e.jsx("div",{className:"space-y-3",children:_.map(S=>{var T,I,L,R,$,q;return e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg border bg-card hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"relative h-16 w-28 rounded-md overflow-hidden bg-muted flex-shrink-0",children:[(T=S.video)!=null&&T.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(Nn,{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:qNs(((I=S.video)==null?void 0:I.duration_seconds)??null)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("p",{className:"font-medium truncate",children:[(L=S.prospect)==null?void 0:L.first_name," ",(R=S.prospect)==null?void 0:R.last_name]}),e.jsx(UNs,{video:S})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:(($=S.video)==null?void 0:$.title)||"Untitled video"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ys(new Date(S.created_at),"MMM d, yyyy"),((q=S.prospect)==null?void 0:q.current_brokerage)&&` · ${S.prospect.current_brokerage}`]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(S.share_token),title:"Copy share link",children:e.jsx(mi,{className:"h-4 w-4"})}),!S.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>j(S.id,"email"),title:"Mark as sent",children:e.jsx(oa,{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(rn,{className:"h-4 w-4"})})]})]},S.id)})})})]})}),e.jsx($s,{value:"scripts",children:e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ot,{className:"text-lg",children:"Recruiting Scripts"}),e.jsxs(_s,{open:u,onOpenChange:p,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1.5"}),"New Script"]})}),e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Create Recruiting Script"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title"}),e.jsx(Fe,{value:f.title,onChange:S=>y(T=>({...T,title:S.target.value})),placeholder:"e.g., Why Switch to Our Brokerage"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Category"}),e.jsxs(rr,{value:f.category,onValueChange:S=>y(T=>({...T,category:S})),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:Qbe.map(S=>e.jsx(Tt,{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Script"}),e.jsx(Ar,{value:f.script_text,onChange:S=>y(T=>({...T,script_text:S.target.value})),placeholder:"Hi [Name], I noticed you've been doing great work at [Brokerage]...",rows:8})]}),e.jsx(K,{onClick:N,disabled:!f.title.trim()||!f.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx(Oe,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(In,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No scripts yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Create teleprompter scripts for common recruiting conversations"})]}):e.jsx("div",{className:"grid gap-3 md:grid-cols-2",children:n.map(S=>{var I;const T=((I=Qbe.find(L=>L.value===S.category))==null?void 0:I.label)||S.category;return e.jsx(Ee,{className:"relative group",children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(nt,{variant:"outline",className:"text-[10px] mb-2",children:T}),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(jr,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-3",children:S.script_text}),S.is_global&&e.jsx(nt,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},S.id)})})})]})}),e.jsx($s,{value:"analytics",children:e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"Engagement Funnel"})}),e.jsxs(Oe,{children:[e.jsx("div",{className:"space-y-4",children:[{label:"Videos Created",count:b.total,pct:100,color:"bg-primary"},{label:"Sent to Prospects",count:b.sent,pct:b.total?Math.round(b.sent/b.total*100):0,color:"bg-blue-500"},{label:"Viewed by Prospect",count:b.viewed,pct:b.sent?Math.round(b.viewed/b.sent*100):0,color:"bg-amber-500"},{label:"CTA Clicked",count:b.ctaClicked,pct:b.viewed?Math.round(b.ctaClicked/b.viewed*100):0,color:"bg-emerald-500"}].map(S=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:S.label}),e.jsxs("span",{className:"font-medium",children:[S.count," (",S.pct,"%)"]})]}),e.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${S.color} rounded-full transition-all`,style:{width:`${S.pct}%`}})})]},S.label))}),s.filter(S=>S.view_count>0).length>0&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h4",{className:"font-medium text-sm mb-3",children:"Most Engaged Prospects"}),e.jsx("div",{className:"space-y-2",children:s.filter(S=>S.view_count>0).sort((S,T)=>T.view_count-S.view_count).slice(0,5).map(S=>{var T,I;return e.jsxs("div",{className:"flex items-center justify-between text-sm p-2 rounded-md bg-muted/30",children:[e.jsxs("span",{className:"font-medium",children:[(T=S.prospect)==null?void 0:T.first_name," ",(I=S.prospect)==null?void 0:I.last_name]}),e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(va,{className:"h-3.5 w-3.5"})," ",S.view_count]}),S.cta_clicked_at&&e.jsx(ha,{className:"h-4 w-4 text-emerald-500"})]})]},S.id)})})]})]})]})})]})]})}function HNs({brokerageId:t}){const{toast:s}=Ra(),r=ss(),{stages:n,prospects:a}=dme(t),[o,l]=C.useState(!1),[i,c]=C.useState({title:"",target_count:"10",target_stage_id:"",period_start:ys(new Date,"yyyy-MM-dd"),period_end:ys(new Date(new Date().getFullYear(),new Date().getMonth()+3,0),"yyyy-MM-dd")}),{data:u=[],isLoading:p}=wt({queryKey:["recruit-goals",t],queryFn:async()=>{const{data:b,error:w}=await G.from("recruit_goals").select("*").eq("brokerage_id",t).order("period_end",{ascending:!1});if(w)throw w;return b}}),f=Dt({mutationFn:async b=>{const{data:{user:w}}=await G.auth.getUser();if(!w)throw new Error("Not authenticated");const{error:j}=await G.from("recruit_goals").insert({brokerage_id:t,title:b.title,target_count:parseInt(b.target_count),target_stage_id:b.target_stage_id||null,period_start:b.period_start,period_end:b.period_end,created_by:w.id});if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal created"}),l(!1)},onError:b=>s({title:"Error",description:b.message,variant:"destructive"})}),y=Dt({mutationFn:async b=>{const{error:w}=await G.from("recruit_goals").delete().eq("id",b);if(w)throw w},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal removed"})}}),_=b=>{const w=n.find(N=>N.id===b.target_stage_id);return{count:a.filter(N=>Ax(new Date(N.created_at),{start:new Date(b.period_start),end:new Date(b.period_end)})?b.target_stage_id?N.stage_id===b.target_stage_id:!0:!1).length,stage:w}};return p?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.length," goal",u.length!==1?"s":""]}),e.jsxs(K,{size:"sm",onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," New Goal"]})]}),u.length===0?e.jsxs(Ee,{className:"py-12 text-center",children:[e.jsx(Am,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No goals set. Create a recruiting target to track progress."})]}):e.jsx("div",{className:"grid md:grid-cols-2 gap-4",children:u.map(b=>{const{count:w,stage:j}=_(b),N=Math.min(100,w/b.target_count*100),S=Ax(new Date,{start:new Date(b.period_start),end:new Date(b.period_end)});return e.jsxs(Ee,{className:S?"":"opacity-60",children:[e.jsx(It,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{className:"text-sm",children:b.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ys(new Date(b.period_start),"MMM d")," – ",ys(new Date(b.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[S?e.jsx(nt,{className:"text-[10px]",children:"Active"}):e.jsx(nt,{variant:"secondary",className:"text-[10px]",children:"Ended"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground",onClick:()=>y.mutate(b.id),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Oe,{className:"space-y-2",children:[j&&e.jsxs(nt,{variant:"outline",className:"text-[10px]",style:{borderColor:j.color,color:j.color},children:["Stage: ",j.name]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-bold text-lg",children:w}),e.jsxs("span",{className:"text-muted-foreground",children:["/ ",b.target_count]})]}),e.jsx(Oi,{value:N,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[N.toFixed(0),"% complete"]})]})]},b.id)})}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Create Recruiting Goal"})}),e.jsxs("form",{onSubmit:b=>{b.preventDefault(),f.mutate(i)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Goal Title *"}),e.jsx(Fe,{required:!0,value:i.title,onChange:b=>c(w=>({...w,title:b.target.value})),placeholder:"e.g. Q2 Recruiting Target"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Target Count *"}),e.jsx(Fe,{type:"number",min:"1",required:!0,value:i.target_count,onChange:b=>c(w=>({...w,target_count:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Target Stage (optional)"}),e.jsxs("select",{className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:i.target_stage_id,onChange:b=>c(w=>({...w,target_stage_id:b.target.value})),children:[e.jsx("option",{value:"",children:"All stages (total prospects)"}),n.map(b=>e.jsx("option",{value:b.id,children:b.name},b.id))]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Count prospects that reach this stage"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Start Date"}),e.jsx(Fe,{type:"date",required:!0,value:i.period_start,onChange:b=>c(w=>({...w,period_start:b.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"End Date"}),e.jsx(Fe,{type:"date",required:!0,value:i.period_end,onChange:b=>c(w=>({...w,period_end:b.target.value}))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"submit",disabled:f.isPending,children:"Create Goal"})]})]})]})})]})}function WNs(){var i;const[t,s]=C.useState(""),[r,n]=C.useState("board"),{data:a=[],isLoading:o}=wt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:c,error:u}=await G.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(Es,{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(Es,{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(rr,{value:l,onValueChange:s,children:[e.jsxs(tr,{className:"w-[280px]",children:[e.jsx(La,{className:"mr-2 h-4 w-4"}),e.jsx(nr,{placeholder:"Select brokerage"})]}),e.jsx(sr,{children:a.map(c=>e.jsx(Tt,{value:c.id,children:c.name},c.id))})]})]}),l?e.jsxs(Aa,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(ja,{className:"flex-wrap h-auto gap-1",children:[e.jsx(js,{value:"pipeline",children:"Pipeline"}),e.jsxs(js,{value:"video-outreach",children:[e.jsx(Nn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(js,{value:"follow-ups",children:"Follow-ups"}),e.jsx(js,{value:"referrals",children:"Referrals"}),e.jsx(js,{value:"interest",children:"Interest Form"}),e.jsx(js,{value:"landing-page",children:"Landing Page"}),e.jsx(js,{value:"goals",children:"Goals"}),e.jsx(js,{value:"metrics",children:"Metrics"}),e.jsx(js,{value:"templates",children:"Email Templates"}),e.jsx(js,{value:"activity",children:"Recruiter Activity"})]}),e.jsxs($s,{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(lf,{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(hL,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(PNs,{brokerageId:l}):e.jsx(INs,{brokerageId:l})]}),e.jsx($s,{value:"video-outreach",children:e.jsx(VNs,{brokerageId:l})}),e.jsx($s,{value:"follow-ups",children:e.jsx(zNs,{brokerageId:l})}),e.jsx($s,{value:"referrals",children:e.jsx(RNs,{brokerageId:l})}),e.jsx($s,{value:"interest",children:e.jsx(FNs,{brokerageId:l})}),e.jsx($s,{value:"landing-page",children:e.jsx($Ns,{brokerageId:l})}),e.jsx($s,{value:"goals",children:e.jsx(HNs,{brokerageId:l})}),e.jsx($s,{value:"metrics",children:e.jsx(LNs,{brokerageId:l})}),e.jsx($s,{value:"templates",children:e.jsx(DNs,{brokerageId:l})}),e.jsx($s,{value:"activity",children:e.jsx(ONs,{brokerageId:l})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(La,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function GNs(){const[t,s]=C.useState(""),{data:r,isLoading:n}=wt({queryKey:["admin-brokerage-content-activity"],queryFn:async()=>{const{data:i}=await G.from("brokerages").select("id, name");if(!i)return[];const{data:c}=await G.from("brokerage_content").select("id, brokerage_id, content_type, created_at"),{data:u}=await G.from("brokerage_content_categories").select("id, brokerage_id"),p=c||[],f=u||[],y=i.map(_=>{const b=p.filter(N=>N.brokerage_id===_.id),w=f.filter(N=>N.brokerage_id===_.id),j=b.length>0?b.reduce((N,S)=>S.created_at>N?S.created_at:N,b[0].created_at):null;return{brokerage_id:_.id,brokerage_name:_.name,total_items:b.length,videos:b.filter(N=>N.content_type==="video").length,pdfs:b.filter(N=>N.content_type==="pdf").length,links:b.filter(N=>N.content_type==="link"||N.content_type==="canva_link").length,events:b.filter(N=>N.content_type==="event").length,graphics:b.filter(N=>N.content_type==="graphic").length,latest_item_date:j,categories:w.length}});return y.sort((_,b)=>b.total_items-_.total_items),y}}),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(Es,{title:"Brokerage Content Activity",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ju,{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(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Active Brokerages"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:l}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with content uploaded"})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Content Items"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"across all brokerages"})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsx(Ot,{className:"text-sm font-medium text-muted-foreground",children:"Total Brokerages"})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"text-2xl font-bold",children:a.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"registered"})]})]})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search brokerages...",value:t,onChange:i=>s(i.target.value),className:"pl-9"})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Brokerage"}),e.jsx(bt,{className:"text-center",children:"Total"}),e.jsx(bt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Nn,{className:"h-3 w-3"})," Videos"]})}),e.jsx(bt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(In,{className:"h-3 w-3"})," PDFs"]})}),e.jsx(bt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(sl,{className:"h-3 w-3"})," Links"]})}),e.jsx(bt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Md,{className:"h-3 w-3"})," Events"]})}),e.jsx(bt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(cl,{className:"h-3 w-3"})," Graphics"]})}),e.jsx(bt,{className:"text-center",children:"Categories"}),e.jsx(bt,{children:"Last Upload"})]})}),e.jsx(Pn,{children:n?e.jsx(ks,{children:e.jsx(dt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(ks,{children:e.jsx(dt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(ks,{className:i.total_items===0?"opacity-50":"",children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(La,{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(nt,{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:ys(new Date(i.latest_item_date),"MMM d, yyyy")}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},i.brokerage_id))})]})})})]})})}function KNs(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 ZNs=(()=>{let t=0;const s=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${s()}${t}`)})();function Xb(t){const s=[];for(let r=0,n=t.length;rHp||t.height>Hp)&&(t.width>Hp&&t.height>Hp?t.width>t.height?(t.height*=Hp/t.width,t.width=Hp):(t.width*=Hp/t.height,t.height=Hp):t.width>Hp?(t.height*=Hp/t.width,t.width=Hp):(t.width*=Hp/t.height,t.height=Hp))}function Kce(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 e4s(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(s=>`data:image/svg+xml;charset=utf-8,${s}`)}async function t4s(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),e4s(a)}const kp=(t,s)=>{if(t instanceof s)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===s.name||kp(r,s)};function s4s(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function r4s(t,s){return mlt(s).map(r=>{const n=t.getPropertyValue(r),a=t.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function n4s(t,s,r,n){const a=`.${t}:${s}`,o=r.cssText?s4s(r):r4s(r,n);return document.createTextNode(`${a}{${o}}`)}function Q7e(t,s,r,n){const a=window.getComputedStyle(t,r),o=a.getPropertyValue("content");if(o===""||o==="none")return;const l=ZNs();try{s.className=`${s.className} ${l}`}catch{return}const i=document.createElement("style");i.appendChild(n4s(l,r,a,n)),s.appendChild(i)}function a4s(t,s,r){Q7e(t,s,":before",r),Q7e(t,s,":after",r)}const J7e="application/font-woff",eze="image/jpeg",i4s={woff:J7e,woff2:J7e,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 o4s(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function qSe(t){const s=o4s(t).toLowerCase();return i4s[s]||""}function l4s(t){return t.split(/,/)[1]}function Jbe(t){return t.search(/^(data:)/)!==-1}function c4s(t,s){return`data:${s};base64,${t}`}async function flt(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 yye={};function d4s(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 USe(t,s,r){const n=d4s(t,s,r.includeQueryParams);if(yye[n]!=null)return yye[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await flt(t,r.fetchRequestInit,({res:l,result:i})=>(s||(s=l.headers.get("Content-Type")||""),l4s(i)));a=c4s(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 yye[n]=a,a}async function u4s(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):Kce(s)}async function h4s(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 Kce(i)}const r=t.poster,n=qSe(r),a=await USe(r,n,s);return Kce(a)}async function m4s(t,s){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await ume(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function p4s(t,s){return kp(t,HTMLCanvasElement)?u4s(t):kp(t,HTMLVideoElement)?h4s(t,s):kp(t,HTMLIFrameElement)?m4s(t,s):t.cloneNode(glt(t))}const f4s=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",glt=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function g4s(t,s,r){var n,a;if(glt(s))return s;let o=[];return f4s(t)&&t.assignedNodes?o=Xb(t.assignedNodes()):kp(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?o=Xb(t.contentDocument.body.childNodes):o=Xb(((a=t.shadowRoot)!==null&&a!==void 0?a:t).childNodes),o.length===0||kp(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>ume(i,r)).then(c=>{c&&s.appendChild(c)}),Promise.resolve()),s}function x4s(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):mlt(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`),kp(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 y4s(t,s){kp(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),kp(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function v4s(t,s){if(kp(t,HTMLSelectElement)){const r=s,n=Array.from(r.children).find(a=>t.value===a.getAttribute("value"));n&&n.setAttribute("selected","")}}function _4s(t,s,r){return kp(s,Element)&&(x4s(t,s,r),a4s(t,s,r),y4s(t,s),v4s(t,s)),s}async function b4s(t,s){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let o=0;op4s(n,s)).then(n=>g4s(t,n,s)).then(n=>_4s(t,n,s)).then(n=>b4s(n,s))}const xlt=/url\((['"]?)([^'"]+?)\1\)/g,w4s=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,j4s=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function k4s(t){const s=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${s})(['"]?\\))`,"g")}function N4s(t){const s=[];return t.replace(xlt,(r,n,a)=>(s.push(a),r)),s.filter(r=>!Jbe(r))}async function S4s(t,s,r,n,a){try{const o=r?KNs(s,r):s,l=qSe(s);let i;return a||(i=await USe(o,l,n)),t.replace(k4s(s),`$1${i}$3`)}catch{}return t}function C4s(t,{preferredFontFormat:s}){return s?t.replace(j4s,r=>{for(;;){const[n,,a]=w4s.exec(r)||[];if(!a)return"";if(a===s)return`src: ${n};`}}):t}function ylt(t){return t.search(xlt)!==-1}async function vlt(t,s,r){if(!ylt(t))return t;const n=C4s(t,r);return N4s(n).reduce((o,l)=>o.then(i=>S4s(i,l,s,r)),Promise.resolve(n))}async function m5(t,s,r){var n;const a=(n=s.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(a){const o=await vlt(a,null,r);return s.style.setProperty(t,o,s.style.getPropertyPriority(t)),!0}return!1}async function M4s(t,s){await m5("background",t,s)||await m5("background-image",t,s),await m5("mask",t,s)||await m5("-webkit-mask",t,s)||await m5("mask-image",t,s)||await m5("-webkit-mask-image",t,s)}async function T4s(t,s){const r=kp(t,HTMLImageElement);if(!(r&&!Jbe(t.src))&&!(kp(t,SVGImageElement)&&!Jbe(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await USe(n,qSe(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 A4s(t,s){const n=Xb(t.childNodes).map(a=>_lt(a,s));await Promise.all(n).then(()=>t)}async function _lt(t,s){kp(t,Element)&&(await M4s(t,s),await T4s(t,s),await A4s(t,s))}function E4s(t,s){const{style:r}=t;s.backgroundColor&&(r.backgroundColor=s.backgroundColor),s.width&&(r.width=`${s.width}px`),s.height&&(r.height=`${s.height}px`);const n=s.style;return n!=null&&Object.keys(n).forEach(a=>{r[a]=n[a]}),t}const tze={};async function sze(t){let s=tze[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},tze[t]=s,s}async function rze(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),flt(i,s.fetchRequestInit,({result:c})=>(r=r.replace(l,`url(${c})`),[l,c]))});return Promise.all(o).then(()=>r)}function nze(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 P4s(t,s){const r=[],n=[];return t.forEach(a=>{if("cssRules"in a)try{Xb(a.cssRules||[]).forEach((o,l)=>{if(o.type===CSSRule.IMPORT_RULE){let i=l+1;const c=o.href,u=sze(c).then(p=>rze(p,s)).then(p=>nze(p).forEach(f=>{try{a.insertRule(f,f.startsWith("@import")?i+=1:a.cssRules.length)}catch(y){console.error("Error inserting rule from remote css",{rule:f,error:y})}})).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(sze(a.href).then(i=>rze(i,s)).then(i=>nze(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{Xb(a.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${a.href}`,o)}}),r))}function I4s(t){return t.filter(s=>s.type===CSSRule.FONT_FACE_RULE).filter(s=>ylt(s.style.getPropertyValue("src")))}async function L4s(t,s){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=Xb(t.ownerDocument.styleSheets),n=await P4s(r,s);return I4s(n)}function blt(t){return t.trim().replace(/["']/g,"")}function D4s(t){const s=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(o=>{s.add(blt(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(t),s}async function O4s(t,s){const r=await L4s(t,s),n=D4s(t);return(await Promise.all(r.filter(o=>n.has(blt(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return vlt(o.cssText,l,s)}))).join(` `)}async function R4s(t,s){const r=s.fontEmbedCSS!=null?s.fontEmbedCSS:s.skipFonts?null:await O4s(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 F4s(t,s={}){const{width:r,height:n}=plt(t,s),a=await ume(t,s,!0);return await R4s(a,s),await _lt(a,s),E4s(a,s),await t4s(a,r,n)}async function z4s(t,s={}){const{width:r,height:n}=plt(t,s),a=await F4s(t,s),o=await Kce(a),l=document.createElement("canvas"),i=l.getContext("2d"),c=s.pixelRatio||QNs(),u=s.canvasWidth||r,p=s.canvasHeight||n;return l.width=u*c,l.height=p*c,s.skipAutoScale||JNs(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 B4s(t,s={}){return(await z4s(t,s)).toDataURL()}const fA=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),hme={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},Lz={"instagram-square":{width:1080,height:1080},"instagram-story":{width:1080,height:1920},"facebook-post":{width:1200,height:630}},$4s=({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})]})]}),wlt=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=hme[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:fA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.028,color:"#C9A84C",marginBottom:l.w*.01},children:["Sold for ",fA(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($4s,{branding:n,dim:l})]})]})]})});wlt.displayName="LuxuryDarkTemplate";const q4s=({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})]})]}),jlt=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var _;const l=r==="instagram-story"?{w:1080,h:1920}:r==="facebook-post"?{w:1200,h:630}:{w:1080,h:1080},i=400/l.w,c=(_=t.photos)==null?void 0:_[a],u=hme[s],p=r==="instagram-story",f=r==="facebook-post",y=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:y,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:y,marginBottom:l.w*.012},children:fA(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:`${y}10`,border:`2px solid ${y}`,borderRadius:l.w*.01,padding:`${l.w*.01}px ${l.w*.02}px`,fontSize:l.w*.022,fontWeight:700,color:y,display:"inline-block",marginBottom:l.w*.015},children:"SAT & SUN • 1–4 PM"}),e.jsx(q4s,{branding:n,dim:l,accentColor:y})]})]})});jlt.displayName="ModernCleanTemplate";const U4s=({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})]})]}),klt=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var y;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=(y=t.photos)==null?void 0:y[a],u=hme[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:fA(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(U4s,{branding:n,dim:l})]})]})]})});klt.displayName="BoldColorfulTemplate";const V4s=({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})]})]}),Nlt=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=hme[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:fA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.02,color:"#8B7355",marginBottom:l.w*.01},children:["Sold: ",fA(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(V4s,{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"}})]})]})})});Nlt.displayName="EditorialTemplate";const H4s=[{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:"📉"}],aze=[{value:"instagram-square",label:"Instagram Post",dimensions:"1080×1080",icon:e.jsx(yu,{className:"h-4 w-4"})},{value:"instagram-story",label:"Instagram Story",dimensions:"1080×1920",icon:e.jsx(yu,{className:"h-4 w-4"})},{value:"facebook-post",label:"Facebook Post",dimensions:"1200×630",icon:e.jsx(xu,{className:"h-4 w-4"})}],W4s=[{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:"📰"}],ize=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),oze={"luxury-dark":wlt,"modern-clean":jlt,"bold-colorful":klt,editorial:Nlt};function G4s(){const[t,s]=C.useState(""),[r,n]=C.useState("address"),[a,o]=C.useState(!1),[l,i]=C.useState([]),[c,u]=C.useState(null),[p,f]=C.useState(0),[y,_]=C.useState("just-listed"),[b,w]=C.useState(["instagram-square"]),[j,N]=C.useState("luxury-dark"),[S,T]=C.useState(!1),[I,L]=C.useState(""),[R,$]=C.useState(""),[q,U]=C.useState(""),[V,X]=C.useState(!1),[se,ee]=C.useState(!1),[Q,de]=C.useState([]),[re,ne]=C.useState("search"),le=C.useRef({});C.useEffect(()=>{(async()=>{const{data:{user:Re}}=await G.auth.getUser();if(!Re)return;const{data:Te}=await G.from("profiles").select("name, avatar_url, brokerages(name)").eq("id",Re.id).single();if(Te){L(Te.name||""),U(Te.avatar_url||"");const qe=Te.brokerages;$((qe==null?void 0:qe.name)||"")}})()},[]);const he=async()=>{var Ae;if(t.trim()){o(!0),i([]);try{const{data:Re,error:Te}=await G.functions.invoke("repliers-mls-search",{body:{searchType:r,query:t.trim()}});if(Te)throw Te;if(Re.error)throw new Error(Re.error);i(Re.listings||[]),((Ae=Re.listings)==null?void 0:Ae.length)===0&&me.info("No listings found. Try a different search.")}catch(Re){me.error(Re.message||"Search failed")}finally{o(!1)}}},we=Ae=>{var Re;u(Ae),f(0),ne("customize"),Ae.soldDate||(Re=Ae.status)!=null&&Re.toLowerCase().includes("sold")?_("just-sold"):_("just-listed")},ye=Ae=>{w(Re=>Re.includes(Ae)?Re.filter(Te=>Te!==Ae):[...Re,Ae])},je=C.useCallback(async()=>{if(!(!c||b.length===0)){X(!0),de([]),ne("generate");try{await new Promise(Re=>setTimeout(Re,500));const Ae=[];for(const Re of b){const Te=`${j}-${Re}`,qe=le.current[Te];if(!qe)continue;const ct=Lz[Re],De=await B4s(qe,{width:ct.width,height:ct.height,pixelRatio:1,cacheBust:!0,style:{transform:"none",transformOrigin:"top left"}});Ae.push({format:Re,imageUrl:De})}de(Ae),me.success(`Generated ${Ae.length} social post${Ae.length>1?"s":""}!`)}catch(Ae){me.error(Ae.message||"Generation failed")}finally{X(!1)}}},[c,b,j,p,S,I,R,q,y]),ke=async()=>{if(!(!c||b.length===0)){X(!0),de([]),ne("generate");try{const Ae={...c,photos:c.photos.length>0?[c.photos[p]]:[]},Re=[];for(const Te of b){const{data:qe,error:ct}=await G.functions.invoke("generate-listing-social-post",{body:{listing:Ae,postType:y,format:Te,branding:S?{enabled:!0,agentName:I,brokerage:R}:{enabled:!1}}});if(ct)throw ct;if(qe.error)throw new Error(qe.error);Re.push({format:Te,imageUrl:qe.imageUrl})}de(Re),me.success(`Generated ${Re.length} AI post${Re.length>1?"s":""}!`)}catch(Ae){me.error(Ae.message||"AI generation failed")}finally{X(!1)}}},We=()=>se?ke():je(),be=(Ae,Re)=>{var qe;const Te=document.createElement("a");Te.href=Ae,Te.download=`${((qe=c==null?void 0:c.address)==null?void 0:qe.replace(/\s+/g,"-"))||"listing"}-${y}-${Re}.png`,document.body.appendChild(Te),Te.click(),document.body.removeChild(Te)},Me=c?{listing:c,postType:y,format:"instagram-square",branding:S?{enabled:!0,agentName:I,brokerage:R,agentPhotoUrl:q||void 0}:{enabled:!1},selectedPhotoIndex:p}:null;return e.jsx(Es,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(Ju,{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:()=>ne("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(xn,{className:"h-3.5 w-3.5"})," 1. Find Listing"]}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("button",{onClick:()=>c&&ne("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(hn,{className:"h-3.5 w-3.5"})," 2. Customize"]}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full ${re==="generate"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground/50"}`,children:[e.jsx(cl,{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(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(xn,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(NYe,{})]}),e.jsx(fr,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx(Aa,{value:r,onValueChange:Ae=>n(Ae),children:e.jsxs(ja,{children:[e.jsxs(js,{value:"address",children:[e.jsx(Ui,{className:"h-4 w-4 mr-1.5"})," Address"]}),e.jsxs(js,{value:"mls",children:[e.jsx(Tm,{className:"h-4 w-4 mr-1.5"})," MLS #"]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Fe,{value:t,onChange:Ae=>s(Ae.target.value),placeholder:r==="mls"?"Enter MLS number...":"Enter property address...",className:"flex-1",onKeyDown:Ae=>Ae.key==="Enter"&&he()}),e.jsxs(K,{onClick:he,disabled:a||!t.trim(),children:[a?e.jsx(Ss,{className:"h-4 w-4 animate-spin"}):e.jsx(xn,{className:"h-4 w-4"})," Search"]})]})]})]}),l.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-sm font-medium text-muted-foreground",children:[l.length," listing",l.length!==1?"s":""," found"]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:l.map((Ae,Re)=>{var Te;return e.jsx(Ee,{className:"cursor-pointer hover:border-primary/50 hover:shadow-md transition-all group",onClick:()=>we(Ae),children:e.jsx(Oe,{className:"p-0",children:e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"w-32 h-28 flex-shrink-0 bg-muted rounded-l-lg overflow-hidden",children:(Te=Ae.photos)!=null&&Te[0]?e.jsx("img",{src:Ae.photos[0],alt:Ae.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(Rn,{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:ize(Ae.price)}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:Ae.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Ae.city,", ",Ae.state," ",Ae.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[Ae.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(AI,{className:"h-3 w-3"})," ",Ae.bedrooms]}),Ae.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(n0,{className:"h-3 w-3"})," ",Ae.bathrooms]}),Ae.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(WI,{className:"h-3 w-3"})," ",Ae.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(nt,{variant:"outline",className:"text-[10px]",children:Ae.mlsNumber}),e.jsx(nt,{variant:"outline",className:"text-[10px]",children:Ae.status})]})]})]})})},Ae.mlsNumber||Re)})})]})]}),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(It,{className:"pb-3",children:e.jsx(Ot,{className:"text-base",children:"Selected Listing"})}),e.jsxs(Oe,{className:"space-y-3",children:[c.photos.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"aspect-[4/3] rounded-lg overflow-hidden bg-muted",children:e.jsx("img",{src:c.photos[p],alt:"Listing photo",className:"w-full h-full object-cover"})}),c.photos.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-7 w-7",onClick:()=>f(Ae=>Math.max(0,Ae-1)),disabled:p===0,children:e.jsx(Xl,{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(Ae=>Math.min(c.photos.length-1,Ae+1)),disabled:p===c.photos.length-1,children:e.jsx(Xa,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg",children:ize(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:()=>{ne("search"),u(null)},children:[e.jsx(a1,{className:"h-3.5 w-3.5 mr-1.5"})," Choose Different Listing"]})]})]}),e.jsxs(Ee,{className:"lg:col-span-2",children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(fr,{children:"Choose template, post type, format, and branding"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ql,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:se?"AI Custom Generation":"Template-Based (Free)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:se?"Uses AI credits for unique designs":"Instant, no credits used"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Use AI"}),e.jsx(Br,{checked:se,onCheckedChange:ee}),se&&e.jsx(Iv,{className:"h-4 w-4 text-purple-500"})]})]}),!se&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ql,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:W4s.map(Ae=>e.jsxs("button",{onClick:()=>N(Ae.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${j===Ae.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-2xl",children:Ae.preview}),e.jsx("span",{className:"text-sm font-medium",children:Ae.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:Ae.description})]},Ae.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Post Type"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:H4s.map(Ae=>e.jsxs("button",{onClick:()=>_(Ae.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm font-medium ${y===Ae.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-lg",children:Ae.icon})," ",Ae.label]},Ae.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Output Formats"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:aze.map(Ae=>e.jsxs("button",{onClick:()=>ye(Ae.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm ${b.includes(Ae.value)?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[Ae.icon,e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:Ae.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:Ae.dimensions})]})]},Ae.value))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(_e,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ro,{className:"h-4 w-4"})," Agent Branding"]}),e.jsx(Br,{checked:S,onCheckedChange:T})]}),S&&e.jsxs("div",{className:"space-y-3 pl-6 border-l-2 border-primary/20",children:[q&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:q,alt:"Agent",className:"w-12 h-12 rounded-full object-cover border-2 border-primary/30"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Profile photo will appear on the post"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Agent Name"}),e.jsx(Fe,{value:I,onChange:Ae=>L(Ae.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Brokerage (optional)"}),e.jsx(Fe,{value:R,onChange:Ae=>$(Ae.target.value),placeholder:"XYZ Realty"})]})]})]})]}),!se&&Me&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Preview"}),e.jsx("div",{className:"bg-muted/30 rounded-lg p-4 flex justify-center overflow-hidden",children:e.jsx("div",{style:{width:400,height:400*(Lz[b[0]||"instagram-square"].height/Lz[b[0]||"instagram-square"].width)},children:(()=>{const Ae=oze[j],Re=b[0]||"instagram-square";return e.jsx(Ae,{...Me,format:Re})})()})})]}),e.jsx(K,{onClick:We,disabled:b.length===0||V,size:"lg",className:"w-full gap-2",children:V?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-5 w-5 animate-spin"})," Generating ",b.length," post",b.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[se?e.jsx(Iv,{className:"h-5 w-5"}):e.jsx(hn,{className:"h-5 w-5"}),"Generate ",b.length," Social Post",b.length>1?"s":"",se&&e.jsx(nt,{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(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(Ss,{className:"h-12 w-12 animate-spin text-primary mb-4"}),e.jsx("p",{className:"text-lg font-medium",children:"Generating your social posts..."}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:se?"AI is creating your unique designs":"Rendering templates to high-res images"})]})}),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:()=>ne("customize"),children:[e.jsx(a1,{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((Ae,Re)=>{const Te=aze.find(qe=>qe.value===Ae.format);return e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 p-1",children:e.jsx("img",{src:Ae.imageUrl,alt:`${Ae.format} social post`,className:"w-full rounded"})}),e.jsxs(Oe,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[Te==null?void 0:Te.icon,e.jsx("span",{className:"text-sm font-medium",children:Te==null?void 0:Te.label})]}),e.jsx(nt,{variant:"outline",className:"text-[10px]",children:Te==null?void 0:Te.dimensions})]}),e.jsxs(K,{size:"sm",className:"w-full gap-1.5",onClick:()=>be(Ae.imageUrl,Ae.format),children:[e.jsx(ki,{className:"h-3.5 w-3.5"})," Download"]})]})]},Re)})})]})]}),re==="generate"&&!se&&c&&Me&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:b.map(Ae=>{const Re=oze[j],Te=Lz[Ae];return e.jsx("div",{style:{width:Te.width,height:Te.height},children:e.jsx(Re,{ref:qe=>{le.current[`${j}-${Ae}`]=qe},...Me,format:Ae})},`${j}-${Ae}`)})})]})})}function K4s(){return wt({queryKey:["lms-courses-admin"],queryFn:async()=>{const{data:t,error:s}=await G.from("lms_courses").select("*, modules:lms_modules(count), access:lms_course_access(*)").order("sort_order");if(s)throw s;return t}})}function Z4s(t){return wt({queryKey:["lms-course-admin",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("lms_courses").select("*, modules:lms_modules(*, resources:lms_module_resources(*)), access:lms_course_access(*)").eq("id",t).single();if(r)throw r;return s!=null&&s.modules&&(s.modules.sort((n,a)=>n.sort_order-a.sort_order),s.modules.forEach(n=>{n.resources&&n.resources.sort((a,o)=>a.sort_order-o.sort_order)})),s},enabled:!!t})}function Y4s(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("lms_courses").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function Slt(){const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("lms_courses").update({...r,updated_at:new Date().toISOString()}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-courses-admin"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function X4s(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("lms_courses").delete().eq("id",s);if(r)throw r},onSuccess:()=>t.invalidateQueries({queryKey:["lms-courses"]})})}function Q4s(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("lms_modules").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function J4s(){const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("lms_modules").update({...r,updated_at:new Date().toISOString()}).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function eSs(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("lms_modules").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function tSs(){const t=ss();return Dt({mutationFn:async s=>{const{data:r,error:n}=await G.from("lms_module_resources").insert(s).select().single();if(n)throw n;return r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function sSs(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("lms_module_resources").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-course"]}),t.invalidateQueries({queryKey:["lms-course-admin"]})}})}function rSs(){const t=ss();return Dt({mutationFn:async({courseId:s,accessRules:r})=>{const{error:n}=await G.from("lms_course_access").delete().eq("course_id",s);if(n)throw n;if(r.length>0){const a=r.map(l=>({...l,course_id:s})),{error:o}=await G.from("lms_course_access").insert(a);if(o)throw o}},onSuccess:()=>{t.invalidateQueries({queryKey:["lms-courses"]}),t.invalidateQueries({queryKey:["lms-course"]})}})}function nSs(){return wt({queryKey:["lms-courses-agent"],queryFn:async()=>{const{data:t,error:s}=await G.from("lms_courses").select("*, modules:lms_modules(id)").eq("is_published",!0).order("sort_order");if(s)throw s;return t}})}function aSs(t){return wt({queryKey:["lms-course-agent",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("lms_courses").select("*, modules:lms_modules(*, resources:lms_module_resources(*))").eq("id",t).single();if(r)throw r;return s!=null&&s.modules&&(s.modules.sort((n,a)=>n.sort_order-a.sort_order),s.modules.forEach(n=>{n.resources&&n.resources.sort((a,o)=>a.sort_order-o.sort_order)})),s},enabled:!!t})}function Clt(t){return wt({queryKey:["lms-progress",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("lms_progress").select("*").eq("course_id",t);if(r)throw r;return s},enabled:!!t})}function iSs(){const t=ss();return Dt({mutationFn:async({courseId:s,moduleId:r,userId:n})=>{const{data:a,error:o}=await G.from("lms_progress").upsert({user_id:n,course_id:s,module_id:r,completed:!0,completed_at:new Date().toISOString()},{onConflict:"user_id,module_id"}).select().single();if(o)throw o;return a},onSuccess:()=>t.invalidateQueries({queryKey:["lms-progress"]})})}function oSs(){const{user:t}=Ws(),s=Pr(),{data:r,isLoading:n}=K4s(),a=Y4s(),o=Slt(),l=X4s(),[i,c]=C.useState(!1),[u,p]=C.useState(""),[f,y]=C.useState(""),[_,b]=C.useState(!0),w=async()=>{if(!(!u.trim()||!t))try{const S=await a.mutateAsync({title:u.trim(),description:f.trim()||void 0,is_sequential:_,created_by:t.id});me.success("Course created"),c(!1),p(""),y(""),b(!0),s(`/admin/lms/${S.id}`)}catch{me.error("Failed to create course")}},j=async S=>{try{await o.mutateAsync({id:S.id,is_published:!S.is_published}),me.success(S.is_published?"Course unpublished":"Course published")}catch{me.error("Failed to update course")}},N=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(Es,{title:"LevelUp U - Admin",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(zh,{className:"h-7 w-7 text-primary"}),"LevelUp U — Course Manager"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Create and manage training courses for your agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>s("/admin/lms/stats"),children:[e.jsx(xl,{className:"h-4 w-4 mr-2"}),"Analytics"]}),e.jsxs(K,{onClick:()=>c(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"New Course"]})]})]}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:[1,2,3].map(S=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(It,{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 R,$;const T=(($=(R=S.modules)==null?void 0:R[0])==null?void 0:$.count)??0,I=S.access||[],L=I.length===0?"No access set":I.some(q=>q.access_type==="all")?"All agents":`${I.length} rule(s)`;return e.jsxs(Ee,{className:"group hover:shadow-md transition-all hover:border-primary/50 cursor-pointer",onClick:()=>s(`/admin/lms/${S.id}`),children:[e.jsx(It,{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(Ot,{className:"text-base truncate",children:S.title}),S.description&&e.jsx(fr,{className:"mt-1 line-clamp-2",children:S.description})]}),e.jsx(nt,{variant:S.is_published?"default":"secondary",className:"ml-2 shrink-0",children:S.is_published?"Published":"Draft"})]})}),e.jsxs(Oe,{className:"pt-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gh,{className:"h-3.5 w-3.5"}),T," module",T!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[S.is_sequential?e.jsx(Jv,{className:"h-3.5 w-3.5"}):e.jsx(G4,{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(mr,{className:"h-3.5 w-3.5"}),L]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-3 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsxs(K,{size:"sm",variant:"ghost",onClick:q=>{q.stopPropagation(),j(S)},children:[S.is_published?e.jsx(xp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(va,{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:q=>{q.stopPropagation(),N(S.id)},children:e.jsx(jr,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx(Ki,{className:"h-4 w-4 text-muted-foreground"})]})]})]},S.id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(gh,{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(Zs,{className:"h-4 w-4 mr-2"}),"Create Course"]})]})})]}),e.jsx(_s,{open:i,onOpenChange:c,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Create New Course"}),e.jsx(Zr,{children:"Set up a new training course for your agents"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Course Title"}),e.jsx(Fe,{value:u,onChange:S=>p(S.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Description"}),e.jsx(Ar,{value:f,onChange:S=>y(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(Br,{checked:_,onCheckedChange:b})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{onClick:w,disabled:!u.trim()||a.isPending,children:a.isPending?"Creating...":"Create Course"})]})]})})]})}function lSs(){const{courseId:t}=Po(),s=Pr(),{data:r,isLoading:n}=Z4s(t),a=Slt(),o=Q4s(),l=J4s(),i=eSs(),c=tSs(),u=sSs(),p=rSs(),{data:f}=wt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:Ue}=await G.from("brokerages").select("id, name").order("name");return Ue||[]}}),[y,_]=C.useState(null),[b,w]=C.useState(!1),[j,N]=C.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[S,T]=C.useState(null),[I,L]=C.useState({title:"",resource_type:"link",url:""}),[R,$]=C.useState(new Set),[q,U]=C.useState(null),[V,X]=C.useState(0),[se,ee]=C.useState(!1),Q=C.useRef(null),de=C.useRef(null),[re,ne]=C.useState(!1),[le,he]=C.useState(""),[we,ye]=C.useState(""),[je,ke]=C.useState(""),[We,be]=C.useState(!1);if(n)return e.jsx(Es,{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(Es,{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(di,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const Me=r.modules||[],Ae=r.access||[],Re=Ae.some(Ue=>Ue.access_type==="all"),Te=Ae.filter(Ue=>Ue.access_type==="brokerage").map(Ue=>Ue.brokerage_id),qe=(f||[]).filter(Ue=>Ue.name.toLowerCase().includes(le.toLowerCase())),ct=Ue=>{const Ke=new Set(R);Ke.has(Ue)?Ke.delete(Ue):Ke.add(Ue),$(Ke)},De=async()=>{if(!q)return null;ee(!0),X(0);try{const{data:Ue,error:Ke}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:q.name}});if(Ke)throw new Error(Ke.message);const{videoId:Xe,libraryId:He}=Ue,{data:Ye,error:tt}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Xe,libraryId:He}});if(tt)throw new Error(tt.message);const Et=new XMLHttpRequest;return await new Promise((qt,ms)=>{Et.upload.onprogress=Xt=>{Xt.lengthComputable&&X(Math.round(Xt.loaded/Xt.total*100))},Et.onload=()=>Et.status>=200&&Et.status<300?qt():ms(new Error(`Upload failed: ${Et.status}`)),Et.onerror=()=>ms(new Error("Upload failed")),Et.open("PUT",Ye.uploadUrl),Et.setRequestHeader("AccessKey",Ye.apiKey),Et.send(q)}),`https://iframe.mediadelivery.net/embed/${He}/${Xe}`}catch(Ue){return console.error("Bunny upload error:",Ue),me.error("Video upload failed"),null}finally{ee(!1),X(0)}},Rt=async()=>{if(j.title.trim())try{let Ue=j.video_url.trim()||void 0;if(q){const Ke=await De();if(!Ke)return;Ue=Ke}await o.mutateAsync({course_id:r.id,title:j.title.trim(),description:j.description.trim()||void 0,video_url:Ue,text_content:j.text_content.trim()||void 0,duration_minutes:j.duration_minutes?parseInt(j.duration_minutes):void 0,sort_order:Me.length}),me.success("Module added"),w(!1),N({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),U(null)}catch{me.error("Failed to add module")}},pe=async()=>{if(y)try{let Ue=j.video_url.trim()||null;if(q){const Ke=await De();if(!Ke)return;Ue=Ke}await l.mutateAsync({id:y.id,title:j.title.trim(),description:j.description.trim()||null,video_url:Ue,text_content:j.text_content.trim()||null,duration_minutes:j.duration_minutes?parseInt(j.duration_minutes):null}),me.success("Module updated"),_(null),U(null)}catch{me.error("Failed to update")}},Je=async Ue=>{if(confirm("Delete this module?"))try{await i.mutateAsync(Ue),me.success("Module deleted")}catch{me.error("Failed to delete")}},lt=async Ue=>{if(I.title.trim())try{await c.mutateAsync({module_id:Ue,title:I.title.trim(),resource_type:I.resource_type,url:I.url.trim()||void 0}),me.success("Resource added"),T(null),L({title:"",resource_type:"link",url:""})}catch{me.error("Failed to add resource")}},rt=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")}},Se=async Ue=>{const Ke=Ae.filter(tt=>tt.access_type==="brokerage").map(tt=>tt.brokerage_id),Xe=Ke.includes(Ue);let He;Xe?He=Ke.filter(tt=>tt!==Ue):He=[...Ke,Ue];const Ye=He.map(tt=>({access_type:"brokerage",brokerage_id:tt}));try{await p.mutateAsync({courseId:r.id,accessRules:Ye}),me.success(Xe?"Brokerage removed":"Brokerage added")}catch{me.error("Failed to update access")}},it=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[]}),me.success("Access cleared")}catch{me.error("Failed")}},$e=async(Ue,Ke)=>{const Xe=Ke==="up"?Ue-1:Ue+1;if(!(Xe<0||Xe>=Me.length))try{await Promise.all([l.mutateAsync({id:Me[Ue].id,sort_order:Xe}),l.mutateAsync({id:Me[Xe].id,sort_order:Ue})])}catch{me.error("Failed to reorder")}},ot=async()=>{try{await a.mutateAsync({id:r.id,title:we,description:je||null}),me.success("Course updated"),be(!1)}catch{me.error("Failed to update")}};return e.jsxs(Es,{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(di,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:r.title}),e.jsx(nt,{variant:r.is_published?"default":"secondary",children:r.is_published?"Published":"Draft"})]}),r.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:r.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[r.is_sequential?e.jsx(Jv,{className:"h-3.5 w-3.5"}):e.jsx(G4,{className:"h-3.5 w-3.5"}),r.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{children:[Me.length," module",Me.length!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{ye(r.title),ke(r.description||""),be(!0)},children:[e.jsx($a,{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(xp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(va,{className:"h-3.5 w-3.5 mr-1"}),r.is_published?"Unpublish":"Publish"]})]})]}),e.jsxs(Aa,{defaultValue:"modules",className:"w-full",children:[e.jsxs(ja,{children:[e.jsx(js,{value:"modules",children:"Modules"}),e.jsx(js,{value:"access",children:"Access & Permissions"}),e.jsx(js,{value:"settings",children:"Settings"})]}),e.jsxs($s,{value:"modules",className:"mt-6 space-y-4",children:[Me.map((Ue,Ke)=>e.jsxs(Ee,{className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>ct(Ue.id),children:[e.jsx("span",{className:"flex items-center gap-1 text-muted-foreground",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("button",{onClick:Xe=>{Xe.stopPropagation(),$e(Ke,"up")},disabled:Ke===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(Hx,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:Xe=>{Xe.stopPropagation(),$e(Ke,"down")},disabled:Ke===Me.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(tl,{className:"h-3.5 w-3.5"})})]})}),e.jsx(nt,{variant:"outline",className:"shrink-0 font-mono text-xs",children:Ke+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:Ue.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[Ue.video_url&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Nn,{className:"h-3 w-3"})," Video"]}),Ue.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(In,{className:"h-3 w-3"})," Text"]}),Ue.duration_minutes&&e.jsxs("span",{children:[Ue.duration_minutes," min"]}),Ue.resources&&Ue.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(sl,{className:"h-3 w-3"})," ",Ue.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:Xe=>{var He;Xe.stopPropagation(),_(Ue),N({title:Ue.title,description:Ue.description||"",video_url:Ue.video_url||"",text_content:Ue.text_content||"",duration_minutes:((He=Ue.duration_minutes)==null?void 0:He.toString())||""})},children:e.jsx($a,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:Xe=>{Xe.stopPropagation(),Je(Ue.id)},children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]}),R.has(Ue.id)&&e.jsxs("div",{className:"border-t bg-muted/30 p-4 space-y-3",children:[Ue.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:Ue.description}),Ue.video_url&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Video: "}),e.jsx("a",{href:Ue.video_url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:Ue.video_url})]}),Ue.text_content&&e.jsx("div",{className:"text-sm bg-background rounded-md p-3 border max-h-40 overflow-auto whitespace-pre-wrap",children:Ue.text_content}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Resources"}),e.jsxs(K,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>{T(Ue.id),L({title:"",resource_type:"link",url:""})},children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add Resource"]})]}),Ue.resources&&Ue.resources.length>0?e.jsx("div",{className:"space-y-1",children:Ue.resources.map(Xe=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-background rounded p-2 border",children:[e.jsx(nt,{variant:"outline",className:"text-[10px]",children:Xe.resource_type}),e.jsx("span",{className:"flex-1 truncate",children:Xe.title}),Xe.url&&e.jsx("a",{href:Xe.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(Xe.id),children:e.jsx(Ur,{className:"h-3 w-3"})})]},Xe.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},Ue.id)),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{w(!0),N({title:"",description:"",video_url:"",text_content:"",duration_minutes:""})},children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Add Module"]})]}),e.jsx($s,{value:"access",className:"mt-6 space-y-4",children:e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:At("flex items-center gap-3 p-4 rounded-xl border-2 cursor-pointer transition-all",Re?"border-primary bg-primary/5":"border-muted hover:border-muted-foreground/30"),onClick:rt,children:[e.jsx("div",{className:At("h-10 w-10 rounded-full flex items-center justify-center shrink-0",Re?"bg-primary/15 text-primary":"bg-muted text-muted-foreground"),children:e.jsx(yp,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:"All Brokerages / All Agents"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Every agent on the platform can access this course"})]}),e.jsx(Br,{checked:Re,onCheckedChange:rt})]}),!Re&&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:Te.length===0?"No brokerages selected — agents won't see this course":`${Te.length} brokerage${Te.length!==1?"s":""} selected`})]}),Te.length>0&&e.jsx(K,{size:"sm",variant:"ghost",className:"text-xs text-muted-foreground",onClick:it,children:"Clear all"})]}),e.jsx(Fe,{placeholder:"Search brokerages...",value:le,onChange:Ue=>he(Ue.target.value),className:"h-9"}),e.jsx("div",{className:"border rounded-lg divide-y max-h-[360px] overflow-auto",children:qe.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No brokerages found"}):qe.map(Ue=>{const Ke=Te.includes(Ue.id);return e.jsxs("div",{className:At("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",Ke?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>Se(Ue.id),children:[e.jsx("div",{className:At("h-5 w-5 rounded border-2 flex items-center justify-center shrink-0 transition-colors",Ke?"bg-primary border-primary":"border-muted-foreground/30"),children:Ke&&e.jsx("svg",{className:"h-3 w-3 text-primary-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx(La,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:Ue.name}),Ke&&e.jsx(nt,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},Ue.id)})})]})]})]})}),e.jsxs($s,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Course Thumbnail"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"flex items-start gap-6",children:[r.thumbnail_url?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:r.thumbnail_url,alt:"Course thumbnail",className:"w-48 h-28 object-cover rounded-lg border"}),e.jsx("button",{onClick:()=>a.mutateAsync({id:r.id,thumbnail_url:null}).then(()=>me.success("Thumbnail removed")),className:"absolute -top-2 -right-2 bg-destructive text-destructive-foreground rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"w-48 h-28 rounded-lg border-2 border-dashed border-muted-foreground/25 flex flex-col items-center justify-center text-muted-foreground",children:[e.jsx(Qv,{className:"h-8 w-8 mb-1 opacity-50"}),e.jsx("span",{className:"text-xs",children:"No thumbnail"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a thumbnail image for this course. Recommended: 800×450px (16:9)."}),e.jsx("input",{ref:de,type:"file",accept:"image/*",className:"hidden",onChange:async Ue=>{var Xe;const Ke=(Xe=Ue.target.files)==null?void 0:Xe[0];if(!(!Ke||!r)){ne(!0);try{const He=Ke.name.split(".").pop(),Ye=`${r.id}/thumbnail.${He}`,{error:tt}=await G.storage.from("lms-thumbnails").upload(Ye,Ke,{upsert:!0});if(tt)throw tt;const{data:Et}=G.storage.from("lms-thumbnails").getPublicUrl(Ye),qt=`${Et.publicUrl}?t=${Date.now()}`;await a.mutateAsync({id:r.id,thumbnail_url:qt}),me.success("Thumbnail uploaded")}catch{me.error("Failed to upload thumbnail")}finally{ne(!1),de.current&&(de.current.value="")}}}}),e.jsxs(K,{variant:"outline",size:"sm",disabled:re,onClick:()=>{var Ue;return(Ue=de.current)==null?void 0:Ue.click()},children:[re?e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ni,{className:"h-4 w-4 mr-2"}),re?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Course Settings"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Sequential Learning"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents must complete modules in order before advancing"})]}),e.jsx(Br,{checked:r.is_sequential,onCheckedChange:Ue=>a.mutateAsync({id:r.id,is_sequential:Ue}).then(()=>me.success("Updated"))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this course visible to agents with access"})]}),e.jsx(Br,{checked:r.is_published,onCheckedChange:Ue=>a.mutateAsync({id:r.id,is_published:Ue}).then(()=>me.success("Updated"))})]})]})]})]})]})]}),e.jsx(_s,{open:b||!!y,onOpenChange:Ue=>{Ue||(w(!1),_(null))},children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:y?"Edit Module":"Add Module"}),e.jsx(Zr,{children:"Configure the module content"})]}),e.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-auto",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title"}),e.jsx(Fe,{value:j.title,onChange:Ue=>N(Ke=>({...Ke,title:Ue.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Description"}),e.jsx(Ar,{value:j.description,onChange:Ue=>N(Ke=>({...Ke,description:Ue.target.value})),placeholder:"Brief description",rows:2})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Video"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:At("border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors hover:border-primary/50",q?"border-primary bg-primary/5":"border-muted-foreground/25"),onClick:()=>{var Ue;return(Ue=Q.current)==null?void 0:Ue.click()},children:[e.jsx("input",{ref:Q,type:"file",accept:"video/*",className:"hidden",onChange:Ue=>{var Xe;const Ke=(Xe=Ue.target.files)==null?void 0:Xe[0];Ke&&(U(Ke),N(He=>({...He,video_url:""})))}}),q?e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm",children:[e.jsx(Nn,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-primary",children:q.name}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:Ue=>{Ue.stopPropagation(),U(null)},children:e.jsx(Ur,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"flex flex-col items-center gap-1 text-muted-foreground",children:[e.jsx(ni,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Click to upload a video file"})]})]}),se&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Ss,{className:"h-3.5 w-3.5 animate-spin"}),e.jsxs("span",{children:["Uploading to Bunny.net... ",V,"%"]})]}),e.jsx(Oi,{value:V,className:"h-1.5"})]}),!q&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("div",{className:"flex-1 h-px bg-border"}),e.jsx("span",{children:"or paste a URL"}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx(Fe,{value:j.video_url,onChange:Ue=>N(Ke=>({...Ke,video_url:Ue.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Text Content"}),e.jsx(Ar,{value:j.text_content,onChange:Ue=>N(Ke=>({...Ke,text_content:Ue.target.value})),placeholder:"Additional text content, instructions, notes...",rows:4})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Duration (minutes)"}),e.jsx(Fe,{type:"number",value:j.duration_minutes,onChange:Ue=>N(Ke=>({...Ke,duration_minutes:Ue.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{w(!1),_(null),U(null)},children:"Cancel"}),e.jsxs(K,{onClick:y?pe:Rt,disabled:!j.title.trim()||se,children:[se?e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Wu,{className:"h-4 w-4 mr-2"}),se?"Uploading...":y?"Save Changes":"Add Module"]})]})]})}),e.jsx(_s,{open:!!S,onOpenChange:Ue=>{Ue||T(null)},children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Add Resource"}),e.jsx(Zr,{children:"Add a link, document, or other resource to this module"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title"}),e.jsx(Fe,{value:I.title,onChange:Ue=>L(Ke=>({...Ke,title:Ue.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Type"}),e.jsxs(rr,{value:I.resource_type,onValueChange:Ue=>L(Ke=>({...Ke,resource_type:Ue})),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"link",children:"Link"}),e.jsx(Tt,{value:"pdf",children:"PDF"}),e.jsx(Tt,{value:"template",children:"Template"}),e.jsx(Tt,{value:"worksheet",children:"Worksheet"})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"URL"}),e.jsx(Fe,{value:I.url,onChange:Ue=>L(Ke=>({...Ke,url:Ue.target.value})),placeholder:"https://..."})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>T(null),children:"Cancel"}),e.jsx(K,{onClick:()=>S&<(S),disabled:!I.title.trim(),children:"Add Resource"})]})]})}),e.jsx(_s,{open:We,onOpenChange:be,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Edit Course"}),e.jsx(Zr,{children:"Update the course title and description"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Title"}),e.jsx(Fe,{value:we,onChange:Ue=>ye(Ue.target.value)})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Description"}),e.jsx(Ar,{value:je,onChange:Ue=>ke(Ue.target.value),rows:3})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>be(!1),children:"Cancel"}),e.jsx(K,{onClick:ot,disabled:!we.trim(),children:"Save"})]})]})})]})}function cSs(){return wt({queryKey:["lms-stats-overview"],queryFn:async()=>{const{data:t,error:s}=await G.rpc("get_lms_stats");if(s)throw s;return t}})}function dSs(){return wt({queryKey:["lms-stats-courses"],queryFn:async()=>{const{data:t,error:s}=await G.rpc("get_lms_course_stats");if(s)throw s;return t||[]}})}function uSs(t){return wt({queryKey:["lms-stats-agents",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.rpc("get_lms_agent_progress",{p_course_id:t});if(r)throw r;return s||[]},enabled:!!t})}function hSs(){const t=Pr(),{data:s,isLoading:r}=cSs(),{data:n,isLoading:a}=dSs(),[o,l]=C.useState(null),{data:i,isLoading:c}=uSs(o),[u,p]=C.useState(""),f=n==null?void 0:n.find(b=>b.course_id===o),y=i==null?void 0:i.filter(b=>{var w,j;return!u||((w=b.agent_name)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))||((j=b.email)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))}),_=[{label:"Total Courses",value:(s==null?void 0:s.total_courses)??0,icon:gh,color:"text-primary"},{label:"Published",value:(s==null?void 0:s.published_courses)??0,icon:ha,color:"text-emerald-500"},{label:"Enrolled Agents",value:(s==null?void 0:s.total_enrollments)??0,icon:mr,color:"text-blue-500"},{label:"Modules Completed",value:(s==null?void 0:s.total_completions)??0,icon:mo,color:"text-amber-500"},{label:"Active (30d)",value:(s==null?void 0:s.active_learners)??0,icon:xc,color:"text-violet-500"},{label:"Total Modules",value:(s==null?void 0:s.total_modules)??0,icon:xl,color:"text-rose-500"}];return e.jsx(Es,{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(di,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(zh,{className:"h-7 w-7 text-primary"}),"LevelUp U — Analytics"]}),e.jsx("p",{className:"text-muted-foreground text-sm mt-0.5",children:"Track enrollment, progress, and completion across all courses"})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-6 gap-3",children:_.map(b=>e.jsx(Ee,{className:At("transition-all",r&&"animate-pulse"),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b.icon,{className:At("h-4 w-4",b.color)}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:b.label})]}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:r?"—":b.value})]})},b.label))}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-5 gap-6",children:[e.jsxs("div",{className:"xl:col-span-2 space-y-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(xl,{className:"h-5 w-5 text-primary"}),"Course Breakdown"]}),a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(b=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-16 bg-muted rounded"})})},b))}):n!=null&&n.length?e.jsx("div",{className:"space-y-2",children:n.map(b=>{const w=o===b.course_id;return e.jsx(Ee,{className:At("cursor-pointer transition-all hover:shadow-md",w?"border-primary ring-1 ring-primary/30 shadow-md":"hover:border-primary/40"),onClick:()=>l(w?null:b.course_id),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-semibold text-sm text-foreground truncate",children:b.course_title}),e.jsx(nt,{variant:b.is_published?"default":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:b.is_published?"Live":"Draft"})]})}),e.jsx(Xa,{className:At("h-4 w-4 text-muted-foreground transition-transform shrink-0 ml-2",w&&"rotate-90")})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:b.enrolled_agents}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Enrolled"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:b.total_completions}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Completed"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-foreground",children:b.total_modules}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Modules"})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:"Avg. Completion"}),e.jsxs("span",{className:"font-semibold text-foreground",children:[b.avg_completion_pct,"%"]})]}),e.jsx(Oi,{value:b.avg_completion_pct,className:"h-2"})]})]})},b.course_id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"No courses created yet"})})})]}),e.jsxs("div",{className:"xl:col-span-3 space-y-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(zb,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{value:u,onChange:b=>p(b.target.value),placeholder:"Search agents...",className:"pl-9"})]}),c?e.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(b=>e.jsx(Ee,{className:"animate-pulse",children:e.jsx(Oe,{className:"p-4",children:e.jsx("div",{className:"h-12 bg-muted rounded"})})},b))}):y!=null&&y.length?e.jsx("div",{className:"space-y-2 max-h-[600px] overflow-y-auto pr-1",children:y.map((b,w)=>{const j=b.completion_pct>=100;return e.jsx(Ee,{className:At("transition-all",j&&"border-emerald-200 bg-emerald-50/30 dark:border-emerald-900/40 dark:bg-emerald-950/10"),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:At("flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold shrink-0",w===0?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":w===1?"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400":w===2?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-muted text-muted-foreground"),children:w+1}),e.jsxs(yn,{className:"h-9 w-9 shrink-0",children:[e.jsx(Da,{src:b.avatar_url||void 0}),e.jsx(vn,{className:"text-xs bg-primary/10 text-primary",children:(b.agent_name||b.email||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:b.agent_name||b.email}),j&&e.jsxs(nt,{variant:"default",className:"text-[10px] px-1.5 py-0 bg-emerald-500 hover:bg-emerald-600 shrink-0",children:[e.jsx(ha,{className:"h-3 w-3 mr-0.5"})," Complete"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-muted-foreground mt-0.5",children:[e.jsxs("span",{children:[b.modules_completed,"/",b.total_modules," modules"]}),b.last_activity&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),ys(new Date(b.last_activity),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"text-right shrink-0 w-20",children:[e.jsxs("p",{className:At("text-sm font-bold",j?"text-emerald-600 dark:text-emerald-400":"text-foreground"),children:[b.completion_pct,"%"]}),e.jsx(Oi,{value:b.completion_pct,className:"h-1.5 mt-1"})]})]})})},b.user_id)})}):e.jsx(Ee,{className:"border-dashed",children:e.jsx(Oe,{className:"py-10 text-center",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:u?"No agents match your search":"No agents have started this course yet"})})})]}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"py-16 text-center",children:[e.jsx(mr,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Select a course to view agent progress"})]})})]})]})]})})}function mSs(){const{user:t}=Ws(),s=Pr(),{data:r,isLoading:n}=nSs();return e.jsx(Es,{title:"LevelUp U",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary/10 via-primary/5 to-background border p-8",children:[e.jsx("div",{className:"relative z-10",children:e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"h-12 w-12 rounded-xl bg-primary/15 flex items-center justify-center",children:e.jsx(zh,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"LevelUp U"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Your training & development hub"})]})]})}),e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-primary/5 rounded-full -translate-y-1/2 translate-x-1/2"})]}),n?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(a=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Oe,{className:"p-6",children:[e.jsx("div",{className:"h-5 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-3"})]})},a))}):r!=null&&r.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map(a=>e.jsx(pSs,{course:a,userId:t==null?void 0:t.id,onClick:()=>s(`/levelup-u/${a.id}`)},a.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(gh,{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 pSs({course:t,userId:s,onClick:r}){var i;const n=((i=t.modules)==null?void 0:i.length)??0,{data:a}=Clt(t.id),o=(a==null?void 0:a.filter(c=>c.completed).length)??0,l=n>0?Math.round(o/n*100):0;return e.jsxs(Ee,{className:"group cursor-pointer hover:shadow-lg transition-all hover:border-primary/50 overflow-hidden",onClick:r,children:[t.thumbnail_url?e.jsx("div",{className:"aspect-video bg-muted overflow-hidden",children:e.jsx("img",{src:t.thumbnail_url,alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"})}):e.jsx("div",{className:"aspect-video bg-gradient-to-br from-primary/15 via-primary/5 to-muted flex items-center justify-center",children:e.jsx(zh,{className:"h-10 w-10 text-primary/40"})}),e.jsxs(Oe,{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors line-clamp-1",children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.description})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gh,{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(Jv,{className:"h-3.5 w-3.5"}):e.jsx(G4,{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(Oi,{value:l,className:"h-1.5"})]}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs("span",{className:"text-xs text-primary font-medium flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[l===100?"Review":l>0?"Continue":"Start"," Course",e.jsx(Xa,{className:"h-3.5 w-3.5"})]})})]})]})}function fSs(){const{courseId:t}=Po(),s=Pr(),{user:r}=Ws(),{data:n,isLoading:a}=aSs(t),{data:o}=Clt(t),l=iSs(),[i,c]=C.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,y=u.length>0?Math.round(f/u.length*100):0;C.useEffect(()=>{if(u.length>0&&!i){const S=u.find(T=>!p.has(T.id));c((S==null?void 0:S.id)||u[0].id)}},[u,i,p]);const _=u.find(S=>S.id===i),b=u.findIndex(S=>S.id===i),w=(S,T)=>{if(!(n!=null&&n.is_sequential)||T===0)return!1;for(let I=0;I{if(!(!_||!r||!t))try{await l.mutateAsync({courseId:t,moduleId:_.id,userId:r.id}),me.success("Module completed! 🎉"),b{const T=S.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(T)return`https://www.youtube.com/embed/${T[1]}`;const I=S.match(/vimeo\.com\/(\d+)/);if(I)return`https://player.vimeo.com/video/${I[1]}`;const L=S.match(/(?:iframe\.mediadelivery\.net|video\.bunnycdn\.com)\/(?:play|embed)\/(\d+)\/([a-f0-9-]+)/);return L?`https://iframe.mediadelivery.net/embed/${L[1]}/${L[2]}?responsive=true`:S};return a?e.jsx(Es,{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(Es,{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(di,{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:[y,"%"]})]})]}),e.jsx("div",{className:"w-32",children:e.jsx(Oi,{value:y,className:"h-2"})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[320px_1fr] gap-4 items-start",children:[e.jsx(Ee,{className:"lg:sticky lg:top-4",children:e.jsxs(Oe,{className:"p-0",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Modules"})}),e.jsx(Vi,{className:"max-h-[calc(100vh-280px)]",children:e.jsx("div",{className:"p-1",children:u.map((S,T)=>{const I=w(S,T),L=p.has(S.id),R=S.id===i;return e.jsxs("button",{disabled:I,onClick:()=>!I&&c(S.id),className:At("w-full flex items-center gap-3 p-3 rounded-lg text-left transition-all text-sm",R?"bg-primary/10 text-primary":"hover:bg-muted/50",I&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"shrink-0",children:I?e.jsx(vh,{className:"h-4 w-4 text-muted-foreground"}):L?e.jsx(ha,{className:"h-4 w-4 text-green-500"}):e.jsx(pd,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:At("font-medium truncate",R&&"text-primary"),children:[T+1,". ",S.title]}),S.duration_minutes&&e.jsxs("span",{className:"text-[11px] text-muted-foreground flex items-center gap-0.5 mt-0.5",children:[e.jsx(Tn,{className:"h-3 w-3"})," ",S.duration_minutes," min"]})]})]},S.id)})})})]})}),e.jsx("div",{className:"space-y-4",children:_?e.jsxs(e.Fragment,{children:[_.video_url&&e.jsx(Ee,{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-video bg-black",children:e.jsx("iframe",{src:N(_.video_url),className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:_.title}),_.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:_.description})]}),p.has(_.id)?e.jsxs(nt,{className:"bg-green-500/15 text-green-600 border-green-500/30 shrink-0",children:[e.jsx(ha,{className:"h-3.5 w-3.5 mr-1"})," Completed"]}):e.jsxs(K,{size:"sm",onClick:j,disabled:l.isPending,children:[e.jsx(ha,{className:"h-4 w-4 mr-1"}),"Mark Complete"]})]}),_.text_content&&e.jsx("div",{className:"prose prose-sm max-w-none text-foreground border-t pt-4 whitespace-pre-wrap",children:_.text_content}),_.resources&&_.resources.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Resources"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:_.resources.map(S=>e.jsxs("a",{href:S.url||S.file_url||"#",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 p-3 rounded-lg border hover:bg-muted/50 transition-colors text-sm",children:[S.resource_type==="pdf"?e.jsx(In,{className:"h-4 w-4 text-red-500 shrink-0"}):S.resource_type==="template"?e.jsx(zh,{className:"h-4 w-4 text-purple-500 shrink-0"}):e.jsx(sl,{className:"h-4 w-4 text-blue-500 shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:S.title}),e.jsx(rn,{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:b===0,onClick:()=>b>0&&c(u[b-1].id),children:[e.jsx(di,{className:"h-3.5 w-3.5 mr-1"})," Previous"]}),bc(u[b+1].id),children:["Next ",e.jsx(Xa,{className:"h-3.5 w-3.5 ml-1"})]}):y===100&&e.jsx(nt,{className:"bg-green-500/15 text-green-600 border-green-500/30 text-sm px-3 py-1.5",children:"🎉 Course Complete!"})]})]})})]}):e.jsx(Ee,{children:e.jsx(Oe,{className:"flex items-center justify-center py-16 text-muted-foreground",children:"Select a module to begin"})})})]})]})}):e.jsx(Es,{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(di,{className:"h-4 w-4 mr-2"})," Back"]})]})})}function gSs(){const{slug:t}=Po(),{toast:s}=Ra(),[r,n]=C.useState(!1),[a,o]=C.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",experience_years:"",annual_production:"",license_number:"",why_interested:""}),{data:l,isLoading:i,error:c}=wt({queryKey:["recruit-form-brokerage",t],queryFn:async()=>{const{data:T,error:I}=await G.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(I)throw I;return T},enabled:!!t}),{data:u}=wt({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:T,error:I}=await G.from("recruit_landing_page_settings").select("*").eq("brokerage_id",l.id).single();if(I&&I.code!=="PGRST116")throw I;return T},enabled:!!(l!=null&&l.id)}),p=Dt({mutationFn:async()=>{const{error:T}=await G.from("recruit_interest_submissions").insert({brokerage_id:l.id,first_name:a.first_name,last_name:a.last_name||null,email:a.email,phone:a.phone||null,current_brokerage:a.current_brokerage||null,experience_years:a.experience_years?parseInt(a.experience_years):null,annual_production:a.annual_production||null,license_number:a.license_number||null,why_interested:a.why_interested||null});if(T)throw T},onSuccess:()=>n(!0),onError:T=>s({title:"Error",description:T.message,variant:"destructive"})});if(i)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})});if(c||!l||!l.recruit_form_enabled)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"max-w-md w-full mx-4 text-center",children:[e.jsx(La,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"This page is not available."})]})});const f=u,y=(f==null?void 0:f.primary_color)||"#406E71",_=(f==null?void 0:f.accent_color)||"#2a4c64",b=(f==null?void 0:f.benefits)||[],w=(f==null?void 0:f.testimonials)||[],j=(f==null?void 0:f.gallery_images)||[],N=(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.";return r?e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:`linear-gradient(135deg, ${y}, ${_})`},children:e.jsxs("div",{className:"max-w-md w-full mx-4 bg-white rounded-2xl shadow-2xl p-8 text-center space-y-4",children:[e.jsx("div",{className:"h-16 w-16 rounded-full flex items-center justify-center mx-auto",style:{backgroundColor:`${y}20`},children:e.jsx(ma,{className:"h-8 w-8",style:{color:y}})}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:"Thank You!"}),e.jsxs("p",{className:"text-gray-600",children:["Your interest in joining ",l.name," has been submitted. A recruiter will be in touch soon."]})]})}):e.jsxs("div",{className:"min-h-screen",style:{"--recruit-primary":y,"--recruit-accent":_},children:[e.jsxs("section",{className:"relative min-h-[70vh] flex items-center justify-center text-white overflow-hidden",style:{background:f!=null&&f.hero_image_url?`linear-gradient(135deg, ${y}dd, ${_}cc)`:`linear-gradient(135deg, ${y}, ${_})`},children:[(f==null?void 0:f.hero_image_url)&&e.jsx("div",{className:"absolute inset-0 bg-cover bg-center mix-blend-overlay opacity-40",style:{backgroundImage:`url(${f.hero_image_url})`}}),e.jsxs("div",{className:"relative z-10 text-center max-w-3xl mx-auto px-6 py-20",children:[(f==null?void 0:f.logo_url)&&e.jsx("img",{src:f.logo_url,alt:l.name,className:"h-16 w-auto mx-auto mb-8 drop-shadow-lg"}),e.jsx("h1",{className:"text-4xl md:text-6xl font-bold mb-6 leading-tight drop-shadow-md",children:N}),e.jsx("p",{className:"text-lg md:text-xl opacity-90 mb-10 max-w-2xl mx-auto leading-relaxed",children:S}),e.jsxs("a",{href:"#apply",className:"inline-flex items-center gap-2 px-8 py-4 rounded-full text-lg font-semibold shadow-lg transition-all hover:scale-105",style:{backgroundColor:"white",color:y},children:["Apply Now ",e.jsx(tl,{className:"h-5 w-5"})]})]})]}),b.length>0&&e.jsx("section",{className:"py-20 px-6 bg-white",children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-center mb-4",style:{color:_},children:"Why Join Us?"}),e.jsx("p",{className:"text-center text-gray-500 mb-12 max-w-2xl mx-auto",children:"Here's what makes our brokerage different."}),e.jsx("div",{className:"grid md:grid-cols-3 gap-8",children:b.map((T,I)=>e.jsxs("div",{className:"text-center p-6 rounded-2xl border border-gray-100 hover:shadow-lg transition-shadow",children:[e.jsx("div",{className:"text-4xl mb-4",children:T.icon}),e.jsx("h3",{className:"text-xl font-bold mb-2",style:{color:_},children:T.title}),e.jsx("p",{className:"text-gray-600",children:T.description})]},I))})]})}),j.length>0&&e.jsx("section",{className:"py-20 px-6",style:{backgroundColor:`${y}08`},children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx(mr,{className:"h-6 w-6",style:{color:y}}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold",style:{color:_},children:"Our Team & Culture"})]}),e.jsx("p",{className:"text-center text-gray-500 mb-12",children:"See what it's like to be part of our team."}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:j.map((T,I)=>e.jsx("img",{src:T,alt:`Team ${I+1}`,className:"w-full h-48 md:h-56 object-cover rounded-xl shadow-md hover:shadow-xl transition-shadow"},I))})]})}),w.length>0&&e.jsx("section",{className:"py-20 px-6 bg-white",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx(bM,{className:"h-6 w-6",style:{color:y}}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold",style:{color:_},children:"What Our Agents Say"})]}),e.jsx("p",{className:"text-center text-gray-500 mb-12",children:"Hear from agents who made the move."}),e.jsx("div",{className:"grid md:grid-cols-2 gap-8",children:w.map((T,I)=>{var L;return e.jsxs("div",{className:"p-6 rounded-2xl border border-gray-100 shadow-sm",children:[e.jsxs("p",{className:"text-gray-700 italic mb-4 leading-relaxed",children:['"',T.quote,'"']}),e.jsxs("div",{className:"flex items-center gap-3",children:[T.photo_url?e.jsx("img",{src:T.photo_url,alt:T.name,className:"h-10 w-10 rounded-full object-cover"}):e.jsx("div",{className:"h-10 w-10 rounded-full flex items-center justify-center text-white text-sm font-bold",style:{backgroundColor:y},children:((L=T.name)==null?void 0:L[0])||"?"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",style:{color:_},children:T.name}),T.role&&e.jsx("p",{className:"text-xs text-gray-500",children:T.role})]})]})]},I)})})]})}),e.jsx("section",{id:"apply",className:"py-20 px-6",style:{backgroundColor:`${y}08`},children:e.jsxs("div",{className:"max-w-lg mx-auto",children:[e.jsx("h2",{className:"text-3xl font-bold text-center mb-2",style:{color:_},children:"Ready to Join?"}),e.jsx("p",{className:"text-center text-gray-500 mb-8",children:"Fill out the form below and a recruiter will be in touch."}),e.jsxs("form",{onSubmit:T=>{T.preventDefault(),p.mutate()},className:"bg-white rounded-2xl shadow-xl p-8 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"First Name *"}),e.jsx(Fe,{required:!0,value:a.first_name,onChange:T=>o(I=>({...I,first_name:T.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Last Name"}),e.jsx(Fe,{value:a.last_name,onChange:T=>o(I=>({...I,last_name:T.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Email *"}),e.jsx(Fe,{type:"email",required:!0,value:a.email,onChange:T=>o(I=>({...I,email:T.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Phone"}),e.jsx(Fe,{value:a.phone,onChange:T=>o(I=>({...I,phone:T.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Current Brokerage"}),e.jsx(Fe,{value:a.current_brokerage,onChange:T=>o(I=>({...I,current_brokerage:T.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"License #"}),e.jsx(Fe,{value:a.license_number,onChange:T=>o(I=>({...I,license_number:T.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Years of Experience"}),e.jsx(Fe,{type:"number",min:"0",value:a.experience_years,onChange:T=>o(I=>({...I,experience_years:T.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Annual Production"}),e.jsx(Fe,{placeholder:"e.g. $5M, 20 transactions",value:a.annual_production,onChange:T=>o(I=>({...I,annual_production:T.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-gray-700",children:"Why are you interested?"}),e.jsx(Ar,{value:a.why_interested,onChange:T=>o(I=>({...I,why_interested:T.target.value})),rows:3,placeholder:"Tell us what you're looking for..."})]}),e.jsx(K,{type:"submit",className:"w-full h-12 text-base font-semibold rounded-xl",style:{backgroundColor:y},disabled:p.isPending,children:p.isPending?"Submitting...":"Submit Interest"})]})]})}),e.jsx("footer",{className:"py-8 text-center text-sm text-white",style:{backgroundColor:_},children:e.jsxs("p",{children:["© ",new Date().getFullYear()," ",l.name,". All rights reserved."]})})]})}function xSs(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 ySs(){var y,_,b,w;const{shareToken:t}=Po(),s=C.useRef(!1),{data:r,isLoading:n,error:a}=wt({queryKey:["public-recruit-video",t],queryFn:async()=>{var L;if(!t)throw new Error("No token");const{data:j,error:N}=await G.from("recruit_videos").select(` *, prospect:recruit_prospects(first_name, last_name), video:agent_videos(id, title, playback_url, thumbnail_url, duration_seconds, owner_user_id) `).eq("share_token",t).single();if(N)throw N;const{data:S}=await G.from("profiles").select("name, avatar_url, title").eq("id",(L=j.video)==null?void 0:L.owner_user_id).single(),{data:T}=await G.from("brokerages").select("name").eq("id",j.brokerage_id).single(),{data:I}=await G.from("recruit_landing_page_settings").select("logo_url, primary_color, accent_color, hero_headline").eq("brokerage_id",j.brokerage_id).maybeSingle();return{rv:j,profile:S,brokerage:T,settings:I}},enabled:!!t});if(C.useEffect(()=>{var j;!((j=r==null?void 0:r.rv)!=null&&j.id)||s.current||(s.current=!0,G.rpc("log_recruit_video_view",{p_recruit_video_id:r.rv.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null}).then(()=>{}))},[(y=r==null?void 0:r.rv)==null?void 0:y.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=((_=o.prospect)==null?void 0:_.first_name)||"there",f=(b=o.video)!=null&&b.playback_url?xSs(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx(qh,{children:e.jsx("title",{children:i!=null&&i.name?`${i.name} — A Message For You`:"Personal Video Message"})}),e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-slate-100",children:[e.jsx("header",{className:"border-b bg-white/80 backdrop-blur-sm",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-4 flex items-center gap-3",children:[(c==null?void 0:c.logo_url)&&e.jsx("img",{src:c.logo_url,alt:"",className:"h-8 object-contain"}),e.jsx("span",{className:"font-semibold text-sm",style:{color:u},children:(i==null?void 0:i.name)||"Recruiting"})]})}),e.jsxs("main",{className:"max-w-3xl mx-auto px-4 py-8 space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground",children:["Hey ",p,", ",l==null?void 0:l.name," has a message for you"]}),o.message&&e.jsx("p",{className:"text-muted-foreground max-w-xl mx-auto",children:o.message})]}),f&&e.jsx("div",{className:"rounded-xl overflow-hidden shadow-xl bg-black",children:e.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:e.jsx("iframe",{src:f,loading:"lazy",style:{border:0,position:"absolute",top:0,left:0,width:"100%",height:"100%"},allow:"accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture",allowFullScreen:!0})})}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border p-6 flex items-center gap-4",children:[l!=null&&l.avatar_url?e.jsx("img",{src:l.avatar_url,alt:"",className:"h-14 w-14 rounded-full object-cover"}):e.jsx("div",{className:"h-14 w-14 rounded-full flex items-center justify-center text-white text-lg font-bold",style:{backgroundColor:u},children:((w=l==null?void 0:l.name)==null?void 0:w.charAt(0))||"?"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-semibold",children:l==null?void 0:l.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[(l==null?void 0:l.title)||"Recruiter"," · ",i==null?void 0:i.name]})]})]}),e.jsx("div",{className:"text-center",children:e.jsxs(K,{size:"lg",className:"text-white shadow-lg hover:shadow-xl transition-shadow px-8",style:{backgroundColor:u},onClick:()=>{G.from("recruit_videos").update({cta_clicked_at:new Date().toISOString()}).eq("id",o.id).then(()=>{})},children:[e.jsx(on,{className:"h-5 w-5 mr-2"})," Schedule a Conversation"]})})]}),e.jsx("footer",{className:"text-center py-6 text-xs text-muted-foreground",children:"Powered by LevelUp"})]})]})}function vSs(){const t=Pr(),s=ss(),{isAdmin:r}=Ws(),[n,a]=C.useState(!1),[o,l]=C.useState(null),[i,c]=C.useState(null),{data:u,isLoading:p}=wt({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:L},error:R}=await G.auth.getUser();if(R)throw R;if(!L)return[];const{data:$,error:q}=await G.from("social_accounts").select("*").eq("user_id",L.id).order("created_at",{ascending:!1});if(q)throw q;return $}}),f=Dt({mutationFn:async L=>{const{data:{user:R},error:$}=await G.auth.getUser();if($)throw $;if(!R)throw new Error("Not authenticated");const{error:q}=await G.from("social_accounts").delete().eq("id",L).eq("user_id",R.id);if(q)throw q},onSuccess:()=>{s.invalidateQueries({queryKey:["my-social-accounts"]}),s.invalidateQueries({queryKey:["social-accounts-for-post"]}),me.success("Account disconnected successfully")},onError:()=>{me.error("Failed to disconnect account")}}),y=async()=>{a(!0);try{const{data:L,error:R}=await G.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(R)throw R;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get authorization URL")}catch(L){console.error("Meta OAuth error:",L),me.error("Failed to start connection. Please try again."),a(!1)}},_=async()=>{a(!0);try{const{data:L,error:R}=await G.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(R)throw R;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(L){console.error("LinkedIn OAuth error:",L),me.error("Failed to start LinkedIn connection. Please try again."),a(!1)}},b=async()=>{a(!0);try{const{data:L,error:R}=await G.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(R)throw R;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get Google authorization URL")}catch(L){console.error("Google OAuth error:",L),me.error("Failed to start Google connection. Please try again."),a(!1)}},w=(u==null?void 0:u.filter(L=>L.platform==="facebook"))||[],j=(u==null?void 0:u.filter(L=>L.platform==="instagram"))||[],N=(u==null?void 0:u.filter(L=>L.platform==="linkedin"))||[],S=(u==null?void 0:u.filter(L=>L.platform==="google_business"))||[],T=((u==null?void 0:u.length)||0)>0,I=async(L,R)=>{l(L),c(null);try{const{data:$,error:q}=await G.functions.invoke("meta-api-test",{body:{testType:"all",accountId:L}});if(q)throw q;c($.results||[]),me.success($.summary||"API tests completed")}catch($){console.error("Meta API test error:",$),me.error("Failed to run API tests")}finally{l(null)}};return e.jsx(Es,{title:"Social Connections",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-2xl bg-gradient-to-br from-pink-500 via-purple-500 to-blue-500 p-6 md:p-8 text-white",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzMiAyIDIgNC0yIDQtMiA0LTItMi0yLTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsxs(nt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(hn,{className:"h-3 w-3 mr-1"}),"Post directly from Social Swag"]})}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold mb-2",children:"Connect Your Social Accounts"}),e.jsx("p",{className:"text-white/90 max-w-xl",children:"Link your Facebook Pages and Instagram Business accounts to post content directly from Social Swag with one click."})]})]}),e.jsxs(K,{variant:"ghost",onClick:()=>t("/social-swag-2"),className:"gap-2",children:[e.jsx(di,{className:"h-4 w-4"}),"Back to Social Swag"]}),!r&&e.jsx(Ee,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"rounded-full bg-amber-100 dark:bg-amber-900/30 p-4 mb-4",children:e.jsx(Tn,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(nt,{variant:"secondary",className:"mb-3 bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Social Connections Coming Soon!"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"We're putting the finishing touches on this feature. Soon you'll be able to connect your social accounts and post directly from Social Swag with one click."})]})}),r&&e.jsxs(e.Fragment,{children:[T&&e.jsx(Ee,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsxs(Oe,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(vi,{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(It,{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(xu,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Facebook"}),e.jsx(fr,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Bo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?e.jsx("div",{className:"space-y-3",children:w.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(yn,{className:"h-10 w-10",children:[e.jsx(Da,{src:L.profile_picture_url||""}),e.jsx(vn,{children:e.jsx(xu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.page_name||L.platform_username||"Facebook Page"}),e.jsx(nt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Disconnect Facebook?"}),e.jsx(Gl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Facebook pages connected yet"}),e.jsxs(K,{onClick:y,disabled:n,className:"w-full gap-2",variant:w.length>0?"outline":"default",children:[n?e.jsx(Bo,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),w.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{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(yu,{className:"h-6 w-6 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Instagram"}),e.jsx(fr,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Bo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):j.length>0?e.jsx("div",{className:"space-y-3",children:j.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(yn,{className:"h-10 w-10",children:[e.jsx(Da,{src:L.profile_picture_url||""}),e.jsx(vn,{children:e.jsx(yu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",L.platform_username||"Instagram Account"]}),e.jsx(nt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Disconnect Instagram?"}),e.jsx(Gl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Instagram accounts connected yet"}),e.jsxs(K,{onClick:y,disabled:n,className:"w-full gap-2",variant:j.length>0?"outline":"default",children:[n?e.jsx(Bo,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),j.length>0?"Connect Another Account":"Connect Instagram"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Instagram Business accounts must be connected to a Facebook Page"})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{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(_p,{className:"h-6 w-6 text-blue-700"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"LinkedIn"}),e.jsx(fr,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Bo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):N.length>0?e.jsx("div",{className:"space-y-3",children:N.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(yn,{className:"h-10 w-10",children:[e.jsx(Da,{src:L.profile_picture_url||""}),e.jsx(vn,{children:e.jsx(_p,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.platform_username||"LinkedIn Account"}),e.jsx(nt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Disconnect LinkedIn?"}),e.jsx(Gl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No LinkedIn account connected yet"}),e.jsxs(K,{onClick:_,disabled:n,className:"w-full gap-2",variant:N.length>0?"outline":"default",children:[n?e.jsx(Bo,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),N.length>0?"Reconnect LinkedIn":"Connect LinkedIn"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Share content directly to your LinkedIn profile"})]})]}),e.jsxs(Ee,{className:`relative overflow-hidden ${r?"":"opacity-75"}`,children:[!r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(nt,{variant:"secondary",className:"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"})}),r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(nt,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),e.jsx(It,{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(Ui,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Google Business"}),e.jsx(fr,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Bo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length>0?e.jsx("div",{className:"space-y-3",children:S.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(yn,{className:"h-10 w-10",children:[e.jsx(Da,{src:L.profile_picture_url||""}),e.jsx(vn,{children:e.jsx(Ui,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.page_name||L.platform_username||"Google Business"}),e.jsx(nt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(gc,{children:[e.jsx(_m,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})}),e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Disconnect Google Business?"}),e.jsx(Gl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:r?"No Google Business account connected yet":"Google Business Profile integration is coming soon!"}),e.jsxs(K,{onClick:r?b:void 0,disabled:!r||n,className:"w-full gap-2",variant:S.length>0?"outline":"default",children:[n?e.jsx(Bo,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"}),S.length>0?"Reconnect Google Business":"Connect Google Business"]}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Post updates directly to your Google Business Profile"})]})]})]}),r&&(w.length>0||j.length>0)&&e.jsxs(Ee,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900",children:[e.jsx(It,{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(Pb,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(fr,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Click "Run Tests" on an account to trigger API calls for: ',e.jsx("strong",{children:"public_profile"}),", ",e.jsx("strong",{children:"pages_show_list"}),", ",e.jsx("strong",{children:"pages_read_engagement"}),", ",e.jsx("strong",{children:"instagram_basic"}),", ",e.jsx("strong",{children:"pages_manage_posts"}),", and ",e.jsx("strong",{children:"instagram_content_publish"}),"."]}),e.jsxs("div",{className:"space-y-3",children:[w.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xu,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{className:"font-medium",children:L.page_name||"Facebook Page"})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>I(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Pb,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${L.id}`)),j.map(L=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(yu,{className:"h-5 w-5 text-pink-600"}),e.jsxs("span",{className:"font-medium",children:["@",L.platform_username||"Instagram"]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>I(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Pb,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-ig-${L.id}`))]}),i&&i.length>0&&e.jsxs("div",{className:"mt-4 rounded-lg border bg-background p-4",children:[e.jsx("h4",{className:"font-medium mb-3",children:"Test Results"}),e.jsx("div",{className:"space-y-2",children:i.map((L,R)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[L.status==="success"?e.jsx(ha,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):L.status==="pending"?e.jsx(Ss,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx($c,{className:"h-4 w-4 text-red-600 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-mono text-xs bg-muted px-1 rounded",children:L.test}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:L.details})]})]},R))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Note: Facebook posts are auto-deleted. Instagram posts will remain and should be manually deleted. Allow up to 24 hours for Meta to register the API calls."})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-lg",children:"How it works"})}),e.jsx(Oe,{children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"1"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Connect your accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Link your Facebook, Instagram, or LinkedIn account"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"2"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Browse Social Swag"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Find the perfect image and caption for your post"})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground text-sm font-medium",children:"3"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Post with one click"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'Click "Create Post" to share directly to your accounts'})]})]})]})})]})]})]})})}function _Ss(){const[t]=Xc(),s=Pr(),[r,n]=C.useState("loading"),[a,o]=C.useState("Processing your connection...");return C.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:y,error:_}=await G.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/social-connections/callback"}});if(_)throw _;if(y!=null&&y.success)n("success"),o(`Successfully connected ${((f=y.accounts)==null?void 0:f.length)||0} account(s)!`),me.success("Social accounts connected successfully!");else throw new Error((y==null?void 0:y.error)||"Unknown error")}catch(y){console.error("OAuth callback error:",y),n("error"),o(y instanceof Error?y.message:"Failed to connect accounts"),me.error("Failed to connect: "+(y instanceof Error?y.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(It,{className:"text-center",children:[r==="loading"&&e.jsx(Ss,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(vi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx($c,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ot,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(fr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function bSs(){const[t]=Xc(),s=Pr(),[r,n]=C.useState("loading"),[a,o]=C.useState("Connecting your Google Business Profile...");return C.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:y}=await G.functions.invoke("google-business-oauth",{body:{action:"exchange_code",code:i,state:p}});if(y)throw y;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(It,{className:"text-center",children:[r==="loading"&&e.jsx(Ss,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(vi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx($c,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(Ot,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(fr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function wSs(){const[t]=Xc(),s=Pr(),[r,n]=C.useState("loading"),[a,o]=C.useState("Connecting your LinkedIn account...");return C.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:y,error:_}=await G.functions.invoke("linkedin-oauth",{body:{action:"exchange_code",code:i,state:c,callbackPath:"/social-connections/linkedin-callback"}});if(_)throw _;if(y!=null&&y.success)n("success"),o(`Successfully connected ${((f=y.accounts)==null?void 0:f.length)||1} LinkedIn account`),me.success("LinkedIn connected successfully!");else throw new Error((y==null?void 0:y.error)||"Failed to connect LinkedIn account")}catch(y){console.error("LinkedIn callback error:",y),n("error"),o(y instanceof Error?y.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(It,{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(Ss,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(vi,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx($c,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(Ot,{className:"flex items-center justify-center gap-2",children:[e.jsx(_p,{className:"h-5 w-5 text-blue-600"}),r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(fr,{children:a})]}),e.jsx(Oe,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function jSs(){const t=Pr(),[s,r]=C.useState(null),{data:n,isLoading:a}=alt(s||void 0,!0),{data:o,isLoading:l}=$Se(!0),{cartItems:i}=due(),c=i.reduce((p,f)=>p+f.quantity,0),u=p=>{t(`/marketplace/${p.id}`)};return a||l?e.jsx(Es,{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(xs,{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(xs,{className:"h-72 w-full"},p))})]})}):e.jsx(Es,{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(dp,{className:"h-4 w-4 mr-2"}),"Cart",c>0&&e.jsx(nt,{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(y=>y.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(bl,{className:"h-12 w-12 text-muted-foreground"})}),p.category&&e.jsx(nt,{className:"absolute top-2 left-2",variant:"secondary",children:p.category.name})]}),e.jsxs(Oe,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1 line-clamp-1",children:p.name}),p.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:p.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-bold text-lg",children:["$",Number(p.base_price).toFixed(2)]}),p.variants&&p.variants.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.variants.length," options"]})]})]})]},p.id)})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(bl,{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 Mlt=C.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));Mlt.displayName="Breadcrumb";const Tlt=C.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:At("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));Tlt.displayName="BreadcrumbList";const Mie=C.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:At("inline-flex items-center gap-1.5",t),...s}));Mie.displayName="BreadcrumbItem";const e2e=C.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?J2e:"a";return e.jsx(a,{ref:n,className:At("transition-colors hover:text-foreground",s),...r})});e2e.displayName="BreadcrumbLink";const Alt=C.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:At("font-normal text-foreground",t),...s}));Alt.displayName="BreadcrumbPage";const t2e=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:At("[&>svg]:size-3.5",s),...r,children:t??e.jsx(Xa,{})});t2e.displayName="BreadcrumbSeparator";function kSs(){var ee,Q;const{productId:t}=Po(),s=Pr(),{data:r,isLoading:n}=Lks(t||""),{addToCart:a,cartItems:o}=due(),[l,i]=C.useState(null),[c,u]=C.useState(1),[p,f]=C.useState(0),[y,_]=C.useState(null),[b,w]=C.useState(!1),[j,N]=C.useState(!1),S=(ee=r==null?void 0:r.variants)==null?void 0:ee.find(de=>de.id===l),T=((Q=r==null?void 0:r.variants)==null?void 0:Q.filter(de=>de.is_active))||[],I=Number((r==null?void 0:r.base_price)||0),L=S?Number(S.price_adjustment):0,R=I+L,$=Number((r==null?void 0:r.shipping_fee)||0),q=o.reduce((de,re)=>de+re.quantity,0),U=async de=>{if(!de.target.files||de.target.files.length===0)return;w(!0);const re=de.target.files[0],ne=re.name.split(".").pop(),le=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${ne}`;try{const{error:he}=await G.storage.from("marketplace").upload(le,re);if(he)throw he;const{data:{publicUrl:we}}=G.storage.from("marketplace").getPublicUrl(le);_(we),me.success("Artwork uploaded successfully")}catch(he){me.error("Failed to upload artwork: "+he.message)}finally{w(!1)}},V=()=>{if(r){if(T.length>0&&!l){me.error("Please select an option");return}a(r,S||void 0,c,y||void 0),N(!0),me.success("Added to cart!"),setTimeout(()=>N(!1),2e3)}},X=()=>{r!=null&&r.images&&f(de=>(de+1)%r.images.length)},se=()=>{r!=null&&r.images&&f(de=>(de-1+r.images.length)%r.images.length)};return n?e.jsx(Es,{title:"Product",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsx(xs,{className:"aspect-square w-full"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(xs,{className:"h-8 w-3/4"}),e.jsx(xs,{className:"h-6 w-1/4"}),e.jsx(xs,{className:"h-24 w-full"}),e.jsx(xs,{className:"h-12 w-full"})]})]})}):r?e.jsxs(Es,{title:r.name,children:[e.jsx(Mlt,{className:"mb-6",children:e.jsxs(Tlt,{children:[e.jsx(Mie,{children:e.jsx(e2e,{asChild:!0,children:e.jsx(So,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(t2e,{}),e.jsx(Mie,{children:e.jsx(e2e,{asChild:!0,children:e.jsx(So,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(t2e,{}),e.jsx(Mie,{children:e.jsx(Alt,{children:r.name})})]})}),e.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"relative aspect-square bg-muted rounded-lg overflow-hidden flex items-center justify-center",children:r.images&&r.images.length>0?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:r.images[p].image_url,alt:r.name,className:"max-w-full max-h-full object-contain"}),r.images.length>1&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:se,children:e.jsx(Xl,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:X,children:e.jsx(Xa,{className:"h-6 w-6"})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(bl,{className:"h-24 w-24 text-muted-foreground"})})}),r.images&&r.images.length>1&&e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:r.images.map((de,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:de.image_url,alt:"",className:"w-full h-full object-cover"})},de.id))}),r.video&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("h4",{className:"font-medium mb-2",children:"Product Video"}),e.jsx("div",{className:"aspect-video",children:e.jsx("iframe",{src:r.video.video_url,className:"w-full h-full rounded-lg",allowFullScreen:!0})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[r.category&&e.jsx(nt,{variant:"secondary",className:"mb-2",children:r.category.name}),e.jsx("h1",{className:"text-3xl font-bold mb-2",children:r.name}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-3xl font-bold",children:["$",R.toFixed(2)]}),$>0&&e.jsxs("span",{className:"text-muted-foreground",children:["+ $",$.toFixed(2)," shipping"]})]})]}),r.description&&e.jsx("div",{className:"prose prose-sm max-w-none",children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})}),T.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{children:"Select Option"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:T.map(de=>e.jsxs(K,{variant:l===de.id?"default":"outline",onClick:()=>i(de.id),children:[de.name,Number(de.price_adjustment)!==0&&e.jsxs("span",{className:"ml-1 opacity-70",children:["(",Number(de.price_adjustment)>0?"+":"","$",Number(de.price_adjustment).toFixed(2),")"]})]},de.id))})]}),r.allow_artwork_upload&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{children:"Upload Your Artwork (Optional)"}),y?e.jsxs("div",{className:"relative inline-block",children:[e.jsx("img",{src:y,alt:"Your artwork",className:"h-24 w-auto rounded-lg border"}),e.jsx(K,{variant:"ghost",size:"sm",className:"absolute -top-2 -right-2",onClick:()=>_(null),children:"×"})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6",children:[e.jsx("input",{type:"file",accept:"image/*,.pdf,.ai,.eps",onChange:U,className:"hidden",id:"artwork-upload",disabled:b}),e.jsxs("label",{htmlFor:"artwork-upload",className:"flex flex-col items-center cursor-pointer",children:[e.jsx(ni,{className:"h-8 w-8 text-muted-foreground mb-2"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:b?"Uploading...":"Click to upload artwork"}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"Supported: JPG, PNG, PDF, AI, EPS"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{children:"Quantity"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(de=>Math.max(1,de-1)),children:"-"}),e.jsx(Fe,{type:"number",value:c,onChange:de=>u(Math.max(1,parseInt(de.target.value)||1)),className:"w-20 text-center",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(de=>de+1),children:"+"})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(K,{size:"lg",className:"flex-1",onClick:V,disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx(ma,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(dp,{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(dp,{className:"h-5 w-5"}),q>0&&e.jsx(nt,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:q})]})]}),r.requires_proof_approval&&e.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-3 rounded-lg",children:"📋 This product requires proof approval before production. You'll receive a proof to review after your order is placed."})]})]})]}):e.jsx(Es,{title:"Product Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(bl,{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 NSs(){const t=Pr(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:c}=due(),[u,p]=C.useState(!1),[f,y]=C.useState(""),_=async()=>{if(s.length===0){me.error("Your cart is empty");return}p(!0);try{const{data:b,error:w}=await G.functions.invoke("marketplace-checkout",{body:{items:s.map(j=>{var N;return{product_id:j.product.id,variant_id:((N=j.variant)==null?void 0:N.id)||null,quantity:j.quantity,artwork_url:j.artworkUrl||null}}),notes:f.trim()||null}});if(w)throw w;if(b!=null&&b.url)c(),window.open(b.url,"_blank");else throw new Error("No checkout URL received")}catch(b){me.error("Checkout failed: "+b.message)}finally{p(!1)}};return s.length===0?e.jsx(Es,{title:"Shopping Cart",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(l0,{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(Es,{title:"Shopping Cart",children:e.jsxs("div",{className:"grid gap-8 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[s.map(b=>{var w,j;return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"w-24 h-24 flex-shrink-0 bg-muted rounded-lg overflow-hidden",children:b.product.images&&b.product.images.length>0?e.jsx("img",{src:((w=b.product.images.find(N=>N.is_primary))==null?void 0:w.image_url)||b.product.images[0].image_url,alt:b.product.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(l0,{className:"h-8 w-8 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold line-clamp-1",children:b.product.name}),b.variant&&e.jsx("p",{className:"text-sm text-muted-foreground",children:b.variant.name}),e.jsxs("p",{className:"font-medium mt-1",children:["$",a(b).toFixed(2),Number(b.product.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:["+ $",Number(b.product.shipping_fee).toFixed(2)," shipping"]})]}),b.artworkUrl&&e.jsx("div",{className:"mt-2",children:e.jsx("span",{className:"text-xs text-muted-foreground",children:"Artwork uploaded ✓"})})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{var N;return r(b.product.id,(N=b.variant)==null?void 0:N.id)},children:e.jsx(jr,{className:"h-4 w-4 text-destructive"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var N;return n(b.product.id,(N=b.variant)==null?void 0:N.id,b.quantity-1)},disabled:b.quantity<=1,children:e.jsx(t1,{className:"h-3 w-3"})}),e.jsx(Fe,{type:"number",value:b.quantity,onChange:N=>{var S;return n(b.product.id,(S=b.variant)==null?void 0:S.id,parseInt(N.target.value)||1)},className:"w-14 h-8 text-center text-sm",min:"1"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var N;return n(b.product.id,(N=b.variant)==null?void 0:N.id,b.quantity+1)},children:e.jsx(Zs,{className:"h-3 w-3"})})]})]})]})})},`${b.product.id}-${((j=b.variant)==null?void 0:j.id)||"base"}`)}),e.jsx(K,{variant:"ghost",className:"text-destructive",onClick:c,children:"Clear Cart"})]}),e.jsx("div",{children:e.jsxs(Ee,{className:"sticky top-4",children:[e.jsx(It,{children:e.jsx(Ot,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Subtotal (",s.reduce((b,w)=>b+w.quantity,0)," items)"]}),e.jsxs("span",{children:["$",o().toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Shipping"}),e.jsxs("span",{children:["$",l().toFixed(2)]})]}),e.jsx(Zl,{}),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(Zl,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(Ar,{id:"orderNotes",placeholder:"Add any special instructions, design notes, or comments for your order...",value:f,onChange:b=>y(b.target.value),rows:3,className:"resize-none"})]}),e.jsx(K,{className:"w-full",size:"lg",onClick:_,disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx(Ki,{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 SSs(){const t=Pr(),{data:s,isLoading:r}=Hks();return r?e.jsx(Es,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>e.jsx(xs,{className:"h-32 w-full"},n))})}):!s||s.length===0?e.jsx(Es,{title:"My Orders",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(bl,{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(Es,{title:"My Orders",children:e.jsx("div",{className:"space-y-4",children:s.map(n=>{var a,o,l;return e.jsx(Ee,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>t(`/marketplace/orders/${n.id}`),children:e.jsxs(Oe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:n.order_number}),e.jsx("span",{className:"text-muted-foreground text-sm ml-2",children:ys(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(nt,{className:BSe[n.status],children:HM[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(rn,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(Xa,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const lze=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function CSs({currentStatus:t,statusHistory:s}){const r=lze.indexOf(t);return e.jsx("div",{className:"space-y-3",children:lze.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(ha,{className:"h-4 w-4"}):i?e.jsx(Tn,{className:"h-4 w-4"}):e.jsx("span",{className:"text-xs",children:a+1})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`font-medium ${c?"text-muted-foreground":""}`,children:HM[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ys(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function MSs(){var N;const{orderId:t}=Po(),s=Pr(),{data:r,isLoading:n,refetch:a}=Wks(t||""),o=Zks(),l=Yks(),[i,c]=C.useState(!1),[u,p]=C.useState(null),[f,y]=C.useState(""),[_,b]=C.useState(null),w=async S=>{b(S);try{await o.mutateAsync({orderId:t,itemId:S}),me.success("Proof approved!"),a()}catch{me.error("Failed to approve proof")}finally{b(null)}},j=async()=>{if(u){b(u);try{await l.mutateAsync({orderId:t,itemId:u,reason:f}),me.success("Revision requested"),c(!1),y(""),p(null),a()}catch{me.error("Failed to request revision")}finally{b(null)}}};return n?e.jsx(Es,{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(xs,{className:"h-64 w-full"}),e.jsx(xs,{className:"h-48 w-full"})]}),e.jsx(xs,{className:"h-96 w-full"})]})}):r?e.jsxs(Es,{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(It,{className:"flex flex-row items-center justify-between",children:[e.jsx(Ot,{children:"Order Status"}),e.jsx(nt,{className:BSe[r.status],children:HM[r.status]})]}),e.jsx(Oe,{children:e.jsx(CSs,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Items"})}),e.jsx(Oe,{className:"space-y-4",children:(N=r.items)==null?void 0:N.map(S=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold",children:S.product_name}),S.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:S.variant_name}),e.jsxs("p",{className:"text-sm",children:["Qty: ",S.quantity," × $",Number(S.unit_price).toFixed(2)]})]}),e.jsxs("p",{className:"font-semibold",children:["$",(Number(S.unit_price)*S.quantity).toFixed(2)]})]}),S.artwork_url&&e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your Artwork:"}),e.jsxs("a",{href:S.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline",children:[e.jsx(Eb,{className:"h-4 w-4"}),"View Artwork",e.jsx(rn,{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(Eb,{className:"h-4 w-4"}),"View Proof",e.jsx(rn,{className:"h-3 w-3"})]}),S.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(K,{size:"sm",onClick:()=>w(S.id),disabled:_===S.id,children:[_===S.id?e.jsx(Ss,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Gu,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{p(S.id),c(!0)},disabled:_===S.id,children:[e.jsx(mL,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),S.proof_status==="approved"&&e.jsxs(nt,{className:"bg-green-100 text-green-800",children:[e.jsx(ha,{className:"h-3 w-3 mr-1"}),"Proof Approved"]}),S.proof_status==="rejected"&&S.proof_notes&&e.jsxs("div",{className:"mt-2",children:[e.jsx(nt,{variant:"destructive",className:"mb-2",children:"Revision Requested"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S.proof_notes})]})]})]},S.id))})]}),r.shipping_name&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(fL,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs(Oe,{children:[e.jsx("p",{className:"font-medium",children:r.shipping_name}),e.jsxs("p",{className:"text-muted-foreground",children:[r.shipping_address,e.jsx("br",{}),r.shipping_city,", ",r.shipping_state," ",r.shipping_zip]}),r.tracking_number&&e.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tracking Number:"}),e.jsx("p",{className:"font-mono font-medium",children:r.tracking_number}),r.tracking_url&&e.jsxs(K,{variant:"link",className:"p-0 h-auto mt-1",onClick:()=>window.open(r.tracking_url,"_blank"),children:["Track Package",e.jsx(rn,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(Ee,{className:"sticky top-4",children:[e.jsx(It,{children:e.jsx(Ot,{children:"Order Summary"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",ys(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(Zl,{}),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(Zl,{}),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(Zl,{}),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(_s,{open:i,onOpenChange:c,children:e.jsxs(vs,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Request Changes"}),e.jsx(Zr,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(Ar,{placeholder:"Describe the changes needed...",value:f,onChange:S=>y(S.target.value),rows:4}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(K,{onClick:j,disabled:!f.trim()||_!==null,children:[_?e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Submit Request"]})]})]})})]}):e.jsx(Es,{title:"Order Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(bl,{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 TSs(){const t=Pr(),[s]=Xc();return s.get("session_id"),C.useEffect(()=>{localStorage.removeItem("marketplace-cart")},[]),e.jsx(Es,{title:"Order Confirmed",children:e.jsx("div",{className:"max-w-lg mx-auto text-center py-8",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-8 pb-6",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(ha,{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(bl,{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(Ki,{className:"h-4 w-4 ml-2"})]}),e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function ASs(){const{user:t}=Ws(),[s,r]=C.useState("store"),[n,a]=C.useState(null),[o,l]=C.useState(null),[i,c]=C.useState(!1),[u,p]=C.useState(5),[f,y]=C.useState(""),[_,b]=C.useState(!1),[w,j]=C.useState(!1),[N,S]=C.useState(""),[T,I]=C.useState(null),[L,R]=C.useState(!1),{hasSubmittedReview:$,submitReview:q,markPostedToGoogle:U}=sYe(),{data:V}=olt(),{data:X,isLoading:se}=ilt(),{data:ee,isLoading:Q}=rNs(n),{data:de,isLoading:re}=nNs(t==null?void 0:t.id),{data:ne=0}=iNs(t==null?void 0:t.id),le=oNs(),he=new Set((de==null?void 0:de.map(Me=>Me.item_id))||[]),we=async()=>{if(o)try{await le.mutateAsync(o.id),me.success(`Successfully purchased "${o.name}"!`),l(null)}catch(Me){me.error(Me.message||"Failed to purchase item")}},ye=async()=>{if(!f.trim()){me.error("Please write a review");return}b(!0);const Me=await q(u,f);b(!1),Me.success?(me.success("Thank you for your review! You earned 25 points!"),S(f),j(!0),y(""),p(5)):me.error(Me.error||"Failed to submit review")},je=()=>{navigator.clipboard.writeText(N),me.success("Review copied to clipboard!")},ke=()=>{U(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},We=()=>{j(!1),c(!1),S("")};return se||Q||re?e.jsx(Es,{title:"Reward Store",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{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(Me=>e.jsx(xs,{className:"h-64"},Me))})]})}):e.jsxs(Es,{title:"Reward Store",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Reward Store"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Redeem your points for exclusive rewards"})]}),e.jsx(Ee,{className:"bg-gradient-to-r from-primary/10 to-primary/5 border-primary/20",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(Kn,{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:ne.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(mo,{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(Fh,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),e.jsx(bg,{open:L,onOpenChange:R,children:e.jsxs(Ee,{className:"border-primary/20",children:[e.jsx(wg,{asChild:!0,children:e.jsx(It,{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(mo,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-base",children:"How to Earn Points"}),e.jsx(fr,{children:"See all the ways you can earn spendable points"})]})]}),L?e.jsx(Hx,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(tl,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(jg,{children:e.jsx(Oe,{className:"pt-0",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[V==null?void 0:V.filter(Me=>Me.is_active).map(Me=>{const Ae=Re=>{switch(Re){case"event_attendance":return e.jsx(on,{className:"h-5 w-5"});case"leave_review":return e.jsx(Kn,{className:"h-5 w-5"});case"add_listing":return e.jsx(Rn,{className:"h-5 w-5"});case"first_contact":return e.jsx(mr,{className:"h-5 w-5"});case"first_video":return e.jsx(Nn,{className:"h-5 w-5"});case"first_community_post":return e.jsx(po,{className:"h-5 w-5"});default:return e.jsx(bo,{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:Ae(Me.action_key)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:Me.action_name}),Me.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Me.description})]}),e.jsxs(nt,{variant:"secondary",className:"font-bold shrink-0",children:["+",Me.points]})]},Me.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(Fh,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"Streak Bonuses"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Attend consecutive weeks for bonus points!"})]}),e.jsx(nt,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!$&&e.jsx(Ee,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-yellow-500/20 flex items-center justify-center",children:e.jsx(po,{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(Kn,{className:"h-4 w-4 mr-2"}),"Leave Review"]})]})})}),e.jsxs(Aa,{value:s,onValueChange:r,children:[e.jsxs(ja,{children:[e.jsxs(js,{value:"store",className:"flex items-center gap-2",children:[e.jsx(l0,{className:"h-4 w-4"}),"Store"]}),e.jsxs(js,{value:"my-rewards",className:"flex items-center gap-2",children:[e.jsx(bl,{className:"h-4 w-4"}),"My Rewards",de&&de.length>0&&e.jsx(nt,{variant:"secondary",className:"ml-1",children:de.length})]})]}),e.jsxs($s,{value:"store",className:"mt-6",children:[X&&X.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx(K,{variant:n===null?"default":"outline",size:"sm",onClick:()=>a(null),children:"All"}),X.map(Me=>e.jsxs(K,{variant:n===Me.id?"default":"outline",size:"sm",onClick:()=>a(Me.id),children:[Me.icon&&`${Me.icon} `,Me.name]},Me.id))]}),!ee||ee.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(bo,{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(Me=>{const Ae=he.has(Me.id),Re=Me.max_quantity!==null&&Me.current_quantity===0,Te=ne>=Me.points_cost;return e.jsxs(Ee,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${Ae?"ring-2 ring-green-500/50 bg-green-500/5":""}`,onClick:()=>I(Me),children:[Me.preview_image_url?e.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[e.jsx("img",{src:Me.preview_image_url,alt:Me.name,className:"w-full h-full object-cover"}),Ae&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(nt,{className:"bg-green-500 text-white",children:[e.jsx(ha,{className:"h-3 w-3 mr-1"}),"Owned"]})}),Re&&!Ae&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(nt,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(bo,{className:"h-12 w-12 text-muted-foreground/50"}),Ae&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(nt,{className:"bg-green-500 text-white",children:[e.jsx(ha,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs(It,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(Ot,{className:"text-lg",children:Me.name}),e.jsxs(nt,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(Kn,{className:"h-3 w-3 mr-1"}),Me.points_cost]})]}),Me.category&&e.jsxs(nt,{variant:"outline",className:"w-fit",children:[Me.category.icon&&`${Me.category.icon} `,Me.category.name]})]}),e.jsxs(Oe,{children:[e.jsx(fr,{className:"mb-4 line-clamp-2",children:Me.description||"No description available"}),Me.max_quantity!==null&&!Ae&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Me.current_quantity," of ",Me.max_quantity," remaining"]}),Ae?e.jsx(K,{className:"w-full",onClick:qe=>{qe.stopPropagation(),Me.file_url&&xye(Me.file_url,Me.name)},disabled:!Me.file_url,children:Me.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(ki,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Access"]})}):e.jsx(K,{className:"w-full",onClick:qe=>{qe.stopPropagation(),l(Me)},disabled:Re||!Te,children:Re?"Sold Out":Te?e.jsxs(e.Fragment,{children:[e.jsx(l0,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Me.points_cost-ne} more pts`})]})]},Me.id)})})]}),e.jsx($s,{value:"my-rewards",className:"mt-6",children:!de||de.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(bl,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{className:"font-medium",children:"No rewards yet"}),e.jsx("p",{className:"text-sm",children:"Purchase items from the store to see them here!"})]})})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:de.map(Me=>{var Ae,Re,Te,qe,ct;return e.jsxs(Ee,{className:"overflow-hidden",children:[(Ae=Me.item)!=null&&Ae.preview_image_url?e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:e.jsx("img",{src:Me.item.preview_image_url,alt:((Re=Me.item)==null?void 0:Re.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(bo,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(It,{className:"pb-2",children:[e.jsx(Ot,{className:"text-lg",children:((Te=Me.item)==null?void 0:Te.name)||"Unknown Item"}),e.jsxs(fr,{className:"text-xs",children:["Purchased for ",Me.points_spent," points • ",new Date(Me.purchased_at).toLocaleDateString()]})]}),e.jsx(Oe,{children:e.jsx(K,{className:"w-full",onClick:()=>{var De,Rt;(De=Me.item)!=null&&De.file_url&&xye(Me.item.file_url,(Rt=Me.item)==null?void 0:Rt.name)},disabled:!((qe=Me.item)!=null&&qe.file_url),children:((ct=Me.item)==null?void 0:ct.item_type)==="file"?e.jsxs(e.Fragment,{children:[e.jsx(ki,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Me.id)})})})]})]}),e.jsx(gc,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Confirm Purchase"}),e.jsxs(Gl,{children:['Are you sure you want to purchase "',o==null?void 0:o.name,'" for ',o==null?void 0:o.points_cost," points?",e.jsx("br",{}),e.jsx("br",{}),"You currently have ",e.jsxs("strong",{children:[ne," points"]}),". After this purchase, you'll have"," ",e.jsxs("strong",{children:[ne-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:we,disabled:le.isPending,children:le.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(_s,{open:i,onOpenChange:Me=>{!Me&&w?We():c(Me)},children:e.jsx(vs,{children:w?e.jsxs(e.Fragment,{children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(ha,{className:"h-5 w-5 text-green-500"}),"Thank You for Your Review!"]}),e.jsx(Zr,{children:"Would you also share your review on Google? It helps other agents discover LevelUp!"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-muted p-4 rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your review:"}),e.jsxs("p",{className:"text-sm italic",children:['"',N,'"']})]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:je,children:[e.jsx(mi,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(Vn,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(K,{variant:"outline",onClick:We,children:"Maybe Later"}),e.jsxs(K,{onClick:ke,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Leave a Review"}),e.jsx(Zr,{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(Me=>e.jsx("button",{type:"button",onClick:()=>p(Me),className:"focus:outline-none",children:e.jsx(Kn,{className:`h-8 w-8 transition-colors ${u>=Me?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},Me))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),e.jsx(Ar,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:f,onChange:Me=>y(Me.target.value),rows:4})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{onClick:ye,disabled:_,className:"bg-yellow-600 hover:bg-yellow-700",children:_?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),e.jsx(_s,{open:!!T,onOpenChange:()=>I(null),children:e.jsxs(vs,{className:"max-w-lg",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[T==null?void 0:T.name,e.jsxs(nt,{variant:"secondary",className:"font-bold",children:[e.jsx(Kn,{className:"h-3 w-3 mr-1"}),T==null?void 0:T.points_cost]})]}),(T==null?void 0:T.category)&&e.jsxs(nt,{variant:"outline",className:"w-fit",children:[T.category.icon&&`${T.category.icon} `,T.category.name]})]}),(T==null?void 0:T.preview_image_url)&&e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted rounded-lg",children:e.jsx("img",{src:T.preview_image_url,alt:T.name,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:(T==null?void 0:T.description)||"No description available"}),(T==null?void 0:T.max_quantity)!==null&&!he.has((T==null?void 0:T.id)||"")&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[T==null?void 0:T.current_quantity," of ",T==null?void 0:T.max_quantity," remaining"]})]}),e.jsx(Vn,{children:T&&he.has(T.id)?e.jsx(K,{className:"w-full",onClick:()=>{T.file_url&&xye(T.file_url,T.name)},disabled:!T.file_url,children:T.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(ki,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Access"]})}):T&&e.jsx(K,{className:"w-full",onClick:()=>{I(null),l(T)},disabled:T.max_quantity!==null&&T.current_quantity===0||ne{const{user:t}=Ws(),s=ss(),r=wt({queryKey:["smart-presentations",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await G.from("smart_presentations").select("*").eq("owner_user_id",t.id).neq("status","archived").order("created_at",{ascending:!1});if(p)throw p;return u||[]},enabled:!!t}),n=wt({queryKey:["smart-presentation-templates",t==null?void 0:t.id],queryFn:async()=>{const{data:u,error:p}=await G.from("smart_presentation_templates").select("*").eq("is_active",!0).order("created_at",{ascending:!0});if(p)throw p;return u||[]},enabled:!!t}),a=Dt({mutationFn:async u=>{const{data:p,error:f}=await G.from("smart_presentations").insert({owner_user_id:t.id,...u}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),o=Dt({mutationFn:async({id:u,...p})=>{const{data:f,error:y}=await G.from("smart_presentations").update(p).eq("id",u).select().single();if(y)throw y;return f},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]})}}),l=Dt({mutationFn:async u=>{const{data:p,error:f}=await G.from("smart_presentations").update({status:"published",published_at:new Date().toISOString()}).eq("id",u).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),me.success("Presentation published!")}}),i=Dt({mutationFn:async u=>{const{error:p}=await G.from("smart_presentations").update({status:"archived"}).eq("id",u);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentations"]}),me.success("Presentation archived")}}),c=Dt({mutationFn:async u=>{const{error:p}=await G.from("smart_presentation_templates").insert({owner_user_id:t.id,name:u.title+" Template",description:"Created from "+u.title,template_type:"custom",icon:"📄",sections:u.sections,cta_config:{type:u.cta_type,label:u.cta_label},is_system:!1});if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["smart-presentation-templates"]}),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}},ESs=()=>{const t=Pr(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=Elt(),o=i=>i.status==="draft"?e.jsx(nt,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(nt,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(nt,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(nt,{variant:"secondary",className:"text-xs",children:"Not Opened"}),l=i=>{const c=`https://presentations.relevelup.com/${i}`;navigator.clipboard.writeText(c),me.success("Link copied!")};return e.jsx(Es,{title:"Smart Presentations",children:e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h1",{className:"text-2xl font-serif font-bold text-foreground",children:"Smart Presentations"})}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Create personalized, video-first presentations for your clients"})]}),e.jsxs(K,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Create Presentation"]})]}),r?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(i=>e.jsx(xs,{className:"h-20 w-full rounded-lg"},i))}):s.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(Gx,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No presentations yet"}),e.jsx("p",{className:"text-muted-foreground mb-6 max-w-md",children:"Create your first Smart Presentation to impress clients with personalized, video-first content."}),e.jsxs(K,{onClick:()=>t("/mission-control/presentations/new"),className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Create Your First Presentation"]})]})}):e.jsx("div",{className:"space-y-3",children:s.map(i=>e.jsx(Ee,{className:"hover:shadow-sm transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(In,{className:"h-5 w-5 text-primary"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold truncate",children:i.title}),o(i)]}),e.jsxs("div",{className:"flex items-center gap-x-3 gap-y-0.5 flex-wrap text-sm text-muted-foreground mt-0.5",children:[i.client_name&&e.jsx("span",{children:i.client_name}),e.jsxs("span",{children:["Created ",ys(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(va,{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(mi,{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(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(ag,{className:"h-4 w-4"})})}),e.jsxs(Jd,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(Ta,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[e.jsx(rn,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(Ta,{onClick:()=>a.mutate(i),children:[e.jsx(In,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(Ta,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(aM,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},cze={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."}]},PSs=[{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 ISs(t){const s=cze[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(cze))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return PSs}function LSs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=C.useState(!1),[o,l]=C.useState("script"),[i,c]=C.useState(0),[u,p]=C.useState(0),{canRecord:f}=vat(),y=nC(),[_,b]=C.useState(""),[w,j]=C.useState(!1),[N,S]=C.useState(!0),[T,I]=C.useState(!1),[L,R]=C.useState(null),$=ISs(t),q=()=>{l("script"),c(0),p(0),b(""),j(!1),S(!0),I(!1),R(null)},U=Q=>{!Q&&(o==="uploading"||o==="processing")||(a(Q),Q||q())},V=Q=>{R(Q),b($[Q].text),j(!1)},X=()=>{l("record"),S(_.trim().length>0)},se=()=>{b(""),S(!1),l("record")},ee=C.useCallback(async(Q,de)=>{l("uploading");try{const re=t||"Presentation Video",{videoId:ne,uploadUrl:le,libraryId:he}=await GO(re),{apiKey:we}=await KO(ne),ye=new XMLHttpRequest;ye.upload.onprogress=Me=>{Me.lengthComputable&&c(Me.loaded/Me.total*100)},await new Promise((Me,Ae)=>{ye.onload=()=>ye.status>=200&&ye.status<300?Me():Ae(new Error("Upload failed")),ye.onerror=()=>Ae(new Error("Upload failed")),ye.open("PUT",le),ye.setRequestHeader("AccessKey",we),ye.send(Q)}),l("processing");let je=0;const ke=Date.now(),We=9e4;let be=null;for(;je<4;){if(await new Promise(Ae=>setTimeout(Ae,3e3)),Date.now()-ke>We){const Ae=Q.size/1048576,Re=`https://iframe.mediadelivery.net/embed/${he}/${ne}?responsive=true`;await y.mutateAsync({bunny_video_id:ne,playback_url:Re,file_size_mb:Ae,title:re,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(Re),me.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Me=await rA(ne);if(je=Me.status,p(Me.encodeProgress||0),je===4)be={playbackUrl:Me.directPlayUrl,thumbnailUrl:Me.thumbnailUrl,previewUrl:Me.previewUrl||null,duration:Me.length||de,fileSizeMb:(Me.storageSize||Q.size)/(1024*1024)};else if(je===5||je===6)throw new Error("Video processing failed")}if(!be)throw new Error("No video data");await y.mutateAsync({bunny_video_id:ne,contact_id:s||void 0,playback_url:be.playbackUrl,thumbnail_url:be.thumbnailUrl,preview_url:be.previewUrl,duration_seconds:be.duration,file_size_mb:be.fileSizeMb,title:re,status:"ready",touch_type:"presentation"}),r(be.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,y]);return e.jsxs(_s,{open:n,onOpenChange:U,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Record a video",children:[e.jsx(Nn,{className:"h-3.5 w-3.5"}),"Record"]})}),e.jsxs(vs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto !top-[5%] !translate-y-0 sm:!top-[5%] sm:!translate-y-0",children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:[o==="script"&&`Prepare your script for "${t}"`,o==="record"&&`Record video for "${t}"`,o==="uploading"&&"Uploading...",o==="processing"&&"Processing...",o==="done"&&"Done!"]})}),o==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a starter script below, edit it to make it yours, or skip and speak freely."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starter Scripts"}),e.jsx("div",{className:"grid gap-2",children:$.map((Q,de)=>e.jsxs("button",{onClick:()=>V(de),className:At("text-left p-3 rounded-lg border transition-all hover:bg-accent/50",L===de?"border-primary bg-primary/5 ring-1 ring-primary":"border-border"),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(In,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:Q.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:Q.text})]},de))})]}),_&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Your Script"}),!w&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>j(!0),className:"h-7 text-xs gap-1",children:[e.jsx($a,{className:"h-3 w-3"}),"Edit"]})]}),w?e.jsx(Ar,{value:_,onChange:Q=>b(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:_})]}),!_&&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(Ar,{value:_,onChange:Q=>{b(Q.target.value),R(null)},rows:4,placeholder:"Type your own script here...",className:"text-sm"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:se,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(K,{onClick:X,disabled:!1,children:_.trim()?"Continue with Script":"Continue Without Script"})]})]}),!f&&o==="record"?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-8 text-center",children:[e.jsx(uh,{className:"h-10 w-10 text-destructive"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You've reached your video storage limit. Delete some videos to free up space."})]}):o==="record"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Record up to 60 seconds. Saved to your library & auto-attached."}),_.trim()&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>S(!N),className:"h-7 text-xs gap-1",children:[N?e.jsx(xp,{className:"h-3 w-3"}):e.jsx(va,{className:"h-3 w-3"}),N?"Hide Script":"Show Script"]})]}),e.jsx(cme,{maxDurationSeconds:60,onRecordingComplete:ee,onRecordingStateChange:I,onError:Q=>me.error(Q),teleprompterContent:_.trim()?e.jsx(Oot,{text:_,isVisible:N,onToggleVisibility:()=>S(!N),isRecording:T,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(Ss,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Oi,{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(Ss,{className:"h-10 w-10 animate-spin text-primary"}),e.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[e.jsx(Oi,{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(vi,{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 DSs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=C.useState(!1),[o,l]=C.useState(null),[i,c]=C.useState("idle"),[u,p]=C.useState(0),f=C.useRef(null),y=nC(),{data:_}=Rhe(),b=(_==null?void 0:_.total_storage_mb)||0,j=((_==null?void 0:_.max_storage_mb)||1024)-b,N=()=>{l(null),c("idle"),p(0)},S=$=>{!$&&i!=="idle"&&i!=="done"||(a($),$||N())},T=$=>{var V;const q=(V=$.target.files)==null?void 0:V[0];if(!q)return;if(!q.type.startsWith("video/")){me.error("Please select a video file");return}const U=q.size/(1024*1024);if(U>500){me.error("Video file must be less than 500MB");return}if(U>j){me.error(`Not enough storage. You have ${j.toFixed(1)} MB remaining.`);return}l(q)},I=C.useCallback(async()=>{if(o){c("creating"),p(0);try{const $=t||o.name,{data:q,error:U}=await G.functions.invoke("bunny-upload",{body:{action:"create",title:$,isAgentVideo:!0}});if(U)throw new Error(U.message);const{videoId:V,libraryId:X}=q;c("uploading");const{data:se,error:ee}=await G.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:V,isAgentVideo:!0}});if(ee)throw new Error(ee.message);await new Promise((re,ne)=>{const le=new XMLHttpRequest;le.upload.addEventListener("progress",he=>{he.lengthComputable&&p(Math.round(he.loaded/he.total*100))}),le.addEventListener("load",()=>le.status>=200&&le.status<300?re():ne(new Error(`Upload failed (${le.status})`))),le.addEventListener("error",()=>ne(new Error("Upload failed"))),le.open("PUT",se.uploadUrl),le.setRequestHeader("AccessKey",se.apiKey),le.send(o)}),c("processing");const Q=o.size/(1024*1024),de=`https://iframe.mediadelivery.net/embed/${X}/${V}`;await y.mutateAsync({bunny_video_id:V,playback_url:de,file_size_mb:Q,title:$,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(de),c("done"),me.success("Video uploaded & attached to section!"),setTimeout(()=>a(!1),1200)}catch($){console.error("Upload error:",$),me.error($ instanceof Error?$.message:"Failed to upload video"),c("idle")}}},[o,t,s,r,y]),L=()=>{switch(i){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${u}%`;case"processing":return"Saving video...";case"done":return"Done!";default:return""}},R=i!=="idle"&&i!=="done";return e.jsxs(_s,{open:n,onOpenChange:S,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[e.jsx(ni,{className:"h-3.5 w-3.5"}),"Upload"]})}),e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:['Upload Video for "',t,'"']})}),e.jsxs("div",{className:"space-y-4 py-2",children:[o?e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[e.jsx(Nn,{className:"h-8 w-8 text-primary flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(o.size/(1024*1024)).toFixed(1)," MB"]})]}),!R&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>{var $;return($=f.current)==null?void 0:$.click()},children:[e.jsx(ni,{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:T,disabled:R}),R&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ss,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:L()})]}),e.jsx(Oi,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>S(!1),disabled:R,children:"Cancel"}),e.jsx(K,{onClick:I,disabled:!o||R,children:R?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ni,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const dze=[{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"}],uze=()=>{const t=Pr(),{id:s}=Po(),{user:r}=Ws(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=Elt(),{isGmailConnected:c,gmailEmail:u}=D0(),[p,f]=C.useState(!1),[y,_]=C.useState("client"),[b,w]=C.useState(!1),[j,N]=C.useState(""),[S,T]=C.useState([]),[I,L]=C.useState(!1),[R,$]=C.useState(null),[q,U]=C.useState(!1),[V,X]=C.useState(""),[se,ee]=C.useState(""),[Q,de]=C.useState(""),[re,ne]=C.useState("buyer"),[le,he]=C.useState(""),[we,ye]=C.useState(null),[je,ke]=C.useState(""),[We,be]=C.useState([]),[Me,Ae]=C.useState("schedule_call"),[Re,Te]=C.useState("Schedule a Call"),[qe,ct]=C.useState(""),[De,Rt]=C.useState(""),[pe,Je]=C.useState(null),[lt,rt]=C.useState(s||null),[Se,it]=C.useState(null),[$e,ot]=C.useState(!1),Ue=async(jt,As)=>{if(!r)return;const Ps=5*1024*1024;if(jt.size>Ps){me.error("Image must be under 5MB");return}if(!jt.type.startsWith("image/")){me.error("Please upload an image file");return}Je(As);try{const ar=jt.name.split(".").pop()||"jpg",Dn=`${r.id}/${Date.now()}.${ar}`,{error:Va}=await G.storage.from("listing-photos").upload(Dn,jt);if(Va)throw Va;const{data:{publicUrl:pa}}=G.storage.from("listing-photos").getPublicUrl(Dn);Et(As,{image_url:pa}),me.success("Image uploaded")}catch{me.error("Failed to upload image")}finally{Je(null)}};C.useEffect(()=>{s&&Ke(s)},[s]);const Ke=async jt=>{const{data:As,error:Ps}=await G.from("smart_presentations").select("*").eq("id",jt).single();if(Ps||!As)return;const ar=As;if(w(!0),ke(ar.title),X(ar.client_name||""),he(ar.property_address||""),be(ar.sections||[]),Ae(ar.cta_type||"schedule_call"),Te(ar.cta_label||"Schedule a Call"),ct(ar.cta_url||""),Rt(ar.heading||""),it(ar.share_token),ot(ar.status==="published"),rt(ar.id),_("builder"),ar.contact_id){const{data:Dn}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",ar.contact_id).maybeSingle();Dn&&($(Dn),ee(Dn.email||""),de(Dn.phone||""))}};C.useEffect(()=>{if(!r||j.length<1){T([]);return}const jt=setTimeout(async()=>{L(!0);const{data:As}=await G.from("innercircle_contacts").select("id, first_name, last_name, email, phone, lead_source").eq("owner_user_id",r.id).or(`first_name.ilike.%${j}%,last_name.ilike.%${j}%,email.ilike.%${j}%`).limit(10);T(As||[]),L(!1)},300);return()=>clearTimeout(jt)},[j,r]);const Xe=jt=>{$(jt),X(`${jt.first_name} ${jt.last_name||""}`.trim()),ee(jt.email||""),de(jt.phone||""),U(!1)},He=async()=>{if(!V.trim()){me.error("Client name is required");return}const jt=V.trim().split(" "),As=jt[0],Ps=jt.slice(1).join(" ")||null,{data:ar,error:Dn}=await G.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:As,last_name:Ps,email:se||null,phone:Q||null,lead_source:"Smart Presentation"}).select().single();if(Dn){me.error("Failed to create client");return}$(ar),me.success("Client created & saved to Agent OS"),_("template")},Ye=jt=>{ye(jt);const As=(jt.sections||[]).map(Ps=>({...Ps,is_visible:!0,video_url:"",text:""}));if(be(As),ke(jt.name+(V?` for ${V}`:"")),jt.cta_config){const Ps=jt.cta_config;Ae(Ps.type||"schedule_call"),Te(Ps.label||"Schedule a Call")}_("builder")},tt=()=>{be([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),ke(V?`Presentation for ${V}`:"New Presentation"),_("builder")},Et=(jt,As)=>{be(Ps=>Ps.map((ar,Dn)=>Dn===jt?{...ar,...As}:ar))},qt=jt=>{Et(jt,{is_visible:!We[jt].is_visible})},ms=()=>{be(jt=>[...jt,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},Xt=jt=>{be(As=>As.filter((Ps,ar)=>ar!==jt))},rs=async()=>{if(!je.trim()){me.error("Title is required");return}try{if(lt){const jt=await l.mutateAsync({id:lt,title:je,sections:We,client_name:V,property_address:le||null,cta_type:Me,cta_label:Re,cta_url:qe||null,heading:De||null});me.success("Saved")}else{const jt=await o.mutateAsync({title:je,contact_id:(R==null?void 0:R.id)||void 0,client_name:V,property_address:le||void 0,template_id:(we==null?void 0:we.id)||void 0,sections:We,cta_type:Me,cta_label:Re,cta_url:qe||void 0,heading:De||void 0});rt(jt.id),it(jt.share_token),me.success("Presentation created!")}}catch(jt){console.error("Failed to save presentation:",jt);const As=(jt==null?void 0:jt.message)||(jt==null?void 0:jt.toString())||"Unknown error";me.error(`Failed to save: ${As}`)}},ps=async()=>{try{await rs();const jt=lt;if(jt){const As=await i.mutateAsync(jt);it(As.share_token),ot(!0),_("share")}}catch(jt){console.error("Failed to publish presentation:",jt),me.error(`Failed to publish: ${(jt==null?void 0:jt.message)||"Unknown error"}`)}},Ms=Se?`https://presentations.relevelup.com/${Se}`:"";return e.jsx(Es,{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(di,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-serif font-bold text-foreground",children:b?"Edit Presentation":"Create Smart Presentation"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[y==="client"&&"Who is this presentation for?",y==="template"&&"Choose a starting template",y==="builder"&&"Customize your presentation",y==="share"&&"Share with your client"]})]})]}),!b&&e.jsx("div",{className:"flex items-center gap-2",children:["client","template","builder","share"].map((jt,As)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:At("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",y===jt?"bg-primary text-primary-foreground":As<["client","template","builder","share"].indexOf(y)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:As<["client","template","builder","share"].indexOf(y)?e.jsx(ma,{className:"h-4 w-4"}):As+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:jt}),As<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},jt))}),y==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{$(null),X(""),ee(""),de(""),U(!1),_("template")},className:"w-full group flex items-center justify-between gap-4 rounded-xl border border-dashed border-primary/30 bg-primary/5 hover:bg-primary/10 transition-all p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(oa,{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(Ki,{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(It,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(xn,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search by name or email...",value:j,onChange:jt=>N(jt.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[I&&e.jsx(xs,{className:"h-12 w-full"}),S.map(jt=>e.jsxs("button",{onClick:()=>Xe(jt),className:At("w-full text-left p-3 rounded-lg border transition-colors",(R==null?void 0:R.id)===jt.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[jt.first_name," ",jt.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:jt.email||jt.phone||"No contact info"})]},jt.id)),!j&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),j&&S.length===0&&!I&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No clients found"})]}),R&&e.jsxs(K,{onClick:()=>_("template"),className:"w-full gap-2",children:["Continue with ",R.first_name,e.jsx(Ki,{className:"h-4 w-4"})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Pc,{className:"h-4 w-4 text-muted-foreground"}),"Add New Client"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(_e,{className:"text-xs",children:"Name *"}),e.jsx(Fe,{value:V,onChange:jt=>{X(jt.target.value),U(!0),$(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Email"}),e.jsx(Fe,{value:se,onChange:jt=>ee(jt.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Phone"}),e.jsx(Fe,{value:Q,onChange:jt=>de(jt.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Client Type"}),e.jsxs(rr,{value:re,onValueChange:ne,children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"buyer",children:"Buyer"}),e.jsx(Tt,{value:"seller",children:"Seller"}),e.jsx(Tt,{value:"recruit",children:"Recruit"}),e.jsx(Tt,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Property Address"}),e.jsx(Fe,{value:le,onChange:jt=>he(jt.target.value),placeholder:"Optional"})]})]}),q&&V&&e.jsxs(K,{onClick:He,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(Ki,{className:"h-4 w-4"})]})]})]})]})]}),y==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Aa,{defaultValue:"system",children:[e.jsxs(ja,{children:[e.jsx(js,{value:"mine",children:"My Core Templates"}),e.jsx(js,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(js,{value:"blank",children:"+ Start Blank"})]}),e.jsx($s,{value:"mine",className:"mt-4",children:a?e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[1,2].map(jt=>e.jsx(xs,{className:"h-32"},jt))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(jt=>!jt.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(jt=>!jt.is_system).map(jt=>e.jsx(hze,{template:jt,onSelect:Ye},jt.id))})}),e.jsx($s,{value:"system",className:"mt-4",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(jt=>jt.is_system).map(jt=>e.jsx(hze,{template:jt,onSelect:Ye},jt.id))})}),e.jsx($s,{value:"blank",className:"mt-4",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start with a blank canvas and add your own sections."}),e.jsx(K,{onClick:tt,children:"Start from Scratch"})]})})})]}),e.jsxs(K,{variant:"outline",onClick:()=>_("client"),className:"gap-2",children:[e.jsx(di,{className:"h-4 w-4"}),"Back"]})]}),y==="builder"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Presentation Title"}),e.jsx(Fe,{value:je,onChange:jt=>ke(jt.target.value)})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Page Heading"}),e.jsx(Fe,{value:De,onChange:jt=>Rt(jt.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(_e,{children:"Client Name"}),e.jsx(Fe,{value:V,onChange:jt=>X(jt.target.value)})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Property Address"}),e.jsx(Fe,{value:le,onChange:jt=>he(jt.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:ms,children:"+ Add Section"})]}),e.jsx("div",{className:"space-y-3",children:We.map((jt,As)=>e.jsx(Ee,{className:At(!jt.is_visible&&"opacity-50"),children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 pt-1",children:[e.jsx(yh,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:jt.icon})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Fe,{value:jt.title,onChange:Ps=>Et(As,{title:Ps.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:()=>qt(As),children:jt.is_visible?e.jsx(va,{className:"h-4 w-4"}):e.jsx(xp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Xt(As),className:"text-destructive hover:text-destructive",children:e.jsx(jr,{className:"h-4 w-4"})})]})]}),e.jsx(Fe,{value:jt.description||"",onChange:Ps=>Et(As,{description:Ps.target.value}),placeholder:"Section description...",className:"text-sm"}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(_e,{className:"text-xs",children:"Video URL"}),e.jsx(Fe,{value:jt.video_url||"",onChange:Ps=>Et(As,{video_url:Ps.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(LSs,{sectionTitle:jt.title,contactId:R==null?void 0:R.id,onVideoReady:Ps=>Et(As,{video_url:Ps})}),e.jsx(DSs,{sectionTitle:jt.title,contactId:R==null?void 0:R.id,onVideoReady:Ps=>Et(As,{video_url:Ps})}),e.jsx(RSe,{userId:r==null?void 0:r.id,onSelect:Ps=>Et(As,{video_url:Ps})})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),jt.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:jt.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:()=>Et(As,{image_url:""}),children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]}):e.jsxs("label",{className:"mt-1 flex items-center gap-2 cursor-pointer rounded-lg border border-dashed border-border hover:border-primary/50 p-3 transition-colors",children:[pe===As?e.jsx(Ss,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(Qv,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:pe===As?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:pe===As,onChange:Ps=>{var Dn;const ar=(Dn=Ps.target.files)==null?void 0:Dn[0];ar&&Ue(ar,As),Ps.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Text (optional)"}),e.jsx(iy,{content:jt.text||"",onChange:Ps=>Et(As,{text:Ps}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},As))})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Call to Action"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"CTA Type"}),e.jsxs(rr,{value:Me,onValueChange:jt=>{Ae(jt);const As=dze.find(Ps=>Ps.value===jt);As&&Te(As.label)},children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:dze.map(jt=>e.jsx(Tt,{value:jt.value,children:jt.label},jt.value))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Button Label"}),e.jsx(Fe,{value:Re,onChange:jt=>Te(jt.target.value)})]}),e.jsxs("div",{children:[e.jsxs(_e,{children:["Link URL ",e.jsx("span",{className:"text-muted-foreground",children:"(optional — leave blank to show a lead capture form instead)"})]}),e.jsx(Fe,{value:qe,onChange:jt=>ct(jt.target.value),placeholder:"https://calendly.com/..."}),!qe&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Without a URL, clients will see a contact form — their info gets added to your contacts and you'll receive an email notification."})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[!b&&e.jsxs(K,{variant:"outline",onClick:()=>_("template"),className:"gap-2",children:[e.jsx(di,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(K,{variant:"outline",onClick:rs,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(K,{onClick:ps,disabled:i.isPending,className:"gap-2",children:[e.jsx(oa,{className:"h-4 w-4"}),$e?"Update & Reshare":"Publish & Share"]})]})]})]}),y==="share"&&Se&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mb-4",children:e.jsx(ma,{className:"h-8 w-8 text-emerald-600"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your Presentation is Live!"}),e.jsxs("p",{className:"text-muted-foreground mb-6 max-w-md",children:["Share this link with ",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(Fe,{value:Ms,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(K,{onClick:()=>{navigator.clipboard.writeText(Ms),me.success("Link copied!")},children:e.jsx(mi,{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 jt=`Hi ${V||""}! I put together something for you — check it out: ${Ms}`;navigator.clipboard.writeText(jt),me.success("Message copied!")},children:[e.jsx(po,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{c?f(!0):window.open(`mailto:${se||""}?subject=${encodeURIComponent(je)}&body=${encodeURIComponent(`Hi ${(R==null?void 0:R.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${Ms} Looking forward to connecting!`)}`)},children:[e.jsx(br,{className:"h-4 w-4"}),"Send Email"]})]}),c&&e.jsx(iE,{open:p,onOpenChange:f,contact:R?{id:R.id,first_name:R.first_name,last_name:R.last_name,email:se||R.email||""}:se?{id:"",first_name:(V==null?void 0:V.split(" ")[0])||"",last_name:(V==null?void 0:V.split(" ").slice(1).join(" "))||"",email:se}:void 0,defaultSubject:je,defaultBody:`Hi ${(R==null?void 0:R.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${Ms} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(K,{variant:"outline",onClick:()=>_("builder"),children:[e.jsx(di,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(K,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},hze=({template:t,onSelect:s})=>e.jsx(Ee,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(Oe,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:t.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(nt,{variant:"outline",className:"text-xs capitalize",children:t.template_type}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(t.sections||[]).length," sections"]})]})]})]}),e.jsx(K,{className:"w-full mt-4",size:"sm",onClick:()=>s(t),children:"Use Template"})]})}),OSs=()=>{var w;const{shareToken:t}=Po(),[s,r]=C.useState(null),[n,a]=C.useState(!0),[o,l]=C.useState(0),[i,c]=C.useState(!1);C.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),C.useEffect(()=>{t&&u()},[t]);const u=async()=>{const{data:j,error:N}=await G.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(N||!j){c(!0),a(!1);return}const{data:S}=await G.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",j.owner_user_id).single();let T;if(S!=null&&S.brokerage_id){const{data:L}=await G.from("brokerages").select("name").eq("id",S.brokerage_id).single();T=(L==null?void 0:L.name)||void 0}let I=null;if(j.contact_id){const{data:L}=await G.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",j.contact_id).single();I=L}r({...j,owner_name:S==null?void 0:S.name,owner_email:S==null?void 0:S.email,owner_phone:S==null?void 0:S.phone,owner_avatar:S==null?void 0:S.avatar_url,owner_title:(S==null?void 0:S.title)||void 0,brokerage_name:T,contact_name:I?[I.first_name,I.last_name].filter(Boolean).join(" "):void 0,contact_email:(I==null?void 0:I.email)||void 0,contact_phone:(I==null?void 0:I.phone)||void 0}),a(!1);try{await G.rpc("log_presentation_view",{p_presentation_id:j.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(s){try{await G.rpc("log_presentation_view",{p_presentation_id:s.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}s.cta_url&&window.open(s.cta_url,"_blank")}};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(xs,{className:"h-12 w-3/4 mx-auto"}),e.jsx(xs,{className:"h-64 w-full"}),e.jsx(xs,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!s)return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),e.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const f=s.sections.filter(j=>j.is_visible!==!1),y=f[o],_=j=>{const N=j.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(N)return`https://www.youtube.com/embed/${N[1]}?rel=0`;if(j.includes("iframe.mediadelivery.net/play/")){const I=j.replace("/play/","/embed/"),L=I.includes("?")?"&":"?";return`${I}${L}responsive=true`}if(j.includes("iframe.mediadelivery.net")){if(j.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const L=j.includes("?")?"&":"?";return`${j}${L}responsive=true`}return""}const S=j.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(S)return`https://www.loom.com/embed/${S[1]}`;const T=j.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return T?`https://iframe.mediadelivery.net/embed/${T[1]}/${T[2]}?responsive=true`:j},b=!!((w=s.cta_url)!=null&&w.trim());return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex items-center gap-3",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),e.jsxs("div",{className:"text-right text-sm",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.owner_title}),s.brokerage_name&&!s.owner_title&&e.jsx("p",{className:"text-gray-500 text-xs",children:s.brokerage_name})]})]})]})}),e.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:s.heading||(s.client_name?`Welcome, ${s.client_name}!`:s.title)}),s.property_address&&e.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",e.jsx("strong",{children:s.property_address}),"."]})]}),e.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[e.jsxs("div",{className:"md:col-span-3",children:[y!=null&&y.video_url&&_(y.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:_(y.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"})}):y!=null&&y.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:y.image_url,alt:y.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:y==null?void 0:y.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:y==null?void 0:y.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:y==null?void 0:y.description})]}),(y==null?void 0:y.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:y.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:f.map((j,N)=>e.jsx("button",{onClick:()=>l(N),className:At("w-full text-left p-4 rounded-xl border transition-all",o===N?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(N+1).padStart(2,"0"),"."]}),e.jsxs("div",{children:[e.jsx("span",{className:"mr-2",children:j.icon}),e.jsx("span",{className:"font-semibold text-gray-900",children:j.title}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:j.description})]})]})},N))})]}),e.jsxs("div",{className:"mt-12 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6 text-center",children:[s.owner_avatar&&e.jsx("img",{src:s.owner_avatar,alt:s.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:s.owner_name}),s.owner_title&&e.jsx("p",{className:"text-sm text-gray-500",children:s.owner_title}),s.brokerage_name&&e.jsx("p",{className:"text-sm text-gray-500",children:s.brokerage_name}),e.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[s.owner_phone&&e.jsx("a",{href:`tel:${s.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:s.owner_phone}),s.owner_email&&e.jsx("a",{href:`mailto:${s.owner_email}`,className:"hover:text-blue-600 transition-colors",children:s.owner_email})]})]}),s.cta_label&&e.jsxs("div",{className:"text-center mt-8 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),b?e.jsxs(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(rn,{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(CWe,{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 RSs({openHouseId:t,enableSurvey:s,onToggleSurvey:r}){const{data:n,isLoading:a}=tNt(t),o=aNt(),l=iNt(),i=oNt(),c=lNt(),[u,p]=C.useState(""),[f,y]=C.useState("rating"),_=async N=>{r(N),N&&(!n||n.length===0)&&await c.mutateAsync(t)},b=async()=>{if(!u.trim())return;const N=(n==null?void 0:n.reduce((S,T)=>Math.max(S,T.sort_order),0))??0;await o.mutateAsync({open_house_id:t,question_type:f,question_text:u.trim(),sort_order:N+1}),p("")},w=async N=>{await l.mutateAsync({id:N.id,open_house_id:t,is_active:!N.is_active})},j=async N=>{await i.mutateAsync({id:N.id,open_house_id:t})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(_e,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ab,{className:"h-4 w-4"}),"Property Feedback Survey"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show a quick feedback survey after visitors sign in"})]}),e.jsx(Br,{checked:s,onCheckedChange:_})]}),s&&e.jsx("div",{className:"space-y-3 pt-2 border-t border-border",children:a?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(Ss,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-2",children:n==null?void 0:n.map(N=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-muted/20",children:[e.jsx(yh,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm truncate",children:N.question_text}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:N.question_type.replace("_"," ")})]}),e.jsx(Br,{checked:N.is_active,onCheckedChange:()=>w(N),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>j(N),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]},N.id))}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(_e,{className:"text-xs text-muted-foreground",children:"Add Question"}),e.jsx(Fe,{value:u,onChange:N=>p(N.target.value),placeholder:"e.g. How did you hear about this listing?",className:"mt-1 h-9 text-sm",onKeyDown:N=>N.key==="Enter"&&b()})]}),e.jsxs(rr,{value:f,onValueChange:y,children:[e.jsx(tr,{className:"w-28 h-9 text-xs",children:e.jsx(nr,{})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"rating",children:"Rating"}),e.jsx(Tt,{value:"open_text",children:"Text"})]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:b,disabled:!u.trim()||o.isPending,className:"h-9",children:e.jsx(Zs,{className:"h-3.5 w-3.5"})})]})]})})]})}function FSs({open:t,onOpenChange:s,openHouse:r}){const n=TWe(),{user:a}=Ws(),o=C.useRef(null),[l,i]=C.useState(r.auto_forward_to_card??!1),[c,u]=C.useState(r.disclosure_pdf_url??""),[p,f]=C.useState(r.enable_survey??!1),[y,_]=C.useState(!1),[b,w]=C.useState(!1),j=async T=>{var q;const I=(q=T.target.files)==null?void 0:q[0];if(!I||!a)return;if(I.size>20*1024*1024){fn({title:"File must be under 20MB",variant:"destructive"});return}if(I.type!=="application/pdf"){fn({title:"Only PDF files are accepted",variant:"destructive"});return}_(!0);const L=`${a.id}/disclosures/${r.id}-${Date.now()}.pdf`,{error:R}=await G.storage.from("open-house-photos").upload(L,I,{upsert:!0});if(R){fn({title:"Upload failed",description:R.message,variant:"destructive"}),_(!1);return}const{data:$}=G.storage.from("open-house-photos").getPublicUrl(L);u($.publicUrl),_(!1),fn({title:"PDF uploaded!"})},N=()=>{u(""),o.current&&(o.current.value="")},S=async()=>{w(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:l,disclosure_pdf_url:c||null,enable_survey:p}),fn({title:"Settings saved!"}),s(!1)}catch{fn({title:"Failed to save",variant:"destructive"})}finally{w(!1)}};return e.jsx(_s,{open:t,onOpenChange:s,children:e.jsxs(vs,{className:"sm:max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Guest Book Settings"}),e.jsx(Zr,{className:"truncate",children:r.property_address})]}),e.jsxs("div",{className:"space-y-6 pt-2",children:[e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Auto-forward to Digital Card"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"After check-in, redirect visitors to your digital business card"})]}),e.jsx(Br,{checked:l,onCheckedChange:i})]})}),!l&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{className:"text-sm font-medium",children:"Seller's Disclosures (PDF)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visitors can view or download this on the thank you screen after check-in"}),e.jsx("input",{ref:o,type:"file",accept:"application/pdf",onChange:j,className:"hidden"}),c?e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-border bg-muted/30",children:[e.jsx(In,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm truncate flex-1",children:"Disclosure PDF uploaded"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:N,children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsx("button",{type:"button",onClick:()=>{var T;return(T=o.current)==null?void 0:T.click()},disabled:y,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:y?e.jsx(Ss,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(ni,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload PDF (max 20MB)"})]})})]}),e.jsx(RSs,{openHouseId:r.id,enableSurvey:p,onToggleSurvey:f}),e.jsx(K,{onClick:S,disabled:b,className:"w-full",children:b?"Saving...":"Save Settings"})]})]})})}const Plt={5:"Excellent",4:"Good",3:"Neutral",2:"Bad",1:"Very Bad"};function zSs({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:Plt[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 BSs({openHouseId:t}){const{data:s,isLoading:r}=nNt(t),{data:n}=MWe(t),a=C.useMemo(()=>{const f={};return n==null||n.forEach(y=>{f[y.id]=y}),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(It,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Ab,{className:"h-4 w-4"}),"Survey Results"]})}),e.jsx(Oe,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No survey responses yet."})})]}):e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-3",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Ab,{className:"h-4 w-4"}),"Survey Results",e.jsxs("span",{className:"text-xs font-normal text-muted-foreground ml-auto",children:[p," respondent",p!==1?"s":""]})]})}),e.jsx(Oe,{children:e.jsxs(Aa,{defaultValue:"summary",children:[e.jsxs(ja,{className:"mb-4",children:[e.jsxs(js,{value:"summary",className:"text-xs gap-1",children:[e.jsx(xl,{className:"h-3.5 w-3.5"})," Summary"]}),e.jsxs(js,{value:"individual",className:"text-xs gap-1",children:[e.jsx(ro,{className:"h-3.5 w-3.5"})," Per Visitor"]})]}),e.jsxs($s,{value:"summary",className:"space-y-6",children:[i.map(f=>e.jsx(zSs,{question:f,responses:l},f.id)),c.map(f=>{const y=l.filter(_=>_.question_id===f.id&&_.text_value);return y.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:y.map(_=>{const b=a[_.visitor_id];return e.jsxs("div",{className:"text-sm p-2 bg-muted/30 rounded-lg",children:[e.jsxs("span",{className:"text-muted-foreground text-xs",children:[b?`${b.first_name} ${b.last_name||""}`.trim():"Visitor",":"]}),e.jsx("p",{className:"mt-0.5",children:_.text_value})]},_.id)})})]},f.id)})]}),e.jsx($s,{value:"individual",className:"space-y-4",children:u.map(f=>{const y=a[f],_=l.filter(b=>b.visitor_id===f);return e.jsxs("div",{className:"p-3 rounded-lg border border-border space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium",children:[y?`${y.first_name} ${y.last_name||""}`.trim():"Unknown Visitor",(y==null?void 0:y.email)&&e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:y.email})]}),e.jsx("div",{className:"space-y-1",children:_.map(b=>{const w=o.find(j=>j.id===b.question_id);return w?e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:w.question_text}),e.jsx("span",{className:"font-medium",children:b.rating_value!=null?Plt[b.rating_value]||b.rating_value:b.text_value})]},b.id):null})})]},f)})})]})})]})}const s2e="guestbook.relevelup.com";function $Ss(){const{data:t,isLoading:s}=Xkt(),r=Qkt(),n=TWe(),a=Jkt(),[o,l]=C.useState(!1),[i,c]=C.useState(null),{user:u}=Ws(),p=ai(),[f,y]=C.useState(null),[_,b]=C.useState(null),[w,j]=C.useState(!1),N=C.useRef(null),[S,T]=C.useState({property_address:"",city:"",state:"",zip:"",event_date:ys(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),I=q=>{var V;const U=(V=q.target.files)==null?void 0:V[0];if(U){if(U.size>5*1024*1024){fn({title:"Photo must be under 5MB",variant:"destructive"});return}y(U),b(URL.createObjectURL(U))}},L=()=>{y(null),b(null),N.current&&(N.current.value="")},R=async()=>{if(!S.property_address){fn({title:S.event_type==="community"?"Event name is required":"Address is required",variant:"destructive"});return}let q;if(f&&u){j(!0);const U=f.name.split(".").pop(),V=`${p}/${Date.now()}.${U}`,{error:X}=await G.storage.from("open-house-photos").upload(V,f,{upsert:!0});if(X){fn({title:"Photo upload failed",description:X.message,variant:"destructive"}),j(!1);return}const{data:se}=G.storage.from("open-house-photos").getPublicUrl(V);q=se.publicUrl,j(!1)}await r.mutateAsync({...S,photo_url:q}),l(!1),T({property_address:"",city:"",state:"",zip:"",event_date:ys(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),L()},$=q=>{navigator.clipboard.writeText(`https://${s2e}/${q}`),fn({title:"Link copied!"})};return e.jsxs(Es,{title:"Guest Book",children:[e.jsx(qh,{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(_s,{open:o,onOpenChange:l,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"New Open House"]})}),e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"Create Open House"}),e.jsx(Zr,{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:()=>T(q=>({...q,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:()=>T(q=>({...q,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(_e,{children:S.event_type==="community"?"Event Name *":"Property Address *"}),e.jsx(Fe,{value:S.property_address,onChange:q=>T(U=>({...U,property_address:q.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(_e,{children:"City"}),e.jsx(Fe,{value:S.city,onChange:q=>T(U=>({...U,city:q.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"State"}),e.jsx(Fe,{value:S.state,onChange:q=>T(U=>({...U,state:q.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"ZIP"}),e.jsx(Fe,{value:S.zip,onChange:q=>T(U=>({...U,zip:q.target.value})),placeholder:"78701"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Date"}),e.jsx(Fe,{type:"date",value:S.event_date,onChange:q=>T(U=>({...U,event_date:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Start Time"}),e.jsx(Fe,{type:"time",value:S.start_time,onChange:q=>T(U=>({...U,start_time:q.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"End Time"}),e.jsx(Fe,{type:"time",value:S.end_time,onChange:q=>T(U=>({...U,end_time:q.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Welcome Message"}),e.jsx(Ar,{value:S.agent_greeting,onChange:q=>T(U=>({...U,agent_greeting:q.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(_e,{children:S.event_type==="community"?"Event Photo":"Property Photo"}),e.jsx("input",{ref:N,type:"file",accept:"image/*",onChange:I,className:"hidden"}),_?e.jsxs("div",{className:"relative mt-1 rounded-xl overflow-hidden border border-border",children:[e.jsx("img",{src:_,alt:"Property preview",className:"w-full h-40 object-cover"}),e.jsx("button",{type:"button",onClick:L,className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white rounded-full p-1 transition-colors",children:e.jsx(Ur,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var q;return(q=N.current)==null?void 0:q.click()},className:"mt-1 w-full h-32 rounded-xl border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(Qv,{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:R,disabled:r.isPending||w,className:"w-full",children:w?"Uploading photo...":r.isPending?"Creating...":S.event_type==="community"?"Create Community Event":"Create Open House"})]})]})]})]}),s?e.jsx("div",{className:"grid gap-4",children:[1,2].map(q=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(It,{children:[e.jsx("div",{className:"h-5 bg-muted rounded w-48"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 mt-2"})]})},q))}):t!=null&&t.length?e.jsx("div",{className:"space-y-4",children:t.map(q=>e.jsx(qSs,{openHouse:q,isExpanded:i===q.id,onToggle:()=>c(i===q.id?null:q.id),onCopyLink:()=>$(q.slug||""),onToggleActive:()=>n.mutate({id:q.id,is_active:!q.is_active}),onDelete:()=>a.mutate(q.id)},q.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(r1,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No Open Houses Yet"}),e.jsx("p",{className:"text-muted-foreground text-sm max-w-sm mb-6",children:"Create your first open house to get a beautiful, mobile-friendly sign-in page with a shareable link and QR code."}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function qSs({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=MWe(s?t.id:void 0),[i,c]=C.useState(!1),[u,p]=C.useState(!1),[f,y]=C.useState(!1),_=C.useRef(null),b=`https://${s2e}/${t.slug}`,w=I=>{if(!I)return"";const[L,R]=I.split(":"),$=parseInt(L),q=$>=12?"PM":"AM";return`${$>12?$-12:$||12}:${R} ${q}`},j=()=>{if(!(l!=null&&l.length))return;const I=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],L=l.map(V=>[V.first_name,V.last_name||"",V.email||"",V.phone||"",V.visitor_intent||"",V.wants_market_updates?"Yes":"No",(V.message||"").replace(/"/g,'""'),ys(new Date(V.created_at),"MM/dd/yyyy h:mm a")]),R=[I,...L].map(V=>V.map(X=>`"${X}"`).join(",")).join(` `),$=new Blob([R],{type:"text/csv"}),q=URL.createObjectURL($),U=document.createElement("a");U.href=q,U.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,U.click(),URL.revokeObjectURL(q)},N=C.useCallback(()=>{if(!_.current)return;const I=_.current.querySelector("svg");if(!I)return;const L=new XMLSerializer().serializeToString(I),R=document.createElement("canvas");R.width=1024,R.height=1024;const $=R.getContext("2d"),q=new Image;q.onload=()=>{$==null||$.drawImage(q,0,0,1024,1024);const U=document.createElement("a");U.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-qr.png`,U.href=R.toDataURL("image/png"),U.click()},q.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(L)))},[t.property_address]),S=C.useCallback(()=>{if(!_.current)return;const I=_.current.querySelector("svg");if(!I)return;const L=new XMLSerializer().serializeToString(I),R="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(L))),$=ys(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),q=t.start_time?`${w(t.start_time)}${t.end_time?" – "+w(t.end_time):""}`:"",U=[t.city,t.state].filter(Boolean).join(", "),V=t.agent_greeting||"Welcome! Please sign in below.",X=window.open("","_blank");X&&(X.document.write(` Open House – ${t.property_address}
${t.event_type==="community"?"Community Event":"Open House"}
${t.property_address}
${U?`
${U}${t.zip?" "+t.zip:""}
`:""}
Date
${$}
${q?`
Time
${q}
`:""}
${V}
QR Code
Scan to Sign In
Point your phone camera at the QR code
`),X.document.close(),setTimeout(()=>{X.focus(),X.print()},500))},[t,b]),T=async()=>{y(!0);try{const{error:I}=await G.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(I)throw I;fn({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(I){fn({title:"Failed to send",description:I.message,variant:"destructive"})}finally{y(!1)}};return e.jsxs(Ee,{className:`transition-all ${t.is_active?"border-primary/30":"opacity-75"}`,children:[e.jsx(It,{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(Ot,{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(nt,{variant:t.is_active?"default":"secondary",className:"shrink-0 text-[11px]",children:t.is_active?"Active":"Inactive"}),t.agent_name&&e.jsxs(nt,{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(ro,{className:"h-3 w-3"}),t.agent_name]}),t.event_type==="community"&&e.jsxs(nt,{variant:"outline",className:"shrink-0 gap-1 text-[11px]",children:[e.jsx(La,{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(Hx,{className:"h-4 w-4"}):e.jsx(tl,{className:"h-4 w-4"})})]}),e.jsxs(fr,{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(Ui,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:"h-3 w-3"}),ys(new Date(t.event_date+"T00:00:00"),"MMM d, yyyy")]}),t.start_time&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),w(t.start_time),t.end_time?` – ${w(t.end_time)}`:""]}),e.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[e.jsx(mr,{className:"h-3 w-3"}),t.visitor_count," visitors"]})]}),e.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto pb-1 -mx-1 px-1 scrollbar-hide",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.location.href=`/mission-control/guest-book/live/${t.id}`,title:"Go Live",className:"shrink-0 gap-1.5 text-emerald-600 border-emerald-200 hover:bg-emerald-50 dark:text-emerald-400 dark:border-emerald-800 dark:hover:bg-emerald-900/20 h-8 text-xs",children:[e.jsx(n1,{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(mi,{className:"h-3.5 w-3.5"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>c(!0),title:"QR Code",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(r1,{className:"h-3.5 w-3.5"}),"QR"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>p(!0),title:"Settings",className:"shrink-0 h-8 text-xs",children:e.jsx(Jl,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>window.open(b,"_blank"),title:"Preview",className:"shrink-0 h-8 text-xs",children:e.jsx(rn,{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(xp,{className:"h-3.5 w-3.5"}):e.jsx(va,{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(jr,{className:"h-3.5 w-3.5"})})]})]})}),s&&e.jsxs(Oe,{className:"pt-0",children:[e.jsx(Zl,{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://",s2e,"/",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:j,className:"h-7 text-xs gap-1",children:[e.jsx(ki,{className:"h-3 w-3"}),"Export CSV"]})]}),e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-muted/30 text-xs text-muted-foreground",children:[e.jsx("th",{className:"text-left p-2 font-medium",children:"Name"}),e.jsx("th",{className:"text-left p-2 font-medium hidden sm:table-cell",children:"Contact"}),e.jsx("th",{className:"text-left p-2 font-medium hidden md:table-cell",children:"Intent"}),e.jsx("th",{className:"text-left p-2 font-medium",children:"Time"})]})}),e.jsx("tbody",{children:l.map(I=>e.jsxs("tr",{className:"border-t border-border/50",children:[e.jsxs("td",{className:"p-2 font-medium",children:[I.first_name,I.last_name?` ${I.last_name}`:""]}),e.jsxs("td",{className:"p-2 text-muted-foreground hidden sm:table-cell",children:[I.email&&e.jsx("div",{className:"truncate max-w-[180px]",children:I.email}),I.phone&&e.jsx("div",{className:"text-xs",children:I.phone})]}),e.jsx("td",{className:"p-2 hidden md:table-cell",children:I.visitor_intent&&e.jsx(nt,{variant:"outline",className:"text-xs capitalize",children:I.visitor_intent})}),e.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:ys(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(BSs,{openHouseId:t.id})})]}),e.jsx(_s,{open:i,onOpenChange:c,children:e.jsxs(vs,{className:"sm:max-w-sm",children:[e.jsxs(Cs,{children:[e.jsx(Ns,{children:"QR Code"}),e.jsx(Zr,{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(nR,{value:b,size:240,level:"H"})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:b}),e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:N,children:[e.jsx(ki,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:S,children:[e.jsx(tL,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(K,{variant:"default",className:"w-full",onClick:T,disabled:f,children:[e.jsx(br,{className:"h-4 w-4 mr-2"}),f?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(FSs,{open:u,onOpenChange:p,openHouse:t})]})}function USs(){const{slug:t}=Po();return t?e.jsx(sZe,{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 Ilt({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=Ws(),l=nC(),i=C.useRef(null),c=C.useRef(null),[u,p]=C.useState(!1),[f,y]=C.useState(!1),[_,b]=C.useState(0),w=async N=>{if(o){p(!0);try{const S=N.name.split(".").pop()||"jpg",T=`${o.id}/card-${Date.now()}.${S}`,{error:I}=await G.storage.from("listing-photos").upload(T,N);if(I)throw I;const{data:{publicUrl:L}}=G.storage.from("listing-photos").getPublicUrl(T);r(L),me.success("Photo uploaded")}catch(S){me.error(S.message||"Failed to upload photo")}finally{p(!1)}}},j=async N=>{if(o){if(N.size>500*1024*1024){me.error("Video must be under 500MB");return}y(!0),b(0);try{const{videoId:S,libraryId:T}=await GO(`Card Video - ${Date.now()}`),{uploadUrl:I,apiKey:L}=await KO(S);await new Promise((q,U)=>{const V=new XMLHttpRequest;V.upload.addEventListener("progress",X=>{X.lengthComputable&&b(Math.round(X.loaded/X.total*100))}),V.addEventListener("load",()=>{V.status>=200&&V.status<300?q():U(new Error("Upload failed"))}),V.addEventListener("error",()=>U(new Error("Upload failed"))),V.open("PUT",I),V.setRequestHeader("AccessKey",L),V.send(N)});const R=`https://iframe.mediadelivery.net/embed/${T}/${S}`;n(R);const $=parseFloat((N.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:S,playback_url:`https://iframe.mediadelivery.net/play/${T}/${S}`,file_size_mb:$,title:"Card Video",status:"processing",touch_type:"video",contact_id:a||void 0}),me.success("Video uploaded & added to your library")}catch(S){me.error(S.message||"Failed to upload video")}finally{y(!1),b(0)}}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(_e,{children:"Media (optional)"}),e.jsxs(Aa,{defaultValue:"photo",className:"w-full",children:[e.jsxs(ja,{className:"grid w-full grid-cols-2",children:[e.jsxs(js,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(cl,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(js,{value:"video",className:"gap-1.5 text-xs",children:[e.jsx(Nn,{className:"h-3.5 w-3.5"}),"Video"]})]}),e.jsxs($s,{value:"photo",className:"mt-3",children:[t?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("img",{src:t,alt:"Card photo",className:"w-full h-40 object-cover"}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>r(null),children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var N;return(N=i.current)==null?void 0:N.click()},disabled:u,className:"w-full h-32 border-2 border-dashed border-border rounded-lg flex flex-col items-center justify-center gap-2 text-muted-foreground hover:border-primary/40 hover:bg-accent/50 transition-colors",children:u?e.jsx(Ss,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Vx,{className:"h-6 w-6"}),e.jsx("span",{className:"text-xs",children:"Upload a photo"})]})}),e.jsx("input",{ref:i,type:"file",accept:"image/*",className:"hidden",onChange:N=>{var T;const S=(T=N.target.files)==null?void 0:T[0];S&&w(S),N.target.value=""}})]}),e.jsxs($s,{value:"video",className:"mt-3",children:[s?e.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[e.jsx("iframe",{src:`${s}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0}),e.jsx(K,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>n(null),children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var N;return(N=c.current)==null?void 0:N.click()},disabled:f,className:"w-full h-32 border-2 border-dashed border-border rounded-lg flex flex-col items-center justify-center gap-2 text-muted-foreground hover:border-primary/40 hover:bg-accent/50 transition-colors",children:f?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(Ss,{className:"h-6 w-6 animate-spin"}),e.jsxs("span",{className:"text-xs",children:["Uploading... ",_,"%"]}),e.jsx("div",{className:"w-32 h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${_}%`}})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ni,{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(FSe,{contactId:a,onVideoReady:N=>n(N)})}),e.jsx("input",{ref:c,type:"file",accept:"video/*",className:"hidden",onChange:N=>{var T;const S=(T=N.target.files)==null?void 0:T[0];S&&j(S),N.target.value=""}}),e.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1.5 text-center",children:"Videos are also saved to your Video Library"})]})]})]})}const VSs=[{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 HSs({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:VSs.map((s,r)=>e.jsxs(wr.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:r*.04,duration:.25},onClick:()=>t(s.type),className:`group relative flex flex-col items-start gap-1 p-3.5 rounded-xl border bg-gradient-to-br ${s.gradient} hover:shadow-md hover:scale-[1.02] active:scale-[0.98] transition-all text-left`,children:[e.jsx("span",{className:"text-2xl",children:s.emoji}),e.jsx("span",{className:"text-sm font-semibold text-foreground",children:s.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground leading-tight",children:s.description})]},s.type))})}const _E={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 mze({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Ws(),c=ss(),[u,p]=C.useState(!1),[f,y]=C.useState("type"),[_,b]=C.useState(""),[w,j]=C.useState(null),[N,S]=C.useState(!1),[T,I]=C.useState("home_anniversary"),[L,R]=C.useState(""),[$,q]=C.useState(""),[U,V]=C.useState(""),[X,se]=C.useState(""),[ee,Q]=C.useState("elegant"),[de,re]=C.useState(null),[ne,le]=C.useState(null),he=C.useState(!1);!he[0]&&t&&s&&(he[1](!0),p(!0),I(s),r&&j(r),n&&R(n),a&&q(a),o&&V(o),y(n?"details":"contact"));const{data:we}=wt({queryKey:["contacts-for-card",i==null?void 0:i.id,_],queryFn:async()=>{let qe=G.from("innercircle_contacts").select("id, first_name, last_name, address, city, state, home_anniversary, email, phone").eq("owner_user_id",i.id).order("first_name").limit(20);_&&(qe=qe.or(`first_name.ilike.%${_}%,last_name.ilike.%${_}%`));const{data:ct,error:De}=await qe;if(De)throw De;return ct},enabled:!!(i!=null&&i.id)&&u}),{data:ye}=wt({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:qe,error:ct}=await G.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(ct)throw ct;return qe},enabled:!!(i!=null&&i.id)}),je=qe=>{j(qe.id),R(`${qe.first_name}${qe.last_name?" "+qe.last_name:""}`),q([qe.address,qe.city,qe.state].filter(Boolean).join(", ")),V(qe.home_anniversary||""),y("details")},ke=qe=>{I(qe),y("contact")},We=async()=>{var qe;if(!(!i||!ye)){S(!0);try{const ct={owner_user_id:i.id,contact_id:w,card_type:T,template:ee,recipient_name:L,property_address:$||null,home_anniversary_date:U||null,custom_message:X||null,property_photo_url:de||null,video_url:ne||null,agent_name:ye.name||"Agent",agent_photo_url:ye.avatar_url,agent_phone:ye.phone,agent_email:ye.email,agent_brokerage:((qe=ye.brokerage)==null?void 0:qe.name)||null},{error:De}=await G.from("sendable_cards").insert(ct);if(De)throw De;me.success("Card created! Copy the link to share it."),c.invalidateQueries({queryKey:["sendable-cards"]}),be()}catch(ct){me.error(ct.message||"Failed to create card")}finally{S(!1)}}},be=()=>{p(!1),y("type"),I("home_anniversary"),b(""),j(null),R(""),q(""),V(""),se(""),Q("elegant"),re(null),le(null)},Me={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"},Ae=_E[T],Re=T==="home_anniversary",Te=["home_anniversary","just_listed","just_sold"].includes(T);return e.jsxs(_s,{open:u,onOpenChange:qe=>{qe?p(!0):(be(),l==null||l(!1))},children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{className:"gap-2",children:[e.jsx(Zs,{className:"h-4 w-4"}),"Create Card"]})}),e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:f==="type"?"What type of card?":f==="contact"?`${Me[T]} — Choose a Contact`:`${Me[T]} — Customize`})}),f==="type"&&e.jsx(HSs,{onSelect:ke}),f==="contact"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>y("type"),children:[e.jsx(di,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search contacts...",value:_,onChange:qe=>b(qe.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[we==null?void 0:we.map(qe=>e.jsxs("button",{onClick:()=>je(qe),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(ro,{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:[qe.first_name," ",qe.last_name]}),qe.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(Rn,{className:"h-3 w-3"}),qe.address]})]}),qe.home_anniversary&&T==="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"})]},qe.id)),(we==null?void 0:we.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:()=>{y("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:()=>y("contact"),children:[e.jsx(di,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Recipient Name"}),e.jsx(Fe,{value:L,onChange:qe=>R(qe.target.value),placeholder:"John & Jane Smith"})]}),Te&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Property Address"}),e.jsx(Fe,{value:$,onChange:qe=>q(qe.target.value),placeholder:"123 Main St, Austin, TX"})]}),Re&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Home Anniversary Date"}),e.jsx(Fe,{type:"date",value:U,onChange:qe=>V(qe.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Personal Message (optional)"}),e.jsx(Ar,{value:X,onChange:qe=>se(qe.target.value),placeholder:Ae.defaultMessage,rows:3})]}),e.jsx(Ilt,{photoUrl:de,videoUrl:ne,onPhotoChange:re,onVideoChange:le,contactId:w}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-5 gap-2",children:[{key:"elegant",label:"Elegant",gradient:"bg-gradient-to-br from-slate-100 to-blue-100 dark:from-slate-800 dark:to-slate-700"},{key:"bold",label:"Bold",gradient:"bg-gradient-to-br from-violet-500 to-fuchsia-500"},{key:"warm",label:"Warm",gradient:"bg-gradient-to-br from-amber-200 to-orange-300"},{key:"glass",label:"Glass",gradient:"bg-gradient-to-br from-slate-900 via-blue-900/50 to-slate-900 border border-white/10"},{key:"cinematic",label:"Cinema",gradient:"bg-gradient-to-br from-slate-950 via-blue-950 to-slate-950"}].map(({key:qe,label:ct,gradient:De})=>e.jsxs("button",{onClick:()=>Q(qe),className:`p-2 rounded-lg border-2 transition-all text-center ${ee===qe?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-10 rounded-md mb-1.5 ${De}`}),e.jsx("span",{className:"text-[10px] font-medium",children:ct})]},qe))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(K,{variant:"outline",onClick:()=>y("contact"),className:"flex-1",children:"Back"}),e.jsx(K,{onClick:We,disabled:!L||N,className:"flex-1 gap-2",children:N?"Creating...":"Create Card"})]})]})]})]})}const WSs={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 GSs({card:t}){const{user:s}=Ws(),{isGmailConnected:r}=D0(),n=ss(),[a,o]=C.useState(!1),[l,i]=C.useState("");C.useEffect(()=>{a&&t.contact_id&&!l&&G.from("innercircle_contacts").select("email").eq("id",t.contact_id).maybeSingle().then(({data:w})=>{w!=null&&w.email&&i(w.email)})},[a,t.contact_id]);const c={home_anniversary:`🏡 Happy Home Anniversary, ${t.recipient_name}!`,just_listed:`🏠 Just Listed — Check This Out, ${t.recipient_name}!`,just_sold:`🎉 Just Sold! Congrats, ${t.recipient_name}!`,congratulations:`🏆 Congratulations, ${t.recipient_name}!`,birthday:`🎂 Happy Birthday, ${t.recipient_name}!`,holiday:`🎄 Happy Holidays, ${t.recipient_name}!`,thank_you:`💐 Thank You, ${t.recipient_name}!`,thinking_of_you:`💭 Thinking of You, ${t.recipient_name}!`},[u,p]=C.useState(c[t.card_type]||`A Special Card for ${t.recipient_name}!`),[f,y]=C.useState(""),_=`https://cardstudio.relevelup.com/c/${t.share_token}`,b=Dt({mutationFn:async()=>{var T;if(!l)throw new Error("Recipient email is required");const w=`
${f?`

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


`:""}

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

${t.property_address?`

${t.property_address}

`:""}
`,{data:j}=await G.auth.getSession(),N=(T=j==null?void 0:j.session)==null?void 0:T.access_token,S=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/gmail-send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({to:l,subject:u,body:w,contactId:t.contact_id||void 0})});if(!S.ok){const I=await S.json();throw new Error(I.error||"Failed to send")}return S.json()},onSuccess:async()=>{await G.from("sendable_cards").update({sent_at:new Date().toISOString(),sent_via:"gmail"}).eq("id",t.id),n.invalidateQueries({queryKey:["sendable-cards"]}),me.success(`Card sent to ${l}!`),o(!1)},onError:w=>{me.error(w.message||"Failed to send email")}});return r?e.jsxs(_s,{open:a,onOpenChange:o,children:[e.jsx(Fi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(oa,{className:"h-3 w-3"})})}),e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Send Card via Gmail"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"To"}),e.jsx(Fe,{type:"email",value:l,onChange:w=>i(w.target.value),placeholder:"recipient@email.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Subject"}),e.jsx(Fe,{value:u,onChange:w=>p(w.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Personal Note (optional)"}),e.jsx(Ar,{value:f,onChange:w=>y(w.target.value),placeholder:"Add a warm personal note before the card link...",rows:3})]}),e.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 text-xs text-muted-foreground",children:["The email will include a beautiful button linking to your card at:",e.jsx("br",{}),e.jsx("span",{className:"font-mono text-foreground",children:_})]}),e.jsx(K,{onClick:()=>b.mutate(),disabled:!l||b.isPending,className:"w-full gap-2",children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oa,{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(oa,{className:"h-3 w-3"})})}function KSs({card:t}){const s=ss(),[r,n]=C.useState(!1),[a,o]=C.useState(!1),[l,i]=C.useState(t.recipient_name),[c,u]=C.useState(t.property_address||""),[p,f]=C.useState(t.home_anniversary_date||""),[y,_]=C.useState(t.custom_message||""),[b,w]=C.useState(t.template),[j,N]=C.useState(t.property_photo_url),[S,T]=C.useState(t.video_url||null),I=R=>{R&&(i(t.recipient_name),u(t.property_address||""),f(t.home_anniversary_date||""),_(t.custom_message||""),w(t.template),N(t.property_photo_url),T(t.video_url||null)),n(R)},L=async()=>{if(!l.trim()){me.error("Recipient name is required");return}o(!0);try{const{error:R}=await G.from("sendable_cards").update({recipient_name:l.trim(),property_address:c.trim()||null,home_anniversary_date:p||null,custom_message:y.trim()||null,template:b,property_photo_url:j||null,video_url:S||null}).eq("id",t.id);if(R)throw R;s.invalidateQueries({queryKey:["sendable-cards"]}),me.success("Card updated"),n(!1)}catch(R){me.error(R.message||"Failed to update card")}finally{o(!1)}};return e.jsxs(_s,{open:r,onOpenChange:I,children:[e.jsx(Fi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx($a,{className:"h-3 w-3"})})}),e.jsxs(vs,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Edit Card"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Recipient Name"}),e.jsx(Fe,{value:l,onChange:R=>i(R.target.value),placeholder:"John & Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Property Address"}),e.jsx(Fe,{value:c,onChange:R=>u(R.target.value),placeholder:"123 Main St, Austin, TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Home Anniversary Date"}),e.jsx(Fe,{type:"date",value:p,onChange:R=>f(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Personal Message (optional)"}),e.jsx(Ar,{value:y,onChange:R=>_(R.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(Ilt,{photoUrl:j,videoUrl:S,onPhotoChange:N,onVideoChange:T,contactId:t.contact_id}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(R=>e.jsxs("button",{onClick:()=>w(R),className:`p-3 rounded-lg border-2 transition-all text-center ${b===R?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-12 rounded-md mb-2 ${R==="elegant"?"bg-gradient-to-br from-slate-100 to-slate-200 dark:from-slate-800 dark:to-slate-700":R==="bold"?"bg-gradient-to-br from-violet-500 to-fuchsia-500":"bg-gradient-to-br from-amber-200 to-orange-300"}`}),e.jsx("span",{className:"text-xs font-medium capitalize",children:R})]},R))})]}),e.jsx(K,{onClick:L,disabled:!l.trim()||a,className:"w-full gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function ZSs(){const{user:t}=Ws(),s=ss(),[r,n]=C.useState(""),[a,o]=Xc(),l=a.get("cardType"),i=a.get("contactId"),c=a.get("name"),u=a.get("address"),p=a.get("date"),f=!!l,{data:y,isLoading:_}=wt({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:T,error:I}=await G.from("sendable_cards").select("*").eq("owner_user_id",t.id).order("created_at",{ascending:!1});if(I)throw I;return T},enabled:!!(t!=null&&t.id)}),b=Dt({mutationFn:async T=>{const{error:I}=await G.from("sendable_cards").delete().eq("id",T);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),me.success("Card deleted")}}),w=T=>{const I=`https://cardstudio.relevelup.com/c/${T}`;navigator.clipboard.writeText(I),me.success("Share link copied!")},j=y==null?void 0:y.filter(T=>{var I;return!r||T.recipient_name.toLowerCase().includes(r.toLowerCase())||((I=T.property_address)==null?void 0:I.toLowerCase().includes(r.toLowerCase()))}),N={elegant:"Elegant",bold:"Bold",warm:"Warm"},S={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"};return e.jsx(Es,{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(mze,{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(xn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Fe,{placeholder:"Search cards...",value:r,onChange:T=>n(T.target.value),className:"pl-9"})]}),_?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(T=>e.jsx(Ee,{className:"animate-pulse",children:e.jsxs(Oe,{className:"p-4",children:[e.jsx("div",{className:"h-40 bg-muted rounded-lg mb-3"}),e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 mb-2"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]})},T))}):j!=null&&j.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:j.map(T=>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 ${T.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":T.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:[T.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"})]}),T.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%)]"})]}),T.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:T.card_type==="home_anniversary"?"🏡":T.card_type==="birthday"?"🎂":T.card_type==="just_sold"?"🎉":T.card_type==="just_listed"?"🏠":T.card_type==="thank_you"?"💐":T.card_type==="congratulations"?"🏆":T.card_type==="holiday"?"🎄":T.card_type==="thinking_of_you"?"💭":"✉️"}),e.jsx("p",{className:`text-[10px] uppercase tracking-[0.2em] mb-1 ${T.template==="bold"?"text-white/70":"text-muted-foreground"}`,children:S[T.card_type]||T.card_type}),e.jsx("p",{className:`font-semibold text-base ${T.template==="bold"?"text-white":"text-foreground"}`,children:T.recipient_name}),T.property_address&&e.jsx("p",{className:`text-xs mt-1 ${T.template==="bold"?"text-white/60":"text-muted-foreground"}`,children:T.property_address})]}),e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(nt,{variant:T.template==="bold"?"outline":"secondary",className:`text-[10px] ${T.template==="bold"?"border-white/30 text-white/80":""}`,children:N[T.template]||T.template})})]}),e.jsxs(Oe,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(va,{className:"h-3 w-3"}),T.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Yd(new Date(T.created_at),{addSuffix:!0})})]}),T.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",ys(new Date(T.sent_at),"MMM d, yyyy")," via ",T.sent_via]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(K,{variant:"outline",size:"sm",className:"flex-1 gap-1 text-xs",onClick:()=>w(T.share_token),children:[e.jsx(mi,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(KSs,{card:T}),e.jsx(GSs,{card:T}),e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${T.share_token}`,"_blank"),children:e.jsx(rn,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1 text-xs",onClick:()=>b.mutate(T.id),children:e.jsx(jr,{className:"h-3 w-3"})})]})]})]},T.id))}):e.jsx(Ee,{className:"border-dashed",children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(br,{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(mze,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:c||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]})})]})})}function G6({delay:t,x:s,y:r,size:n}){return e.jsx(wr.div,{className:"absolute rounded-full bg-slate-300/30 dark:bg-slate-500/20",style:{left:s,top:r,width:n,height:n},animate:{y:[0,-20,0],opacity:[.3,.7,.3],scale:[1,1.2,1]},transition:{duration:4,delay:t,repeat:1/0,ease:"easeInOut"}})}function YSs(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:y}=t,_=_E[s];return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-blue-50/30 to-white dark:from-slate-950 dark:to-slate-900 flex items-center justify-center p-4 overflow-hidden relative",children:[e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx(wr.div,{className:"absolute -top-20 -right-20 w-72 h-72 rounded-full bg-gradient-to-br from-blue-100/40 to-slate-100/20 blur-3xl",animate:{scale:[1,1.1,1],rotate:[0,5,0]},transition:{duration:8,repeat:1/0,ease:"easeInOut"}}),e.jsx(wr.div,{className:"absolute -bottom-20 -left-20 w-64 h-64 rounded-full bg-gradient-to-tr from-slate-200/30 to-blue-100/20 blur-3xl",animate:{scale:[1,1.15,1],rotate:[0,-5,0]},transition:{duration:10,repeat:1/0,ease:"easeInOut"}}),e.jsx(G6,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(G6,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(G6,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(G6,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(G6,{delay:1.5,x:"70%",y:"15%",size:5})]}),e.jsxs(wr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8,ease:"easeOut"},children:[e.jsxs(wr.div,{className:"bg-white/80 dark:bg-slate-900/80 backdrop-blur-xl rounded-3xl shadow-[0_20px_60px_-15px_rgba(0,0,0,0.1)] overflow-hidden border border-slate-200/60 dark:border-slate-700/50",initial:{scale:.95},animate:{scale:1},transition:{duration:.6,delay:.2},children:[e.jsx("div",{className:"relative h-2 bg-gradient-to-r from-slate-200 via-blue-300 to-slate-200 dark:from-slate-700 dark:via-blue-500 dark:to-slate-700 overflow-hidden",children:e.jsx(wr.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/60 to-transparent",animate:{x:["-100%","200%"]},transition:{duration:3,repeat:1/0,repeatDelay:2,ease:"easeInOut"}})}),e.jsxs("div",{className:"px-8 py-10 text-center",children:[e.jsxs(wr.div,{className:"mx-auto mb-6 h-20 w-20 rounded-2xl bg-gradient-to-br from-slate-100 to-blue-50 dark:from-slate-800 dark:to-slate-700 flex items-center justify-center shadow-lg relative",initial:{scale:0,rotate:-10},animate:{scale:1,rotate:0},transition:{duration:.5,delay:.4,type:"spring",stiffness:200},children:[e.jsx(wr.div,{className:"absolute inset-0 rounded-2xl border-2 border-slate-200/50 dark:border-slate-600/50",animate:{scale:[1,1.15,1],opacity:[.5,0,.5]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut"}}),e.jsx("span",{className:"text-4xl",children:_.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(wr.div,{className:"inline-block mb-4",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.4,delay:.6},children:e.jsxs("span",{className:"text-sm font-semibold tracking-[0.25em] uppercase text-blue-400 dark:text-blue-300",children:[a," ",a===1?"Year":"Years"]})}),e.jsx(wr.h1,{className:"text-4xl font-light text-slate-800 dark:text-slate-100 mb-1 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.5,delay:.7},children:_.title[0]}),_.title[1]&&e.jsx(wr.h2,{className:"text-4xl font-bold text-slate-800 dark:text-slate-100 mb-8 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.5,delay:.85},children:_.title[1]}),e.jsxs(wr.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.5,delay:1},children:[e.jsx("p",{className:"text-xl font-medium text-slate-700 dark:text-slate-200 mb-1",children:r}),n&&e.jsx("p",{className:"text-sm text-slate-400 dark:text-slate-500 mb-6",children:n})]}),e.jsx(wr.div,{className:"h-px bg-gradient-to-r from-transparent via-slate-300 dark:via-slate-600 to-transparent mx-auto mb-6",initial:{width:0},animate:{width:"80%"},transition:{duration:.8,delay:1.1},style:{margin:"0 auto 1.5rem"}}),f&&e.jsx(wr.div,{className:"mb-6 rounded-xl overflow-hidden shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.15,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),y&&e.jsx(wr.div,{className:"mb-6 rounded-xl overflow-hidden shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("iframe",{src:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(wr.p,{className:"text-sm text-slate-500 dark:text-slate-400 leading-relaxed max-w-xs mx-auto mb-8 italic",initial:{opacity:0},animate:{opacity:1},transition:{duration:.6,delay:1.3},children:o||_.defaultMessage}),e.jsxs(wr.div,{className:"border-t border-slate-100 dark:border-slate-800 pt-6",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.5,delay:1.5},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?e.jsx(wr.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-slate-200 dark:ring-slate-700 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-full bg-gradient-to-br from-slate-200 to-blue-100 dark:from-slate-700 dark:to-slate-600 flex items-center justify-center shadow-md",children:e.jsx("span",{className:"text-sm font-semibold text-slate-600 dark:text-slate-300",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-700 dark:text-slate-200",children:l}),p&&e.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-4",children:[c&&e.jsxs(wr.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(ea,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(wr.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-4 py-2 rounded-full bg-slate-100 dark:bg-slate-800 text-xs font-medium text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors shadow-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(br,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(wr.p,{className:"text-center text-[10px] text-slate-400 dark:text-slate-600 mt-4",initial:{opacity:0},animate:{opacity:1},transition:{delay:2},children:"Powered by LevelUp"})]})]})}function vye({delay:t,x:s,y:r,color:n,size:a}){return e.jsx(wr.div,{className:`absolute rounded-full blur-2xl ${n}`,style:{left:s,top:r,width:a,height:a},animate:{scale:[1,1.4,1],opacity:[.2,.5,.2]},transition:{duration:5,delay:t,repeat:1/0,ease:"easeInOut"}})}function K6({delay:t,x:s,y:r}){return e.jsx(wr.div,{className:"absolute text-white/30 text-lg",style:{left:s,top:r},animate:{opacity:[0,1,0],scale:[.5,1,.5],rotate:[0,180,360]},transition:{duration:3,delay:t,repeat:1/0,ease:"easeInOut"},children:"✦"})}const pze={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 XSs(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:y}=t,_=_E[s],b=pze[s]||pze.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-br ${b.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx(vye,{delay:0,x:"10%",y:"10%",color:b.orbs[0],size:200}),e.jsx(vye,{delay:1,x:"70%",y:"60%",color:b.orbs[1],size:180}),e.jsx(vye,{delay:2,x:"50%",y:"20%",color:b.orbs[2],size:150}),e.jsx(K6,{delay:0,x:"20%",y:"25%"}),e.jsx(K6,{delay:.8,x:"75%",y:"15%"}),e.jsx(K6,{delay:1.6,x:"85%",y:"65%"}),e.jsx(K6,{delay:2.4,x:"10%",y:"75%"}),e.jsx(K6,{delay:.4,x:"45%",y:"85%"}),e.jsxs(wr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:.7,ease:"easeOut"},children:[e.jsxs(wr.div,{className:"relative rounded-3xl overflow-hidden",initial:{scale:.9},animate:{scale:1},transition:{duration:.5,delay:.2,type:"spring",stiffness:150},children:[e.jsx(wr.div,{className:"absolute -inset-[1px] rounded-3xl bg-gradient-to-r from-violet-500 via-fuchsia-500 to-violet-500 opacity-50",animate:{backgroundPosition:["0% 50%","100% 50%","0% 50%"]},transition:{duration:4,repeat:1/0,ease:"linear"},style:{backgroundSize:"200% 200%"}}),e.jsxs("div",{className:"relative bg-white/5 backdrop-blur-xl border border-white/10 rounded-3xl px-8 py-10 text-center m-[1px]",children:[e.jsxs(wr.div,{className:"mx-auto mb-6 h-20 w-20 rounded-2xl bg-gradient-to-br from-violet-500 to-fuchsia-500 flex items-center justify-center shadow-2xl shadow-violet-500/40 relative",initial:{scale:0,rotate:-20},animate:{scale:1,rotate:0},transition:{duration:.6,delay:.4,type:"spring",stiffness:200},children:[e.jsx(wr.div,{className:"absolute inset-0 rounded-2xl bg-gradient-to-br from-violet-500 to-fuchsia-500",animate:{scale:[1,1.3,1],opacity:[.6,0,.6]},transition:{duration:2,repeat:1/0,ease:"easeInOut"}}),e.jsx("span",{className:"text-4xl relative z-10",children:_.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(wr.div,{className:"inline-flex items-center gap-2 mb-5 px-5 py-2 rounded-full bg-white/10 border border-white/15 backdrop-blur-sm",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.4,delay:.6},children:[e.jsx(wr.span,{className:"text-3xl font-black text-white",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.8},children:a}),e.jsx("span",{className:"text-xs font-semibold text-violet-200 uppercase tracking-widest",children:a===1?"Year":"Years"})]}),e.jsx(wr.h1,{className:"text-5xl font-black text-transparent bg-clip-text bg-gradient-to-r from-violet-200 via-white to-fuchsia-200 mb-2 leading-tight",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.7},children:_.title[0]}),_.title[1]&&e.jsx(wr.h2,{className:"text-5xl font-black text-transparent bg-clip-text bg-gradient-to-r from-fuchsia-300 via-violet-200 to-purple-300 mb-2 leading-tight",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.85},children:_.title[1]}),e.jsx(wr.div,{className:"text-3xl mb-4",initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{duration:.4,delay:1,type:"spring",stiffness:300},children:_.emojis.slice(0,3).join("")}),e.jsxs(wr.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[e.jsx("p",{className:"text-xl font-semibold text-white/90 mb-1",children:r}),n&&e.jsxs("p",{className:"text-sm text-violet-300/70 mb-6 flex items-center justify-center gap-1.5",children:[e.jsx(Rn,{className:"h-3.5 w-3.5"}),n]})]}),f&&e.jsx(wr.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10 shadow-lg",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),y&&e.jsx(wr.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10 shadow-lg",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.25,duration:.5},children:e.jsx("iframe",{src:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(wr.div,{className:"bg-white/5 rounded-2xl p-5 border border-white/10 mb-8 backdrop-blur-sm",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsx("p",{className:"text-sm text-violet-100/80 leading-relaxed",children:o||_.defaultMessage})}),e.jsxs(wr.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?e.jsx(wr.img,{src:i,alt:l,className:"h-12 w-12 rounded-xl object-cover ring-2 ring-violet-500/40 shadow-lg",whileHover:{scale:1.1}}):e.jsx("div",{className:"h-12 w-12 rounded-xl bg-gradient-to-br from-violet-500 to-fuchsia-500 flex items-center justify-center shadow-lg",children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-bold text-white",children:l}),p&&e.jsx("p",{className:"text-xs text-violet-300/60",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-5",children:[c&&e.jsxs(wr.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(ea,{className:"h-3.5 w-3.5"})," Call Me"]}),u&&e.jsxs(wr.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r from-violet-500/30 to-fuchsia-500/30 text-xs font-semibold text-white hover:from-violet-500/50 hover:to-fuchsia-500/50 transition-all border border-white/15 shadow-lg",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(br,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(wr.p,{className:"text-center text-[10px] text-violet-400/40 mt-4",initial:{opacity:0},animate:{opacity:1},transition:{delay:2},children:"Powered by LevelUp"})]})]})}function QSs({emoji:t,delay:s,x:r,duration:n}){return e.jsx(wr.div,{className:"absolute text-2xl pointer-events-none",style:{left:r,bottom:-20},animate:{y:[0,-600],opacity:[0,1,1,0],x:[0,15,-10,5],rotate:[0,20,-15,10]},transition:{duration:n,delay:s,repeat:1/0,ease:"easeOut"},children:t})}const fze={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 JSs(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:y}=t,_=_E[s],b=fze[s]||fze.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${b.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[_.emojis.map((w,j)=>e.jsx(QSs,{emoji:w,delay:j*1.2,x:`${15+j*14}%`,duration:5+j%3},j)),e.jsx(wr.div,{className:"absolute top-1/4 left-1/2 -translate-x-1/2 w-96 h-96 bg-gradient-to-r from-amber-200/30 to-rose-200/30 rounded-full blur-[100px]",animate:{scale:[1,1.2,1],opacity:[.3,.5,.3]},transition:{duration:6,repeat:1/0,ease:"easeInOut"}}),e.jsxs(wr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.7},children:[e.jsxs(wr.div,{className:"bg-white rounded-3xl shadow-[0_20px_60px_-15px_rgba(251,146,60,0.2)] overflow-hidden border border-amber-100",initial:{scale:.9},animate:{scale:1},transition:{duration:.5,delay:.2,type:"spring",stiffness:150},children:[e.jsxs(wr.div,{className:`h-28 bg-gradient-to-r ${b.header} relative overflow-hidden`,children:[e.jsx(wr.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent",animate:{x:["-100%","200%"]},transition:{duration:3,repeat:1/0,repeatDelay:2,ease:"easeInOut"}}),e.jsx(wr.div,{className:"absolute top-3 left-10 text-5xl",animate:{rotate:[0,10,-5,0],y:[0,-3,0]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},children:_.emojis[0]}),e.jsx(wr.div,{className:"absolute top-2 right-14 text-3xl",animate:{scale:[1,1.3,1],rotate:[0,15,0]},transition:{duration:2,repeat:1/0,ease:"easeInOut",delay:.5},children:_.emojis[1]}),e.jsx(wr.div,{className:"absolute bottom-2 left-1/2 -translate-x-1/2 text-3xl",animate:{y:[0,-5,0],scale:[1,1.1,1]},transition:{duration:2.5,repeat:1/0,ease:"easeInOut",delay:1},children:_.emojis[2]})]}),e.jsxs("div",{className:"px-8 py-8 text-center -mt-10 relative",children:[e.jsx(wr.div,{className:"mx-auto mb-4 h-20 w-20 rounded-full bg-white shadow-xl flex items-center justify-center border-4 border-white relative",initial:{scale:0},animate:{scale:1},transition:{delay:.4,type:"spring",stiffness:300},children:e.jsx(wr.div,{animate:{scale:[1,1.2,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-3xl",children:_.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(wr.div,{className:"mb-3",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{delay:.6},children:e.jsxs("span",{className:`inline-flex items-baseline gap-1.5 ${b.accent}`,children:[e.jsx(wr.span,{className:"text-5xl font-black",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.8},children:a}),e.jsx("span",{className:"text-sm font-semibold",children:a===1?"year":"wonderful years"})]})}),e.jsxs(wr.h1,{className:`text-3xl font-bold ${b.accent} mb-1`,initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.9},children:[_.title.join(" ")," ",_.emojis[4]]}),e.jsxs(wr.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[e.jsx("p",{className:`text-lg font-semibold ${b.text} mb-1`,children:r}),n&&e.jsxs("p",{className:`text-sm ${b.text} opacity-70 flex items-center justify-center gap-1 mb-5`,children:[e.jsx(Ui,{className:"h-3 w-3"}),n]})]}),f&&e.jsx(wr.div,{className:"mb-5 rounded-2xl overflow-hidden border border-amber-200 shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),y&&e.jsx(wr.div,{className:"mb-5 rounded-2xl overflow-hidden border border-amber-200 shadow-md",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.25,duration:.5},children:e.jsx("iframe",{src:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(wr.div,{className:"bg-gradient-to-br from-amber-50 to-orange-50 rounded-2xl p-5 mb-6 border border-amber-100 shadow-inner",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsxs("p",{className:`text-sm ${b.text} leading-relaxed italic`,children:['"',o||_.defaultMessage,'"']})}),e.jsxs(wr.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[e.jsxs("div",{className:"flex items-center gap-3 justify-center",children:[i?e.jsx(wr.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-amber-200 shadow-md",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${b.header} flex items-center justify-center shadow-md`,children:e.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:`text-sm font-bold ${b.accent}`,children:l}),p&&e.jsx("p",{className:`text-xs ${b.text} opacity-60`,children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[c&&e.jsxs(wr.a,{href:`tel:${c}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(ea,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(wr.a,{href:`mailto:${u}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(br,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(wr.p,{className:"text-center text-[10px] text-amber-400 mt-4",initial:{opacity:0},animate:{opacity:1},transition:{delay:2},children:"Powered by LevelUp"})]})]})}function Dz({delay:t,x:s,y:r,size:n,color:a}){return e.jsx(wr.div,{className:`absolute rounded-full ${a} blur-3xl`,style:{left:s,top:r,width:n,height:n},animate:{scale:[1,1.3,1],opacity:[.4,.7,.4],x:[0,20,-10,0],y:[0,-15,10,0]},transition:{duration:8,delay:t,repeat:1/0,ease:"easeInOut"}})}function _ye({delay:t,x:s,y:r,size:n}){return e.jsx(wr.div,{className:"absolute rounded-full border border-white/10",style:{left:s,top:r,width:n,height:n},animate:{scale:[1,1.2,1],opacity:[.1,.3,.1],rotate:[0,180,360]},transition:{duration:12,delay:t,repeat:1/0,ease:"linear"}})}const 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 eCs(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:y}=t,_=_E[s],b=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(Dz,{delay:0,x:"5%",y:"10%",size:300,color:b.mesh[0]}),e.jsx(Dz,{delay:2,x:"60%",y:"50%",size:250,color:b.mesh[1]}),e.jsx(Dz,{delay:4,x:"30%",y:"70%",size:200,color:b.mesh[2]}),e.jsx(Dz,{delay:1,x:"80%",y:"15%",size:180,color:b.mesh[0]}),e.jsx(_ye,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(_ye,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(_ye,{delay:6,x:"40%",y:"10%",size:80}),e.jsx("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E")`}}),e.jsxs(wr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:40},animate:{opacity:1,y:0},transition:{duration:.8,ease:[.16,1,.3,1]},children:[e.jsxs(wr.div,{className:`relative rounded-[28px] overflow-hidden backdrop-blur-2xl bg-white/[0.06] border border-white/[0.12] shadow-2xl ${b.glow}`,initial:{scale:.92},animate:{scale:1},transition:{duration:.6,delay:.2,type:"spring",stiffness:120},children:[e.jsx("div",{className:"relative h-[2px] bg-gradient-to-r from-transparent via-white/20 to-transparent overflow-hidden",children:e.jsx(wr.div,{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/60 to-transparent",animate:{x:["-100%","200%"]},transition:{duration:4,repeat:1/0,repeatDelay:3,ease:"easeInOut"}})}),e.jsxs("div",{className:"px-8 py-10 text-center",children:[e.jsxs(wr.div,{className:"mx-auto mb-6 h-24 w-24 rounded-3xl bg-white/[0.08] backdrop-blur-xl border border-white/[0.15] flex items-center justify-center relative",initial:{scale:0,rotate:-15},animate:{scale:1,rotate:0},transition:{duration:.6,delay:.4,type:"spring",stiffness:180},children:[e.jsx(wr.div,{className:"absolute -inset-1 rounded-3xl border border-white/[0.08]",animate:{scale:[1,1.1,1],opacity:[.3,0,.3]},transition:{duration:3,repeat:1/0,ease:"easeInOut"}}),e.jsx(wr.span,{className:"text-5xl",animate:{scale:[1,1.08,1]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},children:_.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(wr.div,{className:"inline-flex items-center gap-2 mb-5 px-5 py-2 rounded-full bg-white/[0.06] border border-white/[0.1] backdrop-blur-sm",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.4,delay:.6},children:[e.jsx(wr.span,{className:"text-3xl font-black text-white",initial:{opacity:0},animate:{opacity:1},transition:{delay:.8},children:a}),e.jsx("span",{className:`text-[10px] font-bold uppercase tracking-[0.2em] ${b.accent}`,children:a===1?"Year":"Years"})]}),e.jsx(wr.h1,{className:"text-4xl font-extralight text-white/90 mb-1 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.6,delay:.7},children:_.title[0]}),_.title[1]&&e.jsx(wr.h2,{className:"text-4xl font-bold text-white mb-6 tracking-tight",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.6,delay:.85},children:_.title[1]}),e.jsxs(wr.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1},children:[e.jsx("p",{className:"text-xl font-medium text-white/80 mb-1",children:r}),n&&e.jsxs("p",{className:"text-sm text-white/30 mb-6 flex items-center justify-center gap-1.5",children:[e.jsx(Ui,{className:"h-3 w-3"})," ",n]})]}),e.jsx(wr.div,{className:"h-px bg-gradient-to-r from-transparent via-white/15 to-transparent mx-auto mb-6",initial:{width:0},animate:{width:"70%"},transition:{duration:1,delay:1.1},style:{margin:"0 auto 1.5rem"}}),f&&e.jsx(wr.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.15,duration:.5},children:e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"})}),y&&e.jsx(wr.div,{className:"mb-6 rounded-2xl overflow-hidden border border-white/10",initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:1.2,duration:.5},children:e.jsx("iframe",{src:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(wr.div,{className:"bg-white/[0.04] rounded-2xl p-5 border border-white/[0.08] mb-8 backdrop-blur-sm",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.3},children:e.jsxs("p",{className:"text-sm text-white/60 leading-relaxed italic",children:['"',o||_.defaultMessage,'"']})}),e.jsxs(wr.div,{className:"border-t border-white/[0.06] pt-6",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?e.jsx(wr.img,{src:i,alt:l,className:"h-12 w-12 rounded-2xl object-cover ring-1 ring-white/10",whileHover:{scale:1.08}}):e.jsx("div",{className:"h-12 w-12 rounded-2xl bg-white/[0.08] border border-white/[0.1] flex items-center justify-center",children:e.jsx("span",{className:"text-sm font-semibold text-white/60",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-white/80",children:l}),p&&e.jsx("p",{className:"text-xs text-white/30",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[c&&e.jsxs(wr.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(ea,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(wr.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/70 hover:bg-white/[0.12] transition-colors backdrop-blur-sm",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(br,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(wr.p,{className:"text-center text-[10px] text-white/20 mt-4",initial:{opacity:0},animate:{opacity:1},transition:{delay:2},children:"Powered by LevelUp"})]})]})}function bye({delay:t,x:s,angle:r,color:n}){return e.jsx(wr.div,{className:`absolute h-[400px] w-[1px] ${n} origin-top`,style:{left:s,top:"-10%",transform:`rotate(${r}deg)`},animate:{opacity:[0,.4,0],scaleY:[.5,1,.5]},transition:{duration:6,delay:t,repeat:1/0,ease:"easeInOut"}})}function Oz({delay:t,x:s}){return e.jsx(wr.div,{className:"absolute w-1 h-1 rounded-full bg-amber-400/60",style:{left:s,bottom:"20%"},animate:{y:[0,-200,-400],x:[0,15,-10],opacity:[0,.8,0],scale:[0,1.5,0]},transition:{duration:4,delay:t,repeat:1/0,ease:"easeOut"}})}const xze={home_anniversary:{gradient:"from-slate-950 via-blue-950 to-slate-950",accent:"from-blue-400 to-cyan-300",stripe:"bg-blue-400/20"},birthday:{gradient:"from-slate-950 via-rose-950 to-slate-950",accent:"from-rose-400 to-pink-300",stripe:"bg-rose-400/20"},just_sold:{gradient:"from-slate-950 via-emerald-950 to-slate-950",accent:"from-emerald-400 to-green-300",stripe:"bg-emerald-400/20"},just_listed:{gradient:"from-slate-950 via-amber-950 to-slate-950",accent:"from-amber-400 to-yellow-300",stripe:"bg-amber-400/20"},thank_you:{gradient:"from-slate-950 via-pink-950 to-slate-950",accent:"from-pink-400 to-rose-300",stripe:"bg-pink-400/20"},congratulations:{gradient:"from-slate-950 via-yellow-950 to-slate-950",accent:"from-yellow-400 to-amber-300",stripe:"bg-yellow-400/20"},holiday:{gradient:"from-slate-950 via-red-950 to-slate-950",accent:"from-red-400 to-green-400",stripe:"bg-red-400/20"},thinking_of_you:{gradient:"from-slate-950 via-purple-950 to-slate-950",accent:"from-purple-400 to-violet-300",stripe:"bg-purple-400/20"}};function tCs(t){const{cardType:s,recipientName:r,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:c,agentEmail:u,agentBrokerage:p,propertyPhotoUrl:f,videoUrl:y}=t,_=_E[s],b=xze[s]||xze.home_anniversary;return e.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${b.gradient} flex items-center justify-center p-4 overflow-hidden relative`,children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,rgba(255,255,255,0.04)_0%,transparent_60%)]"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_bottom,rgba(0,0,0,0.6)_0%,transparent_60%)]"}),e.jsx(bye,{delay:0,x:"20%",angle:15,color:b.stripe}),e.jsx(bye,{delay:2,x:"75%",angle:-12,color:b.stripe}),e.jsx(bye,{delay:4,x:"50%",angle:5,color:b.stripe}),e.jsx(Oz,{delay:0,x:"30%"}),e.jsx(Oz,{delay:1.5,x:"60%"}),e.jsx(Oz,{delay:3,x:"45%"}),e.jsx(Oz,{delay:.7,x:"75%"}),e.jsx("div",{className:"absolute inset-0 opacity-[0.015] mix-blend-overlay",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`}}),e.jsxs(wr.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0},animate:{opacity:1},transition:{duration:1.2},children:[e.jsx(wr.div,{className:"relative overflow-hidden",initial:{y:50},animate:{y:0},transition:{duration:.8,delay:.3,ease:[.16,1,.3,1]},children:e.jsxs("div",{className:"px-8 py-12 text-center",children:[e.jsx(wr.div,{className:"mx-auto mb-8 relative",initial:{scale:0},animate:{scale:1},transition:{duration:.8,delay:.5,type:"spring",stiffness:100},children:e.jsx(wr.div,{className:`h-20 w-20 mx-auto rounded-2xl bg-gradient-to-br ${b.accent} flex items-center justify-center shadow-2xl`,animate:{boxShadow:["0 0 40px rgba(255,255,255,0.05)","0 0 80px rgba(255,255,255,0.1)","0 0 40px rgba(255,255,255,0.05)"]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-4xl",children:_.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(wr.div,{className:"mb-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:.7},children:[e.jsx(wr.span,{className:`text-6xl font-black bg-gradient-to-r ${b.accent} bg-clip-text text-transparent`,initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},transition:{delay:.9,type:"spring"},children:a}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.4em] text-white/30 mt-1",children:a===1?"Year":"Years"})]}),e.jsx("div",{className:"overflow-hidden mb-2",children:e.jsx(wr.h1,{className:"text-5xl font-thin text-white/90 tracking-wide",initial:{y:"100%"},animate:{y:0},transition:{duration:.7,delay:.8,ease:[.16,1,.3,1]},children:_.title[0]})}),_.title[1]&&e.jsx("div",{className:"overflow-hidden mb-8",children:e.jsx(wr.h2,{className:`text-5xl font-black bg-gradient-to-r ${b.accent} bg-clip-text text-transparent`,initial:{y:"100%"},animate:{y:0},transition:{duration:.7,delay:.95,ease:[.16,1,.3,1]},children:_.title[1]})}),e.jsxs(wr.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.1,duration:.6},children:[e.jsx("p",{className:"text-lg font-light text-white/70 tracking-wide",children:r}),n&&e.jsxs("p",{className:"text-xs text-white/25 mt-1 flex items-center justify-center gap-1",children:[e.jsx(Ui,{className:"h-3 w-3"})," ",n]})]}),e.jsxs(wr.div,{className:"flex items-center justify-center gap-3 my-8",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2},children:[e.jsx(wr.div,{className:"h-px flex-1 max-w-[60px] bg-gradient-to-r from-transparent to-white/15",initial:{scaleX:0},animate:{scaleX:1},transition:{delay:1.3,duration:.8},style:{transformOrigin:"right"}}),e.jsx(wr.span,{className:"text-white/10 text-xs",animate:{rotate:[0,360]},transition:{duration:20,repeat:1/0,ease:"linear"},children:"✦"}),e.jsx(wr.div,{className:"h-px flex-1 max-w-[60px] bg-gradient-to-l from-transparent to-white/15",initial:{scaleX:0},animate:{scaleX:1},transition:{delay:1.3,duration:.8},style:{transformOrigin:"left"}})]}),f&&e.jsxs(wr.div,{className:"mb-8 rounded-2xl overflow-hidden ring-1 ring-white/5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.3,duration:.6},children:[e.jsx("img",{src:f,alt:"Property",className:"w-full h-48 object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-950/30 to-transparent pointer-events-none"})]}),y&&e.jsx(wr.div,{className:"mb-8 rounded-2xl overflow-hidden ring-1 ring-white/5",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:1.35,duration:.6},children:e.jsx("iframe",{src:`${y}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),e.jsx(wr.p,{className:"text-sm text-white/40 leading-relaxed max-w-xs mx-auto mb-10 font-light",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.4,duration:.8},children:o||_.defaultMessage}),e.jsxs(wr.div,{className:"pt-6 border-t border-white/[0.04]",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{delay:1.6,duration:.6},children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[i?e.jsx(wr.img,{src:i,alt:l,className:"h-12 w-12 rounded-full object-cover ring-2 ring-white/10 shadow-xl",whileHover:{scale:1.1}}):e.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${b.accent} flex items-center justify-center shadow-xl`,children:e.jsx("span",{className:"text-sm font-bold text-slate-900",children:l.charAt(0)})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium text-white/70",children:l}),p&&e.jsx("p",{className:"text-[11px] text-white/25",children:p})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[c&&e.jsxs(wr.a,{href:`tel:${c}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${b.accent} text-xs font-semibold text-slate-900 shadow-lg`,whileHover:{scale:1.05,boxShadow:"0 10px 40px rgba(255,255,255,0.15)"},whileTap:{scale:.95},children:[e.jsx(ea,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(wr.a,{href:`mailto:${u}`,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-white/[0.06] border border-white/[0.1] text-xs font-medium text-white/60 hover:bg-white/[0.12] transition-colors",whileHover:{scale:1.05},whileTap:{scale:.95},children:[e.jsx(br,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})}),e.jsx(wr.p,{className:"text-center text-[10px] text-white/10 mt-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:2.2},children:"Powered by LevelUp"})]})]})}function Llt(){const{shareToken:t}=Po(),{data:s,isLoading:r,error:n}=wt({queryKey:["public-sendable-card",t],queryFn:async()=>{const{data:l,error:i}=await G.from("sendable_cards").select("*").eq("share_token",t).single();if(i)throw i;return l},enabled:!!t});if(C.useEffect(()=>{t&&G.rpc("log_sendable_card_view",{p_share_token:t}).then(({error:l})=>{l&&console.error("Error tracking view:",l)})},[t]),r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"animate-pulse space-y-4 text-center",children:[e.jsx("div",{className:"h-8 w-48 bg-muted rounded mx-auto"}),e.jsx("div",{className:"h-4 w-32 bg-muted rounded mx-auto"})]})});if(n||!s)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Card not found"}),e.jsx("p",{className:"text-muted-foreground",children:"This card may have been removed or the link is invalid."})]})});const a=s.home_anniversary_date?Math.floor((Date.now()-Ml(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(XSs,{...o});case"warm":return e.jsx(JSs,{...o});case"glass":return e.jsx(eCs,{...o});case"cinematic":return e.jsx(tCs,{...o});case"elegant":default:return e.jsx(YSs,{...o})}}function sCs(){const t=ai();return wt({queryKey:["drip-settings",t],queryFn:async()=>{if(!t)return null;const{data:s,error:r}=await G.from("drip_settings").select("*").eq("user_id",t).maybeSingle();if(r)throw r;return s},enabled:!!t})}function rCs(){const t=ai(),s=ss();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n}=await G.from("drip_settings").select("id").eq("user_id",t).maybeSingle();if(n){const{data:a,error:o}=await G.from("drip_settings").update(r).eq("user_id",t).select().single();if(o)throw o;return a}else{const{data:a,error:o}=await G.from("drip_settings").insert({user_id:t,is_globally_enabled:r.is_globally_enabled??!1,append_signature:r.append_signature??!0}).select().single();if(o)throw o;return a}},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-settings"]})}})}function nCs(){const t=Pr(),{isGmailConnected:s,gmailEmail:r}=D0(),{data:n,isLoading:a}=sCs(),o=rCs(),[l,i]=C.useState(!1),[c,u]=C.useState(!0),[p,f]=C.useState(!1);C.useEffect(()=>{n&&(i(n.is_globally_enabled),u(n.append_signature))},[n]);const y=async b=>{if(b&&!s){me.error("Connect your Gmail account first before enabling Smart Drips");return}i(b);try{await o.mutateAsync({is_globally_enabled:b}),me.success(b?"Smart Drips enabled globally":"Smart Drips paused globally")}catch{i(!b),me.error("Failed to update settings")}},_=async b=>{u(b);try{await o.mutateAsync({append_signature:b}),me.success(b?"Signature will be appended to drip emails":"Signature disabled for drip emails")}catch{u(!b),me.error("Failed to update settings")}};return e.jsxs(_s,{open:p,onOpenChange:f,children:[e.jsx(Fi,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Jl,{className:"h-3.5 w-3.5"}),"Settings"]})}),e.jsxs(vs,{className:"sm:max-w-md",children:[e.jsxs(Cs,{children:[e.jsxs(Ns,{className:"flex items-center gap-2",children:[e.jsx(Jl,{className:"h-5 w-5 text-primary"}),"Smart Drip Settings"]}),e.jsx(Zr,{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(br,{className:`h-4 w-4 ${s?"text-emerald-600":"text-destructive"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s?"Gmail Connected":"Gmail Not Connected"}),r&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r})]})]}),s?e.jsxs(nt,{variant:"outline",className:"gap-1 text-emerald-600 border-emerald-200 bg-emerald-500/10 text-[10px]",children:[e.jsx(ha,{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(rn,{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(Zl,{}),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(eL,{className:`h-4 w-4 ${l?"text-emerald-600":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Enable Smart Drips"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l?"Active drips will send when deals move stages":"All drips are paused — nothing will send"})]})]}),e.jsx(Br,{checked:l,onCheckedChange:y,disabled:a||o.isPending})]}),e.jsx(Zl,{}),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(Wy,{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(Br,{checked:c,onCheckedChange:_,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(Wy,{className:"h-3 w-3 mr-1"}),"Edit your email signature in Profile settings"]})]})]})]})}function aCs(){const t=ai();return wt({queryKey:["drip-templates",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("drip_templates").select("*").or(`owner_user_id.eq.${t},is_starter.eq.true`).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function iCs(){const t=ai();return wt({queryKey:["drip-pipeline-stages",t],queryFn:async()=>{if(!t)return[];const{data:s,error:r}=await G.from("deal_pipeline_stages").select("*").eq("owner_user_id",t).order("sort_order",{ascending:!0});if(r)throw r;return s},enabled:!!t})}function oCs(){const t=ai(),s=ss();return Dt({mutationFn:async r=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await G.from("drip_templates").insert({owner_user_id:t,stage_id:r.stage_id,title:r.title||"",subject:r.subject||"",body:r.body||"",video_url:r.video_url||null,channel:r.channel||"email",delay_type:r.delay_type||"instant",delay_minutes:r.delay_minutes||0,is_enabled:!1,deal_type:r.deal_type||null,sort_order:r.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-templates"]})}})}function lCs(){const t=ss();return Dt({mutationFn:async({id:s,...r})=>{const{data:n,error:a}=await G.from("drip_templates").update(r).eq("id",s).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function cCs(){const t=ss();return Dt({mutationFn:async s=>{const{error:r}=await G.from("drip_templates").delete().eq("id",s);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["drip-templates"]})}})}function dCs(){const t=ai(),s=ss();return Dt({mutationFn:async({templateId:r,stageId:n})=>{if(!t)throw new Error("Not authenticated");const{data:a,error:o}=await G.from("drip_templates").select("*").eq("id",r).single();if(o)throw o;const{data:l,error:i}=await G.from("drip_templates").insert({owner_user_id:t,stage_id:n,title:a.title,subject:a.subject,body:a.body,video_url:a.video_url,channel:a.channel,delay_type:a.delay_type,delay_minutes:a.delay_minutes,is_enabled:!1,is_starter:!1,deal_type:a.deal_type}).select().single();if(i)throw i;return l},onSuccess:()=>{s.invalidateQueries({queryKey:["drip-templates"]})}})}const uCs=[{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 hCs(){const t=ai(),{data:s,isLoading:r}=aCs(),{data:n,isLoading:a}=iCs(),o=oCs(),l=lCs(),i=cCs(),c=dCs(),[u,p]=C.useState(null),[f,y]=C.useState(null),_=(s==null?void 0:s.filter(L=>!L.is_starter&&L.owner_user_id===t))||[],b=(s==null?void 0:s.filter(L=>L.is_starter))||[],w=L=>_.filter(R=>R.stage_id===L),j=async L=>{try{await l.mutateAsync({id:L.id,is_enabled:!L.is_enabled}),me.success(L.is_enabled?"Drip disabled":"Drip enabled")}catch{me.error("Failed to update")}},N=async L=>{try{const R=n==null?void 0:n.find($=>$.id===L);await o.mutateAsync({stage_id:L,title:`${(R==null?void 0:R.name)||"Stage"} follow-up`,subject:"",body:"",channel:"email",delay_type:"instant",delay_minutes:0}),p(L),me.success("Drip template created")}catch{me.error("Failed to create template")}},S=async L=>{try{await i.mutateAsync(L),me.success("Template deleted")}catch{me.error("Failed to delete")}},T=async L=>{if(!n||n.length===0){me.error("No pipeline stages found");return}const R=n[0].id;try{await c.mutateAsync({templateId:L,stageId:R}),me.success("Template copied to your drips!")}catch{me.error("Failed to copy template")}},I=r||a;return e.jsx(Es,{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(wp,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Smart Drips"}),e.jsx(nt,{variant:"outline",className:"text-[9px] font-bold uppercase tracking-wide px-1 py-0.5 border-amber-500 text-amber-600 bg-amber-500/10",children:"Beta"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Automatically send personalized emails when deals move through your pipeline."})]}),e.jsx(nCs,{})]}),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(VI,{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(Aa,{defaultValue:"my-drips",children:[e.jsxs(ja,{className:"grid grid-cols-2 w-full max-w-xs mb-6",children:[e.jsx(js,{value:"my-drips",children:"My Drips"}),e.jsxs(js,{value:"starters",children:["Starter Templates",b.length>0&&e.jsx(nt,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:b.length})]})]}),e.jsx($s,{value:"my-drips",children:I?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(L=>e.jsx(xs,{className:"h-16 w-full rounded-xl"},L))}):!n||n.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(wp,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No Pipeline Stages"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create pipeline stages first to set up drip automations."})]}):e.jsxs("div",{className:"space-y-2",children:[n.filter(L=>!L.is_won_stage&&!L.is_lost_stage).map(L=>{const R=w(L.id),$=u===L.id,q=R.some(U=>U.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>p($?null:L.id),className:"w-full flex items-center gap-3 p-4 hover:bg-muted/30 transition-colors text-left",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:L.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:L.name}),R.length>0&&e.jsxs(nt,{variant:"outline",className:`text-[10px] ${q?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[R.length," drip",R.length!==1?"s":"",q&&" · Active"]}),$?e.jsx(tl,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"})]}),$&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:R.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No drip set for this stage"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>N(L.id),disabled:o.isPending,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1.5"}),"Create Drip"]})]}):e.jsxs(e.Fragment,{children:[R.map(U=>e.jsx(yze,{template:U,isEditing:f===U.id,onToggleEdit:()=>y(f===U.id?null:U.id),onToggleEnabled:()=>j(U),onUpdate:V=>l.mutateAsync({id:U.id,...V}),onDelete:()=>S(U.id),userId:t||""},U.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>N(L.id),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},L.id)}),n.filter(L=>L.is_won_stage||L.is_lost_stage).length>0&&e.jsxs("div",{className:"pt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground font-medium mb-2 px-1",children:"Closing Stages"}),n.filter(L=>L.is_won_stage||L.is_lost_stage).map(L=>{const R=w(L.id),$=u===L.id,q=R.some(U=>U.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden mb-2",children:[e.jsxs("button",{onClick:()=>p($?null:L.id),className:"w-full flex items-center gap-3 p-4 hover:bg-muted/30 transition-colors text-left",children:[e.jsx("div",{className:"w-3 h-3 rounded-full shrink-0",style:{backgroundColor:L.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:L.name}),R.length>0&&e.jsxs(nt,{variant:"outline",className:`text-[10px] ${q?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[R.length," drip",R.length!==1?"s":"",q&&" · Active"]}),$?e.jsx(tl,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"})]}),$&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:R.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No drip set for this stage"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>N(L.id),disabled:o.isPending,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1.5"})," Create Drip"]})]}):e.jsxs(e.Fragment,{children:[R.map(U=>e.jsx(yze,{template:U,isEditing:f===U.id,onToggleEdit:()=>y(f===U.id?null:U.id),onToggleEnabled:()=>j(U),onUpdate:V=>l.mutateAsync({id:U.id,...V}),onDelete:()=>S(U.id),userId:t||""},U.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>N(L.id),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},L.id)})]})]})}),e.jsx($s,{value:"starters",children:b.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(hn,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No Starter Templates Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Admin-created starter templates will appear here. You'll be able to copy them into your own drips."})]}):e.jsx("div",{className:"space-y-3",children:b.map(L=>e.jsx(mCs,{template:L,onCopy:()=>T(L.id),isCopying:c.isPending},L.id))})})]})]})})}function yze({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,c]=C.useState(t.title),[u,p]=C.useState(t.subject),[f,y]=C.useState(t.body),[_,b]=C.useState(t.video_url||""),[w,j]=C.useState(t.channel),[N,S]=C.useState(t.delay_type),[T,I]=C.useState(t.delay_minutes),[L,R]=C.useState(!1),$=async()=>{R(!0);try{await a({title:i,subject:u,body:f,video_url:_||null,channel:w,delay_type:N,delay_minutes:T}),me.success("Drip saved"),r()}catch{me.error("Failed to save")}finally{R(!1)}},q=U=>{y(V=>V+U)};return e.jsxs("div",{className:"border rounded-lg bg-background overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",role:"button",onClick:r,children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.title||"Untitled drip"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.channel==="sms"?e.jsx(po,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(br,{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(Nn,{className:"h-3 w-3 text-primary"})]})]}),e.jsx(Br,{checked:t.is_enabled,onCheckedChange:n})]}),s&&e.jsxs("div",{className:"border-t p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs font-medium",children:"Title (internal)"}),e.jsx(Fe,{value:i,onChange:U=>c(U.target.value),className:"mt-1 h-8 text-sm",placeholder:"e.g. Buyer intro video"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(_e,{className:"text-xs font-medium",children:"Channel"}),e.jsx("div",{className:"flex gap-1 mt-1",children:["email","sms"].map(U=>e.jsxs("button",{onClick:()=>j(U),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${w===U?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[U==="sms"?e.jsx(po,{className:"h-3 w-3"}):e.jsx(br,{className:"h-3 w-3"}),U==="sms"?"SMS":"Email"]},U))})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(_e,{className:"text-xs font-medium",children:"Timing"}),e.jsxs("div",{className:"flex gap-1 mt-1",children:[e.jsx("button",{onClick:()=>S("instant"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${N==="instant"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:"Instant"}),e.jsxs("button",{onClick:()=>S("scheduled"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${N==="scheduled"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[e.jsx(Tn,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),N==="scheduled"&&e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs font-medium",children:"Delay"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Fe,{type:"number",min:1,value:T>=60?Math.round(T/60):T,onChange:U=>{const V=parseInt(U.target.value)||0;I(T>=60?V*60:V)},className:"h-8 w-20 text-sm"}),e.jsx("div",{className:"flex gap-1",children:[{label:"Minutes",mins:T<60?T:30},{label:"Hours",mins:T>=60?T:60},{label:"Days",mins:T>=1440?T:1440}].map(U=>e.jsx("button",{className:`px-2 py-1 rounded text-xs border transition-colors ${U.label==="Minutes"&&T<60||U.label==="Hours"&&T>=60&&T<1440||U.label==="Days"&&T>=1440?"bg-primary/10 text-primary border-primary/30":"text-muted-foreground border-input"}`,onClick:()=>{U.label==="Minutes"?I(30):U.label==="Hours"?I(60):I(1440)},children:U.label},U.label))})]})]}),w==="email"&&e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs font-medium",children:"Subject Line"}),e.jsx(Fe,{value:u,onChange:U=>p(U.target.value),className:"mt-1 h-8 text-sm",placeholder:"e.g. Next steps for your home purchase"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx(_e,{className:"text-xs font-medium",children:w==="sms"?"Message":"Email Body"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Insert:"}),e.jsxs("select",{className:"text-[10px] border rounded px-1 py-0.5 bg-background text-muted-foreground",value:"",onChange:U=>{U.target.value&&q(U.target.value),U.target.value=""},children:[e.jsx("option",{value:"",children:"Merge variable..."}),uCs.map(U=>e.jsx("option",{value:U.key,children:U.label},U.key))]})]})]}),e.jsx("textarea",{value:f,onChange:U=>y(U.target.value),placeholder:w==="sms"?"Hey {{client_first_name}}, great talking with you today! Here's a quick video about what's next...":`Hi {{client_first_name}}, It was great meeting with you! Here's a video about what to expect next...`,className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm min-h-[100px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs font-medium",children:"Attached Video"}),_?e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 text-xs text-muted-foreground truncate bg-muted/50 rounded px-2 py-1.5 border border-input",children:[e.jsx(Nn,{className:"h-3 w-3 inline mr-1 text-primary"}),_.length>50?_.slice(0,50)+"...":_]}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive",onClick:()=>b(""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(FSe,{onVideoReady:U=>b(U)}),e.jsx(RSe,{userId:l,onSelect:U=>b(U),triggerSize:"sm",triggerClassName:"gap-1.5 flex-1"}),e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1 text-xs text-muted-foreground flex-1",onClick:()=>{const U=prompt("Paste a YouTube or Loom URL:");U&&b(U)},children:[e.jsx(Vo,{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(jr,{className:"h-3 w-3 mr-1"})," Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",className:"text-xs",onClick:r,children:"Cancel"}),e.jsx(K,{size:"sm",className:"text-xs",onClick:$,disabled:L,children:L?"Saving...":"Save Drip"})]})]})]})]})}function mCs({template:t,onCopy:s,isCopying:r}){const[n,a]=C.useState(!1),o=t.body.replace(/<[^>]+>/g,""),l=t.deal_type==="buyer"?"Buyer":t.deal_type==="seller"?"Seller":null,i=t.delay_type==="instant"?"Sends instantly":t.delay_minutes>=1440?`Sends after ${Math.round(t.delay_minutes/1440)} day${Math.round(t.delay_minutes/1440)!==1?"s":""}`:t.delay_minutes>=60?`Sends after ${Math.round(t.delay_minutes/60)} hour${Math.round(t.delay_minutes/60)!==1?"s":""}`:`Sends after ${t.delay_minutes} min`;return e.jsxs("div",{className:"border rounded-xl overflow-hidden transition-all hover:shadow-sm",children:[e.jsxs("button",{onClick:()=>a(!n),className:"w-full flex items-start gap-3 p-4 text-left hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-sm",children:t.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:t.subject}),!n&&e.jsx("p",{className:"text-xs text-muted-foreground/70 line-clamp-1 mt-1",children:o})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 pt-0.5",children:[l&&e.jsx(nt,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:l}),e.jsxs(nt,{variant:"outline",className:"text-[10px] gap-1",children:[t.channel==="sms"?e.jsx(po,{className:"h-3 w-3"}):e.jsx(br,{className:"h-3 w-3"}),t.channel==="sms"?"SMS":"Email"]}),e.jsxs(nt,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(Tn,{className:"h-3 w-3"}),t.delay_type==="instant"?"Instant":i.replace("Sends ","")]}),n?e.jsx(tl,{className:"h-4 w-4 text-muted-foreground ml-1"}):e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground ml-1"})]})]}),n&&e.jsxs("div",{className:"border-t bg-muted/10 p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase font-semibold text-muted-foreground tracking-wider mb-1",children:"Subject Line"}),e.jsx("p",{className:"text-sm font-medium",children:t.subject})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase font-semibold text-muted-foreground tracking-wider mb-1",children:"Email Body"}),e.jsx("div",{className:"text-sm text-foreground/80 bg-background rounded-lg border p-4 prose prose-sm max-w-none [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li]:my-0.5 [&_p]:my-2 [&_a]:text-primary [&_a]:underline",dangerouslySetInnerHTML:{__html:t.body}})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Tn,{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(mi,{className:"h-3.5 w-3.5"}),"Use This Template"]})]})]})}const Dlt=()=>{const t=Qu();return C.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 pCs(){return C.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs(Oqe,{children:[e.jsx(Us,{path:"/c/:shareToken",element:e.jsx(Llt,{})}),e.jsx(Us,{path:"*",element:e.jsx(Dlt,{})})]})}const wye={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function Olt({slugOverride:t}){const s=Po(),r=t||s.slug,[n,a]=C.useState("types"),[o,l]=C.useState(null),[i,c]=C.useState(null),[u,p]=C.useState(null),[f,y]=C.useState(new Date),[_,b]=C.useState({name:"",email:"",phone:"",message:""}),[w,j]=C.useState(!1),{data:N,isLoading:S}=wt({queryKey:["public-booking-settings",r],queryFn:async()=>{const{data:Q,error:de}=await G.from("agent_booking_settings").select("*").eq("slug",r).eq("is_active",!0).single();if(de)throw de;return Q},enabled:!!r}),{data:T}=wt({queryKey:["public-booking-profile",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Q,error:de}=await G.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",N.user_id).single();if(de)throw de;return Q},enabled:!!(N!=null&&N.user_id)}),{data:I=[]}=wt({queryKey:["public-booking-types",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Q,error:de}=await G.from("agent_booking_types").select("id, name, description, duration_minutes, color, icon, qualification_enabled").eq("user_id",N.user_id).eq("is_active",!0).order("sort_order");if(de)throw de;return Q},enabled:!!(N!=null&&N.user_id)}),{data:L=[]}=wt({queryKey:["public-availability",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Q,error:de}=await G.from("agent_availability_slots").select("day_of_week, start_time, end_time").eq("user_id",N.user_id).eq("is_active",!0);if(de)throw de;return Q},enabled:!!(N!=null&&N.user_id)}),{data:R=[]}=wt({queryKey:["public-blocked-dates",N==null?void 0:N.user_id],queryFn:async()=>{const{data:Q,error:de}=await G.from("agent_blocked_dates").select("blocked_date").eq("user_id",N.user_id);if(de)throw de;return Q.map(re=>re.blocked_date)},enabled:!!(N!=null&&N.user_id)}),{data:$=[]}=wt({queryKey:["public-existing-bookings",N==null?void 0:N.user_id,i],queryFn:async()=>{if(!i)return[];const Q=ys(i,"yyyy-MM-dd"),{data:de,error:re}=await G.from("bookings").select("start_time, end_time").eq("agent_user_id",N.user_id).eq("booking_date",Q).eq("status","confirmed");if(re)throw re;return de},enabled:!!(N!=null&&N.user_id)&&!!i}),q=C.useMemo(()=>[...new Set(L.map(Q=>Q.day_of_week))],[L]),U=Q=>{const de=Pm(new Date),re=kl(de,(N==null?void 0:N.max_advance_days)||30),ne=kl(de,0);return wS(Q,ne)||bS(Q,re)||R.includes(ys(Q,"yyyy-MM-dd"))?!1:q.includes(Q.getDay())},V=C.useMemo(()=>{if(!i||!o||!N)return[];const Q=L.filter(we=>we.day_of_week===i.getDay()),de=o.duration_minutes,re=N.buffer_minutes||0,ne=[],le=new Date,he=(N.min_notice_hours||2)*60*60*1e3;for(const we of Q){const[ye,je]=we.start_time.split(":").map(Number),[ke,We]=we.end_time.split(":").map(Number);let be=NL(kL(i,ye),je);const Me=NL(kL(i,ke),We);for(;R5(be,de)<=Me;){const Ae=ys(be,"HH:mm"),Re=ys(R5(be,de),"HH:mm");be.getTime()-le.getTime()>=he&&($.some(qe=>{const ct=qe.start_time.slice(0,5),De=qe.end_time.slice(0,5);return Aect})||ne.push(Ae)),be=R5(be,de+re)}}return ne},[i,o,L,N,$]),X=C.useMemo(()=>{const Q=f.getFullYear(),de=f.getMonth(),re=new Date(Q,de,1),ne=new Date(Q,de+1,0),le=re.getDay(),he=[];for(let we=0;we{if(!(!o||!i||!u||!_.name||!N)){j(!0);try{const Q=ys(R5(NL(kL(new Date,parseInt(u.split(":")[0])),parseInt(u.split(":")[1])),o.duration_minutes),"HH:mm"),{error:de}=await G.from("bookings").insert({agent_user_id:N.user_id,booking_type_id:o.id,booking_date:ys(i,"yyyy-MM-dd"),start_time:u,end_time:Q,guest_name:_.name,guest_email:_.email||null,guest_phone:_.phone||null,guest_message:_.message||null});if(de)throw de;G.functions.invoke("booking-notify",{body:{agentUserId:N.user_id,guestName:_.name,guestEmail:_.email||null,guestPhone:_.phone||null,guestMessage:_.message||null,bookingTypeName:o.name,bookingDate:ys(i,"yyyy-MM-dd"),startTime:u,endTime:Q,durationMinutes:o.duration_minutes,meetingLink:N.meeting_link||null}}).catch(re=>console.error("Booking notify error:",re)),a("confirmed")}catch(Q){me.error("Failed to book: "+Q.message)}finally{j(!1)}}},ee=Q=>{const[de,re]=Q.split(":").map(Number),ne=de>=12?"PM":"AM";return`${de%12||12}:${re.toString().padStart(2,"0")} ${ne}`};return S?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8] flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-[#406E71] border-t-transparent"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading booking page..."})]})}):N?e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-[#f0f4f8] via-white to-[#e8f0f8]",children:[e.jsx("div",{className:"h-1.5 bg-gradient-to-r from-[#406E71] via-[#5a9a9d] to-[#2a4c64]"}),e.jsxs("div",{className:"max-w-lg mx-auto px-4 py-6 sm:py-10",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden mb-6",children:[e.jsx("div",{className:"relative bg-gradient-to-r from-[#406E71] to-[#2a4c64] px-6 pt-6 pb-12",children:e.jsxs("div",{className:"absolute inset-0 opacity-10",children:[e.jsx("div",{className:"absolute top-2 right-8 w-20 h-20 rounded-full border-2 border-white/30"}),e.jsx("div",{className:"absolute bottom-4 left-12 w-10 h-10 rounded-full border border-white/20"})]})}),e.jsx("div",{className:"relative -mt-10 px-6",children:e.jsxs("div",{className:"flex items-end gap-4",children:[T!=null&&T.avatar_url?e.jsx("img",{src:T.avatar_url,alt:(T==null?void 0:T.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(ro,{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:(T==null?void 0:T.name)||"Agent"}),(T==null?void 0:T.title)&&e.jsx("p",{className:"text-sm text-slate-500 mt-0.5",children:T.title})]})]})}),e.jsxs("div",{className:"px-6 py-4 flex flex-wrap gap-2",children:[(T==null?void 0:T.phone)&&e.jsxs("a",{href:`tel:${T.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(ea,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:T.phone}),e.jsx("span",{className:"sm:hidden",children:"Call"})]}),(T==null?void 0:T.email)&&e.jsxs("a",{href:`mailto:${T.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(br,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:T.email}),e.jsx("span",{className:"sm:hidden",children:"Email"})]})]})]}),e.jsx("div",{className:"bg-white rounded-2xl shadow-lg shadow-slate-200/60 border border-slate-100 overflow-hidden",children:e.jsxs("div",{className:"p-5 sm:p-6",children:[n==="types"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-slate-800",children:"Select a meeting type"}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Choose the type of meeting you'd like to schedule"})]}),e.jsx("div",{className:"space-y-2.5",children:I.map(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:wye[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(Tn,{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(di,{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:wye[o.icon]||"📅"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"font-semibold text-sm text-slate-800",children:o.name})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-slate-500 font-medium",children:[e.jsx(Tn,{className:"h-3 w-3"}),o.duration_minutes," min"]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ys(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:()=>y(new Date(f.getFullYear(),f.getMonth()-1)),children:e.jsx(Xl,{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:()=>y(new Date(f.getFullYear(),f.getMonth()+1)),children:e.jsx(Xa,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-0.5 text-center",children:[["Su","Mo","Tu","We","Th","Fr","Sa"].map(Q=>e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-semibold py-2",children:Q},Q)),X.map((Q,de)=>{if(!Q)return e.jsx("div",{},`pad-${de}`);const re=U(Q),ne=i&&_l(Q,i),le=_l(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 ${ne?"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"} ${le&&!ne?"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(Md,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ys(i,"EEEE, MMMM d")})]}),V.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(Tn,{className:"h-8 w-8 text-slate-300 mx-auto"}),e.jsx("p",{className:"text-sm text-slate-400",children:"No available times on this day"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Try selecting a different date"})]}):e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2 max-h-52 overflow-y-auto pr-1 custom-scrollbar",children:V.map(Q=>{const de=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 ${de?"bg-[#406E71] text-white shadow-md shadow-[#406E71]/30 scale-[1.02]":"bg-slate-50 text-slate-700 hover:bg-[#406E71]/10 hover:text-[#406E71] border border-slate-150"}`,children: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(di,{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:wye[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(Md,{className:"h-3.5 w-3.5 text-[#406E71]"}),ys(i,"EEE, MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3.5 w-3.5 text-[#406E71]"}),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(_e,{className:"text-xs font-semibold text-slate-700",children:"Full Name *"}),e.jsx(Fe,{value:_.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(_e,{className:"text-xs font-semibold text-slate-700",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(br,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(Fe,{type:"email",value:_.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(_e,{className:"text-xs font-semibold text-slate-700",children:"Phone"}),e.jsxs("div",{className:"relative",children:[e.jsx(ea,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(Fe,{type:"tel",value:_.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(_e,{className:"text-xs font-semibold text-slate-700",children:"Message (optional)"}),e.jsx(Ar,{value:_.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:se,disabled:!_.name||w,children:w?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"}),"Booking..."]}):"Confirm Booking"})]}),n==="confirmed"&&e.jsxs("div",{className:"text-center space-y-5 py-6",children:[e.jsxs("div",{className:"relative mx-auto w-20 h-20",children:[e.jsx("div",{className:"absolute inset-0 rounded-full bg-emerald-100 animate-ping opacity-30"}),e.jsx("div",{className:"relative w-20 h-20 rounded-full bg-gradient-to-br from-emerald-400 to-emerald-600 flex items-center justify-center shadow-lg shadow-emerald-200",children:e.jsx(ha,{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 ",(T==null?void 0:T.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&&ys(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."}),((T==null?void 0:T.phone)||(T==null?void 0:T.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:[(T==null?void 0:T.phone)&&e.jsxs("a",{href:`tel:${T.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(ea,{className:"h-3.5 w-3.5"})," Call"]}),(T==null?void 0:T.email)&&e.jsxs("a",{href:`mailto:${T.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(br,{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(Md,{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 fCs(){const s=Qu().pathname.slice(1).split("/")[0];return C.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(Olt,{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 gCs(){const s=Qu().pathname.slice(1);return C.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(iYe,{slugOverride:s})}function Rlt({slugOverride:t}){const{slug:s}=Po(),r=t||s,[n,a]=C.useState(!1),[o,l]=C.useState({}),[i,c]=C.useState(0),[u,p]=C.useState(!1),{data:f,isLoading:y}=wt({queryKey:["public-landing-page",r],queryFn:async()=>{const{data:$,error:q}=await G.from("landing_pages").select("*").eq("slug",r).eq("is_published",!0).single();if(q)throw q;return $},enabled:!!r}),{data:_=[]}=wt({queryKey:["public-landing-page-fields",f==null?void 0:f.id],queryFn:async()=>{const{data:$,error:q}=await G.from("landing_page_fields").select("*").eq("page_id",f.id).order("sort_order");if(q)throw q;return $},enabled:!!(f!=null&&f.id)});C.useEffect(()=>{f!=null&&f.id&&G.from("landing_pages").update({view_count:(f.view_count||0)+1}).eq("id",f.id).then(()=>{})},[f==null?void 0:f.id]);const b=Dt({mutationFn:async()=>{const $=_.find(X=>X.field_type==="text"&&X.label.toLowerCase().includes("name")),q=_.find(X=>X.field_type==="email"),U=_.find(X=>X.field_type==="phone"),{error:V}=await G.from("landing_page_submissions").insert([{page_id:f.id,answers:JSON.parse(JSON.stringify(o)),contact_name:$?String(o[$.label]||""):null,contact_email:q?String(o[q.label]||""):null,contact_phone:U?String(o[U.label]||""):null,referrer:document.referrer||null,user_agent:navigator.userAgent,utm_source:new URLSearchParams(window.location.search).get("utm_source"),utm_medium:new URLSearchParams(window.location.search).get("utm_medium"),utm_campaign:new URLSearchParams(window.location.search).get("utm_campaign")}]);if(V)throw V},onSuccess:()=>a(!0)}),w=$=>{$.preventDefault(),!(_.filter(U=>U.is_required&&!o[U.label]).length>0)&&b.mutate()};if(y)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-gray-400 border-t-transparent"})});if(!f)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-700",children:"Page Not Found"}),e.jsx("p",{className:"text-gray-500 mt-2",children:"This page doesn't exist or is no longer available."})]})});const j=f.primary_color||"#406E71",N=f.accent_color||"#2a4c64",S=f,T=f.page_type==="lead_magnet",I=f.page_type==="just_listed"||f.page_type==="just_sold",L=Array.isArray(S.property_photos)?S.property_photos:[],R=S.lead_magnet_file_url||S.lead_magnet_external_url;if(n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:`linear-gradient(135deg, ${j}, ${N})`},children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-8 max-w-md mx-4 text-center",children:[e.jsx(ha,{className:"h-16 w-16 mx-auto mb-4",style:{color:j}}),e.jsx("h2",{className:"text-2xl font-bold mb-2",children:T?"Your download is ready!":"Submitted!"}),e.jsx("p",{className:"text-gray-600",children:f.success_message}),T&&R&&e.jsxs("a",{href:R,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 mt-6 px-6 py-3 rounded-lg text-white font-semibold transition-transform hover:scale-105",style:{backgroundColor:j},children:[e.jsx(ki,{className:"h-5 w-5"}),"Download ",S.lead_magnet_file_name||"Your File"]}),f.agent_name&&e.jsxs("div",{className:"mt-6 pt-4 border-t",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Contact"}),e.jsx("p",{className:"font-semibold",children:f.agent_name}),f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:j},children:[e.jsx(ea,{className:"h-3 w-3"})," ",f.agent_phone]}),f.agent_email&&e.jsxs("a",{href:`mailto:${f.agent_email}`,className:"text-sm flex items-center justify-center gap-1 mt-1",style:{color:j},children:[e.jsx(br,{className:"h-3 w-3"})," ",f.agent_email]})]})]})});if(I){const $=q=>{const U=parseFloat(q.replace(/[^0-9.]/g,""));return isNaN(U)?q:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(U)};return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[u&&L.length>0&&e.jsxs("div",{className:"fixed inset-0 z-50 bg-black/95 flex items-center justify-center",onClick:()=>p(!1),children:[e.jsx("button",{onClick:()=>p(!1),className:"absolute top-4 right-4 text-white/80 hover:text-white z-10",children:e.jsx(Ur,{className:"h-8 w-8"})}),e.jsx("button",{onClick:q=>{q.stopPropagation(),c(U=>U===0?L.length-1:U-1)},className:"absolute left-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(Xl,{className:"h-6 w-6"})}),e.jsx("img",{src:L[i],alt:`Property photo ${i+1}`,className:"max-h-[90vh] max-w-[90vw] object-contain rounded-lg",onClick:q=>q.stopPropagation()}),e.jsx("button",{onClick:q=>{q.stopPropagation(),c(U=>U===L.length-1?0:U+1)},className:"absolute right-4 top-1/2 -translate-y-1/2 bg-white/10 hover:bg-white/20 text-white rounded-full p-3 transition-colors z-10",children:e.jsx(Xa,{className:"h-6 w-6"})}),e.jsxs("div",{className:"absolute bottom-6 left-1/2 -translate-x-1/2 text-white/70 text-sm",children:[i+1," / ",L.length]})]}),L.length>0&&e.jsxs("div",{className:"relative max-w-6xl mx-auto px-4 pt-6",children:[e.jsx("div",{className:"absolute top-10 left-8 z-10 px-4 py-1.5 rounded-full text-white font-bold text-sm uppercase tracking-wider shadow-lg",style:{backgroundColor:S.property_status==="just_sold"?"#e74c3c":j},children:S.property_status==="just_sold"?"🎉 Just Sold":"🏡 Just Listed"}),L.length===1?e.jsxs("div",{className:"rounded-2xl overflow-hidden cursor-pointer group",onClick:()=>{c(0),p(!0)},children:[e.jsx("img",{src:L[0],alt:"Property",className:"w-full h-[50vh] object-cover group-hover:scale-105 transition-transform duration-500"}),e.jsxs("div",{className:"absolute bottom-4 right-4 bg-black/60 text-white px-3 py-1.5 rounded-lg text-sm flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(Bb,{className:"h-4 w-4"})," View"]})]}):L.length===2?e.jsx("div",{className:"grid grid-cols-2 gap-2 rounded-2xl overflow-hidden",children:L.slice(0,2).map((q,U)=>e.jsx("div",{className:"cursor-pointer group relative",onClick:()=>{c(U),p(!0)},children:e.jsx("img",{src:q,alt:`Property ${U+1}`,className:"w-full h-[45vh] object-cover group-hover:scale-105 transition-transform duration-500"})},U))}):e.jsxs("div",{className:"grid grid-cols-4 gap-2 rounded-2xl overflow-hidden",style:{height:"55vh"},children:[e.jsx("div",{className:"col-span-2 row-span-2 cursor-pointer group relative",onClick:()=>{c(0),p(!0)},children:e.jsx("img",{src:L[0],alt:"Property main",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),L.slice(1,5).map((q,U)=>e.jsxs("div",{className:"cursor-pointer group relative",onClick:()=>{c(U+1),p(!0)},children:[e.jsx("img",{src:q,alt:`Property ${U+2}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}),U===3&&L.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center text-white font-bold text-lg",children:["+",L.length-5," more"]})]},U))]}),L.length>2&&e.jsxs("button",{onClick:()=>{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(Bb,{className:"h-4 w-4"})," View all ",L.length," photos"]})]}),L.length===0&&e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${j}, ${N})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-4 py-8",children:e.jsxs("div",{className:"grid md:grid-cols-5 gap-6",children:[e.jsx("div",{className:"md:col-span-3 space-y-6",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 md:p-8",children:[S.property_price&&e.jsx("p",{className:"text-3xl md:text-4xl font-bold mb-2",style:{color:j},children:$(S.property_price)}),S.property_address&&e.jsxs("p",{className:"text-gray-600 flex items-center gap-1.5 mb-5 text-lg",children:[e.jsx(Ui,{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(Kv,{className:"h-5 w-5",style:{color:j}})," ",S.property_beds]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bedrooms"})]}),S.property_baths&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(n0,{className:"h-5 w-5",style:{color:j}})," ",S.property_baths]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bathrooms"})]}),S.property_sqft&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-lg font-semibold",children:[e.jsx(aL,{className:"h-5 w-5",style:{color:j}})," ",Number(S.property_sqft).toLocaleString()]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Sq Ft"})]})]}),S.property_description&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-800 mb-2",children:"About This Property"}),e.jsx("p",{className:"text-gray-600 leading-relaxed whitespace-pre-line",children:S.property_description})]})]})}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-6 sticky top-6",children:[e.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:j},children:S.property_status==="just_sold"?"Want results like this?":"Interested in this property?"}),e.jsx("p",{className:"text-gray-500 text-sm mb-4",children:"Fill out the form and I'll be in touch!"}),f.agent_name&&e.jsxs("div",{className:"flex items-center gap-3 mb-5 pb-4 border-b",children:[f.agent_photo_url&&e.jsx("img",{src:f.agent_photo_url,alt:f.agent_name,className:"h-12 w-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm",children:f.agent_name}),e.jsxs("div",{className:"flex flex-col gap-0.5 text-xs text-gray-500",children:[f.agent_phone&&e.jsxs("a",{href:`tel:${f.agent_phone}`,className:"flex items-center gap-1 hover:underline",children:[e.jsx(ea,{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(br,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:w,className:"space-y-3",children:[_.map(q=>e.jsxs("div",{children:[e.jsxs(_e,{className:"text-xs font-medium",children:[q.label,q.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),vze(q,o,l)]},q.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:j},disabled:b.isPending,children:b.isPending?"Submitting...":"Submit"}),b.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"relative py-16 px-4",style:{background:f.hero_image_url?`linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)), url(${f.hero_image_url}) center/cover`:`linear-gradient(135deg, ${j}, ${N})`},children:e.jsxs("div",{className:"max-w-2xl mx-auto text-center text-white",children:[f.logo_url&&e.jsx("img",{src:f.logo_url,alt:"Logo",className:"h-12 w-auto mx-auto mb-6"}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold",children:f.hero_headline}),f.hero_subtext&&e.jsx("p",{className:"mt-3 text-lg opacity-90",children:f.hero_subtext}),T&&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(ki,{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:[T&&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(ea,{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(br,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:w,className:"space-y-4",children:[_.map($=>e.jsxs("div",{children:[e.jsxs(_e,{className:"text-sm font-medium",children:[$.label,$.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),vze($,o,l)]},$.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:j},disabled:b.isPending,children:b.isPending?"Submitting...":T?"Get My Free Download":"Submit"}),b.isError&&e.jsx("p",{className:"text-sm text-red-500 text-center",children:"Something went wrong. Please try again."})]})]})}),e.jsx("div",{className:"text-center py-8 text-xs text-gray-400",children:"Powered by LevelUp"})]})}function vze(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(Fe,{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(Ar,{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(rr,{value:String(a),onValueChange:l=>r(i=>({...i,[t.label]:l})),children:[e.jsx(tr,{className:"mt-1",children:e.jsx(nr,{placeholder:"Select..."})}),e.jsx(sr,{children:o.map(l=>e.jsx(Tt,{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(Yo,{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(Br,{checked:!!a,onCheckedChange:l=>r(i=>({...i,[t.label]:l?"Yes":"No"}))}),e.jsx("span",{className:"text-sm text-gray-600",children:a?"Yes":"No"})]});default:return e.jsx(Fe,{value:String(a),onChange:l=>r(i=>({...i,[t.label]:l.target.value})),className:"mt-1"})}}function xCs(){const s=Qu().pathname.slice(1).split("/")[0];return C.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(Rlt,{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 yCs=({team:t,onSelect:s})=>{const{data:r}=wt({queryKey:["team-card-info",t.id],queryFn:async()=>{const{data:n}=await G.from("team_members").select("user_id, role").eq("team_id",t.id),a=(n==null?void 0:n.length)||0,o=n==null?void 0:n.find(i=>i.role==="team_leader");let l=null;if(o){const{data:i}=await G.from("profiles").select("name, avatar_url").eq("id",o.user_id).single();l=i}return{count:a,leaderProfile:l}}});return e.jsxs(Ee,{className:"cursor-pointer hover:shadow-md transition-shadow group",onClick:s,children:[e.jsx(It,{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(Ot,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(fr,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(nt,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(mr,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs(Oe,{className:"space-y-3",children:[(r==null?void 0:r.leaderProfile)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(yn,{className:"h-6 w-6",children:[e.jsx(Da,{src:r.leaderProfile.avatar_url||""}),e.jsx(vn,{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(Sm,{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(Bh,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"capitalize text-xs",children:t.contact_visibility.replace("_"," ")})]}),t.lead_pond_enabled&&e.jsx(nt,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(nt,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(nt,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},vCs=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Ws(),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:y,addMember:_,removeMember:b,updateMemberRole:w}=QS(i),[j,N]=C.useState(!1),[S,T]=C.useState(null),{data:I}=wt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:$,error:q}=await G.from("brokerages").select("id, name").order("name");if(q)throw q;return $||[]},enabled:s}),{data:L}=wt({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:$,error:q}=await G.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if(q)throw q;return $||[]},enabled:!!l}),R=async $=>{const q=$.brokerage_id||l||null,U=await p.mutateAsync({name:$.name,brokerage_id:q,description:$.description});if($.leaderId&&$.leaderId!=="none"&&await _.mutateAsync({team_id:U.id,user_id:$.leaderId,role:"team_leader"}),$.memberIds)for(const V of $.memberIds)await _.mutateAsync({team_id:U.id,user_id:V,role:"team_member"});N(!1)};return!r&&!s?e.jsx(Es,{title:"Teams",description:"Team Management",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(mr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground",children:"You need brokerage manager access to manage teams."})]})}):e.jsx(Es,{title:"Teams",description:"Create and manage teams within your brokerage",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Teams"}),e.jsx("p",{className:"text-muted-foreground",children:"Organize your agents into teams with leaders and shared resources."})]}),e.jsxs(K,{onClick:()=>N(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(Let,{open:j,onOpenChange:N,onCreateTeam:R,isCreating:p.isPending,brokerageAgents:L||[],isAdmin:s,allBrokerages:I,activeBrokerageId:l}),u&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map($=>e.jsx(Ee,{children:e.jsxs(Oe,{className:"p-6",children:[e.jsx(xs,{className:"h-5 w-32 mb-3"}),e.jsx(xs,{className:"h-4 w-48 mb-4"}),e.jsx(xs,{className:"h-8 w-full"})]})},$))}),!u&&c.length===0&&!S&&e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(mr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first team to organize agents and share resources."}),e.jsxs(K,{onClick:()=>N(!0),children:[e.jsx(Zs,{className:"mr-2 h-4 w-4"}),"Create Your First Team"]})]})}),!u&&c.length>0&&!S&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:c.map($=>e.jsx(yCs,{team:$,onSelect:()=>T($)},$.id))}),S&&e.jsx(Iet,{team:S,brokerageAgents:L||[],onBack:()=>T(null),onUpdate:$=>f.mutateAsync({id:S.id,...$}).then(q=>T(q)),onAddMember:($,q)=>_.mutateAsync({team_id:S.id,user_id:$,role:q}),onRemoveMember:$=>b.mutateAsync({team_id:S.id,member_id:$}),onUpdateRole:($,q)=>w.mutateAsync({team_id:S.id,member_id:$,role:q}),onDeleteTeam:()=>y.mutate(S.id),isUpdating:f.isPending,isAddingMember:_.isPending})]})})},_Cs=()=>{const{data:t,isLoading:s}=Lg(),{useTeamMembers:r}=QS(),{data:n=[],isLoading:a}=r((t==null?void 0:t.teamId)||"");if(s)return e.jsx(Es,{title:"My Team",description:"Your team",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(xs,{className:"h-8 w-48"}),e.jsx(xs,{className:"h-40 w-full"})]})});if(!t)return e.jsx(Es,{title:"My Team",description:"Your team",children:e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(mr,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Team Yet"}),e.jsx("p",{className:"text-muted-foreground",children:"You haven't been assigned to a team. Ask your brokerage manager to add you."})]})})});const o=t.team;return e.jsx(Es,{title:"My Team",description:o.name,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:o.name}),e.jsx(nt,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(Sm,{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(Aa,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(ja,{className:"flex-wrap",children:[e.jsx(js,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(js,{value:"contacts",children:[e.jsx(B4,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(js,{value:"lead-pond",children:[e.jsx(Wx,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(js,{value:"shared-assets",children:[e.jsx(Cm,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]})]}),e.jsx($s,{value:"members",className:"space-y-2",children:a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(l=>e.jsx(xs,{className:"h-16 w-full"},l))}):n.map(l=>{var i,c,u,p;return e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex items-center gap-3 p-4",children:[e.jsxs(yn,{className:"h-10 w-10",children:[e.jsx(Da,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),e.jsx(vn,{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(nt,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(Sm,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(nt,{variant:"secondary",className:"ml-auto",children:"Member"})]})},l.id)})}),o.contact_visibility!=="private"&&e.jsx($s,{value:"contacts",className:"space-y-4",children:e.jsx(gNe,{})}),o.lead_pond_enabled&&e.jsx($s,{value:"lead-pond",className:"space-y-4",children:e.jsx(xNe,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx($s,{value:"shared-assets",className:"space-y-4",children:e.jsx(Pet,{teamId:t.teamId})})]})]})})};function bCs(){const{user:t}=Ws(),s=ss(),r=wt({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:N}=await G.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(N)throw N;return j},enabled:!!t}),n=wt({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:N}=await G.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(N)throw N;return j},enabled:!!t}),a=wt({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:N}=await G.from("agent_availability_slots").select("*").eq("user_id",t.id).order("day_of_week").order("start_time");if(N)throw N;return j},enabled:!!t}),o=wt({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:N}=await G.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(N)throw N;return j},enabled:!!t}),l=wt({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:j,error:N}=await G.from("bookings").select("*, booking_type:agent_booking_types(*)").eq("agent_user_id",t.id).order("booking_date",{ascending:!1});if(N)throw N;return j},enabled:!!t}),i=Dt({mutationFn:async()=>{const{data:j,error:N}=await G.from("agent_booking_settings").insert({user_id:t.id,slug:""}).select().single();if(N)throw N;const S=[{name:"Listing Consultation",description:"Get a comprehensive market analysis and listing strategy for your home",duration_minutes:60,color:"#10B981",icon:"Home",sort_order:0},{name:"Buyer Consultation",description:"Discuss your home search criteria, budget, and buying process",duration_minutes:45,color:"#3B82F6",icon:"Search",sort_order:1},{name:"Home Valuation",description:"Find out what your home is worth in today's market",duration_minutes:30,color:"#F59E0B",icon:"DollarSign",sort_order:2},{name:"General Meeting",description:"Coffee chat, check-in, or quick real estate question",duration_minutes:30,color:"#8B5CF6",icon:"Coffee",sort_order:3}],{error:T}=await G.from("agent_booking_types").insert(S.map(R=>({...R,user_id:t.id})));if(T)throw T;const I=[1,2,3,4,5].map(R=>({user_id:t.id,day_of_week:R,start_time:"09:00",end_time:"17:00"})),{error:L}=await G.from("agent_availability_slots").insert(I);if(L)throw L;return j},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),s.invalidateQueries({queryKey:["booking-types"]}),s.invalidateQueries({queryKey:["availability-slots"]}),me.success("Scheduler set up successfully!")},onError:j=>me.error(j.message)}),c=Dt({mutationFn:async j=>{const{error:N}=await G.from("agent_booking_settings").update(j).eq("user_id",t.id);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),me.success("Settings updated")},onError:j=>me.error(j.message)}),u=Dt({mutationFn:async j=>{const N={...j,user_id:t.id};if(j.id){const{error:S}=await G.from("agent_booking_types").update(N).eq("id",j.id);if(S)throw S}else{const{error:S}=await G.from("agent_booking_types").insert(N);if(S)throw S}},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),me.success("Booking type saved")},onError:j=>me.error(j.message)}),p=Dt({mutationFn:async j=>{const{error:N}=await G.from("agent_booking_types").delete().eq("id",j);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),me.success("Booking type deleted")},onError:j=>me.error(j.message)}),f=Dt({mutationFn:async j=>{const N={...j,user_id:t.id};if(j.id){const{error:S}=await G.from("agent_availability_slots").update(N).eq("id",j.id);if(S)throw S}else{const{error:S}=await G.from("agent_availability_slots").insert(N);if(S)throw S}},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:j=>me.error(j.message)}),y=Dt({mutationFn:async j=>{const{error:N}=await G.from("agent_availability_slots").delete().eq("id",j);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:j=>me.error(j.message)}),_=Dt({mutationFn:async j=>{const{error:N}=await G.from("agent_blocked_dates").insert({...j,user_id:t.id});if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),me.success("Date blocked")},onError:j=>me.error(j.message)}),b=Dt({mutationFn:async j=>{const{error:N}=await G.from("agent_blocked_dates").delete().eq("id",j);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:j=>me.error(j.message)}),w=Dt({mutationFn:async({id:j,reason:N})=>{const{error:S}=await G.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:N}).eq("id",j);if(S)throw S},onSuccess:()=>{s.invalidateQueries({queryKey:["bookings"]}),me.success("Booking cancelled")},onError:j=>me.error(j.message)});return{settings:r.data,bookingTypes:n.data??[],availability:a.data??[],blockedDates:o.data??[],bookings:l.data??[],isLoading:r.isLoading,initializeSettings:i,updateSettings:c,upsertBookingType:u,deleteBookingType:p,upsertAvailability:f,deleteAvailability:y,addBlockedDate:_,removeBlockedDate:b,cancelBooking:w}}const _ze={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function wCs({types:t,onSave:s,onDelete:r}){const[n,a]=C.useState(null),[o,l]=C.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(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(Ot,{children:"Booking Types"}),e.jsx(fr,{children:"The meeting types prospects can book with you"})]}),e.jsxs(K,{onClick:i,size:"sm",children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Add Type"]})]}),e.jsx(Oe,{children:t.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No booking types yet. Add one to get started."}):e.jsx("div",{className:"grid gap-3",children:t.map(p=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-lg",style:{backgroundColor:p.color+"20"},children:_ze[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(nt,{variant:"secondary",className:"text-xs",children:"Inactive"}),p.qualification_enabled&&e.jsxs(nt,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(ZI,{className:"h-3 w-3"})," Qualifying"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3"}),p.duration_minutes," min",p.description&&e.jsxs("span",{children:["· ",p.description.slice(0,60),p.description.length>60?"...":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(p),children:e.jsx($a,{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(jr,{className:"h-4 w-4"})})]})]},p.id))})})]}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsxs(Ns,{children:[n!=null&&n.id?"Edit":"New"," Booking Type"]})}),n&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Name"}),e.jsx(Fe,{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(_e,{children:"Description"}),e.jsx(Ar,{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(_e,{children:"Duration (minutes)"}),e.jsx(Fe,{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(_e,{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(Fe,{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(_e,{children:"Icon"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(_ze).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(_e,{children:"Meeting Link Override (optional)"}),e.jsx(Fe,{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(_e,{children:"Pre-Qualification Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask qualifying questions before booking"})]}),e.jsx(Br,{checked:n.qualification_enabled||!1,onCheckedChange:p=>a({...n,qualification_enabled:p})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(_e,{children:"Active"}),e.jsx(Br,{checked:n.is_active??!0,onCheckedChange:p=>a({...n,is_active:p})})]})]}),e.jsxs(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:u,children:"Save"})]})]})})]})}const bze=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function jCs({slots:t,onSave:s,onDelete:r}){const[n,a]=C.useState(null),[o,l]=C.useState("09:00"),[i,c]=C.useState("17:00"),u=bze.map((f,y)=>t.filter(_=>_.day_of_week===y)),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(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(Tn,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(fr,{children:"Set your available hours for each day"})]}),e.jsx(Oe,{className:"space-y-2",children:bze.map((f,y)=>{const _=u[y];return e.jsxs("div",{className:"flex items-start gap-3 py-2 border-b last:border-0",children:[e.jsx("div",{className:"w-24 pt-1",children:e.jsx("p",{className:"text-sm font-medium",children:f})}),e.jsxs("div",{className:"flex-1 space-y-1",children:[_.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"Unavailable"}):_.map(b=>{var w,j;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(w=b.start_time)==null?void 0:w.slice(0,5),onBlur:N=>s({id:b.id,start_time:N.target.value})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(Fe,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(j=b.end_time)==null?void 0:j.slice(0,5),onBlur:N=>s({id:b.id,end_time:N.target.value})}),e.jsx(Br,{checked:b.is_active,onCheckedChange:N=>s({id:b.id,is_active:N})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>r(b.id),children:e.jsx(jr,{className:"h-3.5 w-3.5 text-muted-foreground"})})]},b.id)}),n===y?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{type:"time",className:"w-28 h-8 text-sm",value:o,onChange:b=>l(b.target.value)}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(Fe,{type:"time",className:"w-28 h-8 text-sm",value:i,onChange:b=>c(b.target.value)}),e.jsx(K,{size:"sm",className:"h-8",onClick:p,children:"Add"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8",onClick:()=>a(null),children:"Cancel"})]}):e.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-muted-foreground",onClick:()=>a(y),children:[e.jsx(Zs,{className:"h-3 w-3 mr-1"})," Add hours"]})]})]},f)})})]})}const kCs={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 NCs({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(ro,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:o.guest_name}),e.jsx(nt,{className:`text-xs ${kCs[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(Md,{className:"h-3.5 w-3.5"}),ys(new Date(o.booking_date+"T00:00:00"),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Tn,{className:"h-3.5 w-3.5"}),(i=o.start_time)==null?void 0:i.slice(0,5)," - ",(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(br,{className:"h-3 w-3"}),o.guest_email]}),o.guest_phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ea,{className:"h-3 w-3"}),o.guest_phone]})]}),o.booking_type&&e.jsx(nt,{variant:"outline",className:"text-xs mt-1",children:o.booking_type.name}),o.guest_message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 italic",children:['"',o.guest_message,'"']})]}),l&&o.status==="confirmed"&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>s(o.id),className:"text-destructive hover:text-destructive",children:[e.jsx($c,{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(It,{children:[e.jsx(Ot,{children:"Upcoming Bookings"}),e.jsxs(fr,{children:[r.length," upcoming appointment",r.length!==1?"s":""]})]}),e.jsx(Oe,{children:r.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No upcoming bookings"}):e.jsx("div",{className:"space-y-3",children:r.map(o=>a(o,!0))})})]}),n.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{children:"Past & Cancelled"})}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function SCs({blockedDates:t,onAdd:s,onRemove:r}){const[n,a]=C.useState(!1),[o,l]=C.useState(""),[i,c]=C.useState(""),u=()=>{o&&(s({blocked_date:o,reason:i||void 0}),a(!1),l(""),c(""))};return e.jsxs(Ee,{children:[e.jsxs(It,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(DI,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(fr,{children:"Block specific dates (vacations, holidays, etc.)"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>a(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-1"})," Block Date"]})]}),e.jsxs(Oe,{children:[n&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx(Fe,{type:"date",value:o,onChange:p=>l(p.target.value),className:"w-40"}),e.jsx(Fe,{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:ys(new Date(p.blocked_date+"T00:00:00"),"MMM d, yyyy")}),p.reason&&e.jsxs("span",{className:"text-muted-foreground",children:["(",p.reason,")"]}),e.jsx("button",{onClick:()=>r(p.id),className:"ml-1 text-muted-foreground hover:text-destructive",children:e.jsx(Ur,{className:"h-3.5 w-3.5"})})]},p.id))})]})]})}function CCs(){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:y,removeBlockedDate:_,cancelBooking:b}=bCs(),[w,j]=C.useState(""),[N,S]=C.useState(15);w||t!=null&&t.meeting_link;const T=t!=null&&t.slug?`https://booking.relevelup.com/${t.slug}`:null;return o?e.jsx(Es,{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(Es,{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(Md,{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:[T&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(T),me.success("Booking link copied!")},children:[e.jsx(mi,{className:"h-4 w-4 mr-1"})," Copy Link"]}),e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:T,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rn,{className:"h-4 w-4 mr-1"})," Preview"]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{htmlFor:"scheduler-active",className:"text-sm",children:"Active"}),e.jsx(Br,{id:"scheduler-active",checked:t.is_active,onCheckedChange:I=>i.mutate({is_active:I})})]})]})]}),e.jsxs(Aa,{defaultValue:"types",className:"space-y-4",children:[e.jsxs(ja,{children:[e.jsx(js,{value:"types",children:"Booking Types"}),e.jsx(js,{value:"availability",children:"Availability"}),e.jsx(js,{value:"settings",children:"Settings"}),e.jsxs(js,{value:"bookings",children:["Bookings",a.filter(I=>I.status==="confirmed").length>0&&e.jsx(nt,{variant:"secondary",className:"ml-1.5 text-xs",children:a.filter(I=>I.status==="confirmed").length})]})]}),e.jsx($s,{value:"types",children:e.jsx(wCs,{types:s,onSave:I=>c.mutate(I),onDelete:I=>u.mutate(I)})}),e.jsx($s,{value:"availability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(jCs,{slots:r,onSave:I=>p.mutate(I),onDelete:I=>f.mutate(I)}),e.jsx(SCs,{blockedDates:n,onAdd:I=>y.mutate(I),onRemove:I=>_.mutate(I)})]})}),e.jsx($s,{value:"settings",children:e.jsxs(Ee,{children:[e.jsxs(It,{children:[e.jsxs(Ot,{className:"flex items-center gap-2",children:[e.jsx(lL,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(fr,{children:"Configure your booking page defaults"})]}),e.jsxs(Oe,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Booking Page URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{value:t.slug,readOnly:!0,className:"bg-muted"}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>{T&&(navigator.clipboard.writeText(T),me.success("Copied!"))},children:e.jsx(mi,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:T})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(_e,{htmlFor:"meeting-link",children:[e.jsx(sl,{className:"h-4 w-4 inline mr-1"}),"Default Meeting Link"]}),e.jsx(Fe,{id:"meeting-link",placeholder:"https://zoom.us/j/your-personal-link",defaultValue:t.meeting_link||"",onBlur:I=>i.mutate({meeting_link:I.target.value||null})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Zoom personal link, Google Meet, or phone number"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Buffer Between Meetings"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{type:"number",min:0,max:60,defaultValue:t.buffer_minutes,onBlur:I=>i.mutate({buffer_minutes:parseInt(I.target.value)||15})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"min"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Minimum Notice"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{type:"number",min:0,max:72,defaultValue:t.min_notice_hours,onBlur:I=>i.mutate({min_notice_hours:parseInt(I.target.value)||2})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"hours"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(_e,{children:"Max Advance Booking"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{type:"number",min:1,max:90,defaultValue:t.max_advance_days,onBlur:I=>i.mutate({max_advance_days:parseInt(I.target.value)||30})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"days"})]})]})]})]})]})}),e.jsx($s,{value:"bookings",children:e.jsx(NCs,{bookings:a,onCancel:I=>b.mutate({id:I})})})]})]})}):e.jsx(Es,{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(Md,{className:"h-8 w-8 text-primary"})}),e.jsx("h1",{className:"text-3xl font-bold",children:"LevelUp Scheduler"}),e.jsx("p",{className:"text-muted-foreground text-lg max-w-md mx-auto",children:"Your own booking page — built for real estate. Prospects book with you, get auto-added to your CRM, and you never miss a lead."})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6 space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[{icon:"🏠",title:"Listing Consultation",desc:"60 min"},{icon:"🔍",title:"Buyer Consultation",desc:"45 min"},{icon:"💰",title:"Home Valuation",desc:"30 min"},{icon:"☕",title:"General Meeting",desc:"30 min"}].map(I=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-muted/30",children:[e.jsx("span",{className:"text-2xl",children:I.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:I.desc})]})]},I.title))}),e.jsx(Zl,{}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsx("p",{children:"✅ Auto-creates CRM contacts from every booking"}),e.jsx("p",{children:"✅ Optional pre-qualification questions per booking type"}),e.jsx("p",{children:"✅ Embeds on your Smart Card — replaces TidyCal"}),e.jsx("p",{children:"✅ Standalone shareable booking page"})]}),e.jsxs(K,{onClick:()=>l.mutate(),disabled:l.isPending,className:"w-full",size:"lg",children:[e.jsx(hn,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const wze=[{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 MCs(){const{user:t}=Ws(),s=ai(),{toast:r}=Ra(),n=Pr(),a=ss(),[o,l]=C.useState(!1),[i,c]=C.useState(null),[u,p]=C.useState(null),[f,y]=C.useState({title:"",description:"",page_type:"lead_capture"}),{data:_=[],isLoading:b}=wt({queryKey:["landing-pages",s],queryFn:async()=>{const{data:S,error:T}=await G.from("landing_pages").select("*").eq("user_id",s).order("created_at",{ascending:!1});if(T)throw T;return S},enabled:!!s}),w=Dt({mutationFn:async()=>{const S=f.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")+"-"+Date.now().toString(36),{data:T}=await G.from("profiles").select("name, phone, avatar_url, email").eq("id",s).single(),I=f.page_type==="just_listed"||f.page_type==="just_sold",{data:L,error:R}=await G.from("landing_pages").insert({user_id:s,title:f.title,description:f.description||null,page_type:f.page_type,slug:S,hero_headline:I?f.page_type==="just_listed"?"🏡 Just Listed":"🎉 Just Sold":f.page_type==="lead_magnet"?"📥 Free Download":f.title,agent_name:(T==null?void 0:T.name)||null,agent_phone:(T==null?void 0:T.phone)||null,agent_email:(T==null?void 0:T.email)||t.email||null,agent_photo_url:(T==null?void 0:T.avatar_url)||null,property_status:I?f.page_type.replace("just_",""):null}).select().single();if(R)throw R;const $=TCs(f.page_type);if($.length>0){const{error:q}=await G.from("landing_page_fields").insert($.map((U,V)=>({...U,page_id:L.id,sort_order:V})));if(q)throw q}return L},onSuccess:S=>{a.invalidateQueries({queryKey:["landing-pages"]}),l(!1),y({title:"",description:"",page_type:"lead_capture"}),r({title:"Landing page created!"}),n(`/mission-control/landing-pages/${S.id}`)},onError:S=>r({title:"Error",description:S.message,variant:"destructive"})}),j=Dt({mutationFn:async S=>{const{error:T}=await G.from("landing_pages").delete().eq("id",S);if(T)throw T},onSuccess:()=>{a.invalidateQueries({queryKey:["landing-pages"]}),c(null),r({title:"Landing page deleted"})}}),N=S=>`https://pages.relevelup.com/${S}`;return e.jsxs(Es,{title:"Landing Pages",children:[e.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Landing Pages"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Create branded lead capture pages for events, consultations, and more"})]}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," New Page"]})]}),b?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?e.jsx(Ee,{children:e.jsxs(Oe,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(In,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold",children:"No landing pages yet"}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1 mb-4",children:"Create your first page to start capturing leads"}),e.jsxs(K,{onClick:()=>l(!0),children:[e.jsx(Zs,{className:"h-4 w-4 mr-2"})," Create Landing Page"]})]})}):e.jsx("div",{className:"grid gap-4",children:_.map(S=>{var T;return e.jsx(Ee,{className:"hover:shadow-md transition-shadow",children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>n(`/mission-control/landing-pages/${S.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:S.title}),e.jsx(nt,{variant:S.is_published?"default":"secondary",className:"text-[10px]",children:S.is_published?"Published":"Draft"}),e.jsx(nt,{variant:"outline",className:"text-[10px]",children:((T=wze.find(I=>I.id===S.page_type))==null?void 0:T.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(va,{className:"h-3 w-3"})," ",S.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(In,{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(N(S.slug)),children:e.jsx(r1,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(N(S.slug)),r({title:"Link copied!"})},children:e.jsx(mi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:N(S.slug),target:"_blank",rel:"noopener noreferrer",children:e.jsx(rn,{className:"h-3.5 w-3.5"})})})]}),e.jsxs(ju,{children:[e.jsx(ku,{asChild:!0,children:e.jsx(K,{size:"sm",variant:"ghost",children:e.jsx(ag,{className:"h-4 w-4"})})}),e.jsxs(Jd,{align:"end",children:[e.jsxs(Ta,{onClick:()=>n(`/mission-control/landing-pages/${S.id}`),children:[e.jsx($a,{className:"h-3.5 w-3.5 mr-2"})," Edit"]}),e.jsxs(Ta,{onClick:()=>c(S.id),className:"text-destructive",children:[e.jsx(jr,{className:"h-3.5 w-3.5 mr-2"})," Delete"]})]})]})]})]})})},S.id)})})]}),e.jsx(_s,{open:o,onOpenChange:l,children:e.jsxs(vs,{children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"Create Landing Page"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Page Title"}),e.jsx(Fe,{value:f.title,onChange:S=>y(T=>({...T,title:S.target.value})),placeholder:"e.g. Veterans Home & Land Expo"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Description (optional)"}),e.jsx(Ar,{value:f.description,onChange:S=>y(T=>({...T,description:S.target.value})),placeholder:"Brief internal description...",rows:2})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Page Template"}),e.jsxs(rr,{value:f.page_type,onValueChange:S=>y(T=>({...T,page_type:S})),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:wze.map(S=>e.jsx(Tt,{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(Vn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>w.mutate(),disabled:!f.title.trim()||w.isPending,children:w.isPending?"Creating...":"Create Page"})]})]})}),e.jsx(gc,{open:!!i,onOpenChange:()=>c(null),children:e.jsxs(Ul,{children:[e.jsxs(Vl,{children:[e.jsx(Wl,{children:"Delete Landing Page?"}),e.jsx(Gl,{children:"This will permanently delete this page and all its submissions."})]}),e.jsxs(Hl,{children:[e.jsx(Kl,{children:"Cancel"}),e.jsx(Tl,{onClick:()=>i&&j.mutate(i),children:"Delete"})]})]})}),e.jsx(_s,{open:!!u,onOpenChange:()=>p(null),children:e.jsxs(vs,{className:"max-w-sm",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[u&&e.jsx(nR,{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(mi,{className:"h-3.5 w-3.5 mr-1"})," Copy URL"]})]})]})})]})}function TCs(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 ACs=[{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 ECs(){const{pageId:t}=Po(),s=Pr(),{user:r}=Ws(),n=ai(),{toast:a}=Ra(),o=ss(),[l,i]=C.useState(null),[c,u]=C.useState(!1),{data:p,isLoading:f}=wt({queryKey:["landing-page",t],queryFn:async()=>{const{data:re,error:ne}=await G.from("landing_pages").select("*").eq("id",t).single();if(ne)throw ne;return re},enabled:!!t}),{data:y=[],isLoading:_}=wt({queryKey:["landing-page-fields",t],queryFn:async()=>{const{data:re,error:ne}=await G.from("landing_page_fields").select("*").eq("page_id",t).order("sort_order");if(ne)throw ne;return re},enabled:!!t}),{data:b=[]}=wt({queryKey:["landing-page-submissions",t],queryFn:async()=>{const{data:re,error:ne}=await G.from("landing_page_submissions").select("*").eq("page_id",t).order("created_at",{ascending:!1});if(ne)throw ne;return re},enabled:!!t}),{data:w=[]}=wt({queryKey:["my-listings-for-pages",n],queryFn:async()=>{const{data:re,error:ne}=await G.from("listings").select("id, property_address, city, state, price, bedrooms, bathrooms, square_footage, description, status").eq("agent_id",n).order("created_at",{ascending:!1});if(ne)throw ne;return re},enabled:!!r&&((p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold")}),[j,N]=C.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,T]=C.useState([]);C.useEffect(()=>{p&&N({title:p.title,hero_headline:p.hero_headline,hero_subtext:p.hero_subtext||"",hero_image_url:p.hero_image_url,logo_url:p.logo_url,primary_color:p.primary_color,accent_color:p.accent_color,agent_name:p.agent_name||"",agent_phone:p.agent_phone||"",agent_email:p.agent_email||"",agent_photo_url:p.agent_photo_url,success_message:p.success_message||"Thank you! We'll be in touch soon.",is_published:p.is_published,description:p.description||"",lead_magnet_file_url:p.lead_magnet_file_url||null,lead_magnet_file_name:p.lead_magnet_file_name||null,lead_magnet_external_url:p.lead_magnet_external_url||null,listing_id:p.listing_id||null,property_address:p.property_address||"",property_price:p.property_price||"",property_beds:p.property_beds||"",property_baths:p.property_baths||"",property_sqft:p.property_sqft||"",property_description:p.property_description||"",property_photos:Array.isArray(p.property_photos)?p.property_photos:[],property_status:p.property_status||"just_listed"})},[p]),C.useEffect(()=>{y.length>0&&T(y.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})))},[y]);const I=Dt({mutationFn:async()=>{const{error:re}=await G.from("landing_pages").update({title:j.title,hero_headline:j.hero_headline,hero_subtext:j.hero_subtext||null,hero_image_url:j.hero_image_url,logo_url:j.logo_url,primary_color:j.primary_color,accent_color:j.accent_color,agent_name:j.agent_name||null,agent_phone:j.agent_phone||null,agent_email:j.agent_email||null,agent_photo_url:j.agent_photo_url,success_message:j.success_message,is_published:j.is_published,description:j.description||null,lead_magnet_file_url:j.lead_magnet_file_url,lead_magnet_file_name:j.lead_magnet_file_name,lead_magnet_external_url:j.lead_magnet_external_url,listing_id:j.listing_id,property_address:j.property_address||null,property_price:j.property_price||null,property_beds:j.property_beds||null,property_baths:j.property_baths||null,property_sqft:j.property_sqft||null,property_description:j.property_description||null,property_photos:j.property_photos,property_status:j.property_status,updated_at:new Date().toISOString()}).eq("id",t);if(re)throw re;if(await G.from("landing_page_fields").delete().eq("page_id",t),S.length>0){const{error:ne}=await G.from("landing_page_fields").insert(S.map((le,he)=>({page_id:t,field_type:le.field_type,label:le.label,placeholder:le.placeholder||null,is_required:le.is_required,options:le.options?JSON.parse(le.options):null,sort_order:he})));if(ne)throw ne}},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"})}),L=async(re,ne)=>{const le=re.name.split(".").pop(),he=`landing-pages/${r.id}/${ne}-${Date.now()}.${le}`,{error:we}=await G.storage.from("recruit-landing").upload(he,re);if(we)throw we;const{data:{publicUrl:ye}}=G.storage.from("recruit-landing").getPublicUrl(he);return ye},R=async(re,ne)=>{var he;const le=(he=re.target.files)==null?void 0:he[0];if(le){i(ne);try{const we=await L(le,ne);N(ye=>({...ye,[ne]:we})),a({title:"Image uploaded!"})}catch(we){a({title:"Upload failed",description:we.message,variant:"destructive"})}finally{i(null)}}},$=async re=>{var le;const ne=(le=re.target.files)==null?void 0:le[0];if(ne){i("lead_magnet");try{const he=await L(ne,"lead-magnet");N(we=>({...we,lead_magnet_file_url:he,lead_magnet_file_name:ne.name})),a({title:"File uploaded!"})}catch(he){a({title:"Upload failed",description:he.message,variant:"destructive"})}finally{i(null)}}},q=async re=>{const ne=re.target.files;if(!(!ne||ne.length===0)){i("property_photos");try{const le=[];for(const he of Array.from(ne)){const we=await L(he,"property-photo");le.push(we)}N(he=>({...he,property_photos:[...he.property_photos,...le]})),a({title:`${le.length} photo(s) uploaded!`})}catch(le){a({title:"Upload failed",description:le.message,variant:"destructive"})}finally{i(null)}}},U=async re=>{const ne=w.find(he=>he.id===re);if(!ne)return;const{data:le}=await G.from("listing_photos").select("photo_url").eq("listing_id",re).order("sort_order");N(he=>({...he,listing_id:re,property_address:ne.property_address||`${ne.city}, ${ne.state}`,property_price:ne.price?`$${ne.price.toLocaleString()}`:"",property_beds:ne.bedrooms?String(ne.bedrooms):"",property_baths:ne.bathrooms?String(ne.bathrooms):"",property_sqft:ne.square_footage?ne.square_footage.toLocaleString():"",property_description:ne.description||"",property_photos:(le==null?void 0:le.map(we=>we.photo_url))||he.property_photos})),a({title:"Listing data imported!"})},V=()=>{T(re=>[...re,{field_type:"text",label:"",placeholder:"",is_required:!1,options:null,sort_order:re.length}])},X=(re,ne)=>{T(le=>le.map((he,we)=>we===re?{...he,...ne}:he))},se=re=>{T(ne=>ne.filter((le,he)=>he!==re))},ee=p?`https://pages.relevelup.com/${p.slug}`:"",Q=(p==null?void 0:p.page_type)==="lead_magnet",de=(p==null?void 0:p.page_type)==="just_listed"||(p==null?void 0:p.page_type)==="just_sold";return f||_?e.jsx(Es,{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(Es,{title:j.title||"Edit Page",children:[e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>s("/mission-control/landing-pages"),children:e.jsx(di,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:j.title||"Untitled Page"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(nt,{variant:j.is_published?"default":"secondary",className:"text-[10px]",children:j.is_published?"Published":"Draft"}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(va,{className:"h-3 w-3"})," ",p.view_count," views"]}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(mr,{className:"h-3 w-3"})," ",b.length," submissions"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[j.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>u(!0),children:e.jsx(r1,{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(mi,{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(rn,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(K,{onClick:()=>I.mutate(),disabled:I.isPending,children:[e.jsx(Wu,{className:"h-4 w-4 mr-2"}),I.isPending?"Saving...":"Save"]})]})]}),e.jsxs(Aa,{defaultValue:"design",children:[e.jsxs(ja,{children:[e.jsx(js,{value:"design",children:"Design"}),Q&&e.jsx(js,{value:"lead_magnet",children:"Lead Magnet"}),de&&e.jsx(js,{value:"property",children:"Property Details"}),e.jsxs(js,{value:"fields",children:["Form Fields (",S.length,")"]}),e.jsxs(js,{value:"submissions",children:["Submissions (",b.length,")"]}),e.jsx(js,{value:"settings",children:"Settings"})]}),e.jsxs($s,{value:"design",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Page Details"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Page Title (internal)"}),e.jsx(Fe,{value:j.title,onChange:re=>N(ne=>({...ne,title:re.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Description (internal)"}),e.jsx(Fe,{value:j.description,onChange:re=>N(ne=>({...ne,description:re.target.value}))})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Hero Section"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Headline"}),e.jsx(Fe,{value:j.hero_headline,onChange:re=>N(ne=>({...ne,hero_headline:re.target.value})),placeholder:"Join us for..."})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Subtext"}),e.jsx(Ar,{value:j.hero_subtext,onChange:re=>N(ne=>({...ne,hero_subtext:re.target.value})),rows:2,placeholder:"A brief description..."})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.hero_image_url&&e.jsx("img",{src:j.hero_image_url,alt:"Hero",className:"h-16 w-28 object-cover rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="hero_image_url",children:e.jsxs("span",{children:[e.jsx(ni,{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=>R(re,"hero_image_url")})]}),j.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N(re=>({...re,hero_image_url:null})),children:e.jsx(jr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Branding"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.logo_url&&e.jsx("img",{src:j.logo_url,alt:"Logo",className:"h-10 w-auto rounded"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="logo_url",children:e.jsxs("span",{children:[e.jsx(ni,{className:"h-3.5 w-3.5 mr-1"}),l==="logo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:re=>R(re,"logo_url")})]})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.agent_photo_url&&e.jsx("img",{src:j.agent_photo_url,alt:"Agent",className:"h-10 w-10 rounded-full object-cover"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="agent_photo_url",children:e.jsxs("span",{children:[e.jsx(ni,{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=>R(re,"agent_photo_url")})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:j.primary_color,onChange:re=>N(ne=>({...ne,primary_color:re.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Fe,{value:j.primary_color,onChange:re=>N(ne=>({...ne,primary_color:re.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:j.accent_color,onChange:re=>N(ne=>({...ne,accent_color:re.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(Fe,{value:j.accent_color,onChange:re=>N(ne=>({...ne,accent_color:re.target.value})),className:"font-mono text-xs"})]})]})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Agent Info (shown on page)"})}),e.jsx(Oe,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Name"}),e.jsx(Fe,{value:j.agent_name,onChange:re=>N(ne=>({...ne,agent_name:re.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Phone"}),e.jsx(Fe,{value:j.agent_phone,onChange:re=>N(ne=>({...ne,agent_phone:re.target.value}))})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Email"}),e.jsx(Fe,{value:j.agent_email,onChange:re=>N(ne=>({...ne,agent_email:re.target.value}))})]})]})})]})]}),Q&&e.jsx($s,{value:"lead_magnet",className:"space-y-4 mt-4",children:e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(ki,{className:"h-4 w-4"})," Giveaway File"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a file or provide an external URL. Visitors will receive the download link after submitting the form."}),e.jsxs("div",{children:[e.jsx(_e,{children:"Upload File (PDF, guide, checklist, etc.)"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[j.lead_magnet_file_name&&e.jsxs(nt,{variant:"outline",className:"gap-1",children:[e.jsx(ki,{className:"h-3 w-3"})," ",j.lead_magnet_file_name]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(K,{variant:"outline",size:"sm",asChild:!0,disabled:l==="lead_magnet",children:e.jsxs("span",{children:[e.jsx(ni,{className:"h-3.5 w-3.5 mr-1"}),l==="lead_magnet"?"Uploading...":"Upload File"]})}),e.jsx("input",{type:"file",className:"hidden",onChange:$})]}),j.lead_magnet_file_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N(re=>({...re,lead_magnet_file_url:null,lead_magnet_file_name:null})),children:e.jsx(jr,{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(_e,{className:"flex items-center gap-1",children:[e.jsx(sl,{className:"h-3.5 w-3.5"})," External URL"]}),e.jsx(Fe,{value:j.lead_magnet_external_url||"",onChange:re=>N(ne=>({...ne,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"})]})]})]})}),de&&e.jsxs($s,{value:"property",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Rn,{className:"h-4 w-4"})," Import from Listing Exchange"]})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pull property details and photos directly from one of your listings, or enter them manually below."}),e.jsxs(rr,{value:j.listing_id||"",onValueChange:re=>U(re),children:[e.jsx(tr,{children:e.jsx(nr,{placeholder:"Select a listing to import..."})}),e.jsx(sr,{children:w.map(re=>{var ne;return e.jsxs(Tt,{value:re.id,children:[re.property_address||`${re.city}, ${re.state}`," — $",(ne=re.price)==null?void 0:ne.toLocaleString()]},re.id)})})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Property Information"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Property Address"}),e.jsx(Fe,{value:j.property_address,onChange:re=>N(ne=>({...ne,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(_e,{children:"Price"}),e.jsx(Fe,{value:j.property_price,onChange:re=>N(ne=>({...ne,property_price:re.target.value})),placeholder:"$450,000"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Beds"}),e.jsx(Fe,{value:j.property_beds,onChange:re=>N(ne=>({...ne,property_beds:re.target.value})),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Baths"}),e.jsx(Fe,{value:j.property_baths,onChange:re=>N(ne=>({...ne,property_baths:re.target.value})),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Sq Ft"}),e.jsx(Fe,{value:j.property_sqft,onChange:re=>N(ne=>({...ne,property_sqft:re.target.value})),placeholder:"2,400"})]})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Description"}),e.jsx(Ar,{value:j.property_description,onChange:re=>N(ne=>({...ne,property_description:re.target.value})),rows:3,placeholder:"Beautiful home in a great neighborhood..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Property Photos"})}),e.jsxs(Oe,{className:"space-y-4",children:[j.property_photos.length>0&&e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:j.property_photos.map((re,ne)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:re,alt:`Property ${ne+1}`,className:"h-24 w-full object-cover rounded"}),e.jsx(K,{variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>N(le=>({...le,property_photos:le.property_photos.filter((he,we)=>we!==ne)})),children:e.jsx(jr,{className:"h-3 w-3"})})]},ne))}),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(ni,{className:"h-3.5 w-3.5 mr-1"}),l==="property_photos"?"Uploading...":"Add Photos"]})}),e.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:q})]})]})]})]}),e.jsxs($s,{value:"fields",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure the form fields visitors will fill out"}),e.jsxs(K,{size:"sm",onClick:V,children:[e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"})," Add Field"]})]}),S.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-8 text-center text-muted-foreground",children:"No fields yet. Add fields to build your form."})}):e.jsx("div",{className:"space-y-3",children:S.map((re,ne)=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(yh,{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(_e,{className:"text-xs",children:"Field Type"}),e.jsxs(rr,{value:re.field_type,onValueChange:le=>X(ne,{field_type:le}),children:[e.jsx(tr,{children:e.jsx(nr,{})}),e.jsx(sr,{children:ACs.map(le=>e.jsx(Tt,{value:le.value,children:le.label},le.value))})]})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Label"}),e.jsx(Fe,{value:re.label,onChange:le=>X(ne,{label:le.target.value}),placeholder:"e.g. Full Name"})]}),e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Placeholder"}),e.jsx(Fe,{value:re.placeholder||"",onChange:le=>X(ne,{placeholder:le.target.value}),placeholder:"Optional hint text"})]})]}),(re.field_type==="select"||re.field_type==="multiselect")&&e.jsxs("div",{children:[e.jsx(_e,{className:"text-xs",children:"Options (comma-separated)"}),e.jsx(Fe,{value:re.options?(typeof re.options=="string"?JSON.parse(re.options):re.options).join(", "):"",onChange:le=>X(ne,{options:JSON.stringify(le.target.value.split(",").map(he=>he.trim()).filter(Boolean))}),placeholder:"Option 1, Option 2, Option 3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Br,{checked:re.is_required,onCheckedChange:le=>X(ne,{is_required:le})}),e.jsx(_e,{className:"text-xs",children:"Required"})]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>se(ne),children:e.jsx(jr,{className:"h-3.5 w-3.5 text-destructive"})})]})})},ne))})]}),e.jsx($s,{value:"submissions",className:"mt-4",children:b.length===0?e.jsx(Ee,{children:e.jsx(Oe,{className:"py-12 text-center text-muted-foreground",children:"No submissions yet. Share your page to start collecting leads!"})}):e.jsx("div",{className:"space-y-3",children:b.map(re=>e.jsx(Ee,{children:e.jsx(Oe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:re.contact_name||"Anonymous"}),re.synced_to_crm&&e.jsx(nt,{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(([ne,le])=>e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-muted-foreground",children:[ne,":"]})," ",e.jsx("span",{children:String(le)})]},ne))})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(re.created_at).toLocaleDateString()})]})})},re.id))})}),e.jsxs($s,{value:"settings",className:"space-y-4 mt-4",children:[e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Publishing"})}),e.jsxs(Oe,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(_e,{children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this page publicly accessible"})]}),e.jsx(Br,{checked:j.is_published,onCheckedChange:re=>N(ne=>({...ne,is_published:re}))})]}),j.is_published&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg border",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Public URL:"}),e.jsx("code",{className:"text-xs ml-2 break-all",children:ee})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsx(Ot,{className:"text-base",children:"Thank You Message"})}),e.jsx(Oe,{children:e.jsx(Ar,{value:j.success_message,onChange:re=>N(ne=>({...ne,success_message:re.target.value})),rows:2,placeholder:"Message shown after form submission"})})]})]})]})]}),e.jsx(_s,{open:c,onOpenChange:u,children:e.jsxs(vs,{className:"max-w-sm",children:[e.jsx(Cs,{children:e.jsx(Ns,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx(nR,{value:ee,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:ee})]})]})})]}):e.jsx(Es,{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 jze({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(MI,{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(CI,{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(t1,{className:"h-3 w-3"}),"0%"]})}const PCs={Phone:ea,MessageSquare:po,Mail:br,Gift:bo,PenTool:Db,Video:Nn},kze=["bg-primary","bg-emerald-500","bg-amber-500","bg-sky-500","bg-purple-500","bg-orange-500","bg-pink-500","bg-teal-500"];function ICs(){const t=Pr(),{contactsWithScores:s,stats:r}=pue(),{data:n}=wO(365),{data:a}=pke(),{data:o}=bO(),l=uke(),i=C.useMemo(()=>{if(!n)return{touchesThisMonth:0,touchesLastMonth:0,touchTrend:0};const T=new Date,I=Mc(T),L=eg(T),R=Mc(d4(T,1)),$=eg(d4(T,1)),q=n.filter(X=>Ax(new Date(X.completed_at),{start:I,end:L})).length,U=n.filter(X=>Ax(new Date(X.completed_at),{start:R,end:$})).length,V=U>0?Math.round((q-U)/U*100):q>0?100:0;return{touchesThisMonth:q,touchesLastMonth:U,touchTrend:V}},[n]),c=C.useMemo(()=>{if(!n)return 0;const T=new Date,I=Mc(T),L=eg(T);return new Set(n.filter(R=>Ax(new Date(R.completed_at),{start:I,end:L})).map(R=>R.contact_id)).size},[n]),u=C.useMemo(()=>{if(!a)return{closedThisMonth:0,totalGCI:0};const T=new Date,I=Mc(T),L=eg(T),R=a.filter($=>$.close_date&&Ax(Ml($.close_date),{start:I,end:L}));return{closedThisMonth:R.length,totalGCI:R.reduce(($,q)=>$+(Number(q.commission_amount)||0),0)}},[a]),p=C.useMemo(()=>{if(!s.length)return{newThisMonth:0,newLastMonth:0,trend:0};const T=new Date,I=Mc(T),L=Mc(d4(T,1)),R=eg(d4(T,1)),$=s.filter(V=>new Date(V.created_at)>=I).length,q=s.filter(V=>Ax(new Date(V.created_at),{start:L,end:R})).length,U=q>0?Math.round(($-q)/q*100):$>0?100:0;return{newThisMonth:$,newLastMonth:q,trend:U}},[s]),f=C.useMemo(()=>{if(!n||!o)return[];const T=new Date,I=Mc(T),L=eg(T),R=n.filter(U=>Ax(new Date(U.completed_at),{start:I,end:L})),$={};R.forEach(U=>{const V=U.action_type_id;$[V]=($[V]||0)+1});const q=R.length||1;return o.filter(U=>$[U.id]).map(U=>({id:U.id,name:U.name,icon:U.icon,count:$[U.id]||0,percent:Math.round(($[U.id]||0)/q*100)})).sort((U,V)=>V.count-U.count)},[n,o]),y=C.useMemo(()=>[...s].filter(T=>T.relationshipScore.status==="at-risk"||T.relationshipScore.status==="cooling").sort((T,I)=>{const L=T.relationshipScore.daysSinceTouch??9999;return(I.relationshipScore.daysSinceTouch??9999)-L}).slice(0,5),[s]),_=C.useMemo(()=>{if(!n)return[];const T=new Date,I=Mc(T),L=eg(T),R=new Set(n.filter($=>Ax(new Date($.completed_at),{start:I,end:L})).map($=>$.contact_id));return s.filter($=>$.relationshipScore.status==="warm"&&R.has($.id)&&$.relationshipScore.touchCountLast12Months>=2).sort(($,q)=>q.relationshipScore.score-$.relationshipScore.score).slice(0,5)},[s,n]),b=C.useMemo(()=>{if(!n)return{currentStreak:0,longestStreak:0};const T=new Set(n.map(V=>{const X=new Date(V.completed_at);return`${X.getFullYear()}-${X.getMonth()}-${X.getDate()}`})),I=new Date;I.setHours(0,0,0,0);let L=0,R=new Date(I);for(;T.has(`${R.getFullYear()}-${R.getMonth()}-${R.getDate()}`);)L++,R.setDate(R.getDate()-1);let $=0,q=0;if(Array.from(T).sort().length>0){const V=n.map(X=>{const se=new Date(X.completed_at);return se.setHours(0,0,0,0),se.getTime()}).filter((X,se,ee)=>ee.indexOf(X)===se).sort((X,se)=>X-se);q=1;for(let X=1;X[...s].sort((T,I)=>T.relationshipScore.score-I.relationshipScore.score),[s]),j=w.filter(T=>T.relationshipScore.status==="warm"),N=w.filter(T=>T.relationshipScore.status==="cooling"),S=w.filter(T=>T.relationshipScore.status==="at-risk");return e.jsx(Es,{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:[ys(new Date,"MMMM yyyy")," — Your monthly relationship health report"]})]}),b.currentStreak>0&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-full bg-orange-500/10 border border-orange-500/20",children:[e.jsx(Fh,{className:"h-5 w-5 text-orange-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-orange-600 dark:text-orange-400",children:b.currentStreak}),e.jsx("span",{className:"text-sm text-muted-foreground ml-1",children:"day streak"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Ii,{className:"h-4 w-4"}),"Avg Score"]}),e.jsx("div",{className:"text-3xl font-bold",children:r.averageScore}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"out of 100"})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(gp,{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(jze,{value:i.touchTrend})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["vs ",i.touchesLastMonth," last month"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(mr,{className:"h-4 w-4"}),"Reached"]}),e.jsx("div",{className:"text-3xl font-bold",children:c}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["of ",r.total," contacts"]})]})}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(xc,{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(jze,{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(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Am,{className:"h-4 w-4 text-primary"}),"Weekly Goal"]})}),e.jsxs(Oe,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[l.actionsThisWeek," of ",l.weeklyGoal," touches"]}),e.jsxs("span",{className:"text-sm font-medium",children:[Math.round(l.progress),"%"]})]}),e.jsx(Oi,{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(mo,{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(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(Fh,{className:"h-4 w-4 text-orange-500"}),"Momentum"]})}),e.jsxs(Oe,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Current Streak"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xl font-bold",children:b.currentStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"}),b.currentStreak>=7&&e.jsx("span",{className:"ml-1",children:"🔥"}),b.currentStreak>=30&&e.jsx("span",{children:"🏆"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Longest Streak"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xl font-bold",children:b.longestStreak}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"days"})]})]}),b.currentStreak===0&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 italic",children:"Log a touch today to start your streak!"})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{className:"pb-2",children:e.jsxs(Ot,{className:"text-base flex items-center gap-2",children:[e.jsx(gp,{className:"h-4 w-4"}),"How You're Reaching Out"]})}),e.jsx(Oe,{children:f.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No touches logged this month yet."}):e.jsx("div",{className:"space-y-2.5",children:f.slice(0,5).map((T,I)=>{const L=PCs[T.icon||""]||gp;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{children:T.name})]}),e.jsxs("span",{className:"text-muted-foreground",children:[T.count," (",T.percent,"%)"]})]}),e.jsx(Oi,{value:T.percent,className:At("h-1.5 bg-muted [&>div]:",kze[I%kze.length])})]},T.id)})})})]})]}),y.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-primary",children:[e.jsxs(It,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(ea,{className:"h-5 w-5 text-primary"}),"Who to Reach Out to Today"]}),e.jsxs(nt,{variant:"secondary",children:[y.length," contacts"]})]}),e.jsx(fr,{children:"These relationships need attention the most"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"space-y-2",children:y.map(T=>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/${T.id}`),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(e8,{score:T.relationshipScore,showScore:!0,size:"sm",showTooltip:!1}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[T.first_name," ",T.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:T.relationshipScore.daysSinceTouch===null?"Never contacted":`Last touch ${T.relationshipScore.daysSinceTouch}d ago`})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[T.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`tel:${T.phone}`)},children:e.jsx(ea,{className:"h-4 w-4"})}),T.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`mailto:${T.email}`)},children:e.jsx(br,{className:"h-4 w-4"})}),e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"})]})]},T.id))})})]}),_.length>0&&e.jsxs(Ee,{className:"border-l-4 border-l-emerald-500",children:[e.jsxs(It,{className:"pb-3",children:[e.jsxs(Ot,{className:"text-lg flex items-center gap-2",children:[e.jsx(fc,{className:"h-5 w-5 text-emerald-500"}),"Biggest Wins This Month"]}),e.jsx(fr,{children:"Relationships you've successfully warmed up"})]}),e.jsx(Oe,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:_.map(T=>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/${T.id}`),children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),e.jsxs("span",{className:"text-sm font-medium",children:[T.first_name," ",T.last_name]}),e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-bold",children:T.relationshipScore.score})]},T.id))})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(Ee,{className:"border-l-4 border-l-emerald-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Warm"}),e.jsx("p",{className:"text-3xl font-bold text-emerald-600 dark:text-emerald-400",children:r.warm})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-emerald-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟢"})})]}),e.jsx(Oi,{value:r.total?r.warm/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-emerald-500"})]})}),e.jsx(Ee,{className:"border-l-4 border-l-amber-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cooling Off"}),e.jsx("p",{className:"text-3xl font-bold text-amber-600 dark:text-amber-400",children:r.cooling})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🟡"})})]}),e.jsx(Oi,{value:r.total?r.cooling/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-amber-500"})]})}),e.jsx(Ee,{className:"border-l-4 border-l-red-500",children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"At Risk"}),e.jsx("p",{className:"text-3xl font-bold text-red-600 dark:text-red-400",children:r.atRisk})]}),e.jsx("div",{className:"h-14 w-14 rounded-full bg-red-500/10 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl",children:"🔴"})})]}),e.jsx(Oi,{value:r.total?r.atRisk/r.total*100:0,className:"mt-3 h-2 bg-muted [&>div]:bg-red-500"})]})})]}),e.jsx(Ee,{children:e.jsx(Oe,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(BI,{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(Aa,{defaultValue:"at-risk",children:[e.jsxs(ja,{children:[e.jsxs(js,{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(js,{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(js,{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:N},{key:"warm",contacts:j}].map(({key:T,contacts:I})=>e.jsx($s,{value:T,children:e.jsx(Ee,{children:e.jsx(Oe,{className:"p-0",children:I.length===0?e.jsx("p",{className:"p-6 text-center text-muted-foreground",children:"No contacts in this category"}):e.jsxs(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Contact"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Last Touch"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Touches (12mo)"}),e.jsx(bt,{children:"Score"}),e.jsx(bt,{className:"w-10"})]})}),e.jsx(Pn,{children:I.slice(0,20).map(L=>e.jsxs(ks,{className:"cursor-pointer",onClick:()=>t(`/mission-control/contacts/${L.id}`),children:[e.jsxs(dt,{className:"font-medium",children:[L.first_name," ",L.last_name]}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:L.relationshipScore.daysSinceTouch===null?"Never":L.relationshipScore.daysSinceTouch===0?"Today":`${L.relationshipScore.daysSinceTouch}d ago`}),e.jsx(dt,{className:"hidden md:table-cell",children:L.relationshipScore.touchCountLast12Months}),e.jsx(dt,{children:e.jsx(e8,{score:L.relationshipScore,showScore:!0})}),e.jsx(dt,{children:e.jsx(Xa,{className:"h-4 w-4 text-muted-foreground"})})]},L.id))})]})})})},T))]})]})})}function Flt(){const{user:t}=Ws(),s=ss(),{data:r,isLoading:n}=wt({queryKey:["contact-intake-page",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return null;const{data:u,error:p}=await G.from("contact_intake_pages").select("*").eq("user_id",t.id).maybeSingle();if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),a=Dt({mutationFn:async u=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const{data:p,error:f}=await G.from("contact_intake_pages").insert({user_id:t.id,slug:u.toLowerCase().replace(/[^a-z0-9-]/g,"-")}).select().single();if(f)throw f;return p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),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 G.from("contact_intake_pages").update({...u,updated_at:new Date().toISOString()}).eq("id",r.id);if(p)throw p},onSuccess:()=>{s.invalidateQueries({queryKey:["contact-intake-page"]}),me.success("Page updated!")},onError:()=>me.error("Failed to update page")}),{data:l=[],isLoading:i}=wt({queryKey:["contact-intake-submissions",t==null?void 0:t.id],queryFn:async()=>{if(!(t!=null&&t.id))return[];const{data:u,error:p}=await G.from("contact_intake_submissions").select("*").eq("agent_user_id",t.id).order("created_at",{ascending:!1}).limit(100);if(p)throw p;return u},enabled:!!(t!=null&&t.id)}),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 G.from("contact_intake_tokens").insert({contact_id:u,intake_page_id:r.id}).select("token").single();if(f)throw f;return`${window.location.origin}/connect/${r.slug}?t=${p.token}`}});return{intakePage:r,isLoading:n,createPage:a,updatePage:o,submissions:l,loadingSubmissions:i,generateUpdateLink:c}}function LCs(){const{user:t}=Ws();return wt({queryKey:["bulk-email-sends",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:s,error:r}=await G.from("bulk_email_sends").select("contact_id, sent_at, subject").eq("user_id",t.id).order("sent_at",{ascending:!1});if(r)throw r;return s}})}function DCs(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:br,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:ea,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:Ui,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:xh,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:Rn,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:Tm,description:"Untagged — won't appear in filtered lists or plans",check:t=>!t.tags||t.tags.length===0,color:"text-slate-500"}];function k5(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 OCs({contact:t,onClose:s}){const r=lke(),[n,a]=C.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(DA,{open:!0,onOpenChange:()=>s(),children:e.jsxs(YS,{className:"sm:max-w-md overflow-y-auto",children:[e.jsxs(OA,{children:[e.jsxs(RA,{children:["Quick Edit — ",t.first_name," ",t.last_name]}),e.jsxs(oZe,{children:["Fill in missing fields to improve this contact's completeness (",k5(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(nt,{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(_e,{className:"flex items-center gap-1.5",children:[e.jsx(br,{className:"h-3.5 w-3.5"})," Email"]}),e.jsx(Fe,{type:"email",placeholder:"email@example.com",value:n.email,onChange:i=>a(c=>({...c,email:i.target.value})),className:At(!t.email&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(_e,{className:"flex items-center gap-1.5",children:[e.jsx(ea,{className:"h-3.5 w-3.5"})," Phone"]}),e.jsx(Fe,{type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:i=>a(c=>({...c,phone:i.target.value})),className:At(!t.phone&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(_e,{className:"flex items-center gap-1.5",children:[e.jsx(Ui,{className:"h-3.5 w-3.5"})," Address"]}),e.jsx(Fe,{placeholder:"123 Main St, City, ST 12345",value:n.address,onChange:i=>a(c=>({...c,address:i.target.value})),className:At(!t.address&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(_e,{className:"flex items-center gap-1.5",children:[e.jsx(xh,{className:"h-3.5 w-3.5"})," Birthday"]}),e.jsx(Fe,{type:"date",value:n.birthday,onChange:i=>a(c=>({...c,birthday:i.target.value})),className:At(!t.birthday&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(_e,{className:"flex items-center gap-1.5",children:[e.jsx(Rn,{className:"h-3.5 w-3.5"})," Home Anniversary"]}),e.jsx(Fe,{type:"date",value:n.home_anniversary,onChange:i=>a(c=>({...c,home_anniversary:i.target.value})),className:At(!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(Wu,{className:"h-4 w-4 mr-1.5"}),r.isPending?"Saving...":"Save Changes"]}),e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"})]})]})]})})}const jye="Quick favor — can you update your info? 🙏",Nze=`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 RCs(){const t=Pr(),{data:s,isLoading:r}=Fm(),{data:n}=Rg(),{intakePage:a}=Flt(),{isGmailConnected:o,gmailEmail:l}=D0(),{data:i}=LCs(),[c,u]=C.useState("blocked"),[p,f]=C.useState("all"),[y,_]=C.useState(null),[b,w]=C.useState(!1),[j,N]=C.useState(!1),[S,T]=C.useState(null),[I,L]=C.useState([]),[R,$]=C.useState(""),[q,U]=C.useState(""),V=C.useMemo(()=>s?p==="all"?s:s.filter(be=>{var Me;return(Me=be.tags)==null?void 0:Me.some(Ae=>Ae.relationship_type_id===p)}):[],[s,p]),X=C.useMemo(()=>V.filter(be=>!be.email&&!be.phone),[V]),se=C.useMemo(()=>{if(!V.length)return{overallCompleteness:0,fullyComplete:0,contactsByGap:{}};const be={};be.blocked=X,pI.forEach(Te=>{be[Te.key]=V.filter(Te.check)});const Me=V.map(k5),Ae=V.length>0?Math.round(Me.reduce((Te,qe)=>Te+qe,0)/V.length):0,Re=Me.filter(Te=>Te===100).length;return{contactsByGap:be,overallCompleteness:Ae,fullyComplete:Re}},[V,X]),ee=C.useMemo(()=>{if(!s||s.length===0)return null;const be=Mc(d4(new Date,1)),Me=s.filter(qe=>new Date(qe.created_at)qe+ct,0)/Me.length),Re=se.overallCompleteness,Te=Re-Ae;return{oldCompleteness:Ae,currentCompleteness:Re,diff:Te,oldCount:Me.length}},[s,se.overallCompleteness]),Q=V.length,de=C.useCallback(()=>{var Rt;const be=se.contactsByGap[c];if(!(be!=null&&be.length))return;const Me=c==="blocked"?"Outreach Blocked":((Rt=pI.find(pe=>pe.key===c))==null?void 0:Rt.label)||c,Ae=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Completeness %"],Re=be.map(pe=>[pe.first_name,pe.last_name||"",pe.email||"",pe.phone||"",pe.address||"",pe.birthday||"",pe.home_anniversary||"",k5(pe).toString()]),Te=[Ae.join(","),...Re.map(pe=>pe.map(Je=>`"${Je.replace(/"/g,'""')}"`).join(","))].join(` `),qe=new Blob([Te],{type:"text/csv"}),ct=URL.createObjectURL(qe),De=document.createElement("a");De.href=ct,De.download=`sphere-gaps-${Me.toLowerCase().replace(/\s+/g,"-")}-${ys(new Date,"yyyy-MM-dd")}.csv`,De.click(),URL.revokeObjectURL(ct),fn({title:`Exported ${be.length} contacts to CSV`})},[se.contactsByGap,c]),re=C.useCallback(async be=>{if(!a)return null;try{const{data:Me,error:Ae}=await G.from("contact_intake_tokens").insert({contact_id:be,intake_page_id:a.id}).select("token").single();if(Ae)throw Ae;return Me.token}catch{return null}},[a]),ne=C.useCallback(be=>a?`https://contacts.relevelup.com/${a.slug}?t=${be}`:"",[a]),le=C.useCallback(async be=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Me=await re(be);Me?(await navigator.clipboard.writeText(ne(Me)),me.success("Update link copied!")):me.error("Failed to generate link")},[a,re,ne,t]),he=C.useCallback(async be=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}if(!be.email){me.error("This contact has no email address");return}const Me=await re(be.id);if(!Me){me.error("Failed to generate link");return}const Ae=ne(Me),Re=Nze.replace("{{update_link}}",Ae).replace(/\{\{first_name\}\}/g,be.first_name).replace(/\{\{last_name\}\}/g,be.last_name||""),Te=jye.replace(/\{\{first_name\}\}/g,be.first_name).replace(/\{\{last_name\}\}/g,be.last_name||"");if(o)T({id:be.id,first_name:be.first_name,last_name:be.last_name,email:be.email}),L([]),$(Te),U(Re),N(!0);else{const qe=encodeURIComponent(jye.replace("{{first_name}}",be.first_name)),ct=encodeURIComponent(Re.replace(/\{\{first_name\}\}/g,be.first_name));window.location.href=`mailto:${be.email}?subject=${qe}&body=${ct}`}},[a,re,ne,o,t]),we=C.useCallback(async be=>{if(!a){me.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Me=be.filter(Ae=>Ae.email);if(!Me.length){me.error("No contacts with email addresses in this group");return}if(!o){me.error("Connect Gmail in Settings to send bulk emails");return}w(!0);try{const{data:Ae,error:Re}=await G.functions.invoke("process-intake-submissions",{body:{action:"generate_tokens",contact_ids:Me.map(pe=>pe.id),intake_page_id:a.id}});if(Re)throw Re;const Te=typeof Ae=="string"?JSON.parse(Ae):Ae,qe=Array.isArray(Te)?Te:Array.isArray(Te==null?void 0:Te.tokens)?Te.tokens:[],ct=new Map(qe.filter(pe=>(pe==null?void 0:pe.contact_id)&&(pe==null?void 0:pe.token)).map(pe=>[pe.contact_id,pe.token]));if(ct.size===0&&(await Promise.all(Me.map(async Je=>({contactId:Je.id,token:await re(Je.id)})))).forEach(({contactId:Je,token:lt})=>{lt&&ct.set(Je,lt)}),ct.size===0){me.error("Failed to generate update links. Please try again.");return}const De=Me.filter(pe=>ct.has(pe.id)).map(pe=>({id:pe.id,first_name:pe.first_name,last_name:pe.last_name,email:pe.email,updateLink:ne(ct.get(pe.id))})),Rt=Nze;T(null),L(De),$(jye),U(Rt),N(!0),me.success(`Ready to email ${De.length} contacts`)}catch{me.error("Failed to generate links")}finally{w(!1)}},[a,o,ne,re,t]),je=[{key:"blocked",label:"Outreach Blocked",icon:Tv,color:"text-destructive",description:"Missing BOTH email AND phone — completely unreachable"},...pI].find(be=>be.key===c),ke=se.contactsByGap[c]||[],We=ke.filter(be=>be.email).length;return e.jsxs(Es,{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(a0,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(rr,{value:p,onValueChange:f,children:[e.jsx(tr,{className:"w-[180px]",children:e.jsx(nr,{placeholder:"Filter by tag"})}),e.jsxs(sr,{children:[e.jsx(Tt,{value:"all",children:"All Contacts"}),n==null?void 0:n.map(be=>e.jsx(Tt,{value:be.id,children:be.name},be.id))]})]})]})]}),e.jsx(Ee,{children:e.jsxs(Oe,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Database Completeness",p!=="all"&&e.jsx("span",{className:"ml-1 text-primary",children:"(filtered)"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("p",{className:"text-4xl font-bold",children:[se.overallCompleteness,"%"]}),ee&&ee.diff!==0&&p==="all"&&e.jsxs("div",{className:At("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:[se.fullyComplete," ",e.jsxs("span",{className:"text-base font-normal text-muted-foreground",children:["/ ",Q]})]})]})]}),e.jsx(Oi,{value:se.overallCompleteness,className:"h-3"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:se.overallCompleteness>=80?"🎉 Great job! Your database is well maintained.":se.overallCompleteness>=50?"⚡ Good start — fill in the gaps below to unlock more outreach channels.":"🔍 Your database needs attention. Start with emails and phone numbers."})]})}),X.length>0&&e.jsx(Ee,{className:At("border-l-4 border-l-destructive cursor-pointer transition-all hover:shadow-md",c==="blocked"&&"ring-2 ring-primary"),onClick:()=>u("blocked"),children:e.jsx(Oe,{className:"pt-5 pb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(Tv,{className:"h-6 w-6 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Outreach Blocked"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Missing both email AND phone — completely unreachable"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-3xl font-bold text-destructive",children:X.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"contacts"})]})]})})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:pI.map(be=>{var qe;const Me=((qe=se.contactsByGap[be.key])==null?void 0:qe.length)||0,Ae=Q>0?Math.round(Me/Q*100):0,Re=be.icon,Te=c===be.key;return e.jsx(Ee,{className:At("cursor-pointer transition-all hover:shadow-md",Te&&"ring-2 ring-primary"),onClick:()=>u(be.key),children:e.jsxs(Oe,{className:"pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Re,{className:At("h-5 w-5",be.color)}),e.jsx("span",{className:"text-sm font-medium",children:be.label})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-2xl font-bold",children:Me}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Ae,"% of contacts"]})]}),e.jsx(Oi,{value:100-Ae,className:"mt-2 h-1.5"})]})},be.key)})}),e.jsxs(Ee,{children:[e.jsxs(It,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Ot,{className:"text-lg",children:[(je==null?void 0:je.label)||"Contacts"," — Contacts to Fix"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(nt,{variant:"secondary",children:[ke.length," contacts"]}),ke.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:de,className:"gap-1.5",children:[e.jsx(ki,{className:"h-3.5 w-3.5"}),"Export"]}),We>0&&a&&e.jsxs(K,{size:"sm",onClick:()=>we(ke),disabled:b,className:"gap-1.5",children:[b?e.jsx(Ss,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(oa,{className:"h-3.5 w-3.5"}),"Email ",We," Update Links"]})]})]})]}),e.jsx(fr,{children:je==null?void 0:je.description})]}),e.jsx(Oe,{className:"p-0",children:ke.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(ha,{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(An,{children:[e.jsx(En,{children:e.jsxs(ks,{children:[e.jsx(bt,{children:"Contact"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Email"}),e.jsx(bt,{className:"hidden md:table-cell",children:"Phone"}),e.jsx(bt,{children:"Completeness"}),e.jsx(bt,{className:"w-28",children:"Actions"})]})}),e.jsx(Pn,{children:ke.map(be=>{const Me=DCs(i,be.id);return e.jsxs(ks,{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/${be.id}`),children:[be.first_name," ",be.last_name]}),!be.email&&!be.phone&&c!=="blocked"&&e.jsx(nt,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Blocked"}),Me&&e.jsxs(hd,{children:[e.jsx(md,{asChild:!0,children:e.jsxs(nt,{variant:"outline",className:"text-[10px] px-1.5 py-0 gap-1 text-muted-foreground border-muted",children:[e.jsx(br,{className:"h-2.5 w-2.5"}),Yd(new Date(Me),{addSuffix:!0})]})}),e.jsxs(Uc,{children:["Last bulk emailed ",ys(new Date(Me),"MMM d, yyyy h:mm a")]})]})]})}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:be.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:be.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(Oi,{value:k5(be),className:"h-2 w-16"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[k5(be),"%"]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs(hd,{children:[e.jsx(md,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>_(be),children:e.jsx(Ev,{className:"h-3.5 w-3.5"})})}),e.jsx(Uc,{children:"Quick edit"})]}),(be.email||be.phone)&&a&&e.jsxs(hd,{children:[e.jsx(md,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>le(be.id),children:e.jsx(mi,{className:"h-3.5 w-3.5"})})}),e.jsx(Uc,{children:"Copy update link"})]}),be.email&&a&&e.jsxs(hd,{children:[e.jsx(md,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>he(be),children:e.jsx(br,{className:"h-3.5 w-3.5"})})}),e.jsx(Uc,{children:"Email update link"})]})]})})]},be.id)})})]})})]})]}),y&&e.jsx(OCs,{contact:y,onClose:()=>_(null)}),e.jsx(iE,{open:j,onOpenChange:N,contact:S||void 0,bulkContacts:I.length>0?I:void 0,defaultSubject:R,defaultBody:q,gmailEmail:l})]})}function FCs(){const{user:t}=Ws(),{intakePage:s,isLoading:r,createPage:n,updatePage:a,submissions:o,loadingSubmissions:l}=Flt(),[i,c]=C.useState(""),[u,p]=C.useState(""),[f,y]=C.useState(!1);C.useEffect(()=>{s&&p(s.welcome_message||"")},[s]),C.useEffect(()=>{if(t!=null&&t.email&&!s){const T=t.email.split("@")[0];c(T.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/-+$/,""))}},[t,s]);const _=s?`https://contacts.relevelup.com/${s.slug}`:"",b=()=>{navigator.clipboard.writeText(_),me.success("Link copied!")};if(r)return e.jsx(Ee,{children:e.jsx(Oe,{className:"p-6 flex items-center justify-center",children:e.jsx(Ss,{className:"h-5 w-5 animate-spin text-muted-foreground"})})});if(!s)return e.jsxs(Ee,{children:[e.jsx(It,{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(sl,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{children:"Connect Page"}),e.jsx(fr,{children:"Create a public link to capture contact info from new leads or update existing contacts"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(_e,{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(Fe,{value:i,onChange:T=>c(T.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(Ss,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Connect Page"]})]})})]});const w=o.filter(T=>!T.is_processed),j=o.filter(T=>T.is_processed),N=w.length,S=(T,I)=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:[T.first_name," ",T.last_name||""]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground mt-0.5",children:[T.email&&e.jsx("span",{children:T.email}),T.phone&&e.jsx("span",{children:T.phone})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[T.real_estate_interest&&T.real_estate_interest!=="not_now"&&e.jsx(nt,{variant:"outline",className:"text-xs",children:T.real_estate_interest==="buying"?"🏠 Buying":T.real_estate_interest==="selling"?"📋 Selling":T.real_estate_interest==="both"?"🔄 Both":T.real_estate_interest}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Tn,{className:"h-3 w-3"}),ys(new Date(T.created_at),"MMM d")]}),I&&e.jsx(ha,{className:"h-4 w-4 text-emerald-500"})]})]},T.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Ee,{children:[e.jsx(It,{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(sl,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(Ot,{children:"Connect Page"}),e.jsx(fr,{children:"Share this link to capture contact info"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{htmlFor:"active-toggle",className:"text-sm text-muted-foreground",children:"Active"}),e.jsx(Br,{id:"active-toggle",checked:s.is_active,onCheckedChange:T=>a.mutate({is_active:T})})]})]})}),e.jsxs(Oe,{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:_}),e.jsxs(K,{size:"sm",variant:"outline",onClick:b,children:[e.jsx(mi,{className:"h-3.5 w-3.5 mr-1.5"})," Copy"]}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",children:e.jsx(rn,{className:"h-3.5 w-3.5"})})})]}),e.jsxs("div",{children:[e.jsx(_e,{children:"Welcome Message"}),f?e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsx("textarea",{value:u,onChange:T=>p(T.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}),y(!1)},children:"Save"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>y(!1),children:"Cancel"})]})]}):e.jsx("p",{className:"mt-1.5 text-sm text-muted-foreground cursor-pointer hover:text-foreground transition-colors",onClick:()=>y(!0),children:s.welcome_message||"Click to set a welcome message..."})]})]})]}),e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(mr,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-base",children:"New Submissions"}),N>0&&e.jsxs(fr,{children:[N," awaiting sync"]})]})]}),N>0&&e.jsxs(K,{size:"sm",onClick:async()=>{try{const{data:T,error:I}=await G.functions.invoke("process-intake-submissions",{body:{action:"process_all"}});if(I)throw I;me.success(`Synced ${T.processed} contacts to your CRM!`)}catch{me.error("Failed to sync")}},className:"gap-1.5",children:["Sync ",N," to CRM"]})]})}),e.jsx(Oe,{children:l?e.jsx(Ss,{className:"h-5 w-5 animate-spin text-muted-foreground"}):w.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"All caught up! No new submissions to sync."}):e.jsx("div",{className:"space-y-3",children:w.map(T=>S(T,!1))})})]}),j.length>0&&e.jsxs(Ee,{children:[e.jsx(It,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ha,{className:"h-5 w-5 text-emerald-500"}),e.jsxs("div",{children:[e.jsx(Ot,{className:"text-base",children:"Synced to CRM"}),e.jsxs(fr,{children:[j.length," contacts already in your database"]})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"space-y-3",children:[j.slice(0,10).map(T=>S(T,!0)),j.length>10&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-1",children:["+ ",j.length-10," more synced contacts"]})]})})]})]})}function zCs(){return e.jsx(Es,{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(FCs,{})]})})}const BCs=C.lazy(()=>Wh(()=>import("./PostcardManager-DbfSngsa.js"),__vite__mapDeps([0,1]))),$Cs=C.lazy(()=>Wh(()=>import("./HomeReelManager-B0rxtnLx.js"),[])),qCs=C.lazy(()=>Wh(()=>import("./AdminCredits-DKRllt7t.js"),[])),UCs=C.lazy(()=>Wh(()=>import("./DirectMail-pbj47pyn.js"),__vite__mapDeps([2,1]))),VCs=C.lazy(()=>Wh(()=>import("./InnerCirclePopbyMap-1oYaLMCf.js"),[])),HCs=C.lazy(()=>Wh(()=>import("./LiveVisitorFeed-IXUVMJzm.js"),[])),WCs=C.lazy(()=>Wh(()=>import("./EmailCampaigns-DTARV5Jq.js"),[])),GCs=C.lazy(()=>Wh(()=>import("./EmailCampaignComposer-DyMpGteY.js"),[])),KCs=C.lazy(()=>Wh(()=>import("./EmailCampaignDetail-BKVeAzey.js"),[])),ZCs=C.lazy(()=>Wh(()=>import("./SharedCampaignTemplates-DgbZqDOk.js"),[])),YCs=new d0t,XCs=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},QCs=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},JCs=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},e3s=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},t3s=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},s3s=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},r3s=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},n3s=()=>{const t=window.location.hostname;return t==="contacts.relevelup.com"||t.startsWith("contacts.")},a3s=()=>{const t=window.location.hostname;return t==="pages.relevelup.com"||t.startsWith("pages.")},i3s=()=>e.jsx(f0t,{client:YCs,children:e.jsx(Uqe,{children:e.jsxs(x2,{children:[e.jsx(Agt,{}),e.jsx(lxt,{}),e.jsx(Cvt,{children:e.jsx(Abt,{children:e.jsx(Ebt,{children:e.jsxs(Ibt,{children:[e.jsx(Pbt,{}),e.jsx(ujt,{}),e.jsx(Cjt,{}),s3s()?e.jsx(pCs,{}):QCs()?e.jsx(Wkt,{}):XCs()?e.jsx(pkt,{}):JCs()?e.jsx(Zkt,{}):e3s()?e.jsx(PAt,{}):t3s()?e.jsx(ZAt,{}):r3s()?e.jsx(fCs,{}):n3s()?e.jsx(gCs,{}):a3s()?e.jsx(xCs,{}):e.jsxs(Oqe,{children:[e.jsx(Us,{path:"/",element:e.jsx(nEt,{})}),e.jsx(Us,{path:"/privacy-policy",element:e.jsx(aEt,{})}),e.jsx(Us,{path:"/terms-of-service",element:e.jsx(iEt,{})}),e.jsx(Us,{path:"/data-deletion",element:e.jsx(oEt,{})}),e.jsx(Us,{path:"/public/listings",element:e.jsx(_We,{})}),e.jsx(Us,{path:"/public/listing/:slugOrId",element:e.jsx(G6t,{})}),e.jsx(Us,{path:"/card/:slug",element:e.jsx(K6t,{})}),e.jsx(Us,{path:"/join-brokerage/:slug",element:e.jsx(gSs,{})}),e.jsx(Us,{path:"/recruit-video/:shareToken",element:e.jsx(ySs,{})}),e.jsx(Us,{path:"/connect/:slug",element:e.jsx(iYe,{})}),e.jsx(Us,{path:"/auth",element:e.jsx(cEt,{})}),e.jsx(Us,{path:"/subscription-success",element:e.jsx(dEt,{})}),e.jsx(Us,{path:"/subscription",element:e.jsx(cr,{children:e.jsx(s6t,{})})}),e.jsxs(Us,{path:"/share/video",element:e.jsx(U6t,{}),children:[e.jsx(Us,{path:":shareToken",element:e.jsx(U6e,{})}),e.jsx(Us,{path:":shareToken/r/:recipientToken",element:e.jsx(U6e,{})})]}),e.jsx(Us,{path:"/p/:shareToken",element:e.jsx(OSs,{})}),e.jsx(Us,{path:"/portal/:slug",element:e.jsx(USs,{})}),e.jsx(Us,{path:"/og/video/:token",element:e.jsx(V6t,{})}),e.jsx(Us,{path:"/setup-brokerage",element:e.jsx(cr,{children:e.jsx(r6t,{})})}),e.jsx(Us,{path:"/claim-account",element:e.jsx(B6e,{})}),e.jsx(Us,{path:"/claim",element:e.jsx(B6e,{})}),e.jsx(Us,{path:"/join",element:e.jsx(n6t,{})}),e.jsx(Us,{path:"/trial",element:e.jsx(f6t,{})}),e.jsx(Us,{path:"/trial/success",element:e.jsx(g6t,{})}),e.jsx(Us,{path:"/dashboard",element:e.jsx(cr,{children:e.jsx(fLt,{})})}),e.jsx(Us,{path:"/profile",element:e.jsx(cr,{children:e.jsx(J9t,{})})}),e.jsx(Us,{path:"/apps",element:e.jsx(cr,{children:e.jsx(mBt,{})})}),e.jsx(Us,{path:"/admin",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(Qqt,{})})}),e.jsx(Us,{path:"/admin/apps",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(tUt,{})})}),e.jsx(Us,{path:"/admin/members",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(cUt,{})})}),e.jsx(Us,{path:"/admin/invite-codes",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(dUt,{})})}),e.jsx(Us,{path:"/admin/events",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(gUt,{})})}),e.jsx(Us,{path:"/events",element:e.jsx(cr,{children:e.jsx(cBt,{})})}),e.jsx(Us,{path:"/events/:eventId",element:e.jsx(cr,{children:e.jsx(uBt,{})})}),e.jsx(Us,{path:"/templates",element:e.jsx(cr,{children:e.jsx(pBt,{})})}),e.jsx(Us,{path:"/templates/:templateId",element:e.jsx(cr,{children:e.jsx(yBt,{})})}),e.jsx(Us,{path:"/admin/templates",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(yUt,{})})}),e.jsx(Us,{path:"/academy",element:e.jsx(cr,{children:e.jsx(vBt,{})})}),e.jsx(Us,{path:"/academy/:videoId",element:e.jsx(cr,{children:e.jsx(bBt,{})})}),e.jsx(Us,{path:"/admin/academy",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(_Ut,{})})}),e.jsx(Us,{path:"/toolbox",element:e.jsx(cr,{children:e.jsx(wBt,{})})}),e.jsx(Us,{path:"/toolbox/:kitId",element:e.jsx(cr,{children:e.jsx(jBt,{})})}),e.jsx(Us,{path:"/admin/toolbox",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(bUt,{})})}),e.jsx(Us,{path:"/social-swag",element:e.jsx(cr,{children:e.jsx(kBt,{})})}),e.jsx(Us,{path:"/social-swag-2",element:e.jsx(cr,{children:e.jsx(wqt,{})})}),e.jsx(Us,{path:"/social-swag/:swagId",element:e.jsx(cr,{children:e.jsx(jqt,{})})}),e.jsx(Us,{path:"/social-connections",element:e.jsx(cr,{children:e.jsx(vSs,{})})}),e.jsx(Us,{path:"/social-connections/callback",element:e.jsx(cr,{children:e.jsx(_Ss,{})})}),e.jsx(Us,{path:"/social-connections/linkedin-callback",element:e.jsx(cr,{children:e.jsx(wSs,{})})}),e.jsx(Us,{path:"/social-connections/google-callback",element:e.jsx(cr,{children:e.jsx(bSs,{})})}),e.jsx(Us,{path:"/admin/social-swag",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(wUt,{})})}),e.jsx(Us,{path:"/admin/social-swag-2",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(aHt,{})})}),e.jsx(Us,{path:"/community",element:e.jsx(cr,{children:e.jsx(qqt,{})})}),e.jsx(Us,{path:"/support",element:e.jsx(cr,{children:e.jsx(Uqt,{})})}),e.jsx(Us,{path:"/admin/community",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(iHt,{})})}),e.jsx(Us,{path:"/admin/support-tickets",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(K0s,{})})}),e.jsx(Us,{path:"/admin/email-templates",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(X0s,{})})}),e.jsx(Us,{path:"/admin/agent-email-templates",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(Q0s,{})})}),e.jsx(Us,{path:"/admin/analytics",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(H0s,{})})}),e.jsx(Us,{path:"/admin/brokerage-resources",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(W0s,{})})}),e.jsx(Us,{path:"/admin/dashboard-management",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(G0s,{})})}),e.jsx(Us,{path:"/brokerage/dashboard",element:e.jsx(cr,{requireBrokerageManager:!0,children:e.jsx(dvs,{})})}),e.jsx(Us,{path:"/brokerage/teams",element:e.jsx(cr,{requireBrokerageManager:!0,children:e.jsx(vCs,{})})}),e.jsx(Us,{path:"/my-team",element:e.jsx(cr,{children:e.jsx(_Cs,{})})}),e.jsx(Us,{path:"/my-brokerage",element:e.jsx(cr,{children:e.jsx(gvs,{})})}),e.jsx(Us,{path:"/brokerage-content",element:e.jsx(cr,{children:e.jsx(wvs,{})})}),e.jsx(Us,{path:"/brokerage-content/:contentId",element:e.jsx(cr,{children:e.jsx(Cvs,{})})}),e.jsx(Us,{path:"/brokerage-resources",element:e.jsx(cr,{requireBrokerageManager:!0,children:e.jsx(Zqt,{})})}),e.jsx(Us,{path:"/brokerage-resources/:resourceId",element:e.jsx(cr,{requireBrokerageManager:!0,children:e.jsx(Yqt,{})})}),e.jsx(Us,{path:"/newsletters",element:e.jsx(cr,{children:e.jsx(Mvs,{})})}),e.jsx(Us,{path:"/newsletters/:id",element:e.jsx(cr,{children:e.jsx(Avs,{})})}),e.jsx(Us,{path:"/wishlist",element:e.jsx(cr,{children:e.jsx(Ivs,{})})}),e.jsx(Us,{path:"/wishlist/:itemId",element:e.jsx(cr,{children:e.jsx(Lvs,{})})}),e.jsx(Us,{path:"/admin/wishlist",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(Dvs,{})})}),e.jsx(Us,{path:"/admin/levelup-brief",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(Ovs,{})})}),e.jsx(Us,{path:"/admin/newsletters",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(Pvs,{})})}),e.jsx(Us,{path:"/admin/additional-services",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(Rvs,{})})}),e.jsx(Us,{path:"/admin/discounts",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(Fvs,{})})}),e.jsx(Us,{path:"/admin/subscriptions",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(zvs,{})})}),e.jsx(Us,{path:"/admin/referrals",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(Bvs,{})})}),e.jsx(Us,{path:"/admin/prospector",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(kNs,{})})}),e.jsx(Us,{path:"/admin/recruiting",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(WNs,{})})}),e.jsx(Us,{path:"/admin/beta/social-post-generator",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(G4s,{})})}),e.jsx(Us,{path:"/admin/credits",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(qCs,{})})})}),e.jsx(Us,{path:"/admin/beta/postcard-manager",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(BCs,{})})})}),e.jsx(Us,{path:"/admin/beta/homereel",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx($Cs,{})})})}),e.jsx(Us,{path:"/admin/lms",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(oSs,{})})}),e.jsx(Us,{path:"/admin/lms/stats",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(hSs,{})})}),e.jsx(Us,{path:"/admin/lms/:courseId",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(lSs,{})})}),e.jsx(Us,{path:"/levelup-u",element:e.jsx(cr,{children:e.jsx(mSs,{})})}),e.jsx(Us,{path:"/levelup-u/:courseId",element:e.jsx(cr,{children:e.jsx(fSs,{})})}),e.jsx(Us,{path:"/admin/brokerage-content-activity",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(GNs,{})})}),e.jsx(Us,{path:"/admin/onboarding-checklist",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(qvs,{})})}),e.jsx(Us,{path:"/admin/marketplace",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(tNs,{})})}),e.jsx(Us,{path:"/admin/agent-points",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(Nks,{})})}),e.jsx(Us,{path:"/admin/reward-store",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(gNs,{})})}),e.jsx(Us,{path:"/admin/integrations",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(yNs,{})})}),e.jsx(Us,{path:"/admin/integrations/callback",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(jNs,{})})}),e.jsx(Us,{path:"/admin/email-campaigns",element:e.jsx(cr,{children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(WCs,{})})})}),e.jsx(Us,{path:"/admin/email-campaigns/templates",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(ZCs,{})})})}),e.jsx(Us,{path:"/admin/email-campaigns/new",element:e.jsx(cr,{children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(GCs,{})})})}),e.jsx(Us,{path:"/admin/email-campaigns/:id",element:e.jsx(cr,{children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(KCs,{})})})}),e.jsx(Us,{path:"/reward-store",element:e.jsx(cr,{children:e.jsx(ASs,{})})}),e.jsx(Us,{path:"/additional-services",element:e.jsx(cr,{children:e.jsx(Jvs,{})})}),e.jsx(Us,{path:"/additional-services/:serviceId",element:e.jsx(cr,{children:e.jsx(e1s,{})})}),e.jsx(Us,{path:"/ai-toolkit",element:e.jsx(cr,{children:e.jsx(t1s,{})})}),e.jsx(Us,{path:"/mission-control",element:e.jsx(cr,{children:e.jsx(g1s,{})})}),e.jsx(Us,{path:"/mission-control/contacts",element:e.jsx(cr,{children:e.jsx(J1s,{})})}),e.jsx(Us,{path:"/mission-control/contacts/:contactId",element:e.jsx(cr,{children:e.jsx(j_s,{})})}),e.jsx(Us,{path:"/mission-control/plans",element:e.jsx(cr,{children:e.jsx(k_s,{})})}),e.jsx(Us,{path:"/mission-control/popbys",element:e.jsx(cr,{children:e.jsx(C_s,{})})}),e.jsx(Us,{path:"/mission-control/popbys/map",element:e.jsx(cr,{children:e.jsx(VCs,{})})}),e.jsx(Us,{path:"/admin/notification-settings",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(_Ns,{})})}),e.jsx(Us,{path:"/admin/agent-os",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(Vvs,{})})}),e.jsx(Us,{path:"/mission-control/listings",element:e.jsx(cr,{children:e.jsx(X_s,{})})}),e.jsx(Us,{path:"/mission-control/listings/new",element:e.jsx(cr,{children:e.jsx(EFe,{})})}),e.jsx(Us,{path:"/mission-control/listings/:listingId",element:e.jsx(cr,{children:e.jsx(hbs,{})})}),e.jsx(Us,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(cr,{children:e.jsx(EFe,{})})}),e.jsx(Us,{path:"/admin/listing-exchange",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(vks,{})})}),e.jsx(Us,{path:"/mission-control/pipeline",element:e.jsx(cr,{children:e.jsx(Sjs,{})})}),e.jsx(Us,{path:"/mission-control/tasks",element:e.jsx(cr,{children:e.jsx(Ojs,{})})}),e.jsx(Us,{path:"/mission-control/my-card",element:e.jsx(cr,{children:e.jsx(sks,{})})}),e.jsx(Us,{path:"/mission-control/integrations",element:e.jsx(cr,{children:e.jsx(hks,{})})}),e.jsx(Us,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(cr,{children:e.jsx(mks,{})})}),e.jsx(Us,{path:"/mission-control/integrations/canva/callback",element:e.jsx(pks,{})}),e.jsx(Us,{path:"/mission-control/integrations/meta/callback",element:e.jsx(cr,{children:e.jsx(fks,{})})}),e.jsx(Us,{path:"/mission-control/scorecard",element:e.jsx(cr,{children:e.jsx($_s,{})})}),e.jsx(Us,{path:"/admin/scorecard",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(xks,{})})}),e.jsx(Us,{path:"/admin/scorecard/:userId",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(V7e,{})})}),e.jsx(Us,{path:"/mission-control/scorecard/:userId",element:e.jsx(cr,{children:e.jsx(V7e,{})})}),e.jsx(Us,{path:"/mission-control/relationship-scorecard",element:e.jsx(cr,{children:e.jsx(ICs,{})})}),e.jsx(Us,{path:"/mission-control/sphere-gaps",element:e.jsx(cr,{children:e.jsx(RCs,{})})}),e.jsx(Us,{path:"/mission-control/connect-page",element:e.jsx(cr,{children:e.jsx(zCs,{})})}),e.jsx(Us,{path:"/admin/membership-reviews",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(_ks,{})})}),e.jsx(Us,{path:"/admin/weekly-digest",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(jks,{})})}),e.jsx(Us,{path:"/mission-control/video/record",element:e.jsx(cr,{children:e.jsx(hws,{})})}),e.jsx(Us,{path:"/mission-control/video-library",element:e.jsx(cr,{children:e.jsx(Cws,{})})}),e.jsx(Us,{path:"/marketplace",element:e.jsx(cr,{children:e.jsx(jSs,{})})}),e.jsx(Us,{path:"/marketplace/:productId",element:e.jsx(cr,{children:e.jsx(kSs,{})})}),e.jsx(Us,{path:"/marketplace/cart",element:e.jsx(cr,{children:e.jsx(NSs,{})})}),e.jsx(Us,{path:"/marketplace/orders",element:e.jsx(cr,{children:e.jsx(SSs,{})})}),e.jsx(Us,{path:"/marketplace/orders/:orderId",element:e.jsx(cr,{children:e.jsx(MSs,{})})}),e.jsx(Us,{path:"/marketplace/success",element:e.jsx(cr,{children:e.jsx(TSs,{})})}),e.jsx(Us,{path:"/admin/agent-cards",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(Sks,{})})}),e.jsx(Us,{path:"/admin/presentation-analytics",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(bNs,{})})}),e.jsx(Us,{path:"/admin/guest-book-analytics",element:e.jsx(cr,{requireAdmin:!0,children:e.jsx(wNs,{})})}),e.jsx(Us,{path:"/mission-control/smart-drips",element:e.jsx(cr,{children:e.jsx(hCs,{})})}),e.jsx(Us,{path:"/mission-control/direct-mail",element:e.jsx(cr,{children:e.jsx(C.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(UCs,{})})})}),e.jsx(Us,{path:"/mission-control/presentations",element:e.jsx(cr,{children:e.jsx(ESs,{})})}),e.jsx(Us,{path:"/mission-control/presentations/new",element:e.jsx(cr,{children:e.jsx(uze,{})})}),e.jsx(Us,{path:"/mission-control/presentations/:id",element:e.jsx(cr,{children:e.jsx(uze,{})})}),e.jsx(Us,{path:"/mission-control/guest-book",element:e.jsx(cr,{children:e.jsx($Ss,{})})}),e.jsx(Us,{path:"/mission-control/guest-book/live/:id",element:e.jsx(cr,{children:e.jsx(HCs,{})})}),e.jsx(Us,{path:"/guestbook/:slug",element:e.jsx(eGe,{})}),e.jsx(Us,{path:"/mission-control/card-studio",element:e.jsx(cr,{children:e.jsx(ZSs,{})})}),e.jsx(Us,{path:"/mission-control/scheduler",element:e.jsx(cr,{children:e.jsx(CCs,{})})}),e.jsx(Us,{path:"/c/:shareToken",element:e.jsx(Llt,{})}),e.jsx(Us,{path:"/book/:slug",element:e.jsx(Olt,{})}),e.jsx(Us,{path:"/page/:slug",element:e.jsx(Rlt,{})}),e.jsx(Us,{path:"/mission-control/landing-pages",element:e.jsx(cr,{children:e.jsx(MCs,{})})}),e.jsx(Us,{path:"/mission-control/landing-pages/:pageId",element:e.jsx(cr,{children:e.jsx(ECs,{})})}),e.jsx(Us,{path:"*",element:e.jsx(Dlt,{})})]}),")"]})})})})]})})}),Sze=window.location.hostname,o3s=Sze.includes("lovable.app")||Sze.includes("lovableproject.com");o3s&&"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))}));YBe(document.getElementById("root")).render(e.jsx(i3s,{}));export{ys as $,di as A,K as B,Ee as C,Es as D,Ar as E,rr as F,tr as G,nr as H,cl as I,sr as J,Tt as K,Ss as L,br as M,Vn as N,y3s as O,Zs as P,ni as Q,$a as R,Wu as S,Aa as T,mr as U,An as V,En as W,ks as X,bt as Y,Pn as Z,dt as _,ja as a,hM as a$,me as a0,G as a1,Ws as a2,BQ as a3,ma as a4,At as a5,cf as a6,wl as a7,yae as a8,Bx as a9,ET as aA,yh as aB,hd as aC,md as aD,Gv as aE,Uc as aF,Lte as aG,ro as aH,Br as aI,ea as aJ,Lo as aK,Do as aL,Eo as aM,Vi as aN,Xc as aO,OI as aP,hn as aQ,ha as aR,yl as aS,va as aT,LQ as aU,MQ as aV,EI as aW,Ju as aX,LU as aY,In as aZ,xn as a_,Iv as aa,Ur as ab,Oi as ac,ki as ad,pM as ae,Bo as af,Fu as ag,Nn as ah,i1 as ai,H4 as aj,t1 as ak,YPt as al,yn as am,Da as an,vn as ao,zet as ap,Z1e as aq,Nse as ar,stt as as,Uet as at,att as au,M3s as av,HU as aw,jNe as ax,Fue as ay,ott as az,js as b,UI as b$,vL as b0,yg as b1,Zr as b2,Oj as b3,Yo as b4,fn as b5,Ght as b6,Co as b7,ht as b8,N1s as b9,DA as bA,YS as bB,OA as bC,RA as bD,cre as bE,I4e as bF,Jl as bG,Ki as bH,Kv as bI,n0 as bJ,aL as bK,Ev as bL,yp as bM,Cm as bN,Rre as bO,R4 as bP,on as bQ,qQe as bR,KQe as bS,yzt as bT,Z0s as bU,iJe as bV,nJe as bW,aJe as bX,iM as bY,mM as bZ,qI as b_,k1s as ba,C1s as bb,$u as bc,Ui as bd,ZY as be,VQ as bf,bo as bg,vi as bh,Po as bi,v3s as bj,MWe as bk,_3s as bl,b3s as bm,w3s as bn,Ad as bo,n1 as bp,qKe as bq,sl as br,mi as bs,Fh as bt,Rn as bu,wr as bv,xc as bw,zb as bx,Tn as by,po as bz,Une as c,Mm as c0,Jv as c1,rM as c2,sM as c3,nM as c4,Vo as c5,kM as c6,wM as c7,BQe as c8,Qu as c9,x2 as ca,mf as cb,BM as cc,Qnt as cd,L0 as ce,zO as cf,rp as cg,Xnt as ch,RS as ci,FS as cj,N1 as ck,tl as cl,Xa as cm,Lh as cn,uh as co,TI as cp,La as d,Oe as e,nt as f,jr as g,_e as h,Fe as i,e as j,ss as k,wt as l,Dt as m,It as n,fr as o,Ot as p,V4 as q,C as r,oa as s,$s as t,Pr as u,_s as v,Fi as w,vs as x,Cs as y,Ns as z};